summaryrefslogtreecommitdiff
path: root/apps/settings_menu.c
diff options
context:
space:
mode:
Diffstat (limited to 'apps/settings_menu.c')
-rw-r--r--apps/settings_menu.c57
1 files changed, 36 insertions, 21 deletions
diff --git a/apps/settings_menu.c b/apps/settings_menu.c
index 6510ea0..e1bfad4 100644
--- a/apps/settings_menu.c
+++ b/apps/settings_menu.c
@@ -100,7 +100,8 @@ static Menu scroll_speed(void)
static Menu deep_discharge(void)
{
set_bool( "[Deep discharge]", &global_settings.discharge );
- charge_restart_level = global_settings.discharge ? CHARGE_RESTART_LO : CHARGE_RESTART_HI;
+ charge_restart_level = global_settings.discharge ?
+ CHARGE_RESTART_LO : CHARGE_RESTART_HI;
return MENU_OK;
}
#endif
@@ -118,30 +119,44 @@ static Menu timedate_set(void)
timedate[4] = rtc_read(0x06); /* month */
timedate[5] = rtc_read(0x05); /* day */
/* day of week not read, calculated */
- timedate[0] = ((timedate[0] & 0x30) >> 4) * 10 + (timedate[0] & 0x0f); /* hour */
- timedate[1] = ((timedate[1] & 0x70) >> 4) * 10 + (timedate[1] & 0x0f); /* minute */
- timedate[2] = ((timedate[2] & 0x70) >> 4) * 10 + (timedate[2] & 0x0f); /* second */
- timedate[3] = ((timedate[3] & 0xf0) >> 4) * 10 + (timedate[3] & 0x0f); /* year */
- timedate[4] = ((timedate[4] & 0x10) >> 4) * 10 + (timedate[4] & 0x0f); /* month */
- timedate[5] = ((timedate[5] & 0x30) >> 4) * 10 + (timedate[5] & 0x0f); /* day */
+ /* hour */
+ timedate[0] = ((timedate[0] & 0x30) >> 4) * 10 + (timedate[0] & 0x0f);
+ /* minute */
+ timedate[1] = ((timedate[1] & 0x70) >> 4) * 10 + (timedate[1] & 0x0f);
+ /* second */
+ timedate[2] = ((timedate[2] & 0x70) >> 4) * 10 + (timedate[2] & 0x0f);
+ /* year */
+ timedate[3] = ((timedate[3] & 0xf0) >> 4) * 10 + (timedate[3] & 0x0f);
+ /* month */
+ timedate[4] = ((timedate[4] & 0x10) >> 4) * 10 + (timedate[4] & 0x0f);
+ /* day */
+ timedate[5] = ((timedate[5] & 0x30) >> 4) * 10 + (timedate[5] & 0x0f);
+
set_time("[Set time/date]",timedate);
if(timedate[0] != -1) {
- timedate[0] = ((timedate[0]/10) << 4 | timedate[0]%10) & 0x3f; /* hour */
- timedate[1] = ((timedate[1]/10) << 4 | timedate[1]%10) & 0x7f; /* minute */
- timedate[2] = ((timedate[2]/10) << 4 | timedate[2]%10) & 0x7f; /* second */
- timedate[3] = ((timedate[3]/10) << 4 | timedate[3]%10) & 0xff; /* year */
- timedate[4] = ((timedate[4]/10) << 4 | timedate[4]%10) & 0x1f; /* month */
- timedate[5] = ((timedate[5]/10) << 4 | timedate[5]%10) & 0x3f; /* day */
- rtc_write(0x03, timedate[0] | (rtc_read(0x03) & 0xc0)); /* hour */
- rtc_write(0x02, timedate[1] | (rtc_read(0x02) & 0x80)); /* minute */
- rtc_write(0x01, timedate[2] | (rtc_read(0x01) & 0x80)); /* second */
- rtc_write(0x07, timedate[3]); /* year */
- rtc_write(0x06, timedate[4] | (rtc_read(0x06) & 0xe0)); /* month */
- rtc_write(0x05, timedate[5] | (rtc_read(0x05) & 0xc0)); /* day */
- rtc_write(0x04, timedate[6] | (rtc_read(0x04) & 0xf8)); /* dayofweek */
- rtc_write(0x00, 0x00); /* 0.1 + 0.01 seconds */
+ /* hour */
+ timedate[0] = ((timedate[0]/10) << 4 | timedate[0]%10) & 0x3f;
+ /* minute */
+ timedate[1] = ((timedate[1]/10) << 4 | timedate[1]%10) & 0x7f;
+ /* second */
+ timedate[2] = ((timedate[2]/10) << 4 | timedate[2]%10) & 0x7f;
+ /* year */
+ timedate[3] = ((timedate[3]/10) << 4 | timedate[3]%10) & 0xff;
+ /* month */
+ timedate[4] = ((timedate[4]/10) << 4 | timedate[4]%10) & 0x1f;
+ /* day */
+ timedate[5] = ((timedate[5]/10) << 4 | timedate[5]%10) & 0x3f;
+
+ rtc_write(0x03, timedate[0] | (rtc_read(0x03) & 0xc0)); /* hour */
+ rtc_write(0x02, timedate[1] | (rtc_read(0x02) & 0x80)); /* minute */
+ rtc_write(0x01, timedate[2] | (rtc_read(0x01) & 0x80)); /* second */
+ rtc_write(0x07, timedate[3]); /* year */
+ rtc_write(0x06, timedate[4] | (rtc_read(0x06) & 0xe0)); /* month */
+ rtc_write(0x05, timedate[5] | (rtc_read(0x05) & 0xc0)); /* day */
+ rtc_write(0x04, timedate[6] | (rtc_read(0x04) & 0xf8)); /* dayofweek */
+ rtc_write(0x00, 0x00); /* 0.1 + 0.01 seconds */
}
return MENU_OK;
}