|
|
|
@ -80,7 +80,7 @@ void conv_24H_to_12H(u8 * hours24, u8 * hours12, u8 * timeAMorPM);
|
|
|
|
|
struct time sTime; |
|
|
|
|
|
|
|
|
|
// Display values for time format selection
|
|
|
|
|
#ifndef CONFIG_METRIC_ONLY |
|
|
|
|
#if (OPTION_TIME_DISPLAY == CLOCK_DISPLAY_SELECT) |
|
|
|
|
const u8 selection_Timeformat[][4] = |
|
|
|
|
{ |
|
|
|
|
"24H", "12H" |
|
|
|
@ -169,7 +169,7 @@ void clock_tick(void)
|
|
|
|
|
// @param u8 hour Hour in 24H format
|
|
|
|
|
// @return u8 Hour in 12H format
|
|
|
|
|
// *************************************************************************************************
|
|
|
|
|
#ifndef CONFIG_METRIC_ONLY |
|
|
|
|
#if (OPTION_TIME_DISPLAY > CLOCK_24HR) |
|
|
|
|
u8 convert_hour_to_12H_format(u8 hour) |
|
|
|
|
{ |
|
|
|
|
// 00:00 .. 11:59 --> AM 12:00 .. 11:59
|
|
|
|
@ -204,12 +204,12 @@ u8 is_hour_am(u8 hour)
|
|
|
|
|
// u8 blanks Not used
|
|
|
|
|
// @return none
|
|
|
|
|
// *************************************************************************************************
|
|
|
|
|
void display_selection_Timeformat1(u8 segments, u32 index, u8 digits, u8 blanks) |
|
|
|
|
void display_selection_Timeformat1(u8 segments, u32 index, u8 digits, u8 blanks, u8 dummy) |
|
|
|
|
{ |
|
|
|
|
if (index < 2) display_chars(segments, (u8 *)selection_Timeformat[index], SEG_ON_BLINK_ON); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
#endif // CONFIG_METRIC_ONLY
|
|
|
|
|
#endif //OPTION_TIME_DISPLAY
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// *************************************************************************************************
|
|
|
|
@ -220,116 +220,118 @@ void display_selection_Timeformat1(u8 segments, u32 index, u8 digits, u8 blanks)
|
|
|
|
|
// *************************************************************************************************
|
|
|
|
|
void mx_time(u8 line) |
|
|
|
|
{ |
|
|
|
|
u8 select; |
|
|
|
|
s32 timeformat; |
|
|
|
|
s16 timeformat1; |
|
|
|
|
s32 hours; |
|
|
|
|
s32 minutes; |
|
|
|
|
s32 seconds; |
|
|
|
|
u8 * str; |
|
|
|
|
|
|
|
|
|
// Clear display
|
|
|
|
|
clear_display_all(); |
|
|
|
|
|
|
|
|
|
// Convert global time to local variables
|
|
|
|
|
// Global time keeps on ticking in background until it is overwritten
|
|
|
|
|
if (sys.flag.use_metric_units) |
|
|
|
|
{ |
|
|
|
|
timeformat = TIMEFORMAT_24H; |
|
|
|
|
} |
|
|
|
|
else |
|
|
|
|
{ |
|
|
|
|
timeformat = TIMEFORMAT_12H; |
|
|
|
|
} |
|
|
|
|
timeformat1 = timeformat; |
|
|
|
|
hours = sTime.hour;
|
|
|
|
|
minutes = sTime.minute; |
|
|
|
|
seconds = sTime.second; |
|
|
|
|
|
|
|
|
|
// Init value index
|
|
|
|
|
select = 0;
|
|
|
|
|
|
|
|
|
|
// Loop values until all are set or user breaks set
|
|
|
|
|
while(1)
|
|
|
|
|
{ |
|
|
|
|
// Idle timeout: exit without saving
|
|
|
|
|
if (sys.flag.idle_timeout) |
|
|
|
|
{ |
|
|
|
|
// Roll back time format
|
|
|
|
|
if (timeformat1 == TIMEFORMAT_24H) sys.flag.use_metric_units = 1; |
|
|
|
|
else sys.flag.use_metric_units = 0; |
|
|
|
|
display_symbol(LCD_SYMB_AM, SEG_OFF); |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// Button STAR (short): save, then exit
|
|
|
|
|
if (button.flag.star)
|
|
|
|
|
{ |
|
|
|
|
// Stop clock timer
|
|
|
|
|
Timer0_Stop(); |
|
|
|
|
|
|
|
|
|
// Store local variables in global clock time
|
|
|
|
|
sTime.hour = hours; |
|
|
|
|
sTime.minute = minutes; |
|
|
|
|
sTime.second = seconds; |
|
|
|
|
|
|
|
|
|
// Start clock timer
|
|
|
|
|
Timer0_Start(); |
|
|
|
|
|
|
|
|
|
// Full display update is done when returning from function
|
|
|
|
|
display_symbol(LCD_SYMB_AM, SEG_OFF); |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
switch (select) |
|
|
|
|
{ |
|
|
|
|
#ifndef CONFIG_METRIC_ONLY |
|
|
|
|
case 0: // Clear LINE1 and LINE2 and AM icon - required when coming back from set_value(seconds)
|
|
|
|
|
clear_display(); |
|
|
|
|
display_symbol(LCD_SYMB_AM, SEG_OFF); |
|
|
|
|
|
|
|
|
|
// Set 24H / 12H time format
|
|
|
|
|
set_value(&timeformat, 1, 0, 0, 1, SETVALUE_ROLLOVER_VALUE + SETVALUE_DISPLAY_SELECTION + SETVALUE_NEXT_VALUE, LCD_SEG_L1_3_1, display_selection_Timeformat1); |
|
|
|
|
|
|
|
|
|
// Modify global time format variable immediately to update AM/PM icon correctly
|
|
|
|
|
if (timeformat == TIMEFORMAT_24H) sys.flag.use_metric_units = 1; |
|
|
|
|
else sys.flag.use_metric_units = 0; |
|
|
|
|
select = 1; |
|
|
|
|
break; |
|
|
|
|
u8 select; |
|
|
|
|
s32 timeformat; |
|
|
|
|
s16 timeformat1; |
|
|
|
|
s32 hours; |
|
|
|
|
s32 minutes; |
|
|
|
|
s32 seconds; |
|
|
|
|
u8 * str; |
|
|
|
|
|
|
|
|
|
// Clear display
|
|
|
|
|
clear_display_all(); |
|
|
|
|
|
|
|
|
|
// Convert global time to local variables
|
|
|
|
|
// Global time keeps on ticking in background until it is overwritten
|
|
|
|
|
if (sys.flag.am_pm_time) |
|
|
|
|
{ |
|
|
|
|
timeformat = TIMEFORMAT_12H; |
|
|
|
|
} |
|
|
|
|
else |
|
|
|
|
{ |
|
|
|
|
timeformat = TIMEFORMAT_24H; |
|
|
|
|
} |
|
|
|
|
timeformat1 = timeformat; |
|
|
|
|
hours = sTime.hour; |
|
|
|
|
minutes = sTime.minute; |
|
|
|
|
seconds = sTime.second; |
|
|
|
|
|
|
|
|
|
// Init value index
|
|
|
|
|
select = 0; |
|
|
|
|
|
|
|
|
|
// Loop values until all are set or user breaks set
|
|
|
|
|
while(1) |
|
|
|
|
{ |
|
|
|
|
// Idle timeout: exit without saving
|
|
|
|
|
if (sys.flag.idle_timeout) |
|
|
|
|
{ |
|
|
|
|
// Roll back time format
|
|
|
|
|
if (timeformat1 == TIMEFORMAT_12H) |
|
|
|
|
sys.flag.am_pm_time = 1; |
|
|
|
|
else |
|
|
|
|
sys.flag.am_pm_time = 0; |
|
|
|
|
display_symbol(LCD_SYMB_AM, SEG_OFF); |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// Button STAR (short): save, then exit
|
|
|
|
|
if (button.flag.star) |
|
|
|
|
{ |
|
|
|
|
// Stop clock timer
|
|
|
|
|
Timer0_Stop(); |
|
|
|
|
|
|
|
|
|
// Store local variables in global clock time
|
|
|
|
|
sTime.hour = hours; |
|
|
|
|
sTime.minute = minutes; |
|
|
|
|
sTime.second = seconds; |
|
|
|
|
|
|
|
|
|
// Start clock timer
|
|
|
|
|
Timer0_Start(); |
|
|
|
|
|
|
|
|
|
// Full display update is done when returning from function
|
|
|
|
|
display_symbol(LCD_SYMB_AM, SEG_OFF); |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
switch (select) |
|
|
|
|
{ |
|
|
|
|
#if (OPTION_TIME_DISPLAY == CLOCK_DISPLAY_SELECT) |
|
|
|
|
case 0: // Clear LINE1 and LINE2 and AM icon - required when coming back from set_value(seconds)
|
|
|
|
|
clear_display(); |
|
|
|
|
display_symbol(LCD_SYMB_AM, SEG_OFF); |
|
|
|
|
|
|
|
|
|
// Set 24H / 12H time format
|
|
|
|
|
set_value(&timeformat, 1, 0, 0, 1, SETVALUE_ROLLOVER_VALUE + SETVALUE_DISPLAY_SELECTION + SETVALUE_NEXT_VALUE, LCD_SEG_L1_3_1, display_selection_Timeformat1); |
|
|
|
|
|
|
|
|
|
// Modify global time format variable immediately to update AM/PM icon correctly
|
|
|
|
|
if (timeformat == TIMEFORMAT_12H) sys.flag.am_pm_time = 1; |
|
|
|
|
else sys.flag.am_pm_time = 0; |
|
|
|
|
select = 1; |
|
|
|
|
break; |
|
|
|
|
#else |
|
|
|
|
case 0: |
|
|
|
|
case 0: |
|
|
|
|
#endif |
|
|
|
|
case 1: // Display HH:MM (LINE1) and .SS (LINE2)
|
|
|
|
|
str = itoa(hours, 2, 0); |
|
|
|
|
display_chars(LCD_SEG_L1_3_2, str, SEG_ON); |
|
|
|
|
display_symbol(LCD_SEG_L1_COL, SEG_ON); |
|
|
|
|
|
|
|
|
|
str = itoa(minutes, 2, 0); |
|
|
|
|
display_chars(LCD_SEG_L1_1_0, str, SEG_ON); |
|
|
|
|
|
|
|
|
|
str = itoa(seconds, 2, 0); |
|
|
|
|
display_chars(LCD_SEG_L2_1_0, str, SEG_ON); |
|
|
|
|
display_symbol(LCD_SEG_L2_DP, SEG_ON); |
|
|
|
|
|
|
|
|
|
// Set hours
|
|
|
|
|
set_value(&hours, 2, 0, 0, 23, SETVALUE_ROLLOVER_VALUE + SETVALUE_DISPLAY_VALUE + SETVALUE_NEXT_VALUE, LCD_SEG_L1_3_2, display_hours1); |
|
|
|
|
select = 2; |
|
|
|
|
break; |
|
|
|
|
|
|
|
|
|
case 2: // Set minutes
|
|
|
|
|
set_value(&minutes, 2, 0, 0, 59, SETVALUE_ROLLOVER_VALUE + SETVALUE_DISPLAY_VALUE + SETVALUE_NEXT_VALUE, LCD_SEG_L1_1_0, display_value1); |
|
|
|
|
select = 3; |
|
|
|
|
break; |
|
|
|
|
|
|
|
|
|
case 3: // Set seconds
|
|
|
|
|
set_value(&seconds, 2, 0, 0, 59, SETVALUE_ROLLOVER_VALUE + SETVALUE_DISPLAY_VALUE + SETVALUE_NEXT_VALUE, LCD_SEG_L2_1_0, display_value1); |
|
|
|
|
select = 0; |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// Clear button flags
|
|
|
|
|
button.all_flags = 0; |
|
|
|
|
case 1: // Display HH:MM (LINE1) and .SS (LINE2)
|
|
|
|
|
str = itoa(hours, 2, 0); |
|
|
|
|
display_chars(LCD_SEG_L1_3_2, str, SEG_ON); |
|
|
|
|
display_symbol(LCD_SEG_L1_COL, SEG_ON); |
|
|
|
|
|
|
|
|
|
str = itoa(minutes, 2, 0); |
|
|
|
|
display_chars(LCD_SEG_L1_1_0, str, SEG_ON); |
|
|
|
|
|
|
|
|
|
str = itoa(seconds, 2, 0); |
|
|
|
|
display_chars(LCD_SEG_L2_1_0, str, SEG_ON); |
|
|
|
|
display_symbol(LCD_SEG_L2_DP, SEG_ON); |
|
|
|
|
|
|
|
|
|
// Set hours
|
|
|
|
|
set_value(&hours, 2, 0, 0, 23, SETVALUE_ROLLOVER_VALUE + SETVALUE_DISPLAY_VALUE + SETVALUE_NEXT_VALUE, LCD_SEG_L1_3_2, display_hours_12_or_24); |
|
|
|
|
select = 2; |
|
|
|
|
break; |
|
|
|
|
|
|
|
|
|
case 2: // Set minutes
|
|
|
|
|
set_value(&minutes, 2, 0, 0, 59, SETVALUE_ROLLOVER_VALUE + SETVALUE_DISPLAY_VALUE + SETVALUE_NEXT_VALUE, LCD_SEG_L1_1_0, display_value1); |
|
|
|
|
select = 3; |
|
|
|
|
break; |
|
|
|
|
|
|
|
|
|
case 3: // Set seconds
|
|
|
|
|
set_value(&seconds, 2, 0, 0, 59, SETVALUE_ROLLOVER_VALUE + SETVALUE_DISPLAY_VALUE + SETVALUE_NEXT_VALUE, LCD_SEG_L2_1_0, display_value1); |
|
|
|
|
select = 0; |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// Clear button flags
|
|
|
|
|
button.all_flags = 0; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -346,99 +348,62 @@ void sx_time(u8 line)
|
|
|
|
|
else sTime.line1ViewStyle = DISPLAY_DEFAULT_VIEW; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// *************************************************************************************************
|
|
|
|
|
// @fn display_time
|
|
|
|
|
// @brief Clock display routine. Supports 24H and 12H time format.
|
|
|
|
|
// @brief Clock display routine. Supports 24H and 12H time format,
|
|
|
|
|
// through the helper display_hours_with_12_24.
|
|
|
|
|
// @param u8 line LINE1
|
|
|
|
|
// u8 update DISPLAY_LINE_UPDATE_FULL, DISPLAY_LINE_UPDATE_PARTIAL
|
|
|
|
|
// @return none
|
|
|
|
|
// *************************************************************************************************
|
|
|
|
|
void display_time(u8 line, u8 update) |
|
|
|
|
{ |
|
|
|
|
#ifndef CONFIG_METRIC_ONLY |
|
|
|
|
u8 hour12; |
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
// Partial update
|
|
|
|
|
if (update == DISPLAY_LINE_UPDATE_PARTIAL)
|
|
|
|
|
if (update == DISPLAY_LINE_UPDATE_PARTIAL) |
|
|
|
|
{ |
|
|
|
|
if(sTime.drawFlag != 0)
|
|
|
|
|
{ |
|
|
|
|
if (sTime.line1ViewStyle == DISPLAY_DEFAULT_VIEW) |
|
|
|
|
{ |
|
|
|
|
switch(sTime.drawFlag)
|
|
|
|
|
{ |
|
|
|
|
case 3: |
|
|
|
|
#ifdef CONFIG_METRIC_ONLY |
|
|
|
|
display_chars(switch_seg(line, LCD_SEG_L1_3_2, LCD_SEG_L2_3_2), itoa(sTime.hour, 2, 0), SEG_ON); |
|
|
|
|
#else |
|
|
|
|
if (sys.flag.use_metric_units) |
|
|
|
|
{ |
|
|
|
|
// Display 24H time "HH"
|
|
|
|
|
display_chars(switch_seg(line, LCD_SEG_L1_3_2, LCD_SEG_L2_3_2), itoa(sTime.hour, 2, 0), SEG_ON); |
|
|
|
|
} |
|
|
|
|
else |
|
|
|
|
{ |
|
|
|
|
// Display 12H time "HH" + AM/PM
|
|
|
|
|
hour12 = convert_hour_to_12H_format(sTime.hour); |
|
|
|
|
display_chars(switch_seg(line, LCD_SEG_L1_3_2, LCD_SEG_L2_3_2), itoa(hour12, 2, 0), SEG_ON);
|
|
|
|
|
display_am_pm_symbol(sTime.hour); |
|
|
|
|
} |
|
|
|
|
#endif |
|
|
|
|
case 2: display_chars(switch_seg(line, LCD_SEG_L1_1_0, LCD_SEG_L2_1_0), itoa(sTime.minute, 2, 0), SEG_ON);
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
else |
|
|
|
|
{ |
|
|
|
|
// Seconds are always updated
|
|
|
|
|
display_chars(switch_seg(line, LCD_SEG_L1_1_0, LCD_SEG_L2_1_0), itoa(sTime.second, 2, 0), SEG_ON); |
|
|
|
|
} |
|
|
|
|
}
|
|
|
|
|
if(sTime.drawFlag != 0) |
|
|
|
|
{ |
|
|
|
|
if (sTime.line1ViewStyle == DISPLAY_DEFAULT_VIEW) |
|
|
|
|
{ |
|
|
|
|
switch(sTime.drawFlag) |
|
|
|
|
{ |
|
|
|
|
case 3: |
|
|
|
|
display_hours_12_or_24(switch_seg(line, LCD_SEG_L1_3_2, LCD_SEG_L2_3_2), sTime.hour, 2, 1, SEG_ON); |
|
|
|
|
case 2: |
|
|
|
|
display_chars(switch_seg(line, LCD_SEG_L1_1_0, LCD_SEG_L2_1_0), itoa(sTime.minute, 2, 0), SEG_ON); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
else |
|
|
|
|
{ |
|
|
|
|
// Seconds are always updated
|
|
|
|
|
display_chars(switch_seg(line, LCD_SEG_L1_1_0, LCD_SEG_L2_1_0), itoa(sTime.second, 2, 0), SEG_ON); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
else if (update == DISPLAY_LINE_UPDATE_FULL)
|
|
|
|
|
{ |
|
|
|
|
// Full update
|
|
|
|
|
if (sTime.line1ViewStyle == DISPLAY_DEFAULT_VIEW) |
|
|
|
|
{
|
|
|
|
|
// Display 24H/12H time
|
|
|
|
|
#ifdef CONFIG_METRIC_ONLY |
|
|
|
|
display_chars(switch_seg(line, LCD_SEG_L1_3_2, LCD_SEG_L2_3_2), itoa(sTime.hour, 2, 0), SEG_ON); |
|
|
|
|
#else |
|
|
|
|
if (sys.flag.use_metric_units) |
|
|
|
|
{ |
|
|
|
|
// Display 24H time "HH"
|
|
|
|
|
display_chars(switch_seg(line, LCD_SEG_L1_3_2, LCD_SEG_L2_3_2), itoa(sTime.hour, 2, 0), SEG_ON); |
|
|
|
|
} |
|
|
|
|
else |
|
|
|
|
{ |
|
|
|
|
// Display 12H time "HH" + AM/PM information
|
|
|
|
|
hour12 = convert_hour_to_12H_format(sTime.hour); |
|
|
|
|
display_chars(switch_seg(line, LCD_SEG_L1_3_2, LCD_SEG_L2_3_2), itoa(hour12, 2, 0), SEG_ON);
|
|
|
|
|
// Display AM/PM information
|
|
|
|
|
if (line == LINE1) |
|
|
|
|
{ |
|
|
|
|
display_am_pm_symbol(sTime.hour); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
#endif |
|
|
|
|
// Display minute
|
|
|
|
|
display_chars(switch_seg(line, LCD_SEG_L1_1_0, LCD_SEG_L2_1_0), itoa(sTime.minute, 2, 0), SEG_ON);
|
|
|
|
|
display_symbol(switch_seg(line, LCD_SEG_L1_COL, LCD_SEG_L2_COL0), SEG_ON_BLINK_ON); |
|
|
|
|
} |
|
|
|
|
else |
|
|
|
|
{ |
|
|
|
|
// Display seconds
|
|
|
|
|
display_chars(switch_seg(line, LCD_SEG_L1_1_0, LCD_SEG_L2_1_0), itoa(sTime.second, 2, 0), SEG_ON); |
|
|
|
|
display_symbol(switch_seg(line, LCD_SEG_L1_DP1, LCD_SEG_L2_DP), SEG_ON); |
|
|
|
|
} |
|
|
|
|
// Full update
|
|
|
|
|
if (sTime.line1ViewStyle == DISPLAY_DEFAULT_VIEW) |
|
|
|
|
{ |
|
|
|
|
// Display hours
|
|
|
|
|
display_hours_12_or_24(switch_seg(line, LCD_SEG_L1_3_2, LCD_SEG_L2_3_2), sTime.hour, 2, 1, SEG_ON); |
|
|
|
|
// Display minute
|
|
|
|
|
display_chars(switch_seg(line, LCD_SEG_L1_1_0, LCD_SEG_L2_1_0), itoa(sTime.minute, 2, 0), SEG_ON); |
|
|
|
|
display_symbol(switch_seg(line, LCD_SEG_L1_COL, LCD_SEG_L2_COL0), SEG_ON_BLINK_ON); |
|
|
|
|
} |
|
|
|
|
else |
|
|
|
|
{ |
|
|
|
|
// Display seconds
|
|
|
|
|
display_chars(switch_seg(line, LCD_SEG_L1_1_0, LCD_SEG_L2_1_0), itoa(sTime.second, 2, 0), SEG_ON); |
|
|
|
|
display_symbol(switch_seg(line, LCD_SEG_L1_DP1, LCD_SEG_L2_DP), SEG_ON); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
else if (update == DISPLAY_LINE_CLEAR) |
|
|
|
|
{ |
|
|
|
|
display_symbol(switch_seg(line, LCD_SEG_L1_COL, LCD_SEG_L2_COL0), SEG_OFF_BLINK_OFF); |
|
|
|
|
// Change display style to default (HH:MM)
|
|
|
|
|
sTime.line1ViewStyle = DISPLAY_DEFAULT_VIEW; |
|
|
|
|
// Clean up AM/PM icon
|
|
|
|
|
display_symbol(LCD_SYMB_AM, SEG_OFF); |
|
|
|
|
display_symbol(switch_seg(line, LCD_SEG_L1_COL, LCD_SEG_L2_COL0), SEG_OFF_BLINK_OFF); |
|
|
|
|
// Change display style to default (HH:MM)
|
|
|
|
|
sTime.line1ViewStyle = DISPLAY_DEFAULT_VIEW; |
|
|
|
|
// Clean up AM/PM icon
|
|
|
|
|
display_symbol(LCD_SYMB_AM, SEG_OFF); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|