Browse Source

Refactored the code to display hours so that a single function from display.c is used.

fertito
Dean Sellers 13 years ago
parent
commit
9a85de57bd
  1. 12
      driver/display.c
  2. 4
      driver/display.h
  3. 30
      logic/alarm.c
  4. 2
      logic/bluerobin.c
  5. 45
      logic/clock.c
  6. 2
      logic/clock.h
  7. 4
      logic/user.c
  8. 2
      logic/user.h

12
driver/display.c

@ -298,21 +298,21 @@ u8 * itoa(u32 n, u8 digits, u8 blanks)
// u8 blanks Number of leadings blanks in itoa result string
// @return none
// *************************************************************************************************
void display_value1(u8 segments, u32 value, u8 digits, u8 blanks)
void display_value1(u8 segments, u32 value, u8 digits, u8 blanks, u8 disp_mode)
{
u8 * str;
str = itoa(value, digits, blanks);
// Display string in blink mode
display_chars(segments, str, SEG_ON_BLINK_ON);
display_chars(segments, str, disp_mode);
}
// *************************************************************************************************
// @fn display_hours
// @fn display_hours_12_or_24
// @brief Display hours in 24H / 12H time format.
// @param u8 segments Segments where to display hour data
// u32 value Hour data
@ -320,7 +320,7 @@ void display_value1(u8 segments, u32 value, u8 digits, u8 blanks)
// u8 blanks Must be "0"
// @return none
// *************************************************************************************************
void display_hours1(u8 segments, u32 value, u8 digits, u8 blanks)
void display_hours_12_or_24(u8 segments, u32 value, u8 digits, u8 blanks, u8 disp_mode)
{
#if (OPTION_TIME_DISPLAY > CLOCK_24HR)
u8 hours;
@ -335,7 +335,7 @@ void display_hours1(u8 segments, u32 value, u8 digits, u8 blanks)
hours = convert_hour_to_12H_format(value);
// display hours in 12H time format
display_value1(segments, hours, digits, blanks);
display_value1(segments, hours, digits, blanks, disp_mode);
display_am_pm_symbol(value);
#endif
#if (OPTION_TIME_DISPLAY == CLOCK_DISPLAY_SELECT)
@ -345,7 +345,7 @@ void display_hours1(u8 segments, u32 value, u8 digits, u8 blanks)
#endif
#if (OPTION_TIME_DISPLAY != CLOCK_AM_PM)
// Display hours in 24H time format
display_value1(segments, (u16) value, digits, blanks);
display_value1(segments, (u16) value, digits, blanks, disp_mode);
#endif
#if (OPTION_TIME_DISPLAY == CLOCK_DISPLAY_SELECT)
}

4
driver/display.h

@ -351,8 +351,8 @@ extern void DisplayTime(u8 updateMode);
extern void display_am_pm_symbol(u8 timeAM);
// Set_value display functions
extern void display_value1(u8 segments, u32 value, u8 digits, u8 blanks);
extern void display_hours1(u8 segments, u32 value, u8 digits, u8 blanks);
extern void display_value1(u8 segments, u32 value, u8 digits, u8 blanks, u8 disp_mode);
extern void display_hours_12_or_24(u8 segments, u32 value, u8 digits, u8 blanks, u8 disp_mode);
// Integer to string conversion
extern u8 * itoa(u32 n, u8 digits, u8 blanks);

30
logic/alarm.c

@ -214,7 +214,7 @@ void mx_alarm(u8 line)
switch (select)
{
case 0: // Set hour
set_value(&hours, 2, 0, 0, 23, SETVALUE_ROLLOVER_VALUE + SETVALUE_DISPLAY_VALUE + SETVALUE_NEXT_VALUE, LCD_SEG_L1_3_2, display_hours1);
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 = 1;
break;
@ -242,36 +242,10 @@ void mx_alarm(u8 line)
// *************************************************************************************************
void display_alarm(u8 line, u8 update)
{
#if (OPTION_TIME_DISPLAY > CLOCK_24HR)
u8 hour12;
#endif
if (update == DISPLAY_LINE_UPDATE_FULL)
{
#if (OPTION_TIME_DISPLAY == CLOCK_DISPLAY_SELECT)
if (sys.flag.am_pm_time)
{
#endif
#if (OPTION_TIME_DISPLAY > CLOCK_24HR)
// Display 12H alarm time "HH:MM" + AM/PM
hour12 = convert_hour_to_12H_format(sAlarm.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
display_am_pm_symbol(sAlarm.hour);
#endif
#if (OPTION_TIME_DISPLAY == CLOCK_DISPLAY_SELECT)
}
else
{
#endif
#if (OPTION_TIME_DISPLAY != CLOCK_AM_PM)
// Display 24H alarm time "HH:MM"
display_chars(switch_seg(line, LCD_SEG_L1_3_2, LCD_SEG_L2_3_2), itoa(sAlarm.hour, 2, 0), SEG_ON);
#endif
#if (OPTION_TIME_DISPLAY == CLOCK_DISPLAY_SELECT)
}
#endif
display_hours_12_or_24(switch_seg(line, LCD_SEG_L1_3_2, LCD_SEG_L2_3_2), sAlarm.hour, 2, 1, SEG_ON);
display_chars(switch_seg(line, LCD_SEG_L1_1_0, LCD_SEG_L2_1_0), itoa(sAlarm.minute, 2, 0), SEG_ON);
display_symbol(switch_seg(line, LCD_SEG_L1_COL, LCD_SEG_L2_COL0), SEG_ON);

2
logic/bluerobin.c

@ -257,7 +257,7 @@ void sx_bluerobin(u8 line)
//
// @return none
// *************************************************************************************************
void display_selection_User_Sex1(u8 segments, u32 index, u8 digits, u8 blanks)
void display_selection_User_Sex1(u8 segments, u32 index, u8 digits, u8 blanks, u8 dummy)
{
if (index < 2) display_chars(segments, (u8 *)selection_User_Sex[index], SEG_ON_BLINK_ON);
}

45
logic/clock.c

@ -204,7 +204,7 @@ 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);
}
@ -314,7 +314,7 @@ void mx_time(u8 line)
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);
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;
@ -348,43 +348,6 @@ void sx_time(u8 line)
else sTime.line1ViewStyle = DISPLAY_DEFAULT_VIEW;
}
// *************************************************************************************************
// @fn display_hours_with_12_24
// @brief Clock display helper routine. Supports 24H and 12H time format.
// @param u8 line LINE1
//
// @return none
// *************************************************************************************************
static void display_hours_with_12_24(u8 line)
{
#if (OPTION_TIME_DISPLAY > CLOCK_24HR)
u8 hour12;
#endif
#if (OPTION_TIME_DISPLAY == CLOCK_DISPLAY_SELECT)
if (sys.flag.am_pm_time)
{
#endif
#if (OPTION_TIME_DISPLAY > CLOCK_24HR)
// 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
#if (OPTION_TIME_DISPLAY == CLOCK_DISPLAY_SELECT)
}
else
{
#endif
#if(OPTION_TIME_DISPLAY != CLOCK_AM_PM)
// 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);
#endif
#if (OPTION_TIME_DISPLAY == CLOCK_DISPLAY_SELECT)
}
#endif
}
// *************************************************************************************************
// @fn display_time
// @brief Clock display routine. Supports 24H and 12H time format,
@ -405,7 +368,7 @@ void display_time(u8 line, u8 update)
switch(sTime.drawFlag)
{
case 3:
display_hours_with_12_24(line);
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);
}
@ -423,7 +386,7 @@ void display_time(u8 line, u8 update)
if (sTime.line1ViewStyle == DISPLAY_DEFAULT_VIEW)
{
// Display hours
display_hours_with_12_24(line);
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);

2
logic/clock.h

@ -49,7 +49,7 @@ extern void reset_clock(void);
extern void sx_time(u8 line);
extern void mx_time(u8 line);
extern void clock_tick(void);
extern void display_selection_Timeformat1(u8 segments, u32 index, u8 digits, u8 blanks);
extern void display_selection_Timeformat1(u8 segments, u32 index, u8 digits, u8 blanks, u8 dummy);
extern void display_time(u8 line, u8 update);
// English units support

4
logic/user.c

@ -96,7 +96,7 @@ void dummy(u8 line)
// fptr_setValue_display_function1 Value-specific display routine
// @return none
// *************************************************************************************************
void set_value(s32 * value, u8 digits, u8 blanks, s32 limitLow, s32 limitHigh, u16 mode, u8 segments, void (*fptr_setValue_display_function1)(u8 segments, u32 value, u8 digits, u8 blanks))
void set_value(s32 * value, u8 digits, u8 blanks, s32 limitLow, s32 limitHigh, u16 mode, u8 segments, void (*fptr_setValue_display_function1)(u8 segments, u32 value, u8 digits, u8 blanks, u8 disp_mode))
{
u8 update;
s16 stepValue = 1;
@ -241,7 +241,7 @@ void set_value(s32 * value, u8 digits, u8 blanks, s32 limitLow, s32 limitHigh, u
// Display function can either display value directly, modify value before displaying
// or display a string referenced by the value
fptr_setValue_display_function1(segments, val, digits, blanks);
fptr_setValue_display_function1(segments, val, digits, blanks, SEG_ON_BLINK_ON);
// Clear update flag
update = 0;

2
logic/user.h

@ -51,7 +51,7 @@
// Prototypes section
extern u8 * select_view_style(u8 line, u8 * view1, u8 * view2);
extern void (*fptr_setValue_display_function1)(u8 segments, u32 value, u8 digits, u8 blanks);
extern void set_value(s32 * value, u8 digits, u8 blanks, s32 limitLow, s32 limitHigh, u16 mode, u8 segments, void (*fptr_setValue_display_function1)(u8 segments, u32 value, u8 digits, u8 blanks));
extern void set_value(s32 * value, u8 digits, u8 blanks, s32 limitLow, s32 limitHigh, u16 mode, u8 segments, void (*fptr_setValue_display_function1)(u8 segments, u32 value, u8 digits, u8 blanks, u8 disp_mode));
extern void dummy(u8 line);
#endif /*USER_H_*/

Loading…
Cancel
Save