Kenji Arai
/
LPC1114_SPI_LCD_ST7565family_test
Controller chip is ST7565
SPI LCD: AQM1248A (Akizuki) or AD-12864-SPI (antendo)
Diff: main.cpp
- Revision:
- 5:9b4d9c139186
- Parent:
- 4:9d99684c6373
--- 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); } }