本文整理汇总了C++中Timeout::start方法的典型用法代码示例。如果您正苦于以下问题:C++ Timeout::start方法的具体用法?C++ Timeout::start怎么用?C++ Timeout::start使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Timeout
的用法示例。
在下文中一共展示了Timeout::start方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: setup
/**
* Application setup
*/
void setup()
{
bcu.begin(4, 0x7054, 2); // We are a "Jung 2118" device, version 0.2
pinMode(PIO_LED, OUTPUT);
digitalWrite(PIO_LED, 1);
// Configure the input pins and initialize the debouncers with the current
// value of the pin.
for (int channel = 0; channel < NUM_CHANNELS; ++channel)
{
pinMode(inputPins[channel], INPUT | HYSTERESIS | PULL_UP);
inputDebouncer[channel].init(digitalRead(inputPins[channel]));
}
// Handle configured power-up delay
unsigned int startupTimeout = calculateTime
( userEeprom[EE_BUS_RETURN_DELAY_BASE] >> 4
, userEeprom[EE_BUS_RETURN_DELAY_FACT] & 0x7F
);
Timeout delay;
int debounceTime = userEeprom[EE_INPUT_DEBOUNCE_TIME] >> 1;
delay.start(startupTimeout);
while (delay.started() && !delay.expired())
{ // while we wait for the power on delay to expire we debounce the input channels
for (int channel = 0; channel < NUM_CHANNELS; ++channel)
{
inputDebouncer[channel].debounce(digitalRead(inputPins[channel]), debounceTime);
}
waitForInterrupt();
}
initApplication();
}
示例2: startLoader
void LoaderQueue::startLoader()
{
LYXERR(Debug::GRAPHICS, "LoaderQueue: waking up");
running_ = true ;
timer.setTimeout(s_millisecs_);
timer.start();
}
示例3: initApplication
void initApplication(void)
{
unsigned int address = currentVersion->baseAddress;
setupPWM();
for (unsigned int i = 0; i < NO_OF_CHANNELS; i++)
{
digitalWrite(outputPins[i], 0);
pinMode(outputPins[i], OUTPUT);
channels[i] = new Channel(i, address+16+i*256);
}
unsigned int initZeit = memMapper.getUInt8(P_InitZeit + address);
Timeout startupDelay;
if (initZeit)
{
startupDelay.start(initZeit);
while (!startupDelay.expired())
{
waitForInterrupt();
}
}
/* no yet used
unsigned int telegrUnbegr = memMapper.getUInt8(PD_TelegrUnbegr + address);
unsigned int telegrUebZeit = memMapper.getUInt16(P_TelegrUebZeit + address);
*/
inBetrieb = memMapper.getUInt8(P_InBetrieb + address);
inBetriebValue_0 = memMapper.getUInt8(P_InBetriebValue_0 + address);
inBetriebZeit = memMapper.getUInt16(P_InBetriebZeit + address);
if(inBetrieb != 255) {
inBetriebTimeout.start(1);
}
unsigned int einerFuerAlle = memMapper.getUInt8(t_EinerFuerAlle + address);
msTimeout.start(1);
timeoutTest.start(1);
}
示例4: checkPeriodicFuntions
void checkPeriodicFuntions(void)
{
if(msTimeout.started() && msTimeout.expired()) {
msTimeout.start(1);
for (unsigned int i = 0; i < NO_OF_CHANNELS; i++)
{
// setChannelPWMRatio(i, pwm&0xffff);
// pwm+=1;
Channel * chn = channels[i];
if (chn)
chn->periodic();
}
memMapper.doFlash();
}
if(inBetriebTimeout.started() && inBetriebTimeout.expired()) {
inBetriebTimeout.start(inBetriebZeit*1000);
objectWrite(COMObj_In_Operation, inBetriebValue_0);
}
if(timeoutTest.started() && timeoutTest.expired()) {
timeoutTest.start(1000);
// objectWrite(209, inBetriebValue_0);
}
}
示例5: if
GameOver::GameOver(Game * _game, float _score) :
MY_Scene_Base(_game),
done(false)
{
std::string pic = "ENDING_";
if(_score > 300){
pic += "5";
}else if(_score > 200){
pic += "4";
}else if(_score > 125){
pic += "3";
}else if(_score > 50){
pic += "2";
}else{
pic += "1";
}
{
VerticalLinearLayout * vl = new VerticalLinearLayout(uiLayer->world);
uiLayer->addChild(vl);
vl->setRationalHeight(1.f, uiLayer);
vl->setRationalWidth(1.f, uiLayer);
vl->horizontalAlignment = kCENTER;
vl->verticalAlignment = kMIDDLE;
NodeUI * menu = new NodeUI(uiLayer->world);
vl->addChild(menu);
menu->setRationalHeight(1.f, vl);
menu->setSquareWidth(1.f);
menu->background->mesh->pushTexture2D(MY_ResourceManager::globalAssets->getTexture(pic)->texture);
menu->background->mesh->setScaleMode(GL_NEAREST);
}
Timeout * doneTimeout = new Timeout(0.5f, [this](sweet::Event * _event){
done = true;
NodeUI * n = new NodeUI(uiLayer->world);
n->setRationalHeight(1.f, uiLayer);
n->setRationalWidth(1.f, uiLayer);
uiLayer->addChild(n);
n->background->mesh->pushTexture2D(MY_ResourceManager::globalAssets->getTexture("CLICK")->texture);
n->background->mesh->setScaleMode(GL_NEAREST);
});
doneTimeout->start();
doneTimeout->name = "done timeout";
childTransform->addChild(doneTimeout, false);
}
示例6: main
int main()
{
Threat threat = Threat(0);
Timeout loopTimeout = Timeout(40);
// game loop
while (1) {
loopTimeout.start();
string enemy1; // name of enemy 1
cin >> enemy1; cin.ignore();
int dist1; // distance to enemy 1
cin >> dist1; cin.ignore();
threat.push_back(Enemy(dist1, enemy1));
string enemy2; // name of enemy 2
cin >> enemy2; cin.ignore();
int dist2; // distance to enemy 2
cin >> dist2; cin.ignore();
threat.push_back(Enemy(dist2, enemy2));
// We have acquired the list of enemy
// We have to sort the list from the
// closest to far away
sort(threat.begin(), threat.end(),
[](const Enemy & a, const Enemy & b)
{
// true will make the sort to let
// the object in the same order
return a.getDist() < b.getDist();
});
// We acquire the enemy which is the closer,
// ie at the end of the list of threat
Enemy threatToEliminate = threat.front();
threat.erase(threat.begin());
// We output the enemy to kill
cout << threatToEliminate.getName() << endl;
if(loopTimeout.hasTimedOut()) break;
}
return EXIT_SUCCESS;
}
示例7: BulletWorld
//.........这里部分代码省略.........
palette = new MY_Palette(bulletWorld, baseShader);
childTransform->addChild(palette);
palette->translateComponents(glm::vec3(0, 3, 2));
// parse palettes
{
Json::Reader reader;
Json::Value json;
bool parsingSuccessful;
parsingSuccessful = reader.parse(sweet::FileUtils::readFile("assets/palettes.json"), json);
assert(parsingSuccessful);
for(Json::Value::ArrayIndex i = 0; i < json["palettes"].size(); ++i){
paletteDefs.push_back(new MY_Palette_Definition(json["palettes"][i].get("name", "NO_NAME").asString(), MY_ResourceManager::globalAssets->getTexture(json["palettes"][i].get("texture", "DEFAULT").asString())->texture));
}
}
Sprite * sprite = new Sprite(MY_ResourceManager::globalAssets->getTexture("indicator")->texture, indicatorShader);
auto sd = sweet::getWindowDimensions();
uiLayer->resize(0, sd.x, 0, sd.y);
VerticalLinearLayout * crosshairLayout = new VerticalLinearLayout(uiLayer->world);
crosshairLayout->setRationalWidth(1.0f, uiLayer);
crosshairLayout->setRationalHeight(1.0f, uiLayer);
crosshairLayout->horizontalAlignment = kCENTER;
crosshairLayout->verticalAlignment = kMIDDLE;
NodeUI * crossHair = new NodeUI(uiLayer->world);
crossHair->setWidth(15);
crossHair->setHeight(15);
crossHair->background->mesh->pushTexture2D(MY_ResourceManager::globalAssets->getTexture("crosshair")->texture);
crossHair->background->mesh->setScaleMode(GL_NEAREST);
crosshairLayout->addChild(crossHair);
crossHair->childTransform->addChild(sprite)->scale(100)->translate(7.5f, 7.5f, 0.f);
uiLayer->addChild(crosshairLayout);
// setup mirror
mirrorCamera = new PerspectiveCamera();
childTransform->addChild(mirrorCamera);
cameras.push_back(mirrorCamera);
mirrorCamera->firstParent()->translate(-0.5f, 3.25f, 4, false);
mirrorFBO = new StandardFrameBuffer(true);
mirrorTex = new FBOTexture(mirrorFBO, true, 0, false);
mirrorTex->load();
mirrorSurface = new MeshEntity(MY_ResourceManager::globalAssets->getMesh("salon-mirror")->meshes.at(0), mirrorShader);
mirrorSurface->mesh->setScaleMode(GL_LINEAR);
mirrorSurface->mesh->uvEdgeMode = GL_CLAMP_TO_EDGE;
mirrorSurface->mesh->pushTexture2D(mirrorTex);
childTransform->addChild(mirrorSurface);
mirrorFBO->incrementReferenceCount();
// memory management
screenSurface->incrementReferenceCount();
screenSurfaceShader->incrementReferenceCount();
screenFBO->incrementReferenceCount();
// load the tracks
tracks = new Tracks();
// start the experience
getNextTrack();
loadNextPalette();
fade = new NodeUI(uiLayer->world);
uiLayer->addChild(fade);
fade->setRationalHeight(1.f, uiLayer);
fade->setRationalWidth(1.f, uiLayer);
fade->setBackgroundColour(0,0,0,1);
Timeout * fadeIn = new Timeout(1.f, [this](sweet::Event * _event){
fade->setVisible(false);
});
fadeIn->eventManager->addEventListener("progress", [this](sweet::Event * _event){
float p = _event->getFloatData("progress");
fade->setBackgroundColour(0,0,0,1.f-p);
});
fadeIn->start();
childTransform->addChild(fadeIn, false);
// recenter HMD
ovr_RecenterPose(*sweet::hmd);
startTime = glfwGetTime();
}
示例8:
static void _start_to_20(void * refState, unsigned int param)
{
to.start(20);
_check_expired_no(refState, param);
}
示例9: initApplication
void initApplication(void)
{
unsigned int channels = currentVersion->noOfChannels;
unsigned int longKeyTime = userEeprom.getUInt16(
currentVersion->baseAddress + 2);
unsigned int addressStartupDelay = currentVersion->baseAddress + 4 // debounce, longTime
+ channels * 46 + channels + (11 + channels) * 4 // logic config
+ 10;
unsigned int busReturn = userEeprom.getUInt8(addressStartupDelay - 1) & 0x2; // bit offset is 6: means 2^(7-bit offset)
memset(channelConfig, 0, sizeof(channelConfig));
inputs.begin(channels, currentVersion->baseAddress);
Timeout startupDelay;
// delay in config is in seconds
unsigned int delay = userEeprom.getUInt16(addressStartupDelay) * 1000;
startupDelay.start(delay);
if (delay)
{
while (!startupDelay.expired())
{
inputs.scan();
for (int unsigned i = 0; i < currentVersion->noOfChannels; i++)
{
unsigned int value;
inputs.checkInput(i, &value);
}
waitForInterrupt();
}
}
unsigned int busReturnLogic = userEeprom.getUInt8(addressStartupDelay - 1) & 0x01;
for (unsigned int i = 0; i < MAX_LOGIC; i++)
{
if (userEeprom.getUInt8(currentVersion->logicBaseAddress + i * (11 + channels))
!= 0xff)
{
logicConfig[i] = new Logic(currentVersion->logicBaseAddress, i,
channels, busReturnLogic);
}
}
inputs.scan();
for (unsigned int i = 0; i < channels; i++)
{
unsigned int value;
int configBase = currentVersion->baseAddress + 4 + i * 46;
word channelType = userEeprom.getUInt16(configBase);
Channel * channel;
inputs.checkInput(i, &value);
//leds.setStatus(i, value);
for (unsigned int n = 0; n < MAX_LOGIC; n++)
{
if (logicConfig[n])
{
logicConfig[n]->inputChanged(n, value);
}
}
busReturn = userEeprom.getUInt8(configBase + 32) || userEeprom.getUInt8(addressStartupDelay - 1) & 0x02; // param sendValue || readToggleObject
switch (channelType)
{
case 0: // channel is configured as switch
channel = new Switch(i, longKeyTime, configBase, busReturn, value);
break;
case 256: // channel is configured as switch short/long
channel = new Switch2Level(i, longKeyTime, configBase, busReturn,
value);
break;
case 1: // channel is configured as dimmer
channel = new Dimmer(i, longKeyTime, configBase, busReturn, value);
break;
case 2: // channel is configured as jalo
channel = new Jalo(i, longKeyTime, configBase, busReturn, value);
break;
case 3: // channel is configured as scene
channel = new Scene(i, longKeyTime, configBase, busReturn, value);
break;
case 4: // channel is configured as counter
channel = new Counter(i, longKeyTime, configBase, busReturn, value);
break;
case 511: // channel is configured as LED output
channel = new LedOutput(i, longKeyTime, configBase, busReturn, value);
break;
default:
channel = 0;
}
channelConfig[i] = channel;
}
}
示例10:
static void _start_to_20(void * refState)
{
to.start(20);
_check_expired_no(refState);
}