void showRunningTime() { LCDGotoXY(10,0) ; if (runningHours > 1000) { LCDWriteInt(runningHours / 1000,1); LCDData(',') ; } LCDWriteInt(runningHours % 1000,1); }
void showTime() { LCDWriteInt(hour,2); LCDData(':') ; LCDWriteInt(minute,2); LCDData(':') ; LCDWriteInt(seconds,2); // setLED(0,minute / 10) ; // setLED(1,minute % 10) ; // setLED(2,seconds / 10) ; // setLED(3,seconds % 10) ; }
void showDate() { int d = (day-1) * 3 ; LCDWriteInt(date,2); LCDData('/') ; LCDWriteInt(month,2); LCDData('/') ; LCDData('2') ; LCDData('0') ; LCDWriteInt(year,2); LCDData(32) ; LCDData(32) ; LCDData(daysOfTheWeek[d++]) ; LCDData(daysOfTheWeek[d++]) ; LCDData(daysOfTheWeek[d]) ; }
void zero_init() { lcd_clear(); lcd_puts("Memory init"); write_var(0, 0, 0x19); write_var(0, 1, 0x08); write_var(0, 2, 0x1E); //30 block = 0; addr = 3; for(i = 0; i < MAX_PATTERNS; i++) { write_var(block, addr, v1.length); addr++; check_ab(); for(j = 0; j < MAX_ITEMS; j++) { lcd_gotoxy(0, 1); lcd_puts(t_preset); lcd_putchar(' '); LCDWriteInt(i, 0); lcd_putchar(' '); lcd_puts(t_item); lcd_putchar(' '); LCDWriteInt(j, 0); lcd_putchar(' '); write_var(block, addr, v1.out[j]); addr++; check_ab(); } } }
t_pattern read_pattern(unsigned char num) { t_pattern patt; #asm("cli") lcd_clear(); lcd_puts("Memory read"); addr = 3 + num * (MAX_ITEMS + 1); block = addr / 256; addr = addr % 256; patt.length = read_var(block, addr); addr++; check_ab(); lcd_gotoxy(0, 1); lcd_puts(t_preset); lcd_putchar(' '); LCDWriteInt(num, 0); lcd_putchar(' '); lcd_puts(t_item); lcd_putchar(' '); for(j = 0; j < MAX_ITEMS; j++) { lcd_gotoxy(14, 1); LCDWriteInt(j, 0); lcd_putchar(' '); patt.out[j] = read_var(block, addr); addr++; check_ab(); } #asm("sei") return patt; }
void write_pattern(t_pattern patt, unsigned char num) { #asm("cli") lcd_clear(); lcd_puts("Memory write"); addr = 3 + num * (MAX_ITEMS + 1); block = addr / 256; addr = addr % 256; write_var(block, addr, patt.length); addr++; check_ab(); lcd_gotoxy(0, 1); lcd_puts(t_preset); lcd_putchar(' '); LCDWriteInt(num, 0); lcd_putchar(' '); lcd_puts(t_item); lcd_putchar(' '); for(j = 0; j < MAX_ITEMS; j++) { lcd_gotoxy(14, 1); LCDWriteInt(j, 0); lcd_putchar(' '); write_var(block, addr, patt.out[j]); addr++; check_ab(); } #asm("sei") }
void main(void) { // initialise the RTC communication line I2C_Init() ; // initialise the LCD display LCDInit(LS_NONE); // initialise the actual RTC DS1307_Init() ; //clear the display LCDClear(); // read back our running time DS1307_readRam(&runningMinutes,0,2) ; DS1307_readRam(&runningHours,2,2) ; LCDWriteString("Starting counter"); LCDGotoXY(0,1) ; LCDWriteString("at "); LCDWriteInt(runningHours,1); LCDWriteString(":"); LCDWriteInt(runningMinutes,1); __delay_ms(750) ; __delay_ms(750) ; __delay_ms(750) ; __delay_ms(750) ; // compensate for our handling on the first run of the readClock routine runningMinutes-- ; LCDClear(); // infinite loop, read the clock, display on the LCD, check for the button, and if needed, process the menus while(1) { readClock(); showClock() ; readInputs() ; if (bButton) doMenu(); else if (state & 0x30) { // rotate the encoder to select a menu function, well, that was the aim, but encoder reading // seems a tad slow or inaccurate. // // there is a timeout if the button isn't pressed after selecting the menu option if (state & DIR_CW) { menuFunction++ ; if (menuFunction == MENU_LAST) menuFunction = MENU_NONE ; } else if (state & DIR_CCW) { menuFunction-- ; if (menuFunction < MENU_NONE) menuFunction = MENU_LAST-1 ; } if (menuFunction != MENU_NONE) { next_menu_clear = minute * 60 + seconds + 20 ; LCDGotoXY(9,0); if (menuFunction == MENU_TIME) LCDWriteString("Time ?"); if (menuFunction == MENU_DATE) LCDWriteString("Date ?"); } else clearPrompt(); } else if (next_menu_clear && ((minute * 60 + seconds) > next_menu_clear)) { clearPrompt(); } } }