Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of Skool_wkshp_lib2015 by
serial_lcd.cpp
00001 #include "mbed.h" 00002 #include "serial_lcd.h" 00003 #include "pc_uart.h" 00004 00005 I2C i2c1(I2C_SDA, I2C_SCL); // I2C interface for LCD display 00006 DigitalOut LCD_RST(PB_10); // LCD RST 00007 DigitalOut LCD_BL(PA_8); // LCD BackLight 00008 00009 #define NUM_USER_CHARS 2 00010 00011 const char CGData[NUM_USER_CHARS][8] = {{0x0A,0x0A,0x00,0x0E,0x11,0x11,0x0E,0x00}, 00012 {0x04,0x0E,0x0E,0x1F,0x1F,0x1F,0x04,0x00}}; 00013 00014 void write_ser_CGdata(void) { 00015 int i; 00016 00017 write_ser_lcd(0x38, false); 00018 wait_us(30); 00019 write_ser_lcd(0x40, false); 00020 wait_us(30); 00021 for (i = 0; i < NUM_USER_CHARS; i++) { 00022 write_ser_text(CGData[i], 8); 00023 } 00024 } 00025 00026 int write_ser_lcd(char data, bool mode) { 00027 char wd[2]; 00028 int status; 00029 00030 wd[0] = ((mode) ? 0x40 : 0x00); 00031 wd[1] = (char)data; 00032 status = i2c1.write(ST7032I_ADDR, wd, 2, false); 00033 return status; 00034 } 00035 00036 void write_ser_text(const char* text, uint32_t len) { 00037 int i; 00038 char wd[41]; 00039 int status; 00040 00041 wd[0] = 0x40; 00042 for (i = 0; i < len; i++) { 00043 wd[i + 1] = text[i]; 00044 } 00045 status = i2c1.write(ST7032I_ADDR, wd, len + 1, false); 00046 if (status != 0) { 00047 Error(0); 00048 } 00049 } 00050 00051 int init_ser_lcd(void) { 00052 int status; 00053 00054 LCD_RST = 0x0; // Generating Reset pulse 00055 LCD_BL = 0x0; // BackLight off 00056 // BL_LCD = 0.0; 00057 wait_us(200); 00058 LCD_RST = 0x1; 00059 wait_ms(40); 00060 status = write_ser_lcd(0x38, false); // Function set with IS = 0 00061 if (status != 0) { 00062 Error(0); 00063 } 00064 wait_us(30); 00065 status = write_ser_lcd(0x10, false); // Cursor or display shift S/C = 0 - cursor 00066 if (status != 0) { 00067 Error(0); 00068 } 00069 wait_us(30); 00070 status = write_ser_lcd(0x39, false); // Function set with IS = 1 00071 if (status != 0) { 00072 Error(0); 00073 } 00074 wait_us(30); 00075 status = write_ser_lcd(0x14, false); // Internal OSC frequency adjustment 00076 if (status != 0) { 00077 Error(0); 00078 } 00079 wait_us(30); 00080 status = write_ser_lcd(0x79, false); // Contrast set 00081 if (status != 0) { 00082 Error(0); 00083 } 00084 wait_us(30); 00085 status = write_ser_lcd(0x5C, false); // Power/Icon/Contrast control 00086 if (status != 0) { 00087 Error(0); 00088 } 00089 wait_us(30); 00090 status = write_ser_lcd(0x6E, false); // Follower control 00091 if (status != 0) { 00092 Error(0); 00093 } 00094 wait_ms(200); 00095 // wait_us(30); 00096 status = write_ser_lcd(0x0C, false); // Display ON 00097 if (status != 0) { 00098 Error(0); 00099 } 00100 wait_us(30); 00101 status = write_ser_lcd(0x01, false); // Clear display 00102 if (status != 0) { 00103 Error(0); 00104 } 00105 wait_us(30); 00106 status = write_ser_lcd(0x06, false); // Entry mode set 00107 if (status != 0) { 00108 Error(0); 00109 } 00110 wait_us(30); 00111 status = write_ser_lcd(0x02, false); // Home 00112 if (status != 0) { 00113 Error(0); 00114 } 00115 wait_us(30); 00116 write_ser_CGdata(); 00117 LCD_BL = 0x1; // BackLight ON 00118 // BL_LCD = 0.5; 00119 return 0; 00120 }
Generated on Thu Jul 14 2022 17:13:24 by
1.7.2
