void Drawing::SetMessage(int x, int y, char* msg) { // Determine the size of the message and clear it if it is empty. size_t len = strnlen(msg, MSG_MAX - 1); if (len == 0) { ClearMessage(); return; } // Set the message, location, and mark new lines. strncpy(msgVal, msg, len + 1); newLineCount = 0; for (size_t i = 0; i < len && newLineCount < MSG_LINE_MAX; ++i) { if (msgVal[i] == '\n' || msgVal[i] == '\r') { msgVal[i] = 0; newLines[newLineCount++] = i + 1; } } msgX = x < 0 ? 10 : x; msgY = y < 0 ? 600 : y; // Enable drawing if necessary if (!msgEnabled) { XPLMRegisterDrawCallback(MessageDrawCallback, xplm_Phase_Window, 0, NULL); msgEnabled = true; } }
task main() { int message_first; int message_second; int message_third; while(true) { //Read the messages to variables message_first = messageParm[0]; message_second = messageParm[1]; message_third = messageParm[2]; //Something got through if the signals are not all zero if(message_first != 0 || message_second != 0 || message_third != 0) { //display the values as stored in the variables nxtDisplayBigTextLine(2,"1: %d",message_first); nxtDisplayBigTextLine(4,"2: %d",message_second); //nxtDisplayBigTextLine(6,"3: %d",message_third); //Clear the messages, set them to 0 ClearMessage(); } //Checking for a message every half a second is //fine for this simple test wait1Msec(100); } }
task listenToBluetooth(){ int receiver, method, payload; while(true) { receiver = messageParm[0]; method = messageParm[1]; payload = messageParm[2]; if(receiver != 0 || method != 0 || payload != 0){ PlaySound(soundBlip); switch(method){ case CONVEYOR_JOB_START: nxtDisplayBigTextLine(2,"Job: %d", payload); moteToPrinterAndSendJob(payload); break; case CONVEYOR_MOVE: conveyor_move(payload); break; default: PlaySound(soundException); // method not supported } ClearMessage(); } wait1Msec(500); } }
bool Bluetooth_ReadMessage(int* One, int* Two, int* Three) { Bluetooth_Initialize(); if(bQueuedMsgAvailable()) { eraseDisplay(); nxtDisplayString(1, "%i", messageParm[0]); nxtDisplayString(2, "%i", messageParm[1]); nxtDisplayString(3, "%i", messageParm[2]); *One = messageParm[0]; *Two = messageParm[1]; *Three = messageParm[2]; ClearMessage(); return true; } else { return false; } }
void SuggestionsSidebarBlock::Update(const CatalogItemPtr& item) { ClearMessage(); ClearSuggestions(); UpdateSuggestionsForItem(item); }
/* This is a program for mohair's robot. Mohair's "Bat Mobeile" for the outreach places that we go to. This program will look for bluetooth signals coming fromm 2 nxt bricks This is the reveiving program for the "Master, Slave" setup it will allow us to have 1 nxt brick contolling the motors getting signals of what motors to move from another nxt This program will use the left right and enter button of 1 of the nxt's to control 2 motors */ task main() { /* Here just for syntax refrence (ignore) motor[mL]=100; motor[mR]=100; while (true) {} while (nNxtButtonPressed!=kRightButton) {} motor[mR]=-100; int x=0; while (nNxtButtonPressed=kRightButton) {} x++; (nxtDisplayString(3, "%d", x); */ int x=0; //Ths line sets the variable x to 0 allowing us for cetain dislpay properties int xx=0; // This allows another variale to set to 0 for certain parts with the reciving program while(true) //Just a while loop that makes sure the program runs indefianatly { eraseDisplay (); //erases the display at the beining of the program to clear xx = message; //this sets our variable to be able to reseave messages from the "Master Nxt" devise if (xx==1) //If the varibable for the messages is equal to 1 witch is the motion for the movment of right { x++; //Adds +1 to display everytime right button is pressed nxtDisplayString (3, "%d", x); motor[mL]=100; //robot turns right when right button is pressed motor[mR]=-100; wait1Msec(1000); //waits so it doesn bug up motor[mL] = 0; motor[mR] = 0; wait1Msec(1000); } if (xx==2) //If the variable equals 2 it will move left { x--; //Subtracts -1 to display everytime left button is pressed nxtDisplayString (3, "%d", x); motor[mL]=-100; //robot turns left with left button is pressed motor[mR]=100; wait1Msec(1000); // waits so it doesnt bug up - no motor[mL] = 0; motor[mR] = 0; wait1Msec(1000); } if (xx==3) //If the varibable equals 3 ( if the ceneter/orange/enter button is pressed) it moves forward { motor[mL]=100; //robot moves forward when enter button is pressed motor[mR]=100; wait1Msec(1000); //waits so it doesnt bug up motor[mL] = 0; motor[mR] = 0; wait1Msec(1000); } ClearMessage(); } }
void SuggestionsSidebarBlock::Update(CatalogItem *item) { // FIXME: Cancel previous pending async operation if any ClearMessage(); ClearSuggestions(); QueryAllProviders(item); }
void Bluetooth_Initialize() { if(!Bluetooth_Initialized) { Bluetooth_Initialized = true; while(bQueuedMsgAvailable()) { ClearMessage(); } } }
bool notReceived (int messageNumber1) //checks to make sure the sensor block hasn't sent a message { int myMessage=0; if(myMessage==0) { myMessage=message; } if (myMessage==messageNumber1) { ClearMessage(); return false; //returns false if it finds a message corresponding to the specified integer } else return true; //returns true if none have been found }
void SuggestionsSidebarBlock::Update(const CatalogItemPtr& item) { // FIXME: Cancel previous pending async operation if any ClearMessage(); ClearSuggestions(); auto srclang = m_parent->GetCurrentSourceLanguage(); auto lang = m_parent->GetCurrentLanguage(); if (!srclang.IsValid() || !lang.IsValid() || srclang == lang) { OnQueriesFinished(); return; } QueryAllProviders(item); }
task main(){ RgtMUp = 0; RgtMRnd = 0; LftMUp = 0; LftMRnd = 0; checkBTLinkConnected(); while(true){ wait1Msec(1); while (bQueuedMsgAvailable()){ ClearMessage(); LftRec = messageParm[0]; RgtRec = messageParm[1]; } /*if(message == 0){ wait1Msec(5); nxtDisplayTextLine(2,"no message"); continue; }*/ nxtDisplayTextLine(1,"message[0] = %d",LftRec); nxtDisplayTextLine(2,"message[1] = %d",RgtRec); LftGUp = LftRec/100; LftGRnd = LftRec%100; RgtGUp = RgtRec/100; RgtGRnd = RgtRec%100; RgtMUp = RgtGUp * 16; RgtMRnd = (RgtGRnd * 16); LftMUp = LftGUp * 16; LftMRnd = (LftGRnd * 16); nxtDisplayTextLine(3,"RGU = %d",RgtGUp); nxtDisplayTextLine(4,"RGR = %d",RgtGRnd); nxtDisplayTextLine(5,"LGU = %d",LftGUp); nxtDisplayTextLine(6,"LGR = %d",LftGRnd); servo[srvo_S1_C2_1] = RgtMUp; servo[srvo_S1_C2_2] = RgtMRnd; servo[srvo_S1_C2_3] = LftMUp; servo[srvo_S1_C2_4] = LftMRnd; } }
task listenToBluetooth(){ int receiver, method, payload; while(true) { receiver = messageParm[0]; method = messageParm[1]; payload = messageParm[2]; if(receiver != 0 || method != 0 || payload != 0){ PlaySound(soundBlip); switch(method){ case PRINTER_PRINT: // print the letter startPrint(payload); break; default: PlaySound(soundException); // method not supported } ClearMessage(); } wait1Msec(500); } }
void RocketTaskbar::SetMessage(const QString &message, uint autoHideTimeMsec) { if (message.isEmpty()) { ClearMessage(); return; } if (loadBarEnabled_) { if (ui_.labelLoaderInfo->text() != message) { ui_.labelLoaderInfo->setText(message); ui_.labelLoaderInfo->show(); if (!ui_.frameLoader->isVisible()) ui_.frameLoader->show(); resizeDelayTimer_.start(5); } } if (autoHideTimeMsec > 0) messageHideTimer_.start(autoHideTimeMsec); }
task main() { ClearMessage(); float widthOfRoom=perimeterX(); //calculate the width of the room float distanceY=perimeterY(); //calculate the length of the room int repitition=reps(widthOfRoom); //calculate how many repititions of the cleaning cycle it needs to do float distanceX= distX(widthOfRoom); //calculate the distance per strafe on the repititions bool hit= false; int counter=0; while((counter<repitition-3)&&hit!=1)// run while it hasn't hit the bottom, or has not completed all of its repititions { hit=drive(1,distanceY-40); //drive forward -20cm for clearance from wall if(hit) //if it hit something go through obstacle functions { float lengthOfObstacle=obstacle(1); //drive around the obstacle drive(1, distanceY-lengthOfObstacle +10); //drive forward the remainder of the distance hit=false; //reset hit } drive(3, distanceX); //drive right hit=drive(2, (distanceY+20) ); //drive backwards -20cm for clearance from wall if(hit) //if it hits something go through obstacle functions { wait1Msec(2000); //wait for sensor to rotate float lengthOfObstacle=obstacle(2); //drive around the obstacle drive(2, distanceY+lengthOfObstacle); //drive the remainder of the distance hit=false; //reset hit } hit=drive(3, distanceX);//drive right counter++; } motor[motorA]=0; motor[motorB]=0; motor[motorC]=0; }
/******************************************************************************* 関数名: void UpdateGame(void) 引数: なし 戻り値: なし 説明: ゲームの更新関数 *******************************************************************************/ void UpdateGame(void) { //初期値 g_fTimeSpeed = 0.01f; GAME_STEP stepNow = GetGameStep(); switch(stepNow) { case STEP_PLAY: UpdatePlayer(); UpdateCamera(); UpdateGun(); UpdatePlayerBullet(g_fTimeSpeed); UpdateEnemy( g_fTimeSpeed); UpdateEnemyBullet( g_fTimeSpeed); //UpdateBillBoard(); UpdateParticle( g_fTimeSpeed); UpdateStageManager( g_fTimeSpeed); //UpdateModel(); UpdateGunSight(); UpdateItemBullet(); UpdateClock( g_fTimeSpeed); UpdateTime( g_fTimeSpeed); if(GetKeyboardTrigger(DIK_P) ) { SetGameStep(STEP_PAUSE); SetMessage(MSG_PAUSE); } break; case STEP_SHOOT: ChangeTimeSpeed( 1.0f); UpdateEnemy( g_fTimeSpeed); //UpdatePlayer(); UpdatePlayerBullet( g_fTimeSpeed); //UpdateEnemyBullet( g_fTimeSpeed); UpdateClock( g_fTimeSpeed); UpdateTime( g_fTimeSpeed); g_nCounterShoot++; if( g_nCounterShoot > 15) { g_nCounterShoot = 0; SetGameStep(STEP_PLAY); } break; case STEP_PAUSE: StopSound(); if(GetKeyboardTrigger(DIK_P) ) { SetGameStep(STEP_PLAY); ClearMessage(MSG_PAUSE); } break; case STEP_DIE: ChangeTimeSpeed( 1.0f); UpdateEnemy( g_fTimeSpeed); UpdateEnemyBullet( g_fTimeSpeed); UpdatePlayerBullet( g_fTimeSpeed); UpdateParticle( g_fTimeSpeed); g_nCounterFrame++; if( g_nCounterFrame > 90) { g_nCounterFrame = 0; if( GetPlayer()->nLife <= 0) { FadeOutToNext(MODE_RESULT); } else { FadeOutToNext(STEP_RESET); SetGameStep(STEP_NOTHING); } } break; case STEP_RESET: InitStageManager( false, GetPlayer()->nLife); SetGameStep(STEP_PLAY); break; case STEP_CLEAR: StopSound(SOUND_LABEL_SE_RUN); SetMessage(MSG_STAGECLEAR); g_nCounterFrame++; if( g_nCounterFrame > 90) { g_nCounterFrame = 0; switch(GetStageMode()) { case STAGE0: FadeOutToNext(STAGE1); break; case STAGE1: FadeOutToNext(STAGE2); break; case STAGE2: FadeOutToNext(STAGE3); break; case STAGE3: FadeOutToNext(MODE_RESULT); g_bGameClear = true; break; } SetGameStep(STEP_NOTHING); } break; case STEP_NOTHING: //just let time go, and do nothing break; } //UI update UpdateNumBullet(); //Debug update UpdateMeshDome(); if(GetKeyboardTrigger(DIK_RETURN) ) { FadeOutToNext(MODE_RESULT); } if(GetKeyboardTrigger(DIK_F3)) { PlaySound( SOUND_LABEL_SE_CLEAR); SetGameStep(STEP_CLEAR); } if(GetKeyboardTrigger(DIK_F2)) { PlaySound(SOUND_LABEL_SE_SWITCH); SwitchDebug(); } }
void cGameStateCredits::initialize(){ SCROLL_MSG msg; // msg = ; m_msg.push_back(SetGraphic(-1, 1006));//credits graphic m_msg.push_back(ClearMessage()); m_msg.push_back(ClearMessage()); m_msg.push_back(ClearMessage()); m_msg.push_back(ClearMessage()); m_msg.push_back(SetMessage(-1,F_V20, 180, 0, 0, "Team \"Pacific - Atlantic Gameworks\" ")); m_msg.push_back(ClearMessage()); m_msg.push_back(SetGraphic(50, 1009));//large cloud m_msg.push_back(ClearMessage()); m_msg.push_back(ClearMessage()); m_msg.push_back(SetMessage(500,F_V20, 0, 70, 0, "www.gameinstitute.com")); m_msg.push_back(SetMessage(500,F_V20, 0, 70, 0, " Game Challenge 10")); m_msg.push_back(ClearMessage()); m_msg.push_back(ClearMessage()); m_msg.push_back(ClearMessage()); m_msg.push_back(ClearMessage()); m_msg.push_back(ClearMessage()); m_msg.push_back(SetMessage(-1,F_V20, 0, 0, 0, "Editor Programmed by Chuck Bolin")); m_msg.push_back(SetMessage(-1,F_V16, 0, 0, 0, "January 2009")); m_msg.push_back(ClearMessage()); m_msg.push_back(SetGraphic(712, 1010));//credits graphic m_msg.push_back(ClearMessage()); m_msg.push_back(ClearMessage()); m_msg.push_back(ClearMessage()); m_msg.push_back(ClearMessage()); m_timer.initialize(); m_scrollValue = 0; //used to show several images in the background m_secondTimer.initialize(); m_secondCount = 0; //used for fading m_red = 255;//255; m_green =255;//255; m_blue = 255;//255; m_fadeTimer.initialize(); }
RocketTaskbar::RocketTaskbar(Framework *framework, QWidget *observed) : QGraphicsProxyWidget(0, Qt::Widget), LC("[RocketTaskbar]: "), framework_(framework), observed_(observed), widget_(new QWidget(0)), anchor_(Bottom), style_(SolidDefault), sizePolicy_(QSizePolicy::Minimum), loadBarEnabled_(true), hideRequested_(false), minimumWidth_(0), loaderAnimation_(0) { ui_.setupUi(widget_); setWidget(widget_); loaderAnimation_ = new QMovie(":/images/loader.gif", "GIF", this); if (loaderAnimation_->isValid()) { ui_.labelLoader->setMovie(loaderAnimation_); loaderAnimation_->setCacheMode(QMovie::CacheAll); } // Hide loader widgets initially. ui_.labelLoader->hide(); ui_.labelLoaderInfo->hide(); ui_.frameLoader->hide(); // Prepare toolbar for QActions toolBarRight_ = new QToolBar(widget_); toolBarRight_->setContentsMargins(0,0,0,0); toolBarRight_->setStyleSheet("background-color: none; border: 0px;"); toolBarRight_->setToolButtonStyle(Qt::ToolButtonIconOnly); toolBarRight_->setOrientation(Qt::Horizontal); toolBarRight_->setIconSize(QSize(32,32)); toolBarRight_->setFloatable(false); toolBarRight_->setMovable(false); toolBarRight_->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); QHBoxLayout *lRight = qobject_cast<QHBoxLayout*>(ui_.frameRight->layout()); if (lRight) lRight->addWidget(toolBarRight_); // Set initial style CheckStyleSheets(); // Support "legacy" icons from BrowserUiPlugin, without linking to it, we don't want to fail loading if not present. QObject *browserPlugin = framework_->property("browserplugin").value<QObject*>(); if (browserPlugin) { connect(browserPlugin, SIGNAL(ActionAddRequest(QAction*, QString)), SLOT(AddAction(QAction*))); connect(browserPlugin, SIGNAL(OpenUrlRequest(const QUrl&, bool)), SLOT(OnOpenUrl(const QUrl&))); } resizeDelayTimer_.setSingleShot(true); messageHideTimer_.setSingleShot(true); // Connections. connect(framework_->Ui()->GraphicsScene(), SIGNAL(sceneRectChanged(const QRectF&)), SLOT(OnWindowResized(const QRectF&))); connect(&resizeDelayTimer_, SIGNAL(timeout()), SLOT(OnDelayedResize())); connect(&messageHideTimer_, SIGNAL(timeout()), SLOT(ClearMessage())); connect(ui_.buttonDisconnect, SIGNAL(clicked()), SIGNAL(DisconnectRequest())); // Add ourselves to the scene. framework_->Ui()->GraphicsScene()->addItem(this); hide(); }
void RocketTaskbar::ClearMessageAndStopLoadAnimation() { ClearMessage(); StopLoadAnimation(); }