void Seg7_4511_addon::displayNextDigit(uint32_t blink_interval) { uint32_t millis_tmp; millis_tmp = millis(); if (millis_tmp - millisTimeBlink > blink_interval) { millisTimeBlink = millis_tmp; blink_flag = !blink_flag; } currentDigit++; if (currentDigit > digitNum) currentDigit = 0; turnOff(); for (int8_t p = 0; p < 4; p++) { if (digitData[currentDigit] & (0x01 << p)) digitalWrite(bcd4511Pin[p], HIGH); else digitalWrite(bcd4511Pin[p], LOW); } if (blink_interval == 0 || digit_pos != currentDigit) turnOn(); else if (blink_flag) turnOn(); }
/******************* Verander de status van de lader. Deze functie moet gebruikt worden aangezien bepaalde combinaties van relaystanden niet goed zijn voor de batterij mogelijke status: USE CHARGING DISCHARGING *******************/ int setState(enum status new_state){ if (new_state == status) return 1; // Huidige status bepaalt overgangsmethode switch (status) { case CHARGING: // Stel stroom in op 0A setCurrent(0); if (new_state == DISCHARGING) { // Ontkoppel de lader turnOff(); // Schakel naar ontladen discharge(); // Koppel lader turnOn(); // Stel stroom in op gewenste waarde // TODO: gewenste stroom instellen }else if (new_state == USE){ // Veilig ontkoppelen na opladen // Schakel naar ontladen discharge(); // Ontkoppel de lader turnOff(); } break; case DISCHARGING: // Stel stroom in op 0A setCurrent(0); // Ontkoppel de lader turnOff(); if (new_state == CHARGING){ // Schakel naar opladen charge(); // Koppel de lader turnOn(); } break; case USE: if (new_state == DISCHARGING) { // Schakel naar ontladen discharge(); //instellen van de stroom setCurrentCharger(0); // Koppel de lader turnOn(); // Stel stroom in // TODO: gewenste stroom instellen }else if (new_state == CHARGING){ // Schakel naar opladen charge(); // Koppel de lader turnOn(); // Stel stroom in // TODO: gewenste stroom instellen } break; default: break; } return 0; }
void Buzzer::playFanfare() { for (int i = 0; i < 3; i++) { turnOn(Cmaj[0]); delay(150); turnOff(); } turnOn(Cmaj[4]); delay(150*4); turnOff(); }
void Speaker::playNote(uint8_t n,uint16_t dur){ setNote(n); turnOn(); DelayLoop(dur); turnOff(); DelayLoop(5); }
// light walks thru all 8 buttons void walkyStartup(int iR,int iG, int iB) { for (int i = 0; i < LED_COUNT; ++i) { turnOn(i, iR,iG,iB); } }
void switchState(int id) { if (relays[id].isOn) { turnOff(id); } else { turnOn(id); } }
Doors_Controller::Doors_Controller(SubteStatus *subte, SingleButton *openLeftDoors, SingleButton *closeLeftDoors, SingleButton *selectLeftDoors, SingleButton *openRightDoors, SingleButton *closeRightDoors, SingleButton *selectRightDoors, SingleButton *silbato) : Base_Controller(subte) { m_selectLeftDoors = selectLeftDoors; m_openLeftDoors = openLeftDoors; m_closeLeftDoors = closeLeftDoors; m_selectRightDoors = selectRightDoors; m_openRightDoors = openRightDoors; m_closeRightDoors = closeRightDoors; m_silbato = silbato; m_closeRightDoors->setButtonImage(QUrl("qrc:/resources/greenON.png"),QUrl("qrc:/resources/green.png")); m_closeLeftDoors->setButtonImage(QUrl("qrc:/resources/greenON.png"),QUrl("qrc:/resources/green.png")); m_openRightDoors->setButtonImage(QUrl("qrc:/resources/greenON.png"),QUrl("qrc:/resources/green.png")); m_openLeftDoors->setButtonImage(QUrl("qrc:/resources/greenON.png"),QUrl("qrc:/resources/green.png")); m_silbato->setButtonImage(QUrl("qrc:/resources/blueON.png"),QUrl("qrc:/resources/blueplane.png")); m_closeLeftDoors->setLightManagement(false); m_closeRightDoors->setLightManagement(false); m_openLeftDoors->setLightManagement(false); m_openRightDoors->setLightManagement(false); turnOn(); connect(m_closeLeftDoors,SIGNAL(buttonClicked()),this,SLOT(closeLeft())); connect(m_openLeftDoors,SIGNAL(buttonClicked()),this,SLOT(openLeft())); connect(m_closeRightDoors,SIGNAL(buttonClicked()),this,SLOT(closeRight())); connect(m_openRightDoors,SIGNAL(buttonClicked()),this,SLOT(openRight())); connect(m_selectLeftDoors,SIGNAL(buttonClicked()),this,SLOT(enableLeftPanel())); connect(m_selectRightDoors,SIGNAL(buttonClicked()),this,SLOT(enableRightPanel())); connect(m_subte,SIGNAL(DoorsChanged(bool)),this,SLOT(updatePanel(bool))); }
static void reset(){ unloadRegisters(); clockDown(); //FIXME: fix the reset code turnOff(); turnOn(); }
void MotorClass::setValue(int value) { if (value == 0) { turnOff(); } else { turnOn(value); } }
//light walks thru all 8 buttons void walkyStartup(int iR,int iG, int iB) { for (int i = 1; i <= LED_COUNT; i++) { turnOn(i, iR,iG,iB); // test all switches and exit idle animation if active switch found } kaimana.setALL(BLACK); }
int main(void) { WDTCTL = WDTPW + WDTHOLD; // Stop watchdog timer uart_timer_configure(); uart_init(); _enable_interrupts(); uart_puts("\n\r***************\n\r"); uart_puts("MSP430 SunV2\n\r"); uart_puts("***************\n\r\n\r"); uint8_t c; // Timeshare between UART and dimming while(1) { if(uart_getc(&c)) { if(c == '\r') { uart_putc('\n'); uart_putc('\r'); } else { uart_putc('['); uart_putc(c); uart_putc(']'); // Clear UART configuration _disable_interrupts(); timer_deconfigure(); uart_disable(); uart_timerA_disable(); switch (c) { case 'w': turnOn(); break; case 's': turnOff(); break; case 'r': remember(); break; case 'd': dimUp(); break; case 'a': dimDown(); break; } // UART configuration art_init(); timer_deconfigure(); uart_timer_configure(); uart_timerA_enable(); _enable_interrupts(); } } } }
EngineController::EngineController(QWidget *parent) : QWidget(parent), ui(new Ui::EngineController) { ui->setupUi(this); connect(ui->engineSelect, SIGNAL(activated(int)), this, SLOT(selectEngine(int))); /* Create Engines */ uci = new UCIEngine("/bin/stockfish"); chess = new ChessEngine("/home/alex/cpp/giraffe/giraffe"); engine = NULL; selectEngine(0); // set default engine connect(ui->goButton, SIGNAL(pressed()), this, SLOT(toggleGoStop())); goButtonPressed = false; /* Link QDials and QSpinBoxes */ connect(ui->spinBox_depth, SIGNAL(valueChanged(int)), ui->searchdepth, SLOT(setValue(int))); connect(ui->spinBox_movetime, SIGNAL(valueChanged(int)), ui->movetime, SLOT(setValue(int))); connect(ui->spinBox_nodes, SIGNAL(valueChanged(int)), ui->nodes, SLOT(setValue(int))); connect(ui->searchdepth, SIGNAL(valueChanged(int)), ui->spinBox_depth, SLOT(setValue(int))); connect(ui->movetime, SIGNAL(valueChanged(int)), ui->spinBox_movetime, SLOT(setValue(int))); connect(ui->nodes, SIGNAL(valueChanged(int)), ui->spinBox_nodes, SLOT(setValue(int))); connect(ui->playButton, SIGNAL(pressed()), this, SLOT(play())); connect(ui->radio_play, SIGNAL(pressed()), this, SLOT(turnOn())); connect(ui->radio_think, SIGNAL(pressed()), this, SLOT(turnOn())); connect(ui->radio_power, SIGNAL(pressed()), this, SLOT(turnOff())); ui->searchdepth->setMinimum(0); ui->searchdepth->setMaximum(25); ui->movetime->setMinimum(0); //ui->movetime->setMaximum(100000); ui->nodes->setMinimum(0); ui->nodes->setMaximum(500); ui->spinBox_depth->setMaximum(ui->searchdepth->maximum()); ui->spinBox_movetime->setMaximum(ui->movetime->maximum()); ui->spinBox_nodes->setMaximum(ui->nodes->maximum()); turnOff(); //ui->verticalLayout->addWidget(uci->output); //ui->verticalLayout->addWidget(chess->output); }
static void readRoutine(uint8_t num_regs, float* result){ turnOn(); clockUp(); loadRegisters(); //FIXME: add a delay here clockDown(); //FIXME: add a delay here unloadRegisters(); //TODO: code to read pins }
void webSocketEvent(uint8_t num, WStype_t type, uint8_t *payload, size_t length){ switch(type) { case WStype_DISCONNECTED: Serial.println("Websocket Disconnected..."); break; case WStype_CONNECTED: Serial.println("Websocket Connected!"); break; case WStype_TEXT: String text = String((char *) &payload[0]); Serial.println("Received text:"); Serial.println(text); // process the text however you want if (text.startsWith("on:")) { ws.sendTXT(num, "ack: on"); String outletNumber = text.substring(3, 4); if (outletNumber.equals("1")) { turnOn(OUTLET_1); } else if (outletNumber.equals("2")) { turnOn(OUTLET_2); } } else if (text.startsWith("off:")) { ws.sendTXT(num, "ack: off"); String outletNumber = text.substring(4, 5); if (outletNumber.equals("1")) { turnOff(OUTLET_1); } else if (outletNumber.equals("2")) { turnOff(OUTLET_2); } } break; } }
Piece::Piece(const boost::shared_ptr<Board>& board, unsigned int row, unsigned int column) : mType(Bar), mColumn(column), mRow(row), mBoard(board), mStuck(false) { mType = getRandomType(); mRotation = getRandomRotation(); for(int k=0; k<sNumBlocks; ++k) { mColors[k] = Block::getRandomColor(); } turnOn(); }
int main(int argc, char* argv[]) { if(argc!=2) { printf("Wrong syntax...\n"); return 2; } printf("----Start GPIO program----\n"); printf("GPIO49 path is: %s\n",GPIO49_PATH); if(!strcmp(argv[1],"on")) { turnOn(); } else if(!strcmp(argv[1],"off")) { turnOff(); } else if(!strcmp(argv[1],"flash")) { while(1) { turnOn(); delay_ms(2000); turnOff(); delay_ms(2000); } } else if(!strcmp(argv[1],"reset")) { turnOff(); WriteGPIO("/direction","in"); } else { printf("Command is not supported...\n"); return 2; } return 0; }
String ActuatorRelay::set(String instruction_code, int instruction_id, String instruction_parameter) { if ((instruction_code == instruction_code_) && (instruction_id == instruction_id_)) { if (instruction_parameter.toInt() == 1) { turnOn(); return ""; } else if(instruction_parameter.toInt() == 0) { turnOff(); return ""; } } return ""; }
ControlPoint::ControlPoint() : BrisaControlPoint() { this->selected = NULL; handle = new HandleCmds(); connect(this, SIGNAL(deviceFound(BrisaControlPointDevice*)), this, SLOT(onNewDevice(BrisaControlPointDevice*)), Qt::DirectConnection); connect(this, SIGNAL(deviceGone(QString)), this, SLOT(onRemovedDevice(QString)), Qt::DirectConnection); this->start(); this->discover(); connect(handle, SIGNAL(leave()), this, SLOT(exit())); connect(handle, SIGNAL(list()), this, SLOT(list())); connect(handle, SIGNAL(help()), this, SLOT(help())); connect(handle, SIGNAL(getTarget()), this, SLOT(getTarget())); connect(handle, SIGNAL(getStatus()), this, SLOT(getStatus())); connect(handle, SIGNAL(setLight(int)), this, SLOT(setLight(int))); connect(handle, SIGNAL(turnOn()), this, SLOT(turnOn())); connect(handle, SIGNAL(turnOff()), this, SLOT(turnOff())); handle->start(); }
/** * Schaltet zwischen den Zuständen ON und OFF um. * Ist der Zustand BLINK passiert nichts. * @return void */ void CLED::toggle() { // Zustand überprüfen und umschalten switch (checkStatus()) { case ON: turnOff(); break; case OFF: turnOn(); break; } //if (checkStatus() == ON) // turnOff(); //else if (checkStatus() == OFF) // turnOn(); }
bool Piece::rotatePrivate(Rotation rot) { bool out = hitOnRotate(rot); if(!out) { int dRot; getRotationVariation(rot, dRot); turnOff(); mRotation = (mRotation + dRot) % sRotationCount; turnOn(); } return out; }
void FBO::init(int width, int height) { glGenFramebuffersEXT(1, &fb); // generate the FBO turnOn(); // bind the FBO to initialize data for it glGenRenderbuffersEXT(1, &rb); // generate the render buffer glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, rb); // bind it glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, GL_DEPTH_COMPONENT, width, height); glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER_EXT, rb); glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, 0); // unbind the render buffer turnOff(); // unbind it to resume normal frame buffer }
ProjectorShutterBlock::ProjectorShutterBlock(MainController* controller, QString uid) : OneInputBlock(controller, uid) , m_onNode(nullptr) , m_offNode(nullptr) , m_openShutterNode(nullptr) , m_tcpSocket(new QTcpSocket()) , m_ipAddress(this, "ipAddress", "") , m_port(this, "port", 4352, 1, 65535) , m_password(this, "password", "") , m_projectorName(this, "projectorName", "", /*persistent=*/ false) , m_shutterIsOpen(this, "shutterIsOpen", true, /*persistent=*/ false) , m_connected(this, "connected", false, /*persistent=*/ false) , m_authenticated(this, "authenticated", false, /*persistent=*/ false) , m_passwordIsWrong(this, "passwordIsWrong", false, /*persistent=*/ false) , m_powerStatus(this, "powerStatus", 0, /*persistent=*/ false) { m_onNode = createInputNode("on"); m_onNode->enableImpulseDetection(); connect(m_onNode, SIGNAL(impulseBegin()), this, SLOT(turnOn())); m_offNode = createInputNode("off"); m_offNode->enableImpulseDetection(); connect(m_offNode, SIGNAL(impulseBegin()), this, SLOT(turnOff())); m_openShutterNode = createInputNode("openShutter"); m_openShutterNode->enableImpulseDetection(); connect(m_openShutterNode, SIGNAL(impulseBegin()), this, SLOT(turnAvMuteOff())); m_inputNode->enableImpulseDetection(); connect(m_inputNode, SIGNAL(impulseBegin()), this, SLOT(turnAvMuteOn())); m_connectionCheckTimer.setInterval(3*1000); m_connectionCheckTimer.setSingleShot(false); connect(&m_connectionCheckTimer, &QTimer::timeout, this, &ProjectorShutterBlock::checkConnection); m_connectionCheckTimer.start(); // it is required to send a command at least every 30s to hold the connection open // therefore we will query the power status every 5s: m_powerStatusTimer.setInterval(5*1000); m_powerStatusTimer.setSingleShot(false); connect(&m_powerStatusTimer, &QTimer::timeout, this, &ProjectorShutterBlock::checkPower); m_powerStatusTimer.start(); connect(m_tcpSocket, &QTcpSocket::stateChanged, this, &ProjectorShutterBlock::onConnectionStateChanged); connect(m_tcpSocket, &QTcpSocket::readyRead, this, &ProjectorShutterBlock::onMessageReceived); }
xuiWindowManager::xuiWindowManager(IRenderApi* pRenderApi , xBaseTextureMgr* pTexMgr) :m_XMLManager(L"UIXMLManager" , 1) { m_RefCount = 1; m_pRenderApi = pRenderApi; m_pTextureMgr = pTexMgr; m_AutoUpdater = new xuiWMUpdateObject(this); m_AutoUpdater->turnOn(true); turnOn(true); m_thisTime = 0; m_pActiveWindow = NULL; m_pMouseFocusWindow = NULL; m_commandProc = NULL; m_p2DRenderer = new x2DRenderer(pRenderApi); }
// LEDS blink on randomly void starryStartup(int iR,int iG, int iB) { static int i; int delay_val; for (i = 0; i < LED_COUNT; ++i) //randomizing the array { int rand = random(1,LED_COUNT); int temp = trackled[i]; trackled[i] = trackled[rand]; trackled[rand] = temp; } delay_val = FAST_COLOR_DELAY; for (i = 0; i <= LED_COUNT; ++i) { turnOn(trackled[i], iR,iG,iB); } }
bool Piece::movePrivate(Direction dir) { bool out = hitOnMove(dir); if(!out) { turnOff(); int dRow, dColumn; getMovementVariations(dir, dRow, dColumn); setRow(getRow() + dRow); setColumn(getColumn() + dColumn); turnOn(); } return out; }
void CpuCas01::apply_event(tmgr_trace_iterator_t event, double value) { if (event == speed_.event) { /* TODO (Hypervisor): do the same thing for constraint_core[i] */ xbt_assert(coresAmount_ == 1, "FIXME: add speed scaling code also for constraint_core[i]"); speed_.scale = value; onSpeedChange(); tmgr_trace_event_unref(&speed_.event); } else if (event == stateEvent_) { /* TODO (Hypervisor): do the same thing for constraint_core[i] */ xbt_assert(coresAmount_ == 1, "FIXME: add state change code also for constraint_core[i]"); if (value > 0) { if(isOff()) host_that_restart.push_back(getHost()); turnOn(); } else { lmm_constraint_t cnst = getConstraint(); lmm_variable_t var = nullptr; lmm_element_t elem = nullptr; double date = surf_get_clock(); turnOff(); while ((var = lmm_get_var_from_cnst(getModel()->getMaxminSystem(), cnst, &elem))) { Action *action = static_cast<Action*>(lmm_variable_id(var)); if (action->getState() == Action::State::running || action->getState() == Action::State::ready || action->getState() == Action::State::not_in_the_system) { action->setFinishTime(date); action->setState(Action::State::failed); } } } tmgr_trace_event_unref(&stateEvent_); } else { xbt_die("Unknown event!\n"); } }
bool Piece::hitOnRotate(Rotation rot) const { bool out = false; // displacement int dRot = 0; getRotationVariation(rot, dRot); unsigned int newRot = (mRotation + dRot) % sRotationCount; // deactivate current piece turnOff(); // check hit int row = 0, column = 0; for(int k=0; k<sNumBlocks; ++k) { row = mRow + BlockRow[mType][newRot][k]; column = mColumn + BlockColumn[mType][newRot][k]; // hit a wall if(row >= (int) mBoard->getNumRows() || column < 0 || column >= (int) mBoard->getNumColumns()) { out = true; break; } // hit another piece // note that row and column are valid board indices if(mBoard->checkBoardPosition(row, column)) { out = true; break; } } // activate blocks turnOn(); return out; }
NetworkSettingsWidget::NetworkSettingsWidget(Device *device, QWidget *parent) : StandardWidget(device, parent), ui(new Ui::NetworkSettingsWidget) { ui->setupUi(this); performStandardSetup(tr("Network Settings")); ui->turnOn->setVisible(false); ui->turnOff->setVisible(false); QObject::connect(ui->connect, SIGNAL(clicked()), SLOT(connect())); QObject::connect(ui->manage, SIGNAL(clicked()), SLOT(manage())); NetworkManager::ref().connect(ui->turnOn, SIGNAL(clicked()), SLOT(turnOn())); NetworkManager::ref().connect(ui->turnOff, SIGNAL(clicked()), SLOT(turnOff())); QObject::connect(&NetworkManager::ref(), SIGNAL(stateChanged(const NetworkManager::State &, const NetworkManager::State &)), SLOT(stateChanged(const NetworkManager::State &, const NetworkManager::State &))); updateInformation(); }
bool Piece::hitOnMove(Direction dir) const { bool out = false; // displacement int dRow = 0, dColumn = 0; getMovementVariations(dir, dRow, dColumn); // deactivate current piece turnOff(); // check hit int row = 0, column = 0; for(int k=0; k<sNumBlocks; ++k) { row = mRow + BlockRow[mType][mRotation][k] + dRow; column = mColumn + BlockColumn[mType][mRotation][k] + dColumn; // hit a wall if((dir == MoveDown && row >= (int) mBoard->getNumRows()) || (dir == MoveLeft && column < 0) || (dir == MoveRight && column >= (int) mBoard->getNumColumns())) { out = true; break; } // hit another piece if(mBoard->checkBoardPosition(row, column)) { out = true; break; } } // activate blocks turnOn(); return out; }
/* @(/1/0/1/2) .............................................................*/ static QState LPJ_On(LPJ * const me, QEvent const * const e) { QState status; switch (e->sig) { /* @(/1/0/1/2) */ case Q_ENTRY_SIG: { //printf("LPJ_On\r\n"); turnOn(); //kirimReport(0x02); me->dimm = 0; status = Q_HANDLED(); break; } /* @(/1/0/1/2/0) */ case HighLight_SIG: { status = Q_TRAN(&LPJ_Off); break; } /* @(/1/0/1/2/2/1/0) */ case reportAfter_SIG: { me->after =((reportEvt const *)e)->presence; status = Q_HANDLED(); break; } case reportBefore_SIG: { me->before =((reportEvt const *)e)->presence; status = Q_HANDLED(); break; } case TickTime_SIG: { // periksaLux(); status = Q_HANDLED(); break; } default: { status = Q_SUPER(&QHsm_top); break; } } return status; }