static void onKeyPressed(uint8_t key) { switch(key) { case KEY_PLUS: if (timer_mode == TIMER_MODE_WAIT && timer_interval < MAX_TIME_INTERVAL_MINUTES) { timer_interval++; } break; case KEY_MINUS: if (timer_mode == TIMER_MODE_WAIT && timer_interval > 0) { timer_interval--; } break; case KEY_ENTER: if (timer_mode == TIMER_MODE_WAIT) { eeprom_update_word(EEPROM_OFFSET_TIME, timer_interval); time = timer_interval * 60; enableLed(true); enablePower(true); timer_mode = TIMER_MODE_RUN; } break; case KEY_BACK: if (timer_mode == TIMER_MODE_RUN) { timer_mode = TIMER_MODE_WAIT; enableLed(false); enablePower(false); } break; } }
int main(void) { DDRD = 0xff; DDRB = 0xff; DDRC = 0; PORTC = _BV(2) | _BV(3) | _BV(4) | _BV(5); // keyboard pull-up TCCR1A = 0; TCCR1B = _BV(CS11) | _BV(CS10); TIMSK = _BV(OCIE1A); sei(); enableLed(false); enablePower(false); displayOutTime(0); timer_interval = eeprom_read_word(EEPROM_OFFSET_TIME); if (timer_interval > MAX_TIME_INTERVAL_MINUTES || timer_interval == 0) { timer_interval = 10; } while(1) { keyboardCheck(); if (timer_mode == TIMER_MODE_WAIT) { if (key_pressed[KEY_PLUS] == 0xff && timer_interval < MAX_TIME_INTERVAL_MINUTES) { timer_interval++; key_pressed[KEY_PLUS] = 220; } else if (key_pressed[KEY_MINUS] == 0xff && timer_interval > 0) { timer_interval--; key_pressed[KEY_MINUS] = 220; } } for (uint8_t i = 0; i < 8; i++) { displayUpdate(i); if (timer_mode == TIMER_MODE_RUN) { displayOutTime(time); displayOutSeparator(hsec < 50); if (time < 30) { enableLed(hsec < 25 || (hsec > 50 && hsec < 75)); } else if (time < 60) { enableLed(hsec < 75); } } else { displayOutTime(timer_interval); displayOutSeparator(true); //displayOutSeparator(hsec < 25 || (hsec > 50 && hsec < 75)); //if (hsec < 25 || (hsec > 50 && hsec < 75)) { //displayOutTime(timer_interval); //displayOutSeparator(true); //} else { //displayClear(); //} } _delay_us(500); } } }
void LEDNotificationSink::updateStatusOfLedFeedback() { #ifdef HAVE_QMSYSTEM if (displayState.get() == MeeGo::QmDisplayState::Off && notifierEnabled) { // Display is off and notifier is enabled, LED should be ON enableLed(); } else { // Display is on or notifier is disabled, LED should be OFF disableLed(); } #endif }
//------------------------------------------------------------------------------ int __attribute__((OS_main)) main(void) { dnaUsbInit(); // will initialize the port and start listening sei(); // turning interrupts on starts the system going enableLed(); setLedOn(); for(;;) { usbPoll(); // must be called at least once every 50ms to service USB data // user code here } }
//------------------------------------------------------------------------------ int __attribute__((OS_main)) main(void) { dnaUsbInit(); enableLed(); usbCommand = ceCommandIdle; usbRNAPacketExpected = 1; TCCR0B = 1<<CS01 | 1<<CS00; // set 8-bit timer prescaler to div/64 TIMSK0 = 1<<TOIE0; // enable the interrupt rnaInit(); sei(); setLedOff(); for(;;) { rnaPoll(); if ( rnaPacketAvail ) { setLedOn(); rnaPacketAvail = 0; _delay_ms( 50 ); while ( !rnaSend(usbRNATo, usbRNAPacket, usbRNAPacketExpected) ) { _delay_ms(1); } setLedOff(); } /* if ( usbRNAPacketPos == usbRNAPacketExpected ) { usbRNAPacketPos = 0; if ( *usbRNAPacket == RNATypeDebugString ) { usbRNAPacket[usbRNAPacketExpected] = 0; usbprint( (char *)usbRNAPacket + 1, usbRNAPacketExpected ); } } */ } }