Permalink
Browse files

Added additional date display modes

  • Loading branch information...
1 parent 8f6ff06 commit 451a78df9149c8d62b016d830dba2aa5bf1ef630 @CaitSith2 CaitSith2 committed Feb 28, 2010
Showing with 435 additions and 147 deletions.
  1. +182 −28 firmware/anim.c
  2. +166 −115 firmware/config.c
  3. +69 −4 firmware/ratt.c
  4. +18 −0 firmware/ratt.h
View
210 firmware/anim.c
@@ -12,6 +12,7 @@
#include "ratt.h"
#include "ks0108.h"
#include "glcd.h"
+#include "font5x7.h"
extern volatile uint8_t time_s, time_m, time_h;
extern volatile uint8_t old_m, old_h;
@@ -113,6 +114,11 @@ void setscore(void)
last_score_mode = score_mode;
}
switch(score_mode) {
+ case SCORE_MODE_DOW:
+ break;
+ case SCORE_MODE_DATELONG:
+ right_score = date_d;
+ break;
case SCORE_MODE_TIME:
if(alarming && (minute_changed || hour_changed)) {
if(hour_changed) {
@@ -127,7 +133,7 @@ void setscore(void)
}
break;
case SCORE_MODE_DATE:
- if(region == REGION_US) {
+ if((region == REGION_US)||(region == DOW_REGION_US)) {
left_score = date_m;
right_score = date_d;
} else {
@@ -601,33 +607,7 @@ void draw(uint8_t inverted) {
}
TIMSK2 = _BV(TOIE2); //Race issue gone, renable.
- // redraw 10's of hours
- if (redraw_digits || intersectrect(oldball_x, oldball_y, ball_radius*2, ball_radius*2,
- DISPLAY_H10_X, DISPLAY_TIME_Y, DISPLAY_DIGITW, DISPLAY_DIGITH)) {
-
- if ((time_format == TIME_12H) && ((score_mode == SCORE_MODE_TIME) || (score_mode == SCORE_MODE_ALARM)))
- drawbigdigit(DISPLAY_H10_X, DISPLAY_TIME_Y, ((left_score + 23)%12 + 1)/10, inverted);
- else
- drawbigdigit(DISPLAY_H10_X, DISPLAY_TIME_Y, left_score/10, inverted);
- }
-
- // redraw 1's of hours
- if (redraw_digits || intersectrect(oldball_x, oldball_y, ball_radius*2, ball_radius*2,
- DISPLAY_H1_X, DISPLAY_TIME_Y, DISPLAY_DIGITW, DISPLAY_DIGITH)) {
- if ((time_format == TIME_12H) && ((score_mode == SCORE_MODE_TIME) || (score_mode == SCORE_MODE_ALARM)))
- drawbigdigit(DISPLAY_H1_X, DISPLAY_TIME_Y, ((left_score + 23)%12 + 1)%10, inverted);
- else
- drawbigdigit(DISPLAY_H1_X, DISPLAY_TIME_Y, left_score%10, inverted);
- }
-
- if (redraw_digits || intersectrect(oldball_x, oldball_y, ball_radius*2, ball_radius*2,
- DISPLAY_M10_X, DISPLAY_TIME_Y, DISPLAY_DIGITW, DISPLAY_DIGITH)) {
- drawbigdigit(DISPLAY_M10_X, DISPLAY_TIME_Y, right_score/10, inverted);
- }
- if (redraw_digits || intersectrect(oldball_x, oldball_y, ball_radius*2, ball_radius*2,
- DISPLAY_M1_X, DISPLAY_TIME_Y, DISPLAY_DIGITW, DISPLAY_DIGITH)) {
- drawbigdigit(DISPLAY_M1_X, DISPLAY_TIME_Y, right_score%10, inverted);
- }
+ draw_score(redraw_digits,inverted);
redraw_digits = 0;
// print 'alarm'
@@ -678,8 +658,167 @@ static unsigned char __attribute__ ((progmem)) BigFont[] = {
0x80, 0x80, 0x80, 0xFF,// 7
0xFF, 0x91, 0x91, 0xFF,// 8
0xF1, 0x91, 0x91, 0xFF,// 9
+ 0x00, 0x00, 0x00, 0x00,// SPACE
+};
+
+static unsigned char __attribute__ ((progmem)) MonthText[] = {
+ 0,0,0,
+ 'J','A','N',
+ 'F','E','B',
+ 'M','A','R',
+ 'A','P','R',
+ 'M','A','Y',
+ 'J','U','N',
+ 'J','U','L',
+ 'A','U','G',
+ 'S','E','P',
+ 'O','C','T',
+ 'N','O','V',
+ 'D','E','C',
+};
+
+static unsigned char __attribute__ ((progmem)) DOWText[] = {
+ 'S','U','N',
+ 'M','O','N',
+ 'T','U','E',
+ 'W','E','D',
+ 'T','H','U',
+ 'F','R','I',
+ 'S','A','T',
};
+uint8_t dotw(uint8_t mon, uint8_t day, uint8_t yr)
+{
+ uint16_t month, year;
+
+ // Calculate day of the week
+
+ month = mon;
+ year = 2000 + yr;
+ if (mon < 3) {
+ month += 12;
+ year -= 1;
+ }
+ return (day + (2 * month) + (6 * (month+1)/10) + year + (year/4) - (year/100) + (year/400) + 1) % 7;
+}
+
+void draw_score(uint8_t redraw_digits, uint8_t inverted) {
+ static uint8_t prev_mode;
+ if(score_mode==SCORE_MODE_DOW) {
+ if(prev_mode != SCORE_MODE_DOW)
+ {
+ drawbigdigit(DISPLAY_H10_X, DISPLAY_TIME_Y, 10, inverted);
+ drawbigdigit(DISPLAY_H1_X, DISPLAY_TIME_Y, 10, inverted);
+ drawbigdigit(DISPLAY_M10_X, DISPLAY_TIME_Y, 10, inverted);
+ drawbigdigit(DISPLAY_M1_X, DISPLAY_TIME_Y, 10, inverted);
+ glcdFillRectangle(ball_x, ball_y, ball_radius*2, ball_radius*2, ! inverted);
+ prev_mode = SCORE_MODE_DOW;
+ }
+
+ if(redraw_digits || intersectrect(oldball_x, oldball_y, ball_radius*2, ball_radius*2,
+ DISPLAY_DOW1_X, DISPLAY_TIME_Y, DISPLAY_DIGITW, DISPLAY_DIGITH)) {
+ drawbigfont(DISPLAY_DOW1_X, DISPLAY_TIME_Y, pgm_read_byte(DOWText+(dotw(date_m,date_d,date_y)*3)+0), inverted);
+ }
+ if(redraw_digits || intersectrect(oldball_x, oldball_y, ball_radius*2, ball_radius*2,
+ DISPLAY_DOW2_X, DISPLAY_TIME_Y, DISPLAY_DIGITW, DISPLAY_DIGITH)) {
+ drawbigfont(DISPLAY_DOW2_X, DISPLAY_TIME_Y, pgm_read_byte(DOWText+(dotw(date_m,date_d,date_y)*3)+1), inverted);
+ }
+ if(redraw_digits || intersectrect(oldball_x, oldball_y, ball_radius*2, ball_radius*2,
+ DISPLAY_DOW3_X, DISPLAY_TIME_Y, DISPLAY_DIGITW, DISPLAY_DIGITH)) {
+ drawbigfont(DISPLAY_DOW3_X, DISPLAY_TIME_Y, pgm_read_byte(DOWText+(dotw(date_m,date_d,date_y)*3)+2), inverted);
+ }
+ }
+ else if (score_mode==SCORE_MODE_DATELONG) {
+ if(prev_mode != SCORE_MODE_DATELONG)
+ {
+ if(prev_mode == SCORE_MODE_DOW) {
+ drawbigfont(DISPLAY_DOW1_X, DISPLAY_TIME_Y, ' ', inverted);
+ drawbigfont(DISPLAY_DOW2_X, DISPLAY_TIME_Y, ' ', inverted);
+ drawbigfont(DISPLAY_DOW3_X, DISPLAY_TIME_Y, ' ', inverted);
+ }
+ if(prev_mode == SCORE_MODE_TIME) {
+ drawbigdigit(DISPLAY_H10_X, DISPLAY_TIME_Y, 10, inverted);
+ drawbigdigit(DISPLAY_H1_X, DISPLAY_TIME_Y, 10, inverted);
+ drawbigdigit(DISPLAY_M10_X, DISPLAY_TIME_Y, 10, inverted);
+ drawbigdigit(DISPLAY_M1_X, DISPLAY_TIME_Y, 10, inverted);
+ }
+ glcdFillRectangle(ball_x, ball_y, ball_radius*2, ball_radius*2, ! inverted);
+ prev_mode = SCORE_MODE_DATELONG;
+ }
+ if(redraw_digits || intersectrect(oldball_x, oldball_y, ball_radius*2, ball_radius*2,
+ DISPLAY_MON1_X, DISPLAY_TIME_Y, DISPLAY_DIGITW, DISPLAY_DIGITH)) {
+ drawbigfont(DISPLAY_MON1_X, DISPLAY_TIME_Y, pgm_read_byte(MonthText+(date_m*3)+0), inverted);
+ }
+ if(redraw_digits || intersectrect(oldball_x, oldball_y, ball_radius*2, ball_radius*2,
+ DISPLAY_MON2_X, DISPLAY_TIME_Y, DISPLAY_DIGITW, DISPLAY_DIGITH)) {
+ drawbigfont(DISPLAY_MON2_X, DISPLAY_TIME_Y, pgm_read_byte(MonthText+(date_m*3)+1), inverted);
+ }
+ if(redraw_digits || intersectrect(oldball_x, oldball_y, ball_radius*2, ball_radius*2,
+ DISPLAY_MON3_X, DISPLAY_TIME_Y, DISPLAY_DIGITW, DISPLAY_DIGITH)) {
+ drawbigfont(DISPLAY_MON3_X, DISPLAY_TIME_Y, pgm_read_byte(MonthText+(date_m*3)+2), inverted);
+ }
+ if (redraw_digits || intersectrect(oldball_x, oldball_y, ball_radius*2, ball_radius*2,
+ DISPLAY_DAY10_X, DISPLAY_TIME_Y, DISPLAY_DIGITW, DISPLAY_DIGITH)) {
+ drawbigdigit(DISPLAY_DAY10_X, DISPLAY_TIME_Y, right_score/10, inverted);
+ }
+ if (redraw_digits || intersectrect(oldball_x, oldball_y, ball_radius*2, ball_radius*2,
+ DISPLAY_DAY1_X, DISPLAY_TIME_Y, DISPLAY_DIGITW, DISPLAY_DIGITH)) {
+ drawbigdigit(DISPLAY_DAY1_X, DISPLAY_TIME_Y, right_score%10, inverted);
+ }
+ }
+ else {
+ if((prev_mode == SCORE_MODE_DOW) || (prev_mode == SCORE_MODE_DATELONG))
+ {
+ if(prev_mode == SCORE_MODE_DATELONG) {
+ drawbigfont(DISPLAY_MON1_X, DISPLAY_TIME_Y, ' ', inverted);
+ drawbigfont(DISPLAY_MON2_X, DISPLAY_TIME_Y, ' ', inverted);
+ drawbigfont(DISPLAY_MON3_X, DISPLAY_TIME_Y, ' ', inverted);
+ drawbigdigit(DISPLAY_DAY10_X, DISPLAY_TIME_Y, 10, inverted);
+ drawbigdigit(DISPLAY_DAY1_X, DISPLAY_TIME_Y, 10, inverted);
+ }
+ if(prev_mode == SCORE_MODE_DOW) {
+ drawbigfont(DISPLAY_DOW1_X, DISPLAY_TIME_Y, ' ', inverted);
+ drawbigfont(DISPLAY_DOW2_X, DISPLAY_TIME_Y, ' ', inverted);
+ drawbigfont(DISPLAY_DOW3_X, DISPLAY_TIME_Y, ' ', inverted);
+ }
+ if(prev_mode == SCORE_MODE_TIME) {
+ drawbigdigit(DISPLAY_H10_X, DISPLAY_TIME_Y, 10, inverted);
+ drawbigdigit(DISPLAY_H1_X, DISPLAY_TIME_Y, 10, inverted);
+ drawbigdigit(DISPLAY_M10_X, DISPLAY_TIME_Y, 10, inverted);
+ drawbigdigit(DISPLAY_M1_X, DISPLAY_TIME_Y, 10, inverted);
+ }
+ glcdFillRectangle(ball_x, ball_y, ball_radius*2, ball_radius*2, ! inverted);
+ prev_mode = SCORE_MODE_TIME;
+ }
+ if (redraw_digits || intersectrect(oldball_x, oldball_y, ball_radius*2, ball_radius*2,
+ DISPLAY_H10_X, DISPLAY_TIME_Y, DISPLAY_DIGITW, DISPLAY_DIGITH)) {
+
+ if ((time_format == TIME_12H) && ((score_mode == SCORE_MODE_TIME) || (score_mode == SCORE_MODE_ALARM)))
+ drawbigdigit(DISPLAY_H10_X, DISPLAY_TIME_Y, ((left_score + 23)%12 + 1)/10, inverted);
+ else
+ drawbigdigit(DISPLAY_H10_X, DISPLAY_TIME_Y, left_score/10, inverted);
+ }
+
+ // redraw 1's of hours
+ if (redraw_digits || intersectrect(oldball_x, oldball_y, ball_radius*2, ball_radius*2,
+ DISPLAY_H1_X, DISPLAY_TIME_Y, DISPLAY_DIGITW, DISPLAY_DIGITH)) {
+ if ((time_format == TIME_12H) && ((score_mode == SCORE_MODE_TIME) || (score_mode == SCORE_MODE_ALARM)))
+ drawbigdigit(DISPLAY_H1_X, DISPLAY_TIME_Y, ((left_score + 23)%12 + 1)%10, inverted);
+ else
+ drawbigdigit(DISPLAY_H1_X, DISPLAY_TIME_Y, left_score%10, inverted);
+ }
+
+ if (redraw_digits || intersectrect(oldball_x, oldball_y, ball_radius*2, ball_radius*2,
+ DISPLAY_M10_X, DISPLAY_TIME_Y, DISPLAY_DIGITW, DISPLAY_DIGITH)) {
+ drawbigdigit(DISPLAY_M10_X, DISPLAY_TIME_Y, right_score/10, inverted);
+ }
+ if (redraw_digits || intersectrect(oldball_x, oldball_y, ball_radius*2, ball_radius*2,
+ DISPLAY_M1_X, DISPLAY_TIME_Y, DISPLAY_DIGITW, DISPLAY_DIGITH)) {
+ drawbigdigit(DISPLAY_M1_X, DISPLAY_TIME_Y, right_score%10, inverted);
+ }
+ }
+}
+
void drawbigdigit(uint8_t x, uint8_t y, uint8_t n, uint8_t inverted) {
uint8_t i, j;
@@ -696,6 +835,21 @@ void drawbigdigit(uint8_t x, uint8_t y, uint8_t n, uint8_t inverted) {
}
}
+void drawbigfont(uint8_t x, uint8_t y, uint8_t n, uint8_t inverted) {
+ uint8_t i, j;
+
+ for (i = 0; i < 5; i++) {
+ uint8_t d = pgm_read_byte(Font5x7+((n-0x20)*5)+i);
+ for (j=0; j<7; j++) {
+ if (d & _BV(j)) {
+ glcdFillRectangle(x+i*2, y+j*2, 2, 2, !inverted);
+ } else {
+ glcdFillRectangle(x+i*2, y+j*2, 2, 2, inverted);
+ }
+ }
+ }
+}
+
float random_angle_rads(void) {
// create random vector MEME seed it ok???
float angle = crand(0);
View
281 firmware/config.c
@@ -56,31 +56,8 @@ void display_menu(void) {
}
}
- glcdSetAddress(MENU_INDENT, 3);
- glcdPutStr("Set Date: ", NORMAL);
- if (region == REGION_US) {
- printnumber(date_m, NORMAL);
- glcdWriteChar('/', NORMAL);
- printnumber(date_d, NORMAL);
- } else {
- printnumber(date_d, NORMAL);
- glcdWriteChar('/', NORMAL);
- printnumber(date_m, NORMAL);
- }
- glcdWriteChar('/', NORMAL);
- printnumber(date_y, NORMAL);
-
- glcdSetAddress(MENU_INDENT, 4);
- glcdPutStr("Set region: ", NORMAL);
- if ((region == REGION_US) && (time_format == TIME_12H)) {
- glcdPutStr("US 12hr", NORMAL);
- } else if ((region == REGION_US) && (time_format == TIME_24H)) {
- glcdPutStr("US 24hr", NORMAL);
- } else if ((region == REGION_EU) && (time_format == TIME_12H)) {
- glcdPutStr("EU 12hr", NORMAL);
- } else {
- glcdPutStr("EU 24hr", NORMAL);
- }
+ print_date(date_m,date_d,date_y,SET_DATE);
+ print_region_setting(NORMAL);
#ifdef BACKLIGHT_ADJUST
glcdSetAddress(MENU_INDENT, 5);
@@ -96,6 +73,120 @@ void display_menu(void) {
screenmutex--;
}
+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 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_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) {
+ glcdPutStr(" ",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) {
+ glcdPutStr(" ",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);
+ 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);
+ printnumber(day, (mode == SET_DAY)?INVERTED:NORMAL);
+ glcdWriteChar(',', NORMAL);
+ glcdWriteChar(' ', NORMAL);
+ }
+ printnumber(year, (mode == SET_YEAR)?INVERTED:NORMAL);
+}
+
void set_date(void) {
uint8_t mode = SET_DATE;
uint8_t day, month, year;
@@ -129,81 +220,57 @@ void set_date(void) {
just_pressed = 0;
screenmutex++;
- if ((mode == SET_DATE) && (region == REGION_US)) {
+ 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
- glcdSetAddress(MENU_INDENT + 12*6, 3);
- printnumber(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)) {
+ } 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
- glcdSetAddress(MENU_INDENT + 12*6, 3);
- printnumber(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)) {
+ } 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 the month normal
- glcdSetAddress(MENU_INDENT + 12*6, 3);
- printnumber(month, NORMAL);
- // and the day inverted
- glcdWriteChar('/', NORMAL);
- printnumber(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_DAY) && (region == REGION_EU)) {
+ }else if ((mode == SET_DAY) && ((region == REGION_EU) || (region == DOW_REGION_EU))) {
DEBUG(putstring("Set date month"));
mode = SET_MONTH;
- // print the day normal
- glcdSetAddress(MENU_INDENT + 12*6, 3);
- printnumber(day, NORMAL);
- // and the month inverted
- glcdWriteChar('/', NORMAL);
- printnumber(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_DAY) && (region == REGION_US)) ||
- ((mode == SET_MONTH) && (region == REGION_EU)) ) {
+ } 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
- glcdSetAddress(MENU_INDENT + 12*6, 3);
- if (region == REGION_US) {
- printnumber(month, NORMAL);
- glcdWriteChar('/', NORMAL);
- printnumber(day, NORMAL);
- } else {
- printnumber(day, NORMAL);
- glcdWriteChar('/', NORMAL);
- printnumber(month, NORMAL);
- }
- glcdWriteChar('/', NORMAL);
- // and the year inverted
- printnumber(year, INVERTED);
+ print_date(month,day,year,mode);
// display instructions below
glcdSetAddress(0, 6);
glcdPutStr("Press + to change yr.", NORMAL);
@@ -214,8 +281,7 @@ void set_date(void) {
DEBUG(putstring("done setting date"));
mode = SET_DATE;
// print the seconds normal
- glcdSetAddress(MENU_INDENT + 18*6, 3);
- printnumber(year, NORMAL);
+ print_date(month,day,year,mode);
// display instructions below
glcdSetAddress(0, 6);
glcdPutStr("Press MENU to advance", NORMAL);
@@ -248,16 +314,7 @@ void set_date(void) {
if(day > 30)
day = 30;
}
- glcdSetAddress(MENU_INDENT + 12*6, 3);
- if (region == REGION_US) {
- printnumber(month, INVERTED);
- glcdWriteChar('/', NORMAL);
- printnumber(day, NORMAL);
- } else {
- printnumber(day, NORMAL);
- glcdWriteChar('/', NORMAL);
- printnumber(month, INVERTED);
- }
+ print_date(month,day,year,mode);
}
if (mode == SET_DAY) {
@@ -273,21 +330,11 @@ void set_date(void) {
if(day > 30)
day = 1;
}
- glcdSetAddress(MENU_INDENT + 12*6, 3);
- if (region == REGION_US) {
- printnumber(month, NORMAL);
- glcdWriteChar('/', NORMAL);
- printnumber(day, INVERTED);
- } else {
- printnumber(day, INVERTED);
- glcdWriteChar('/', NORMAL);
- printnumber(month, NORMAL);
- }
+ print_date(month,day,year,mode);
}
if (mode == SET_YEAR) {
year = (year+1) % 100;
- glcdSetAddress(MENU_INDENT + 18*6, 3);
- printnumber(year, INVERTED);
+ print_date(month,day,year,mode);
}
screenmutex--;
@@ -385,6 +432,35 @@ void set_backlight(void) {
}
#endif
+void print_region_setting(uint8_t inverted) {
+ glcdSetAddress(MENU_INDENT, 4);
+ glcdPutStr("Region: ", NORMAL);
+ if ((region == REGION_US) && (time_format == TIME_12H)) {
+ glcdPutStr(" US 12hr", inverted);
+ } else if ((region == REGION_US) && (time_format == TIME_24H)) {
+ glcdPutStr(" US 24hr", inverted);
+ } else if ((region == REGION_EU) && (time_format == TIME_12H)) {
+ glcdPutStr(" EU 12hr", inverted);
+ } else if ((region == REGION_EU) && (time_format == TIME_24H)){
+ glcdPutStr(" EU 24hr", inverted);
+ } else if ((region == DOW_REGION_US) && (time_format == TIME_12H)) {
+ glcdPutStr(" US 12hr DOW", inverted);
+ } else if ((region == DOW_REGION_US) && (time_format == TIME_24H)) {
+ glcdPutStr(" US 24hr DOW", inverted);
+ } else if ((region == DOW_REGION_EU) && (time_format == TIME_12H)) {
+ glcdPutStr(" EU 12hr DOW", inverted);
+ } else if ((region == DOW_REGION_EU) && (time_format == TIME_24H)){
+ glcdPutStr(" EU 24hr DOW", inverted);
+ } else if ((region == DATELONG) && (time_format == TIME_12H)) {
+ glcdPutStr(" 12hr LONG", inverted);
+ } else if ((region == DATELONG) && (time_format == TIME_24H)) {
+ glcdPutStr(" 24hr LONG", inverted);
+ } else if ((region == DATELONG_DOW) && (time_format == TIME_12H)) {
+ glcdPutStr("12h LONG DOW", inverted);
+ } else if ((region == DATELONG_DOW) && (time_format == TIME_24H)){
+ glcdPutStr("24h LONG DOW", inverted);
+ }
+}
void set_region(void) {
uint8_t mode = SET_REGION;
@@ -426,16 +502,7 @@ void set_region(void) {
// ok now its selected
mode = SET_REG;
// print the region
- glcdSetAddress(MENU_INDENT + 12*6, 4);
- if ((region == REGION_US) && (time_format == TIME_12H)) {
- glcdPutStr("US 12hr", INVERTED);
- } else if ((region == REGION_US) && (time_format == TIME_24H)) {
- glcdPutStr("US 24hr", INVERTED);
- } else if ((region == REGION_EU) && (time_format == TIME_12H)) {
- glcdPutStr("EU 12hr", INVERTED);
- } else {
- glcdPutStr("EU 24hr", INVERTED);
- }
+ print_region_setting(INVERTED);
// display instructions below
glcdSetAddress(0, 6);
glcdPutStr("Press + to change ", NORMAL);
@@ -444,16 +511,7 @@ void set_region(void) {
} else {
mode = SET_REGION;
// print the region normal
- glcdSetAddress(MENU_INDENT + 12*6, 4);
- if ((region == REGION_US) && (time_format == TIME_12H)) {
- glcdPutStr("US 12hr", NORMAL);
- } else if ((region == REGION_US) && (time_format == TIME_24H)) {
- glcdPutStr("US 24hr", NORMAL);
- } else if ((region == REGION_EU) && (time_format == TIME_12H)) {
- glcdPutStr("EU 12hr", NORMAL);
- } else {
- glcdPutStr("EU 24hr", NORMAL);
- }
+ print_region_setting(NORMAL);
glcdSetAddress(0, 6);
#ifdef BACKLIGHT_ADJUST
@@ -471,7 +529,9 @@ void set_region(void) {
if (mode == SET_REG) {
if(time_format) {
- region = !region;
+ region++;
+ if(region > DATELONG_DOW)
+ region = 0;
time_format = !time_format;
} else {
time_format = !time_format;
@@ -486,16 +546,7 @@ void set_region(void) {
// put a small arrow next to 'set 12h/24h'
drawArrow(0, 35, MENU_INDENT -1);
- glcdSetAddress(MENU_INDENT + 12*6, 4);
- if ((region == REGION_US) && (time_format == TIME_12H)) {
- glcdPutStr("US 12hr", INVERTED);
- } else if ((region == REGION_US) && (time_format == TIME_24H)) {
- glcdPutStr("US 24hr", INVERTED);
- } else if ((region == REGION_EU) && (time_format == TIME_12H)) {
- glcdPutStr("EU 12hr", INVERTED);
- } else {
- glcdPutStr("EU 24hr", INVERTED);
- }
+ print_region_setting(INVERTED);
screenmutex--;
eeprom_write_byte((uint8_t *)EE_REGION, region);
View
73 firmware/ratt.c
@@ -27,6 +27,7 @@ extern volatile uint8_t screenmutex;
volatile uint8_t minute_changed = 0, hour_changed = 0;
volatile uint8_t score_mode_timeout = 0;
volatile uint8_t score_mode = SCORE_MODE_TIME;
+volatile uint8_t last_score_mode;
// These store the current button states for all 3 buttons. We can
// then query whether the buttons are pressed and released or pressed
@@ -158,28 +159,91 @@ int main(void) {
just_pressed = 0;
setsnooze();
}
- if(display_date && !score_mode_timeout)
+ if(display_date==1 && !score_mode_timeout)
+ {
+ display_date=3;
+ score_mode = SCORE_MODE_DATELONG;
+ score_mode_timeout = 3;
+ setscore();
+ }
+ else if(display_date==2 && !score_mode_timeout)
+ {
+ display_date=3;
+ score_mode = SCORE_MODE_DATE;
+ score_mode_timeout = 3;
+ setscore();
+ }
+ else if(display_date==3 && !score_mode_timeout)
+ {
+ display_date=0;
+ score_mode = SCORE_MODE_YEAR;
+ score_mode_timeout = 3;
+ setscore();
+ }
+ /*if(display_date && !score_mode_timeout)
+ {
+ if(last_score_mode == SCORE_MODE_DATELONG)
+ {
+ score_mode = SCORE_MODE_DOW;
+ score_mode_timeout = 3;
+ setscore();
+ }
+
+ else if(last_score_mode == SCORE_MODE_DOW)
+ {
+ score_mode = SCORE_MODE_DATE;
+ score_mode_timeout = 3;
+ setscore();
+ }
+ else if(last_score_mode == SCORE_MODE_DATE)
+ {
+ score_mode = SCORE_MODE_YEAR;
+ score_mode_timeout = 3;
+ setscore();
+ display_date = 0;
+ }
+
+ }*/
+ /*if(display_date && !score_mode_timeout)
{
score_mode = SCORE_MODE_YEAR;
score_mode_timeout = 3;
setscore();
display_date = 0;
- }
+ }*/
//Was formally set for just the + button. However, because the Set button was never
//accounted for, If the alarm was turned on, and ONLY the set button was pushed since then,
//the alarm would not sound at alarm time, but go into a snooze immediately after going off.
//This could potentially make you late for work, and had to be fixed.
if (just_pressed & 0x6) {
just_pressed = 0;
- display_date = 1;
- score_mode = SCORE_MODE_DATE;
+ if((region == REGION_US) || (region == REGION_EU)) {
+ display_date = 3;
+ score_mode = SCORE_MODE_DATE;
+ }
+ else if ((region == DOW_REGION_US) || (region == DOW_REGION_EU)) {
+ display_date = 2;
+ score_mode = SCORE_MODE_DOW;
+ }
+ else if (region == DATELONG) {
+ display_date = 3;
+ score_mode = SCORE_MODE_DATELONG;
+ }
+ else {
+ display_date = 1;
+ score_mode = SCORE_MODE_DOW;
+ }
score_mode_timeout = 3;
setscore();
}
if (just_pressed & 0x1) {
just_pressed = 0;
+ display_date = 0;
+ score_mode = SCORE_MODE_TIME;
+ score_mode_timeout = 0;
+ setscore();
switch(displaymode) {
case (SHOW_TIME):
displaymode = SET_ALARM;
@@ -419,6 +483,7 @@ SIGNAL (TIMER2_OVF_vect) {
if(score_mode_timeout) {
score_mode_timeout--;
if(!score_mode_timeout) {
+ last_score_mode = score_mode;
score_mode = SCORE_MODE_TIME;
if(hour_changed) {
time_h = old_h;
View
18 firmware/ratt.h
@@ -41,6 +41,17 @@
#define DISPLAY_M10_X 70
#define DISPLAY_M1_X 85
+#define DISPLAY_DOW1_X 35
+#define DISPLAY_DOW2_X 50
+#define DISPLAY_DOW3_X 70
+
+#define DISPLAY_MON1_X 20
+#define DISPLAY_MON2_X 35
+#define DISPLAY_MON3_X 50
+
+#define DISPLAY_DAY10_X 70
+#define DISPLAY_DAY1_X 85
+
// buffer space from the top
#define DISPLAY_TIME_Y 4
@@ -99,10 +110,16 @@
#define SCORE_MODE_DATE 1
#define SCORE_MODE_YEAR 2
#define SCORE_MODE_ALARM 3
+#define SCORE_MODE_DOW 4
+#define SCORE_MODE_DATELONG 5
// Constants for how to display time & date
#define REGION_US 0
#define REGION_EU 1
+#define DOW_REGION_US 2
+#define DOW_REGION_EU 3
+#define DATELONG 4
+#define DATELONG_DOW 5
#define TIME_12H 0
#define TIME_24H 1
@@ -189,6 +206,7 @@ void drawmidline(uint8_t inverted);
float random_angle_rads(void);
void init_crand();
+uint8_t dotw(uint8_t mon, uint8_t day, uint8_t yr);
uint8_t i2bcd(uint8_t x);

0 comments on commit 451a78d

Please sign in to comment.