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 6510ea0211..e1bfad4939 100644
--- a/apps/settings_menu.c
+++ b/apps/settings_menu.c
@@ -100,7 +100,8 @@ static Menu scroll_speed(void)
100static Menu deep_discharge(void) 100static Menu deep_discharge(void)
101{ 101{
102 set_bool( "[Deep discharge]", &global_settings.discharge ); 102 set_bool( "[Deep discharge]", &global_settings.discharge );
103 charge_restart_level = global_settings.discharge ? CHARGE_RESTART_LO : CHARGE_RESTART_HI; 103 charge_restart_level = global_settings.discharge ?
104 CHARGE_RESTART_LO : CHARGE_RESTART_HI;
104 return MENU_OK; 105 return MENU_OK;
105} 106}
106#endif 107#endif
@@ -118,30 +119,44 @@ static Menu timedate_set(void)
118 timedate[4] = rtc_read(0x06); /* month */ 119 timedate[4] = rtc_read(0x06); /* month */
119 timedate[5] = rtc_read(0x05); /* day */ 120 timedate[5] = rtc_read(0x05); /* day */
120 /* day of week not read, calculated */ 121 /* day of week not read, calculated */
121 timedate[0] = ((timedate[0] & 0x30) >> 4) * 10 + (timedate[0] & 0x0f); /* hour */ 122 /* hour */
122 timedate[1] = ((timedate[1] & 0x70) >> 4) * 10 + (timedate[1] & 0x0f); /* minute */ 123 timedate[0] = ((timedate[0] & 0x30) >> 4) * 10 + (timedate[0] & 0x0f);
123 timedate[2] = ((timedate[2] & 0x70) >> 4) * 10 + (timedate[2] & 0x0f); /* second */ 124 /* minute */
124 timedate[3] = ((timedate[3] & 0xf0) >> 4) * 10 + (timedate[3] & 0x0f); /* year */ 125 timedate[1] = ((timedate[1] & 0x70) >> 4) * 10 + (timedate[1] & 0x0f);
125 timedate[4] = ((timedate[4] & 0x10) >> 4) * 10 + (timedate[4] & 0x0f); /* month */ 126 /* second */
126 timedate[5] = ((timedate[5] & 0x30) >> 4) * 10 + (timedate[5] & 0x0f); /* day */ 127 timedate[2] = ((timedate[2] & 0x70) >> 4) * 10 + (timedate[2] & 0x0f);
128 /* year */
129 timedate[3] = ((timedate[3] & 0xf0) >> 4) * 10 + (timedate[3] & 0x0f);
130 /* month */
131 timedate[4] = ((timedate[4] & 0x10) >> 4) * 10 + (timedate[4] & 0x0f);
132 /* day */
133 timedate[5] = ((timedate[5] & 0x30) >> 4) * 10 + (timedate[5] & 0x0f);
134
127 135
128 set_time("[Set time/date]",timedate); 136 set_time("[Set time/date]",timedate);
129 137
130 if(timedate[0] != -1) { 138 if(timedate[0] != -1) {
131 timedate[0] = ((timedate[0]/10) << 4 | timedate[0]%10) & 0x3f; /* hour */ 139 /* hour */
132 timedate[1] = ((timedate[1]/10) << 4 | timedate[1]%10) & 0x7f; /* minute */ 140 timedate[0] = ((timedate[0]/10) << 4 | timedate[0]%10) & 0x3f;
133 timedate[2] = ((timedate[2]/10) << 4 | timedate[2]%10) & 0x7f; /* second */ 141 /* minute */
134 timedate[3] = ((timedate[3]/10) << 4 | timedate[3]%10) & 0xff; /* year */ 142 timedate[1] = ((timedate[1]/10) << 4 | timedate[1]%10) & 0x7f;
135 timedate[4] = ((timedate[4]/10) << 4 | timedate[4]%10) & 0x1f; /* month */ 143 /* second */
136 timedate[5] = ((timedate[5]/10) << 4 | timedate[5]%10) & 0x3f; /* day */ 144 timedate[2] = ((timedate[2]/10) << 4 | timedate[2]%10) & 0x7f;
137 rtc_write(0x03, timedate[0] | (rtc_read(0x03) & 0xc0)); /* hour */ 145 /* year */
138 rtc_write(0x02, timedate[1] | (rtc_read(0x02) & 0x80)); /* minute */ 146 timedate[3] = ((timedate[3]/10) << 4 | timedate[3]%10) & 0xff;
139 rtc_write(0x01, timedate[2] | (rtc_read(0x01) & 0x80)); /* second */ 147 /* month */
140 rtc_write(0x07, timedate[3]); /* year */ 148 timedate[4] = ((timedate[4]/10) << 4 | timedate[4]%10) & 0x1f;
141 rtc_write(0x06, timedate[4] | (rtc_read(0x06) & 0xe0)); /* month */ 149 /* day */
142 rtc_write(0x05, timedate[5] | (rtc_read(0x05) & 0xc0)); /* day */ 150 timedate[5] = ((timedate[5]/10) << 4 | timedate[5]%10) & 0x3f;
143 rtc_write(0x04, timedate[6] | (rtc_read(0x04) & 0xf8)); /* dayofweek */ 151
144 rtc_write(0x00, 0x00); /* 0.1 + 0.01 seconds */ 152 rtc_write(0x03, timedate[0] | (rtc_read(0x03) & 0xc0)); /* hour */
153 rtc_write(0x02, timedate[1] | (rtc_read(0x02) & 0x80)); /* minute */
154 rtc_write(0x01, timedate[2] | (rtc_read(0x01) & 0x80)); /* second */
155 rtc_write(0x07, timedate[3]); /* year */
156 rtc_write(0x06, timedate[4] | (rtc_read(0x06) & 0xe0)); /* month */
157 rtc_write(0x05, timedate[5] | (rtc_read(0x05) & 0xc0)); /* day */
158 rtc_write(0x04, timedate[6] | (rtc_read(0x04) & 0xf8)); /* dayofweek */
159 rtc_write(0x00, 0x00); /* 0.1 + 0.01 seconds */
145 } 160 }
146 return MENU_OK; 161 return MENU_OK;
147} 162}