#include #define F_CPU 3686400UL #include "myavr_lcd.h" #include #include #include #include #include #include #define Tweiter !(PINB & (1<1: key press detect if( (key_state & REPEAT_MASK) == 0 ) // check repeat function rpt = REPEAT_START; // start delay if( --rpt == 0 ){ rpt = REPEAT_NEXT; // repeat delay key_rpt |= key_state & REPEAT_MASK; } } /////////////////////////////////////////////////////////////////// // // check if a key has been pressed. Each pressed key is reported // only once // uint8_t get_key_press( uint8_t key_mask ) { cli(); // read and clear atomic ! key_mask &= key_press; // read key(s) key_press ^= key_mask; // clear key(s) sei(); return key_mask; } /////////////////////////////////////////////////////////////////// // // check if a key has been pressed long enough such that the // key repeat functionality kicks in. After a small setup delay // the key is reported beeing pressed in subsequent calls // to this function. This simulates the user repeatedly // pressing and releasing the key. // uint8_t get_key_rpt( uint8_t key_mask ) { cli(); // read and clear atomic ! key_mask &= key_rpt; // read key(s) key_rpt ^= key_mask; // clear key(s) sei(); return key_mask; } /////////////////////////////////////////////////////////////////// // uint8_t get_key_short( uint8_t key_mask ) { cli(); // read key state and key press atomic ! return get_key_press( ~key_state & key_mask ); } /////////////////////////////////////////////////////////////////// // uint8_t get_key_long( uint8_t key_mask ) { return get_key_press( get_key_rpt( key_mask )); } const char haupt[] PROGMEM = "Hauptmenue "; const char ict[] PROGMEM = "1. ICT "; const char unidib[] PROGMEM = "2. UniDIB "; const char and[] PROGMEM = "AND "; const char or[] PROGMEM = "OR "; const char not[] PROGMEM = "NOT "; const char nand[] PROGMEM = "NAND "; const char nor[] PROGMEM = "NOR "; const char trenn[] PROGMEM = "----------------"; void display (int number) { switch (number) { case 0: lcd_clrscr(); lcd_puts_p(haupt); lcd_gotoxy(0,1); lcd_puts_p(ict); break; case 1: lcd_clrscr(); lcd_puts_p(ict); lcd_gotoxy(0,1); lcd_puts_p(and); break; case 2: lcd_clrscr(); lcd_puts_p(ict); lcd_gotoxy(0,1); lcd_puts_p(or); break; case 3: lcd_clrscr(); lcd_puts_p(ict); lcd_gotoxy(0,1); lcd_puts_p(not); break; case 4: lcd_clrscr(); lcd_puts_p(ict); lcd_gotoxy(0,1); lcd_puts_p(nor); break; case 5: lcd_clrscr(); lcd_puts_p(ict); lcd_gotoxy(0,1); lcd_puts_p(nand); break; case 6: lcd_clrscr(); lcd_puts_p(haupt); lcd_gotoxy(0,1); lcd_puts_p(unidib); break; case 7: lcd_clrscr(); lcd_puts_p(unidib); lcd_gotoxy(0,1); lcd_puts_p(and); break; case 8: lcd_clrscr(); lcd_puts_p(unidib); lcd_gotoxy(0,1); lcd_puts_p(or); break; case 9: lcd_clrscr(); lcd_puts_p(unidib); lcd_gotoxy(0,1); lcd_puts_p(not); break; case 10: lcd_clrscr(); lcd_puts_p(unidib); lcd_gotoxy(0,1); lcd_puts_p(nor); break; case 11: lcd_clrscr(); lcd_puts_p(unidib); lcd_gotoxy(0,1); lcd_puts_p(nand); break; case 12: lcd_clrscr(); lcd_puts_p(trenn); break; } } int main() { int menue = 0; int sub = 0; KEY_DDR &= ~ALL_KEYS; KEY_PORT |= ALL_KEYS; TCCR0 = (1<