Browse Source

add option to compile out 12h code

we can save some space by compiling out the 12h am/pm code
fertito
Daniel Poelzleithner 12 years ago
parent
commit
850892a9dd
  1. 2
      .gitignore
  2. 9
      driver/display.c
  3. 5
      ezchronos.c
  4. 4
      logic/alarm.c
  5. 20
      logic/clock.c
  6. 14
      tools/config.py

2
.gitignore vendored

@ -1,3 +1,5 @@
*.[oa]
*.pyc
*.*~
.pida-metadata
config.h

9
driver/display.c

@ -322,8 +322,11 @@ void display_value1(u8 segments, u32 value, u8 digits, u8 blanks)
// *************************************************************************************************
void display_hours1(u8 segments, u32 value, u8 digits, u8 blanks)
{
#ifdef CONFIG_METRIC_ONLY
display_value1(segments, (u16) value, digits, blanks);
#else
u8 hours;
if (sys.flag.use_metric_units)
{
// Display hours in 24H time format
@ -338,6 +341,7 @@ void display_hours1(u8 segments, u32 value, u8 digits, u8 blanks)
display_value1(segments, hours, digits, blanks);
display_am_pm_symbol(value);
}
#endif
}
@ -347,6 +351,7 @@ void display_hours1(u8 segments, u32 value, u8 digits, u8 blanks)
// @param u8 hour 24H internal time format
// @return none
// *************************************************************************************************
#ifndef CONFIG_METRIC_ONLY
void display_am_pm_symbol(u8 hour)
{
// Display AM/PM symbol
@ -361,7 +366,7 @@ void display_am_pm_symbol(u8 hour)
display_symbol(LCD_SYMB_PM, SEG_ON);
}
}
#endif
// *************************************************************************************************
// @fn display_symbol

5
ezchronos.c

@ -321,8 +321,13 @@ void init_global_variables(void)
display.flag.full_update = 1;
#ifndef ISM_US
// Use metric units when displaying values
sys.flag.use_metric_units = 1;
#else
#ifdef CONFIG_METRIC_ONLY
sys.flag.use_metric_units = 1;
#endif
#endif
// Read calibration values from info memory

4
logic/alarm.c

@ -246,6 +246,9 @@ void display_alarm(u8 line, u8 update)
if (update == DISPLAY_LINE_UPDATE_FULL)
{
#ifdef CONFIG_METRIC_ONLY
display_chars(switch_seg(line, LCD_SEG_L1_3_2, LCD_SEG_L2_3_2), itoa(sAlarm.hour, 2, 0), SEG_ON);
#else
if (sys.flag.use_metric_units)
{
// Display 24H alarm time "HH:MM"
@ -260,6 +263,7 @@ void display_alarm(u8 line, u8 update)
// Display AM/PM symbol
display_am_pm_symbol(sAlarm.hour);
}
#endif
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);

20
logic/clock.c

@ -167,6 +167,7 @@ void clock_tick(void)
// @param u8 hour Hour in 24H format
// @return u8 Hour in 12H format
// *************************************************************************************************
#ifndef CONFIG_METRIC_ONLY
u8 convert_hour_to_12H_format(u8 hour)
{
// 00:00 .. 11:59 --> AM 12:00 .. 11:59
@ -191,6 +192,7 @@ u8 is_hour_am(u8 hour)
else return (0);
}
#endif // CONFIG_METRIC_ONLY
// *************************************************************************************************
// @fn display_selection_Timeformat
@ -278,6 +280,7 @@ void mx_time(u8 line)
switch (select)
{
#ifdef 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);
@ -290,7 +293,9 @@ void mx_time(u8 line)
else sys.flag.use_metric_units = 0;
select = 1;
break;
#else
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);
@ -359,7 +364,11 @@ void display_time(u8 line, u8 update)
{
switch(sTime.drawFlag)
{
case 3: if (sys.flag.use_metric_units)
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);
@ -371,7 +380,7 @@ void display_time(u8 line, u8 update)
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);
}
}
@ -388,6 +397,9 @@ void display_time(u8 line, u8 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"
@ -404,7 +416,7 @@ void display_time(u8 line, u8 update)
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);

14
tools/config.py

@ -13,6 +13,14 @@ DATA = {
"type": "choices",
"values": [911, 868, 433]},
"CONFIG_METRIC_ONLY": {
"name": "Metric only code (saves space)",
"depends": [],
"default": False
},
# modules
"CONFIG_ACCEL": {
"name": "Accleration",
"depends": [],
@ -106,7 +114,6 @@ class OpenChronosApp(npyscreen.NPSApp):
# This lets the user play with the Form.
F.edit()
print "done", F
def save_config(self):
for key,field in self.fields.iteritems():
@ -116,6 +123,7 @@ class OpenChronosApp(npyscreen.NPSApp):
DATA[key]["value"] = value
fp = open("config.h", "w")
fp.write("// !!!! DO NOT EDIT !!!, use: make config\n")
for key,dat in DATA.iteritems():
if isinstance(dat["value"], bool):
if dat["value"]:
@ -129,7 +137,7 @@ class OpenChronosApp(npyscreen.NPSApp):
def load_config(self):
def set_default():
for key,dat in DATA.iteritems():
print dat
#print dat
if not "value" in dat:
dat["value"] = dat["default"]
@ -141,9 +149,7 @@ class OpenChronosApp(npyscreen.NPSApp):
match = re.compile('^[\t ]*#[\t ]*define[\t ]+([a-zA-Z0-9_]+)[\t ]*(.*)$')
match2 = re.compile('^// ([a-zA-Z0-9_]+) is not set$')
for line in fp:
print line
m = match.search(line)
print m
if m:
m = m.groups()
if not m[0] in DATA:

Loading…
Cancel
Save