ST7920 based Chinese LCD driver

Dependencies:   mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

00001 #include "mbed.h"
00002 #include "chn12864.h"
00003 int main() {
00004     ChnLCD12864 lcd(D11,D10,D12); // sid(RW), sck(E), cs(RS)
00005     
00006     //Text to HEX converter: https://www.streamlet.org/tool/str2hex/
00007     lcd.printf("\xC4\xE3\xBA\xC3\xCA\xC0\xBD\xE7!123456789abcd");
00008     wait_ms(1000); //等待1秒
00009     lcd.cls(); //清屏
00010     
00011     for(int i=0; i<10000; i+=4){
00012         lcd.locate(0,0); //分别控制起始的列和行,从0开始
00013         lcd.printf("%d", i);
00014         wait_ms(1000); //等待1秒
00015         
00016         lcd.locate(0,1);
00017         lcd.printf("%d", i+1);
00018         wait_ms(1000);
00019         
00020         lcd.locate(0,2);
00021         lcd.printf("%d", i+2);
00022         wait_ms(1000);
00023         
00024         lcd.locate(0,3);
00025         lcd.printf("%d", i+3);
00026         wait_ms(1000);
00027         
00028         lcd.cls(); //清屏
00029     }
00030 
00031 
00032     while(1);
00033 }