void ObcUITask::runButtonEvents() { for(std::vector<uint32_t>::iterator buttonMask = buttonEventsActive.begin(); buttonMask != buttonEventsActive.end(); buttonEventsActive.erase(buttonMask)) { buttonHandler(ObcUITaskFocus::active, *buttonMask); } for(std::vector<uint32_t>::iterator buttonMask = buttonEventsBackground.begin(); buttonMask != buttonEventsBackground.end(); buttonEventsBackground.erase(buttonMask)) { buttonHandler(ObcUITaskFocus::background, *buttonMask); } }
THREAD(ButtonHandlerThread, arg) { for (;;) { NutSleep(100); buttonHandler(KbGetKey()); } }
int main(void){ secondInit(); eintInit(); pulseInit(); RSInit(); sleepInit(); adcInit(); sei(); //ODBLOKOWANIE PRZERWAN // loadConfig(); // strcpy(txt_buf,"\n\n\n\nWitam Panstwa"); // RSTransmit(txt_buf); RSTransmit("\n\n\n\nWitam Panstwa2"); // saveConfig(); //loadConfig(); while(1) { if(tmp!=0){ consoleCMD(tmp); tmp=0; } if(button_handle_flag==1){ button_handle_flag=0; buttonHandler(); } } return 0; }
bool Adafruit_Controller::process() { if (comm.available()) { char in = comm.read(); if (in == '!') { // start of packet packet_idx = 2; memset(packet_buffer.buffer, 0, 21); } packet_buffer.buffer[packet_idx++] = in; if (isValidPacket()) { switch (packet_buffer.pkt.action) { case 'A': if (accelHandler) accelHandler(packet_buffer.pkt.type.accel.x, packet_buffer.pkt.type.accel.y, packet_buffer.pkt.type.accel.z); break; case 'G': if (gyroHandler) gyroHandler(packet_buffer.pkt.type.gyro.x, packet_buffer.pkt.type.gyro.y, packet_buffer.pkt.type.gyro.z); break; case 'M': if (magHandler) magHandler(packet_buffer.pkt.type.mag.x, packet_buffer.pkt.type.mag.y, packet_buffer.pkt.type.mag.z); break; case 'Q': if (quatHandler) quatHandler(packet_buffer.pkt.type.quat.x, packet_buffer.pkt.type.quat.y, packet_buffer.pkt.type.quat.z, packet_buffer.pkt.type.quat.w); break; case 'B': if (buttonHandler) { byte btn = packet_buffer.pkt.type.button.button - '0'; bool state = packet_buffer.pkt.type.button.state == '1' ? true : false; buttonHandler(btn, state); } break; case 'C': if (colorHandler) colorHandler(packet_buffer.pkt.type.color.red, packet_buffer.pkt.type.color.green, packet_buffer.pkt.type.color.blue); break; case 'L': if (locationHandler) locationHandler(packet_buffer.pkt.type.location.lat, packet_buffer.pkt.type.location.lon, packet_buffer.pkt.type.location.alt); break; default: // unknown type return false; break; } return true; } } return false; }
static void checkSignals(void) { // Check for UNIT IRQ if (signal_pending(SIGNAL_UNIT_IRQ) && signal_status(SIGNAL_UNIT_IRQ)) { // Notify only on transitionn to LOW value notifyFault(); } // Checking for BUTTON if (signal_pending(SIGNAL_PLAT_BUTTON)) { DB2(LOG_INFO("USR BUTTON [%d]\r\n\n", signal_status(SIGNAL_PLAT_BUTTON))); buttonHandler(); } }