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 displaySetAddress(0, 6); displayPutStr("Press + to change mon", NORMAL); displaySetAddress(0, 7); displayPutStr("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 displaySetAddress(0, 6); displayPutStr("Press + to change day", NORMAL); displaySetAddress(0, 7); displayPutStr("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 displaySetAddress(0, 6); displayPutStr("Press + to change day", NORMAL); displaySetAddress(0, 7); displayPutStr("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 displaySetAddress(0, 6); displayPutStr("Press + to change mon", NORMAL); displaySetAddress(0, 7); displayPutStr("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 displaySetAddress(0, 6); displayPutStr("Press + to change yr.", NORMAL); displaySetAddress(0, 7); displayPutStr("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 displaySetAddress(0, 6); displayPutStr("Press MENU to advance", NORMAL); displaySetAddress(0, 7); displayPutStr("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 setscore_rat(void) { if(score_mode != last_score_mode_rat) { redraw_time_rat = 1; last_score_mode_rat = score_mode; } switch(score_mode) { #ifdef OPTION_DOW_DATELONG case SCORE_MODE_DOW: break; case SCORE_MODE_DATELONG: right_score = date_d; break; #endif case SCORE_MODE_TIME: if((minute_changed || hour_changed)) { if(hour_changed) { left_score = hours(old_h); right_score = old_m; } else if (minute_changed) { right_score = old_m; } } else { left_score = hours(time_h); right_score = time_m; } break; case SCORE_MODE_DATE: #ifdef OPTION_DOW_DATELONG if((region == REGION_US)||(region == DOW_REGION_US)) { #else if(region == REGION_US) { #endif left_score = date_m; right_score = date_d; } else { left_score = date_d; right_score = date_m; } break; case SCORE_MODE_YEAR: left_score = 20; right_score = date_y; break; case SCORE_MODE_ALARM: left_score = hours(alarm_h); right_score = alarm_m; break; } } int16_t ticksremaining; //JMM !! FIX THIS !! It's a global and it's passed as an arg void initanim_rat(void) { DEBUG(putstring("screen width: ")); DEBUG(uart_putw_dec(GLCD_XPIXELS)); DEBUG(putstring("\n\rscreen height: ")); DEBUG(uart_putw_dec(GLCD_YPIXELS)); DEBUG(putstring_nl("")); oldball_x = ball_x = 25*FIXED_MATH; oldball_y = ball_y = 25*FIXED_MATH; //Somewhere away from 0,0. oldleftpaddle_y = leftpaddle_y = 25*FIXED_MATH; oldrightpaddle_y = rightpaddle_y = 25*FIXED_MATH; init_crand(); ball_dx = ball_dy = 0; initdisplay_rat(0); }