diff --git a/apps/gui/statusbar.c b/apps/gui/statusbar.c index 945013e4b9..d336d8ad0e 100644 --- a/apps/gui/statusbar.c +++ b/apps/gui/statusbar.c @@ -143,8 +143,10 @@ void gui_statusbar_draw(struct gui_statusbar * bar, bool force_redraw) #endif bar->info.repeat = global_settings.repeat_mode; bar->info.playmode = current_playmode(); +#if (CONFIG_LED == LED_VIRTUAL) || defined(HAVE_REMOTE_LCD) if(!display->has_disk_led) bar->info.led = led_read(HZ/2); /* delay should match polling interval */ +#endif #ifdef HAVE_USB_POWER bar->info.usb_power = usb_powered(); @@ -258,8 +260,10 @@ void gui_statusbar_draw(struct gui_statusbar * bar, bool force_redraw) #ifdef HAVE_RTC gui_statusbar_time(display, bar->info.hour, bar->info.minute); #endif /* HAVE_RTC */ +#if (CONFIG_LED == LED_VIRTUAL) || defined(HAVE_REMOTE_LCD) if(!display->has_disk_led && bar->info.led) gui_statusbar_led(display); +#endif display->update_rect(0, 0, display->width, STATUSBAR_HEIGHT); bar->lastinfo = bar->info; #endif /* HAVE_LCD_BITMAP */ @@ -465,6 +469,7 @@ void gui_statusbar_icon_lock_remote(struct screen * display) STATUSBAR_LOCKR_WIDTH, STATUSBAR_HEIGHT); } +#if (CONFIG_LED == LED_VIRTUAL) || defined(HAVE_REMOTE_LCD) /* * no real LED: disk activity in status bar */ @@ -475,6 +480,7 @@ void gui_statusbar_led(struct screen * display) STATUSBAR_Y_POS, STATUSBAR_DISK_WIDTH, STATUSBAR_HEIGHT); } +#endif #ifdef HAVE_RTC /* diff --git a/apps/gui/statusbar.h b/apps/gui/statusbar.h index 88dfd4c4a2..62f6b90820 100644 --- a/apps/gui/statusbar.h +++ b/apps/gui/statusbar.h @@ -46,7 +46,9 @@ struct status_info { #endif bool battery_safe; bool redraw_volume; /* true if the volume gauge needs updating */ +#if (CONFIG_LED == LED_VIRTUAL) || defined(HAVE_REMOTE_LCD) bool led; /* disk LED simulation in the status bar */ +#endif #ifdef HAVE_USB_POWER bool usb_power; diff --git a/apps/recorder/icons.c b/apps/recorder/icons.c index 68985c2028..bee0f47f12 100644 --- a/apps/recorder/icons.c +++ b/apps/recorder/icons.c @@ -74,8 +74,12 @@ const unsigned char bitmap_icons_7x8[][7] = }; /* Disk/MMC activity */ -const unsigned char bitmap_icon_disk[12] = +const unsigned char bitmap_icon_disk[12] = +#ifdef HAVE_MMC {0x15,0x3f,0x7d,0x7B,0x77,0x67,0x79,0x7b,0x57,0x4f,0x47,0x7f}; +#else + {0x00,0x00,0x00,0x1c,0x22,0x41,0x49,0x41,0x22,0x1c,0x00,0x00}; +#endif #if LCD_WIDTH == 112 || LCD_WIDTH == 128 \ || (defined(HAVE_REMOTE_LCD) && LCD_REMOTE_WIDTH == 128) diff --git a/apps/screen_access.c b/apps/screen_access.c index 9ea33ba25f..56fe131869 100644 --- a/apps/screen_access.c +++ b/apps/screen_access.c @@ -100,7 +100,7 @@ void screen_init(struct screen * screen, enum screen_type screen_type) screen->depth=LCD_DEPTH; #if CONFIG_LED == LED_VIRTUAL screen->has_disk_led=false; -#else +#elif defined(HAVE_REMOTE_LCD) screen->has_disk_led=true; #endif #ifdef HAVE_LCD_BITMAP diff --git a/apps/screen_access.h b/apps/screen_access.h index 430d5ab661..8eb89152aa 100644 --- a/apps/screen_access.h +++ b/apps/screen_access.h @@ -54,7 +54,9 @@ struct screen int depth; int char_width; int char_height; +#if (CONFIG_LED == LED_VIRTUAL) || defined(HAVE_REMOTE_LCD) bool has_disk_led; +#endif #ifdef HAS_BUTTONBAR bool has_buttonbar; #endif diff --git a/firmware/drivers/ata.c b/firmware/drivers/ata.c index a3dd8be241..ec4b342beb 100644 --- a/firmware/drivers/ata.c +++ b/firmware/drivers/ata.c @@ -512,7 +512,9 @@ static void copy_read_sectors(unsigned char* buf, int wordcount) #endif } -#ifdef CONFIG_LED +#if CONFIG_LED == LED_REAL +/* Conditionally block LED access for the ATA driver, so the LED can be + * (mis)used for other purposes */ static void ata_led(bool on) { ata_led_on = on; if (ata_led_enabled) { @@ -520,7 +522,7 @@ static void ata_led(bool on) { } } #else -#define ata_led(on) +#define ata_led(on) led(on) #endif int ata_read_sectors(IF_MV2(int drive,) diff --git a/firmware/drivers/led.c b/firmware/drivers/led.c index 1e38fa63d3..118911a746 100644 --- a/firmware/drivers/led.c +++ b/firmware/drivers/led.c @@ -23,50 +23,50 @@ #include "system.h" #include "kernel.h" -static bool disk_led_status; -static long last_on; /* timestamp of switching off */ - - - -void disk_led_on(void) -{ - disk_led_status=true; #if CONFIG_LED == LED_REAL -#ifdef GMINI_ARCH - P2 |= 1; -#else - or_b(0x40, &PBDRL); -#endif -#endif -} - -void disk_led_off(void) -{ - if(disk_led_status) - { - last_on = current_tick;/* remember for off delay */ - disk_led_status=false; -#if CONFIG_LED == LED_REAL -#ifdef GMINI_ARCH - P2 &= ~1; -#else - and_b(~0x40, &PBDRL); -#endif -#endif - } -} void led(bool on) { if ( on ) - disk_led_on(); +#ifdef GMINI_ARCH + P2 |= 1; else - disk_led_off(); + P2 &= ~1; +#else + { + or_b(0x40, &PBDRL); + } + else + { + and_b(~0x40, &PBDRL); + } +#endif } -bool led_read(int delayticks) +#elif (CONFIG_LED == LED_VIRTUAL) || defined(HAVE_REMOTE_LCD) + +static bool current; +static long last_on; /* timestamp of switching off */ + +void led(bool on) +{ + if (current && !on) /* switching off */ + { + last_on = current_tick; /* remember for off delay */ + } + current = on; +} + +bool led_read(int delayticks) /* read by status bar update */ { /* reading "off" is delayed by user-supplied monoflop value */ - return (disk_led_status || - TIME_BEFORE(current_tick, last_on+delayticks)); + return (current || TIME_BEFORE(current_tick, last_on+delayticks)); } + +#else + +void led(bool on) +{ + (void)on; +} +#endif /* CONFIG_LED, HAVE_REMOTE_LCD */