Controller chip is ST7565

Dependencies:   ST7565_SPI_LCD

SPI LCD: AQM1248A (Akizuki) or AD-12864-SPI (antendo)

Files at this revision

API Documentation at this revision

Comitter:
kenjiArai
Date:
Sat Feb 27 01:14:00 2021 +0000
Parent:
4:9d99684c6373
Commit message:
run on Mbed-os6.8.0

Changed in this revision

check_revision.cpp Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed-os.lib Show annotated file Show diff for this revision Revisions of this file
redirect_stdio/redirect_stdio.cpp Show diff for this revision Revisions of this file
redirect_stdio/redirect_stdio.h Show diff for this revision Revisions of this file
uart_as_stdio/uart_as_stdio.cpp Show annotated file Show diff for this revision Revisions of this file
uart_as_stdio/uart_as_stdio.h Show annotated file Show diff for this revision Revisions of this file
diff -r 9d99684c6373 -r 9b4d9c139186 check_revision.cpp
--- a/check_revision.cpp	Sat Aug 08 04:20:39 2020 +0000
+++ b/check_revision.cpp	Sat Feb 27 01:14:00 2021 +0000
@@ -1,22 +1,22 @@
 /*
  * Check Mbed revision
  *
- * Copyright (c) 2019,'20 Kenji Arai / JH1PJL
+ * Copyright (c) 2019,'20,'21 Kenji Arai / JH1PJL
  *  http://www7b.biglobe.ne.jp/~kenjia/
  *  https://os.mbed.com/users/kenjiArai/
  *      Created:    July      17th, 2019
- *      Revised:    August     1st, 2020
+ *      Revised:    February  27th, 2021
  */
 
 #include "mbed.h"
- 
-//    RUN ONLY ON mbed-os-6.2.0
-//      https://github.com/ARMmbed/mbed-os/releases/tag/mbed-os-6.2.0
+
+//    RUN ONLY ON mbed-os-6.8.0
+//      https://github.com/ARMmbed/mbed-os/releases/tag/mbed-os-6.8.0
 #if (MBED_MAJOR_VERSION == 6) &&\
-    (MBED_MINOR_VERSION == 2) &&\
+    (MBED_MINOR_VERSION == 8) &&\
     (MBED_PATCH_VERSION == 0)
 #else
-#   error "Please use mbed-os-6.2.0"
+#   error "Please use mbed-os-6.8.0"
 #endif
 
 void print_revision(void)
diff -r 9d99684c6373 -r 9b4d9c139186 main.cpp
--- a/main.cpp	Sat Aug 08 04:20:39 2020 +0000
+++ b/main.cpp	Sat Feb 27 01:14:00 2021 +0000
@@ -1,12 +1,12 @@
 /*
  * mbed Application program for the mbed LPC1114FN28
  *
- * Copyright (c) 2014,'20 Kenji Arai / JH1PJL
+ * Copyright (c) 2014,'20,'21 Kenji Arai / JH1PJL
  *  http://www7b.biglobe.ne.jp/~kenjia/
  *  https://os.mbed.com/users/kenjiArai/
  *      Created: September 14th, 2014
  *      Revised: September 21st, 2014
- *      Revised: August     8th, 2020
+ *      Revised: February  27th, 2021
  */
 /*
     Tested LCD
@@ -19,15 +19,15 @@
         2) AE-AQM1248(AQM1248A-RN-FBW-P) / 128 x 48 dots / Interface: SPI
             http://akizukidenshi.com/catalog/g/gK-07007/
             http://akizukidenshi.com/catalog/g/gP-07005/
-            
+
             1)VDD  2)/CS  3)/RES  4)RS  5)SCLK  6)SDI  7)GND
-              +3.3V  dp9    dp10    dp4   dp6     dp2    GND        
+              +3.3V  dp9    dp10    dp4   dp6     dp2    GND
  */
 
 //  Include --------------------------------------------------------------------
 #include    "mbed.h"
 #include    "ST7565_SPI_LCD.h"
-#include    "redirect_stdio.h"
+#include    "uart_as_stdio.h"
 
 //  Definition -----------------------------------------------------------------
 //#define AITENDO
@@ -40,12 +40,16 @@
 #   define CONTRAST     0x32
 #elif defined(AKIZUKI)
 #   define MAX_Y        48
-#   define CONTRAST     0x23
+#   define CONTRAST     0x24
+#else
+#   error "Please choose AKIZUKI or AITENDO"
 #endif
 
-#define Y0   (MAX_Y - 2) 
-#define Y1   (MAX_Y - 9) 
-#define Y2   (MAX_Y - 1) 
+#define Y0   (MAX_Y - 2)
+#define Y1   (MAX_Y - 9)
+#define Y2   (MAX_Y - 1)
+
+//#define ADJ_CONTRAST
 
 //  Object ---------------------------------------------------------------------
 // LED
@@ -74,9 +78,6 @@
 //  Function prototypes --------------------------------------------------------
 
 //  Function prototypes --------------------------------------------------------
-uint8_t getc(void);
-void putc(uint8_t c);
-FileHandle *mbed::mbed_override_console(int fd);
 extern void print_revision(void);
 
 //------------------------------------------------------------------------------
@@ -91,8 +92,9 @@
     lcd.cls();
     lcd.set_contrast(CONTRAST);
     lcd.printf("test\r\n" );
-    lcd.printf("Run on mbed-os6.2.0\r\n" );
-    lcd.printf("ABCDEFG 1234567890\r\n" );
+    lcd.printf("Run on  Mbed-os%d.%d.%d\r\n",
+               MBED_MAJOR_VERSION, MBED_MINOR_VERSION, MBED_PATCH_VERSION);
+    lcd.printf("1234567890 ABCDEFG\r\n" );
     //lcd.rect(5,30,120,62,1);
     lcd.rect(5,30,120,Y0,1);
     lcd.circle(5,35,5,1);
@@ -104,22 +106,32 @@
     printf("You can see something on the LCD screen.\r\n");
     printf("H:%d W:%d\r\n", lcd.height(), lcd.width());
     while(true) {
-#if 1
+#ifndef ADJ_CONTRAST
         myled = !myled;
         c = getc();
         putc(c);
-        if (c == '\b') {
+        if (c == '\b') {    // Enter Back Space
             myled = 0;
             break;
         }
         lcd.putc(c);
 #else
         // check best contrast
-        uint8_t px = 0;
-        for (px = 0; px < 0x40; px++) {
-            c = getc();
+        printf("Entered contrast adjustment mode.\r\n");
+        uint8_t px = CONTRAST;
+        while(true) {
             lcd.set_contrast(px);
             printf("0x%x\r\n",px);
+            c = getc();
+            if ((c == '-') || (c == 'd')) {
+                if (px != 0) {
+                    --px;
+                }
+            } else {
+                if (px < 0x40) {
+                    ++px;
+                }
+            }
         }
 #endif
     }
@@ -128,6 +140,7 @@
         i = 10 - k;
         k++;
         c = getc();
+        lcd.cls();
         lcd.rect(10, i, 100, Y1, 1);
         c = getc();
         lcd.circle(10,10,i,1);
@@ -136,14 +149,16 @@
         c = getc();
         lcd.line(0, 0, 110-i, Y1, 1);
         c = getc();
-        if (c == '\b') {
+        if (c == '\b') {    // Enter Back Space
             myled = 0;
             break;
         }
     }
+    lcd.cls();
+    lcd.locate(10, 10);
+    lcd.printf("JH1PJL  Mbed-os%d.%d.%d\r\n",
+               MBED_MAJOR_VERSION, MBED_MINOR_VERSION, MBED_PATCH_VERSION);
     while(true) {
-        lcd.cls();
-        lcd.locate(4, 32);
-        lcd.printf("JH1PJL" );
+        ThisThread::sleep_for(100s);
     }
 }
diff -r 9d99684c6373 -r 9b4d9c139186 mbed-os.lib
--- a/mbed-os.lib	Sat Aug 08 04:20:39 2020 +0000
+++ b/mbed-os.lib	Sat Feb 27 01:14:00 2021 +0000
@@ -1,1 +1,1 @@
-https://github.com/ARMmbed/mbed-os/#a2ada74770f043aff3e61e29d164a8e78274fcd4
+https://github.com/ARMmbed/mbed-os/#bfde5aa1e74802771eaeacfa74789f71677325cb
diff -r 9d99684c6373 -r 9b4d9c139186 redirect_stdio/redirect_stdio.cpp
--- a/redirect_stdio/redirect_stdio.cpp	Sat Aug 08 04:20:39 2020 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,21 +0,0 @@
-/*
- * mbed Application program
- *      Redirect Standard Input/Output
- *
- * Copyright (c) 2020 Kenji Arai / JH1PJL
- *  http://www7b.biglobe.ne.jp/~kenjia/
- *  https://os.mbed.com/users/kenjiArai/
- *      Created: August     7th, 2020
- *      Revised: August     7th, 2020
- */
-
-#include "mbed.h"
-
-// Create a BufferedSerial object to be used by the system I/O retarget code
-BufferedSerial pc(USBTX, USBRX, 9600);
-
-//  the system I/O retarget
-FileHandle *mbed::mbed_override_console(int fd)
-{
-    return &pc;
-}
diff -r 9d99684c6373 -r 9b4d9c139186 redirect_stdio/redirect_stdio.h
--- a/redirect_stdio/redirect_stdio.h	Sat Aug 08 04:20:39 2020 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,36 +0,0 @@
-/*
- * mbed Application program
- *      Redirect Standard Input/Output
- *
- * Copyright (c) 2020 Kenji Arai / JH1PJL
- *  http://www7b.biglobe.ne.jp/~kenjia/
- *  https://os.mbed.com/users/kenjiArai/
- *      Created: August     7th, 2020
- *      Revised: August     7th, 2020
- */
-
-extern BufferedSerial pc;
-
-FileHandle *mbed::mbed_override_console(int fd);
-
-inline uint8_t readable(void)
-{
-    return pc.readable();
-}
-
-inline void putc(uint8_t c)
-{
-    char dt = c;
-    pc.write(&dt, 1);
-}
-
-inline uint8_t getc(void)
-{
-    int c = getchar();
-    return (uint8_t)c;
-}
-
-inline void puts_wo_cr(char *bf, uint32_t len)
-{
-    pc.write(bf, len);
-}
diff -r 9d99684c6373 -r 9b4d9c139186 uart_as_stdio/uart_as_stdio.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/uart_as_stdio/uart_as_stdio.cpp	Sat Feb 27 01:14:00 2021 +0000
@@ -0,0 +1,46 @@
+/*
+ * mbed Application program
+ *      Redirect Standard Input/Output
+ *
+ * Copyright (c) 2021 Kenji Arai / JH1PJL
+ *  http://www7b.biglobe.ne.jp/~kenjia/
+ *  https://os.mbed.com/users/kenjiArai/
+ *      Created:    January   13th, 2021
+ *      Revised:    January   14th, 2021
+ */
+
+//  Include --------------------------------------------------------------------
+#include "mbed.h"
+
+//  Definition -----------------------------------------------------------------
+
+//  Constructor ----------------------------------------------------------------
+static BufferedSerial pc(USBTX, USBRX, 115200);
+
+//  RAM ------------------------------------------------------------------------
+
+//  ROM / Constant data --------------------------------------------------------
+
+//  Function prototypes --------------------------------------------------------
+
+//------------------------------------------------------------------------------
+//  Control Program
+//------------------------------------------------------------------------------
+uint8_t readable()
+{
+    return pc.readable();
+}
+
+void putc(uint8_t c)
+{
+    char dt[4];
+    dt[0] = (char)c;
+    pc.write(dt, 1);
+}
+
+uint8_t getc()
+{
+    char dt[4];
+    pc.read(dt, 1);
+    return (uint8_t)dt[0];
+}
diff -r 9d99684c6373 -r 9b4d9c139186 uart_as_stdio/uart_as_stdio.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/uart_as_stdio/uart_as_stdio.h	Sat Feb 27 01:14:00 2021 +0000
@@ -0,0 +1,17 @@
+/*
+ * mbed Application program
+ *      Redirect Standard Input/Output
+ *
+ * Copyright (c) 2021 Kenji Arai / JH1PJL
+ *  http://www7b.biglobe.ne.jp/~kenjia/
+ *  https://os.mbed.com/users/kenjiArai/
+ *      Created:    January   13th, 2021
+ *      Revised:    January   14th, 2021
+ */
+
+#include "mbed.h"
+
+//  Function prototypes --------------------------------------------------------
+uint8_t readable(void);
+void putc(uint8_t c);
+uint8_t getc(void);