diff options
-rw-r--r-- | apps/settings_menu.c | 10 | ||||
-rw-r--r-- | firmware/backlight.c | 24 |
2 files changed, 26 insertions, 8 deletions
diff --git a/apps/settings_menu.c b/apps/settings_menu.c index 3def0574a1..517716ef3c 100644 --- a/apps/settings_menu.c +++ b/apps/settings_menu.c | |||
@@ -59,9 +59,13 @@ static void sort_case(void) | |||
59 | 59 | ||
60 | static void backlight_timer(void) | 60 | static void backlight_timer(void) |
61 | { | 61 | { |
62 | set_int( "[Backlight]", "s", &global_settings.backlight, | 62 | char* names[] = { "off", "on ", |
63 | backlight_time, 1, 0, 60 ); | 63 | "1s ", "2s ", "3s ", "4s ", "5s ", |
64 | backlight_on(); | 64 | "6s ", "7s ", "8s ", "9s ", "10s", |
65 | "15s", "20s", "25s", "30s", "45s", | ||
66 | "60s", "90s"}; | ||
67 | set_option("[Backlight]", &global_settings.backlight, names, 19 ); | ||
68 | backlight_time(global_settings.backlight); | ||
65 | } | 69 | } |
66 | 70 | ||
67 | static void scroll_speed(void) | 71 | static void scroll_speed(void) |
diff --git a/firmware/backlight.c b/firmware/backlight.c index 9fe73f4d9a..b7f4761415 100644 --- a/firmware/backlight.c +++ b/firmware/backlight.c | |||
@@ -37,6 +37,11 @@ static struct event_queue backlight_queue; | |||
37 | static int backlight_timer; | 37 | static int backlight_timer; |
38 | static int backlight_timeout = 5; | 38 | static int backlight_timeout = 5; |
39 | 39 | ||
40 | static char timeout_value[19] = | ||
41 | { | ||
42 | -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 15, 20, 25, 30, 45, 60, 90 | ||
43 | }; | ||
44 | |||
40 | void backlight_thread(void) | 45 | void backlight_thread(void) |
41 | { | 46 | { |
42 | struct event ev; | 47 | struct event ev; |
@@ -47,8 +52,17 @@ void backlight_thread(void) | |||
47 | switch(ev.id) | 52 | switch(ev.id) |
48 | { | 53 | { |
49 | case BACKLIGHT_ON: | 54 | case BACKLIGHT_ON: |
50 | backlight_timer = HZ*backlight_timeout; | 55 | backlight_timer = HZ*timeout_value[backlight_timeout]; |
51 | if(backlight_timer) | 56 | if(backlight_timer < 0) |
57 | { | ||
58 | #ifdef HAVE_RTC | ||
59 | /* Disable square wave */ | ||
60 | rtc_write(0x0a, rtc_read(0x0a) & ~0x40); | ||
61 | #else | ||
62 | PADR |= 0x4000; | ||
63 | #endif | ||
64 | } | ||
65 | else if(backlight_timer) | ||
52 | { | 66 | { |
53 | #ifdef HAVE_RTC | 67 | #ifdef HAVE_RTC |
54 | /* Enable square wave */ | 68 | /* Enable square wave */ |
@@ -65,7 +79,7 @@ void backlight_thread(void) | |||
65 | rtc_write(0x0a, rtc_read(0x0a) & ~0x40); | 79 | rtc_write(0x0a, rtc_read(0x0a) & ~0x40); |
66 | #else | 80 | #else |
67 | PADR |= 0x4000; | 81 | PADR |= 0x4000; |
68 | #endif | 82 | #endif |
69 | break; | 83 | break; |
70 | 84 | ||
71 | case SYS_USB_CONNECTED: | 85 | case SYS_USB_CONNECTED: |
@@ -91,9 +105,9 @@ void backlight_off(void) | |||
91 | queue_post(&backlight_queue, BACKLIGHT_OFF, NULL); | 105 | queue_post(&backlight_queue, BACKLIGHT_OFF, NULL); |
92 | } | 106 | } |
93 | 107 | ||
94 | void backlight_time(int seconds) | 108 | void backlight_time(int value) |
95 | { | 109 | { |
96 | backlight_timeout = seconds; | 110 | backlight_timeout = value; |
97 | backlight_on(); | 111 | backlight_on(); |
98 | } | 112 | } |
99 | 113 | ||