void display_menu(uint8_t line) { DEBUGP("display menu"); screenmutex++; glcdClearScreen(); //Dataman - Mode Menu Option //glcdSetAddress(0, 0); //glcdPutStr("Configuration Menu", NORMAL); glcdSetAddress(MENU_INDENT, 0); glcdPutStr("Mode:", NORMAL); print_style_setting(NORMAL); print_alarmline(SET_ALARM); print_time(time_h,time_m,time_s,SET_TIME); print_date(date_m,date_d,date_y,SET_DATE); print_region_setting(NORMAL); #ifdef BACKLIGHT_ADJUST print_backlight(SET_BRIGHTNESS); if(displaymode == SET_BRIGHTNESS) #else if(displaymode == SET_REGION) #endif print_menu_exit(); else print_menu_advance(); drawArrow(0, (line*8)+3, MENU_INDENT -1); screenmutex--; }
void set_backlight(void) { uint8_t mode = SET_BRIGHTNESS; display_menu(); screenmutex++; glcdSetAddress(0, 6); glcdPutStr("Press MENU to exit ", NORMAL); // put a small arrow next to 'set 12h/24h' drawArrow(0, 43, MENU_INDENT -1); screenmutex--; timeoutcounter = INACTIVITYTIMEOUT; while (1) { if (just_pressed & 0x1) { // mode change return; } if (just_pressed || pressed) { timeoutcounter = INACTIVITYTIMEOUT; // timeout w/no buttons pressed after 3 seconds? } else if (!timeoutcounter) { //timed out! displaymode = SHOW_TIME; return; } if (just_pressed & 0x2) { just_pressed = 0; screenmutex++; if (mode == SET_BRIGHTNESS) { DEBUG(putstring("Setting backlight")); // ok now its selected mode = SET_BRT; // print the region glcdSetAddress(MENU_INDENT + 15*6, 5); printnumber(OCR2B>>OCR2B_BITSHIFT,INVERTED); // display instructions below glcdSetAddress(0, 6); glcdPutStr("Press + to change ", NORMAL); glcdSetAddress(0, 7); glcdPutStr("Press SET to save ", NORMAL); } else {
static void print_date(uint8_t month, uint8_t day, uint8_t year, uint8_t mode) { glcdSetAddress(MENU_INDENT, 3); glcdPutStr("Date:", NORMAL); if (region == REGION_US) { glcdPutStr(" ",NORMAL); printnumber(month, (mode == SET_MONTH)?INVERTED:NORMAL); glcdWriteChar('/', NORMAL); printnumber(day, (mode == SET_DAY)?INVERTED:NORMAL); glcdWriteChar('/', NORMAL); } else if (region == REGION_EU) { glcdPutStr(" ",NORMAL); printnumber(day, (mode == SET_DAY)?INVERTED:NORMAL); glcdWriteChar('/', NORMAL); printnumber(month, (mode == SET_MONTH)?INVERTED:NORMAL); glcdWriteChar('/', NORMAL); } else if ( region == DOW_REGION_US) { glcdWriteChar(' ', NORMAL); print_dow(NORMAL,month,day,year); printnumber(month, (mode == SET_MONTH)?INVERTED:NORMAL); glcdWriteChar('/', NORMAL); printnumber(day, (mode == SET_DAY)?INVERTED:NORMAL); glcdWriteChar('/', NORMAL); } else if ( region == DOW_REGION_EU) { glcdWriteChar(' ', NORMAL); print_dow(NORMAL,month,day,year); printnumber(day, (mode == SET_DAY)?INVERTED:NORMAL); glcdWriteChar('/', NORMAL); printnumber(month, (mode == SET_MONTH)?INVERTED:NORMAL); glcdWriteChar('/', NORMAL); } else if ( region == DATELONG) { glcdPutStr(" ",NORMAL); print_month((mode == SET_MONTH)?INVERTED:NORMAL,month); glcdWriteChar(' ', NORMAL); printnumber(day, (mode == SET_DAY)?INVERTED:NORMAL); glcdWriteChar(',', NORMAL); glcdWriteChar(' ', NORMAL); } else { print_dow(NORMAL,month,day,year); print_month((mode == SET_MONTH)?INVERTED:NORMAL,month); glcdWriteChar(' ', NORMAL); printnumber(day, (mode == SET_DAY)?INVERTED:NORMAL); glcdWriteChar(',', NORMAL); } printnumber(20,(mode == SET_YEAR)?INVERTED:NORMAL); printnumber(year, (mode == SET_YEAR)?INVERTED:NORMAL); }
void print_alarmline(uint8_t mode) { glcdSetAddress(MENU_INDENT, 1); glcdPutStr("Set Alarm: ", NORMAL); print_alarmhour(alarm_h, ((mode==SET_HOUR)?INVERTED:NORMAL)); glcdWriteChar(':', NORMAL); printnumber(alarm_m, ((mode==SET_MIN)?INVERTED:NORMAL)); }
void print_dow(uint8_t inverted, uint8_t mon, uint8_t day, uint8_t yr) { switch(dotw(mon,day,yr)) { case 0: glcdPutStr("Sun ", inverted); break; case 1: glcdPutStr("Mon ", inverted); break; case 2: glcdPutStr("Tue ", inverted); break; case 3: glcdPutStr("Wed ", inverted); break; case 4: glcdPutStr("Thu ", inverted); break; case 5: glcdPutStr("Fri ", inverted); break; case 6: glcdPutStr("Sat ", inverted); break; } }
void print_time(uint8_t hour, uint8_t min, uint8_t sec, uint8_t mode) { glcdSetAddress(MENU_INDENT, 2); glcdPutStr("Set Time: ", NORMAL); print_timehour(hour, ((mode==SET_HOUR)?INVERTED:NORMAL)); glcdWriteChar(':', NORMAL); printnumber(min, ((mode==SET_MIN)?INVERTED:NORMAL)); glcdWriteChar(':', NORMAL); printnumber(sec, ((mode==SET_SEC)?INVERTED:NORMAL)); if (time_format == TIME_12H) { glcdWriteChar(' ', NORMAL); if (hour >= 12) { glcdWriteChar('P', ((mode==SET_HOUR)?INVERTED:NORMAL)); } else { glcdWriteChar('A', ((mode==SET_HOUR)?INVERTED:NORMAL)); } } }
void display_menu(void) { DEBUGP("display menu"); screenmutex++; glcdClearScreen(); glcdSetAddress(0, 0); glcdPutStr("Configuration Menu", NORMAL); glcdSetAddress(MENU_INDENT, 1); glcdPutStr("Set Alarm: ", NORMAL); print_alarmhour(alarm_h, NORMAL); glcdWriteChar(':', NORMAL); printnumber(alarm_m, NORMAL); glcdSetAddress(MENU_INDENT, 2); glcdPutStr("Set Time: ", NORMAL); print_timehour(time_h, NORMAL); glcdWriteChar(':', NORMAL); printnumber(time_m, NORMAL); glcdWriteChar(':', NORMAL); printnumber(time_s, NORMAL); if (time_format == TIME_12H) { glcdWriteChar(' ', NORMAL); if (time_h >= 12) { glcdWriteChar('P', NORMAL); } else { glcdWriteChar('A', NORMAL); } } print_date(date_m,date_d,date_y,SET_DATE); print_region_setting(NORMAL); #ifdef BACKLIGHT_ADJUST glcdSetAddress(MENU_INDENT, 5); glcdPutStr("Set Backlight: ", NORMAL); printnumber(OCR2B>>OCR2B_BITSHIFT,NORMAL); #endif glcdSetAddress(0, 6); glcdPutStr("Press MENU to advance", NORMAL); glcdSetAddress(0, 7); glcdPutStr("Press SET to set", NORMAL); screenmutex--; }
void lcdtest(void) { unsigned char key = 0; glcdClearScreen(); glcdSetAddress(4,LINE2); glcdPutStr("Graphic LCD Test"); glcdSetAddress(4,LINE3); glcdPutStr("HD61202/3 controller"); glcdSetAddress(4,LINE4); glcdPutStr("KS0108/7 controller"); glcdSetAddress(4,LINE5); glcdPutStr("Press buttons to"); glcdSetAddress(4,LINE6); glcdPutStr("test functions..."); glcdRectangle(0, 0, 64, 128); while(1) { timerPause(10); key = ~inb(PINA); glcdSetAddress(4,LINE7); rprintf("Button status: %x ", key); if(key == KEY1) { unsigned char i ; glcdClearScreen(); for ( i=0; i<128; i+=3) { glcdSetDot(i,63 - i/2); glcdDelay(0x5fff); } for ( i=0; i<128; i+=3) { glcdClearDot(i,63 - i/2); glcdDelay(0x5fff); } } if(key == KEY2) { glcdClearScreen(); glcdCircle(25,20,17); glcdDelay(0xffff); glcdCircle(90,30,15); glcdDelay(0xffff); glcdCircle(55,30,23); glcdDelay(0xffff); glcdCircle(100,48,15); glcdDelay(0xffff); glcdCircle(34,50,10); glcdDelay(0xffff); glcdCircle(60,55,8); } if(key == KEY3) { glcdClearScreen(); glcdRectangle(54, 41, 6 , 12); glcdDelay(0xffff); glcdRectangle(34, 12, 32, 2); glcdDelay(0xffff); glcdRectangle(23, 34, 17, 21); glcdDelay(0xffff); glcdRectangle(62, 20, 42, 58); glcdDelay(0xffff); glcdRectangle(4 , 30, 12, 12); } if(key == KEY4) { glcdClearScreen(); glcdSetAddress(0,LINE1); glcdPutStr("LINE 1"); glcdDelay(0xffff); glcdSetAddress(5,LINE2); glcdPutStr("LINE 2"); glcdDelay(0xffff); glcdSetAddress(10,LINE3); glcdPutStr("LINE 3"); glcdDelay(0xffff); glcdSetAddress(15,LINE4); glcdPutStr("LINE 4"); glcdDelay(0xffff); glcdSetAddress(20,LINE5); glcdPutStr("LINE 5"); glcdDelay(0xffff); glcdSetAddress(25,LINE6); glcdPutStr("LINE 6"); glcdDelay(0xffff); glcdSetAddress(30,LINE7); glcdPutStr("LINE 7"); glcdDelay(0xffff); glcdSetAddress(35,LINE8); glcdPutStr("LINE 8"); glcdDelay(0xffff); } if(key == KEY5) { glcdClearScreen(); glcdSetAddress(0,LINE2); glcdPutStr(" !"); glcdWriteChar('"'); glcdPutStr("#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ"); glcdPutStr("[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~"); } if(key == KEY6) { unsigned char i; for (i=0; i<64; i++) { glcdStartLine(64- i - 1); glcdDelay(0x5fff); } } if(key == KEY7) { unsigned char i; for (i=0; i<64; i++) { glcdStartLine(i + 1); glcdDelay(0x5fff); } } if (key == KEY8) { // glcdBackLight(OFF); // glcdBackLight(ON); } } }
void print_month(uint8_t inverted, uint8_t month) { switch(month) { case 1: glcdPutStr("Jan", inverted); break; case 2: glcdPutStr("Feb", inverted); break; case 3: glcdPutStr("Mar", inverted); break; case 4: glcdPutStr("Apr", inverted); break; case 5: glcdPutStr("May", inverted); break; case 6: glcdPutStr("Jun", inverted); break; case 7: glcdPutStr("Jul", inverted); break; case 8: glcdPutStr("Aug", inverted); break; case 9: glcdPutStr("Sep", inverted); break; case 10: glcdPutStr("Oct", inverted); break; case 11: glcdPutStr("Nov", inverted); break; case 12: glcdPutStr("Dec", inverted); break; } }
void set_date(void) { uint8_t mode = SET_DATE; uint8_t day, month, year; day = date_d; month = date_m; year = date_y; display_menu(); screenmutex++; // put a small arrow next to 'set date' drawArrow(0, 27, MENU_INDENT -1); screenmutex--; timeoutcounter = INACTIVITYTIMEOUT; while (1) { if (just_pressed & 0x1) { // mode change return; } if (just_pressed || pressed) { timeoutcounter = INACTIVITYTIMEOUT; // timeout w/no buttons pressed after 3 seconds? } else if (!timeoutcounter) { //timed out! displaymode = SHOW_TIME; return; } if (just_pressed & 0x2) { just_pressed = 0; screenmutex++; if ((mode == SET_DATE) && ((region == REGION_US) || (region == DOW_REGION_US) || (region == DATELONG) || (region == DATELONG_DOW))) { DEBUG(putstring("Set date month")); // ok now its selected mode = SET_MONTH; // print the month inverted print_date(month,day,year,mode); // display instructions below glcdSetAddress(0, 6); glcdPutStr("Press + to change mon", NORMAL); glcdSetAddress(0, 7); glcdPutStr("Press SET to set mon.", NORMAL); } else if ((mode == SET_DATE) && ((region == REGION_EU) || (region == DOW_REGION_EU))) { DEBUG(putstring("Set date month")); // ok now its selected mode = SET_DAY; // print the day inverted print_date(month,day,year,mode); // display instructions below glcdSetAddress(0, 6); glcdPutStr("Press + to change day", NORMAL); glcdSetAddress(0, 7); glcdPutStr("Press SET to set date", NORMAL); } else if ((mode == SET_MONTH) && ((region == REGION_US) || (region == DOW_REGION_US) || (region == DATELONG) || (region == DATELONG_DOW))) { DEBUG(putstring("Set date day")); mode = SET_DAY; print_date(month,day,year,mode); // display instructions below glcdSetAddress(0, 6); glcdPutStr("Press + to change day", NORMAL); glcdSetAddress(0, 7); glcdPutStr("Press SET to set date", NORMAL); }else if ((mode == SET_DAY) && ((region == REGION_EU) || (region == DOW_REGION_EU))) { DEBUG(putstring("Set date month")); mode = SET_MONTH; print_date(month,day,year,mode); // display instructions below glcdSetAddress(0, 6); glcdPutStr("Press + to change mon", NORMAL); glcdSetAddress(0, 7); glcdPutStr("Press SET to set mon.", NORMAL); } else if ( ((mode == SET_DAY) && ((region == REGION_US) || (region == DOW_REGION_US) || (region == DATELONG) || (region == DATELONG_DOW))) || ((mode == SET_MONTH) && ((region == REGION_EU) || (region == DOW_REGION_EU))) ) { DEBUG(putstring("Set year")); mode = SET_YEAR; // print the date normal print_date(month,day,year,mode); // display instructions below glcdSetAddress(0, 6); glcdPutStr("Press + to change yr.", NORMAL); glcdSetAddress(0, 7); glcdPutStr("Press SET to set year", NORMAL); } else { // done! DEBUG(putstring("done setting date")); mode = SET_DATE; // print the seconds normal print_date(month,day,year,mode); // display instructions below glcdSetAddress(0, 6); glcdPutStr("Press MENU to advance", NORMAL); glcdSetAddress(0, 7); glcdPutStr("Press SET to set", NORMAL); date_y = year; date_m = month; date_d = day; writei2ctime(time_s, time_m, time_h, 0, date_d, date_m, date_y); init_crand(); } screenmutex--; } if ((just_pressed & 0x4) || (pressed & 0x4)) { just_pressed = 0; screenmutex++; if (mode == SET_MONTH) { month++; if (month >= 13) month = 1; if(month == 2) { if(leapyear(year) && (day > 29)) day = 29; else if (!leapyear(year) && (day > 28)) day = 28; } else if ((month == 4) || (month == 6) || (month == 9) || (month == 11)) { if(day > 30) day = 30; } print_date(month,day,year,mode); } if (mode == SET_DAY) { day++; if (day > 31) day = 1; if(month == 2) { if(leapyear(year) && (day > 29)) day = 1; else if (!leapyear(year) && (day > 28)) day = 1; } else if ((month == 4) || (month == 6) || (month == 9) || (month == 11)) { if(day > 30) day = 1; } print_date(month,day,year,mode); } if (mode == SET_YEAR) { year = (year+1) % 100; print_date(month,day,year,mode); } screenmutex--; if (pressed & 0x4) _delay_ms(200); } } }
void print_backlight(uint8_t mode) { glcdSetAddress(MENU_INDENT, 5); glcdPutStr("Set Backlight: ", NORMAL); printnumber(OCR2B>>OCR2B_BITSHIFT,((mode==SET_BRT)?INVERTED:NORMAL)); }
void print_region_setting(uint8_t inverted) { glcdSetAddress(MENU_INDENT, 4); glcdPutStr("Region: ", NORMAL); glcdPutStr_rom(®ion_setting_table[(region * 2) + time_format][0], inverted); }