summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--firmware/export/config/sansaclipzip.h2
-rw-r--r--firmware/target/arm/as3525/sansa-clipzip/backlight-clipzip.c8
-rw-r--r--firmware/target/arm/as3525/sansa-clipzip/lcd-clipzip.c57
3 files changed, 66 insertions, 1 deletions
diff --git a/firmware/export/config/sansaclipzip.h b/firmware/export/config/sansaclipzip.h
index 749439c668..58b19664b8 100644
--- a/firmware/export/config/sansaclipzip.h
+++ b/firmware/export/config/sansaclipzip.h
@@ -48,7 +48,7 @@
#define LCD_PIXELFORMAT RGB565SWAPPED /* rgb565 swapped */
/* define this if you have LCD enable function */
-//#define HAVE_LCD_ENABLE
+#define HAVE_LCD_ENABLE
#ifndef BOOTLOADER
/* Define this if your LCD can be put to sleep.
diff --git a/firmware/target/arm/as3525/sansa-clipzip/backlight-clipzip.c b/firmware/target/arm/as3525/sansa-clipzip/backlight-clipzip.c
index 1fae4b3007..e2a175b574 100644
--- a/firmware/target/arm/as3525/sansa-clipzip/backlight-clipzip.c
+++ b/firmware/target/arm/as3525/sansa-clipzip/backlight-clipzip.c
@@ -39,10 +39,18 @@ void _backlight_on(void)
ascodec_write_pmu(AS3543_BACKLIGHT, 1, 0x91);
sleep(1);
ascodec_write_pmu(AS3543_BACKLIGHT, 1, 0x91);
+
+#ifdef HAVE_LCD_ENABLE
+ lcd_enable(true);
+#endif
}
void _backlight_off(void)
{
+#ifdef HAVE_LCD_ENABLE
+ lcd_enable(false);
+#endif
+
GPIOB_PIN(1) = 0;
ascodec_write_pmu(AS3543_BACKLIGHT, 1, 0x91);
diff --git a/firmware/target/arm/as3525/sansa-clipzip/lcd-clipzip.c b/firmware/target/arm/as3525/sansa-clipzip/lcd-clipzip.c
index 47d896a2f3..c828bab61c 100644
--- a/firmware/target/arm/as3525/sansa-clipzip/lcd-clipzip.c
+++ b/firmware/target/arm/as3525/sansa-clipzip/lcd-clipzip.c
@@ -29,6 +29,11 @@
/* the detected lcd type (0 or 1) */
static int lcd_type;
+#ifdef HAVE_LCD_ENABLE
+/* whether the lcd is currently enabled or not */
+static bool lcd_enabled;
+#endif
+
/* initialises the host lcd hardware, returns the lcd type */
int lcd_hw_init(void)
{
@@ -262,6 +267,57 @@ static void lcd_init_type1(void)
lcd_write_dat(0x00);
}
+#ifdef HAVE_LCD_ENABLE
+/* enables/disables the lcd */
+void lcd_enable(bool on)
+{
+ lcd_enabled = on;
+
+ if (lcd_type == 0) {
+ if (on) {
+ lcd_write(0x14, 0x00);
+ lcd_write(0x02, 0x01);
+ lcd_write(0xD2, 0x04);
+ lcd_write(0xD0, 0x80);
+ sleep(HZ * 100/1000);
+
+ lcd_write(0xD0, 0x00);
+ }
+ else {
+ lcd_write(0xD2, 0x05);
+ lcd_write(0xD0, 0x80);
+ sleep(HZ * 100/1000);
+
+ lcd_write(0x02, 0x00);
+ lcd_write(0xD0, 0x00);
+ lcd_write(0x14, 0x01);
+ }
+ }
+ else {
+ if (on) {
+ lcd_write_cmd(0x03);
+ lcd_write_dat(0x00);
+
+ lcd_write_cmd(0x02);
+ lcd_write_dat(0x01);
+ }
+ else {
+ lcd_write_cmd(0x02);
+ lcd_write_dat(0x00);
+
+ lcd_write_cmd(0x03);
+ lcd_write_dat(0x01);
+ }
+ }
+}
+
+/* returns true if the lcd is enabled */
+bool lcd_active(void)
+{
+ return lcd_enabled;
+}
+#endif /* HAVE_LCD_ENABLE */
+
/* initialises the lcd */
void lcd_init_device(void)
{
@@ -272,6 +328,7 @@ void lcd_init_device(void)
else {
lcd_init_type1();
}
+ lcd_enable(true);
}
/* sets up the lcd to receive frame buffer data */