OSDN Git Service

[LCD] Add backlight manipulation.
authorK.Ohta <whatisthis.sowhat@gmail.com>
Tue, 18 Jun 2013 05:22:11 +0000 (14:22 +0900)
committerK.Ohta <whatisthis.sowhat@gmail.com>
Tue, 18 Jun 2013 05:22:11 +0000 (14:22 +0900)
iodef.h
lcd_acm1602.c
lcd_acm1602.h
main.c

diff --git a/iodef.h b/iodef.h
index b418c98..e4b6634 100644 (file)
--- a/iodef.h
+++ b/iodef.h
@@ -226,9 +226,11 @@ typedef union {
 #define _LCDPORT_CONT_RSbit b0
 #define _LCDPORT_CONT_RWbit b1
 #define _LCDPORT_CONT_ENbit b2
+#define _LCDPORT_CONT_BLbit b3
 #define _LCDPORT_CONT_RS _PORTD_RD0
 #define _LCDPORT_CONT_RW _PORTD_RD1
 #define _LCDPORT_CONT_EN _PORTD_RD2
+#define _LCDPORT_CONT_BACKLIGHT _PORTD_RD2
  #endif
 
 #else
index 8932bf5..3f4cc93 100644 (file)
@@ -626,3 +626,16 @@ void st7032_setcontrast(unsigned char addr, unsigned char value,
     val |= 0x70;
     st7032_extcmd(addr, 0x38, val, busyf);
 }
+
+void acm1602_setbacklight(unsigned char flag)
+{
+    unsigned char b;
+
+    b = _LCDPORT_CONT;
+    if(flag == 0){
+        b &= ~_LCDPORT_CONT_BACKLIGHT;
+    } else {
+        b |= _LCDPORT_CONT_BACKLIGHT;
+    }
+    _LCDPORT_CONT_LATCH = b;
+}
\ No newline at end of file
index 124a452..24f9834 100644 (file)
@@ -66,6 +66,7 @@ extern void acm1602_printf(unsigned char addr, const char *fmt, ...);
 extern void acm1602_cursordir(unsigned char addr, unsigned char right);
 extern void acm1602_init(unsigned char addr, unsigned char cls);
 extern unsigned char acm1602_getchar(unsigned char addr);
+extern void acm1602_setbacklight(unsigned char flag);
 
 /*
  * ST7032 extension functions
diff --git a/main.c b/main.c
index acd0e3e..3b368ce 100644 (file)
--- a/main.c
+++ b/main.c
@@ -896,13 +896,10 @@ int main(void)
     ui_idlecount = 0xf800;
 
     acm1602_init(0xa0, 1); //Init LCD
-//    _AKC6955_WAIT_125_0MS(); // Wait 125ms
+    _AKC6955_WAIT_125_0MS(); // Wait 125ms
     _LOCATE(0,0);
     printstr("Hello;-)");
-//    TRISD = 0x00;
-    PORTDbits.RD3 = 1;
-//    LATDbits.LATD3 = 1;
-    
+    acm1602_setbacklight(0xff);
 #if 1
     i = 10001;
     do {