summaryrefslogtreecommitdiff
path: root/apps/settings.c
diff options
context:
space:
mode:
Diffstat (limited to 'apps/settings.c')
-rw-r--r--apps/settings.c30
1 files changed, 18 insertions, 12 deletions
diff --git a/apps/settings.c b/apps/settings.c
index 957f77d959..ead61d88f8 100644
--- a/apps/settings.c
+++ b/apps/settings.c
@@ -425,7 +425,11 @@ void settings_apply(void)
425 backlight_set_timeout(global_settings.backlight_timeout); 425 backlight_set_timeout(global_settings.backlight_timeout);
426 backlight_set_on_when_charging(global_settings.backlight_on_when_charging); 426 backlight_set_on_when_charging(global_settings.backlight_on_when_charging);
427 ata_spindown(global_settings.disk_spindown); 427 ata_spindown(global_settings.disk_spindown);
428
429#ifdef ATA_POWER_OFF
428 ata_poweroff(global_settings.disk_poweroff); 430 ata_poweroff(global_settings.disk_poweroff);
431#endif
432
429 set_poweroff_timeout(global_settings.poweroff); 433 set_poweroff_timeout(global_settings.poweroff);
430#ifdef HAVE_CHARGE_CTRL 434#ifdef HAVE_CHARGE_CTRL
431 charge_restart_level = global_settings.discharge ? 435 charge_restart_level = global_settings.discharge ?
@@ -1035,6 +1039,8 @@ bool set_time(char* string, int timedate[])
1035 char cursor[][3] = {{ 0, 8, 12}, {18, 8, 12}, {36, 8, 12}, 1039 char cursor[][3] = {{ 0, 8, 12}, {18, 8, 12}, {36, 8, 12},
1036 {24, 16, 24}, {54, 16, 18}, {78, 16, 12}}; 1040 {24, 16, 24}, {54, 16, 18}, {78, 16, 12}};
1037 char daysinmonth[] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; 1041 char daysinmonth[] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
1042
1043 int monthname_len = 0, dayname_len = 0;
1038 1044
1039 1045
1040#ifdef HAVE_LCD_BITMAP 1046#ifdef HAVE_LCD_BITMAP
@@ -1068,9 +1074,7 @@ bool set_time(char* string, int timedate[])
1068 (realyear - 1) / 100 + (realyear - 1) / 400 + 7 - 1) % 7; 1074 (realyear - 1) / 100 + (realyear - 1) / 400 + 7 - 1) % 7;
1069 1075
1070 snprintf(buffer, sizeof(buffer), "%02d:%02d:%02d ", 1076 snprintf(buffer, sizeof(buffer), "%02d:%02d:%02d ",
1071 timedate[0], 1077 timedate[0], timedate[1], timedate[2]);
1072 timedate[1],
1073 timedate[2]);
1074 lcd_puts(0, 1, buffer); 1078 lcd_puts(0, 1, buffer);
1075 1079
1076 /* recalculate the positions and offsets */ 1080 /* recalculate the positions and offsets */
@@ -1106,23 +1110,25 @@ bool set_time(char* string, int timedate[])
1106 lcd_getstringsize(buffer, &width, &prev_line_height); 1110 lcd_getstringsize(buffer, &width, &prev_line_height);
1107 1111
1108 snprintf(buffer, sizeof(buffer), "%s 20%02d %s %02d ", 1112 snprintf(buffer, sizeof(buffer), "%s 20%02d %s %02d ",
1109 dayname[timedate[6]], 1113 dayname[timedate[6]], timedate[3], monthname[timedate[4] - 1],
1110 timedate[3],
1111 monthname[timedate[4] - 1],
1112 timedate[5]); 1114 timedate[5]);
1113 lcd_puts(0, 2, buffer); 1115 lcd_puts(0, 2, buffer);
1114 1116
1115 /* recalculate the positions and offsets */ 1117 /* recalculate the positions and offsets */
1116 lcd_getstringsize(buffer, &width, &line_height); 1118 lcd_getstringsize(buffer, &width, &line_height);
1117 1119
1120 /* store these 2 to prevent _repeated_ strlen calls */
1121 monthname_len = strlen(monthname[timedate[4] - 1]);
1122 dayname_len = strlen(dayname[timedate[6]]);
1123
1118 /* weekday */ 1124 /* weekday */
1119 strncpy(reffub, buffer, strlen(dayname[timedate[6]])); 1125 strncpy(reffub, buffer, dayname_len);
1120 reffub[strlen(dayname[timedate[6]])] = '\0'; 1126 reffub[dayname_len] = '\0';
1121 lcd_getstringsize(reffub, &weekday_width, &height); 1127 lcd_getstringsize(reffub, &weekday_width, &height);
1122 lcd_getstringsize(" ", &separator_width, &height); 1128 lcd_getstringsize(" ", &separator_width, &height);
1123 1129
1124 /* year */ 1130 /* year */
1125 strncpy(reffub, buffer + strlen(dayname[timedate[6]]) + 1, 4); 1131 strncpy(reffub, buffer + dayname_len + 1, 4);
1126 reffub[4] = '\0'; 1132 reffub[4] = '\0';
1127 lcd_getstringsize(reffub, &width, &height); 1133 lcd_getstringsize(reffub, &width, &height);
1128 cursor[3][INDEX_X] = weekday_width + separator_width; 1134 cursor[3][INDEX_X] = weekday_width + separator_width;
@@ -1130,8 +1136,8 @@ bool set_time(char* string, int timedate[])
1130 cursor[3][INDEX_WIDTH] = width; 1136 cursor[3][INDEX_WIDTH] = width;
1131 1137
1132 /* month */ 1138 /* month */
1133 strncpy(reffub, buffer + strlen(dayname[timedate[6]]) + 6, strlen(monthname[timedate[4] - 1])); 1139 strncpy(reffub, buffer + dayname_len + 6, monthname_len);
1134 reffub[strlen(monthname[timedate[4] - 1])] = '\0'; 1140 reffub[monthname_len] = '\0';
1135 lcd_getstringsize(reffub, &width, &height); 1141 lcd_getstringsize(reffub, &width, &height);
1136 cursor[4][INDEX_X] = weekday_width + separator_width + 1142 cursor[4][INDEX_X] = weekday_width + separator_width +
1137 cursor[3][INDEX_WIDTH] + separator_width; 1143 cursor[3][INDEX_WIDTH] + separator_width;
@@ -1139,7 +1145,7 @@ bool set_time(char* string, int timedate[])
1139 cursor[4][INDEX_WIDTH] = width; 1145 cursor[4][INDEX_WIDTH] = width;
1140 1146
1141 /* day */ 1147 /* day */
1142 strncpy(reffub, buffer + strlen(dayname[timedate[6]]) + strlen(monthname[timedate[4] - 1]) + 7, 2); 1148 strncpy(reffub, buffer + dayname_len + monthname_len + 7, 2);
1143 reffub[2] = '\0'; 1149 reffub[2] = '\0';
1144 lcd_getstringsize(reffub, &width, &height); 1150 lcd_getstringsize(reffub, &width, &height);
1145 cursor[5][INDEX_X] = weekday_width + separator_width + 1151 cursor[5][INDEX_X] = weekday_width + separator_width +