/* Our function that handles the key presses for time setting*/ void handle_key_press_time() { // Key 1 increments the seconds if (edge_capture == 2) { increment_seconds(top_row, &seconds); alt_up_character_lcd_set_cursor_pos(char_lcd_dev, 0, 0); alt_up_character_lcd_string(char_lcd_dev, top_row); } // Key 2 increments the minutes else if (edge_capture == 4) { increment_minutes(top_row, &minutes); alt_up_character_lcd_set_cursor_pos(char_lcd_dev, 0, 0); alt_up_character_lcd_string(char_lcd_dev, top_row); } // Key 3 increments the hours else if (edge_capture == 8) { increment_hours(top_row, &hours, am_pm_mode); alt_up_character_lcd_set_cursor_pos(char_lcd_dev, 0, 0); alt_up_character_lcd_string(char_lcd_dev, top_row); } // Reset our edge capture back to 0 edge_capture = 0; }
__interrupt void Timer_A (void) { P1OUT ^= BIT6; increment_hours(increment_minutes(increment_seconds())); if(hours < 10) sprintf(msg_buffer, "0%d:", hours); else sprintf(msg_buffer, "%d:", hours); if(minutes < 10) sprintf(msg_buffer + 3, "0%d:", minutes); else sprintf(msg_buffer + 3, "%d:", minutes); if(seconds < 10) sprintf(msg_buffer + 6, "0%d", seconds); else sprintf(msg_buffer + 6, "%d", seconds); write_cmd(BIT1); write_msg(msg_buffer); }