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.
Revision 42:1962dc501f94, committed 2020-01-14
- Comitter:
- reedas
- Date:
- Tue Jan 14 11:27:31 2020 +0000
- Parent:
- 41:111ca62e8a59
- Commit message:
- Initial Commit;
Changed in this revision
TextLCD.cpp | Show annotated file Show diff for this revision Revisions of this file |
TextLCD_Config.h | Show annotated file Show diff for this revision Revisions of this file |
--- a/TextLCD.cpp Fri Nov 06 18:59:27 2015 +0000 +++ b/TextLCD.cpp Tue Jan 14 11:27:31 2020 +0000 @@ -24,6 +24,7 @@ * Fixed and Added more fonttable support for PCF2119R_3V3, Added HD66712 controller. * 2015, v21: WH, Added LCD32x2 defines and code, Fixed KS0073 DL=1 init for SPI, Added defines to reduce memory footprint (LCD_TWO_CTRL, LCD_CONTRAST, LCD_UTF8_FONT) * Added SPLC792A controller, Added UTF8_2_LCD decode for Cyrilic font (By Andriy Ribalko). Added setFont() + * 2019, v22?: AR Changed wait_ms to ThisThread::sleep_for and added (char) casts for int conversion on parameters passed to a couple of function definitions. MBED 5.xx * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -47,7 +48,7 @@ #include "TextLCD.h" #include "TextLCD_UDC.inc" #include "TextLCD_UTF8.inc" - + /** Create a TextLCD_Base interface * * @param type Sets the panel size/addressing mode (default = LCD16x2) @@ -77,7 +78,7 @@ */ void TextLCD_Base::_init(_LCDDatalength dl) { - wait_ms(100); // Wait 100ms to ensure powered up + ThisThread::sleep_for(100); // Wait 100ms to ensure powered up #if (LCD_TWO_CTRL == 1) // Select and configure second LCD controller when needed @@ -123,15 +124,15 @@ //------------------------------------------------------------------------------------------------- _writeNibble(0x3); // set 8 bit mode (MSN) and dummy LSN, | set 8 bit mode (MSN), | set dummy LSN, // remains in 8 bit mode | remains in 4 bit mode | remains in 4 bit mode - wait_ms(15); // + ThisThread::sleep_for(15); // _writeNibble(0x3); // set 8 bit mode (MSN) and dummy LSN, | set dummy LSN, | set 8bit mode (MSN), // remains in 8 bit mode | change to 8 bit mode | remains in 4 bit mode - wait_ms(15); // + ThisThread::sleep_for(15); // _writeNibble(0x3); // set 8 bit mode (MSN) and dummy LSN, | set 8 bit mode (MSN) and dummy LSN, | set dummy LSN, // remains in 8 bit mode | remains in 8 bit mode | change to 8 bit mode - wait_ms(15); // + ThisThread::sleep_for(15); // // Controller is now in 8 bit mode @@ -145,7 +146,7 @@ else { // Reset in 8 bit mode, final Function set will follow _writeCommand(0x30); // Function set 0 0 1 DL=1 N F x x - wait_ms(1); // most instructions take 40us + ThisThread::sleep_for(1); // most instructions take 40us } // Device specific initialisations: DC/DC converter to generate VLCD or VLED, number of lines etc @@ -442,10 +443,10 @@ // Saved to allow contrast change at later time } _writeCommand(0x50 | _icon_power | ((_contrast >> 4) & 0x03)); // Set Icon, Booster and Contrast High bits, 0 1 0 1 Ion Bon C5 C4 (IS=1) - wait_ms(10); // Wait 10ms to ensure powered up + ThisThread::sleep_for(10); // Wait 10ms to ensure powered up _writeCommand(0x68 | (LCD_ST7032_RAB & 0x07)); // Voltage follower, 0 1 1 0 FOn=1, Ampl ratio Rab2=1, Rab1=0, Rab0=0 (IS=1) - wait_ms(10); // Wait 10ms to ensure powered up + ThisThread::sleep_for(10); // Wait 10ms to ensure powered up _writeCommand(0x20 | _function); // Select Instruction Set = 0 @@ -518,10 +519,10 @@ } _writeCommand(0x50 | _icon_power | ((_contrast >> 4) & 0x03)); // Set Contrast C5, C4 (Instr Set 1) - wait_ms(10); // Wait 10ms to ensure powered up + ThisThread::sleep_for(10); // Wait 10ms to ensure powered up _writeCommand(0x68 | (LCD_ST7036_RAB & 0x07)); // Voltagefollower On = 1, Ampl ratio Rab2, Rab1, Rab0 = 1 0 1 (Instr Set 1) - wait_ms(10); // Wait 10ms to ensure powered up + ThisThread::sleep_for(10); // Wait 10ms to ensure powered up _writeCommand(0x20 | _function); // Set function, IS2,IS1 = 00 (Select Instruction Set = 0) @@ -691,7 +692,7 @@ _writeCommand(0x06); // Set ext entry mode, 0 0 0 0 0 1 BDC=1 COM1-32, BDS=0 SEG100-1 "Bottom View" (Ext Instr Set) // _writeCommand(0x05); // Set ext entry mode, 0 0 0 0 0 1 BDC=0 COM32-1, BDS=1 SEG1-100 "Top View" (Ext Instr Set) - wait_ms(5); // Wait to ensure completion or SSD1803 fails to set Top/Bottom after reset.. + ThisThread::sleep_for(5); // Wait to ensure completion or SSD1803 fails to set Top/Bottom after reset.. _writeCommand(0x08 | _lines); // Set ext function 0 0 0 0 1 FW BW NW 1,2,3 or 4 lines (Ext Instr Set) @@ -710,10 +711,10 @@ _icon_power = 0x0C; // Icon on, Booster on (Instr Set 1) // Saved to allow contrast change at later time _writeCommand(0x50 | _icon_power | ((_contrast >> 4) & 0x03)); // Set Power, Icon and Contrast, 0 1 0 1 Ion Bon C5 C4 (Instr Set 1) - wait_ms(10); // Wait 10ms to ensure powered up + ThisThread::sleep_for(10); // Wait 10ms to ensure powered up _writeCommand(0x68 | (LCD_SSD1_RAB & 0x07)); // Set Voltagefollower 0 1 1 0 Don = 1, Ampl ratio Rab2, Rab1, Rab0 = 1 1 0 (Instr Set 1) - wait_ms(10); // Wait 10ms to ensure powered up + ThisThread::sleep_for(10); // Wait 10ms to ensure powered up _writeCommand(0x20 | _function_1); // Set function, 0 0 1 DL N BE RE(1) REV // Select Extended Instruction Set 1 @@ -761,7 +762,7 @@ } // switch type _writeCommand(0x20 | _function | 0x01); // Set function, Select Instr Set = 1 - wait_ms(10); // Wait 10ms to ensure powered up + ThisThread::sleep_for(10); // Wait 10ms to ensure powered up // Note: Display from GA628 shows 12 chars. This is actually the right half of a 24x1 display. The commons have been connected in reverse order. _writeCommand(0x05); // Display Conf Set 0000 0, 1, P=0, Q=1 (Instr. Set 1) @@ -817,7 +818,7 @@ _contrast = LCD_PCF2_CONTRAST; _writeCommand(0x80 | 0x00 | (_contrast & 0x3F)); // VLCD_set (Instr. Set 1) 1, V=0, VA=contrast _writeCommand(0x80 | 0x40 | (_contrast & 0x3F)); // VLCD_set (Instr. Set 1) 1, V=1, VB=contrast - wait_ms(10); // Wait 10ms to ensure powered up + ThisThread::sleep_for(10); // Wait 10ms to ensure powered up _writeCommand(0x02); // Screen Config 0000 001, L=0 (Instr. Set 1) _writeCommand(0x08); // ICON Conf 0000 1, IM=0 (Char mode), IB=0 (no icon blink) DM=0 (no direct mode) (Instr. Set 1) @@ -841,7 +842,7 @@ case LCD24x1: _writeCommand(0x22); //FUNCTION SET 0 0 1 DL=0 4-bit, N=0/M=0 1-line/24 chars display mode, G=1 Vgen on, 0 //Note: 4 bit mode is ignored for I2C mode - wait_ms(10); // Wait 10ms to ensure powered up + ThisThread::sleep_for(10); // Wait 10ms to ensure powered up break; case LCD12x3D: // Special mode for KS0078 and PCF21XX @@ -849,13 +850,13 @@ case LCD12x4D: // Special mode for PCF21XX: _writeCommand(0x2E); //FUNCTION SET 0 0 1 DL=0 4-bit, N=1/M=1 4-line/12 chars display mode, G=1 VGen on, 0 //Note: 4 bit mode is ignored for I2C mode - wait_ms(10); // Wait 10ms to ensure powered up + ThisThread::sleep_for(10); // Wait 10ms to ensure powered up break; case LCD24x2: _writeCommand(0x2A); //FUNCTION SET 0 0 1 DL=0 4-bit, N=1/M=0 2-line/24 chars display mode, G=1 VGen on, 0 //Note: 4 bit mode is ignored for I2C mode - wait_ms(10); // Wait 10ms to ensure powered up + ThisThread::sleep_for(10); // Wait 10ms to ensure powered up break; default: @@ -878,7 +879,7 @@ // case LCD24x1: // _writeCommand(0x20); //FUNCTION SET 0 0 1 DL=0 4-bit, N=0/M=0 1-line/24 chars display mode, G=0 no Vgen, 0 //Note: 4 bit mode is ignored for I2C mode -// wait_ms(10); // Wait 10ms to ensure powered up +// ThisThread::sleep_for(10); // Wait 10ms to ensure powered up // break; case LCD12x3D: // Special mode for KS0078 and PCF21XX @@ -888,13 +889,13 @@ // _writeCommand(0x24); //FUNCTION SET 4 bit, N=0/M=1 4-line/12 chars display mode OK _writeCommand(0x2C); //FUNCTION SET 0 0 1 DL=0 4-bit, N=1/M=1 4-line/12 chars display mode, G=0 no Vgen, 0 OK //Note: 4 bit mode is ignored for I2C mode - wait_ms(10); // Wait 10ms to ensure powered up + ThisThread::sleep_for(10); // Wait 10ms to ensure powered up break; // case LCD24x2: // _writeCommand(0x28); //FUNCTION SET 4 bit, N=1/M=0 2-line/24 chars display mode //Note: 4 bit mode is ignored for I2C mode -// wait_ms(10); // Wait 10ms to ensure powered up +// ThisThread::sleep_for(10); // Wait 10ms to ensure powered up // break; default: @@ -912,7 +913,7 @@ // Note2: Vgen is switched off when the contrast voltage VA or VB is set to 0x00. //POR or Hardware Reset should be applied - wait_ms(10); // Wait 10ms to ensure powered up + ThisThread::sleep_for(10); // Wait 10ms to ensure powered up // Initialise Display configuration switch (_type) { @@ -957,7 +958,7 @@ _contrast = LCD_PCF2_CONTRAST; _writeCommand(0x80 | 0x00 | (_contrast & 0x3F)); // VLCD_set (Instr. Set 1) V=0, VA=contrast _writeCommand(0x80 | 0x40 | (_contrast & 0x3F)); // VLCD_set (Instr. Set 1) V=1, VB=contrast - wait_ms(10); // Wait 10ms to ensure powered up + ThisThread::sleep_for(10); // Wait 10ms to ensure powered up _writeCommand(0x02); // SCRN CONF (Instr. Set 1) L=0 _writeCommand(0x08); // ICON CONF (Instr. Set 1) IM=0 (Char mode) IB=0 (no icon blink) DM=0 (no direct mode) @@ -985,9 +986,9 @@ //@Todo: This may be needed to enable a warm reboot //_writeCommand(0x13); // Char mode, DC/DC off - //wait_ms(10); // Wait 10ms to ensure powered down + //ThisThread::sleep_for(10); // Wait 10ms to ensure powered down _writeCommand(0x17); // Char mode, DC/DC on - wait_ms(10); // Wait 10ms to ensure powered up + ThisThread::sleep_for(10); // Wait 10ms to ensure powered up // Initialise Display configuration switch (_type) { @@ -1175,7 +1176,7 @@ _writeCommand(0xDB); // Set VCOMH Deselect Lvl: 1 1 0 1 1 0 1 1 (Ext Instr Set, OLED) _writeCommand(0x30); // Set VCOMH Deselect Value: 0.83 x VCC - wait_ms(10); // Wait 10ms to ensure powered up + ThisThread::sleep_for(10); // Wait 10ms to ensure powered up //Test Fade/Blinking. Hard Blink on/off, No fade in/out ?? // _writeCommand(0x23); // Set (Ext Instr Set, OLED) @@ -1394,11 +1395,11 @@ // Saved to allow contrast change at later time _writeCommand(0x50 | _icon_power | ((_contrast >> 4) & 0x03)); // Set Icon, Booster and Contrast High bits, 0 1 0 1 Ion Bon C5 C4 (IS=1) - wait_ms(10); // Wait 10ms to ensure powered up + ThisThread::sleep_for(10); // Wait 10ms to ensure powered up _writeCommand(0x68 | (LCD_SPLC792A_RAB & 0x07)); // Voltage follower, 0 1 1 0 FOn=1, Ampl ratio Rab2=1, Rab1=0, Rab0=0 (IS=1) // Note: Follower circuit always on for SPLC792A, Bit3 is dont care - wait_ms(10); // Wait 10ms to ensure powered up + ThisThread::sleep_for(10); // Wait 10ms to ensure powered up _writeCommand(0x20 | _function); // Select Instruction Set = 0 @@ -1452,11 +1453,11 @@ // Controller general initialisations // _writeCommand(0x01); // Clear Display and set cursor to 0 -// wait_ms(10); // The CLS command takes 1.64 ms. +// ThisThread::sleep_for(10); // The CLS command takes 1.64 ms. // // Since we are not using the Busy flag, Lets be safe and take 10 ms _writeCommand(0x02); // Cursor Home, DDRAM Address to Origin - wait_ms(10); // The Return Home command takes 1.64 ms. + ThisThread::sleep_for(10); // The Return Home command takes 1.64 ms. // Since we are not using the Busy flag, Lets be safe and take 10 ms _writeCommand(0x06); // Entry Mode 0000 0 1 I/D S @@ -1494,7 +1495,7 @@ // Second LCD controller Clearscreen _writeCommand(0x01); // cls, and set cursor to 0 - wait_ms(20); // The CLS command takes 1.64 ms. + ThisThread::sleep_for(20); // The CLS command takes 1.64 ms. // Since we are not using the Busy flag, Lets be safe and take 10 ms _ctrl_idx=_LCDCtrl_0; // Select primary controller @@ -1503,7 +1504,7 @@ // Primary LCD controller Clearscreen _writeCommand(0x01); // cls, and set cursor to 0 - wait_ms(20); // The CLS command takes 1.64 ms. + ThisThread::sleep_for(20); // The CLS command takes 1.64 ms. // Since we are not using the Busy flag, Lets be safe and take 10 ms // Restore cursormode on primary LCD controller when needed @@ -1514,7 +1515,7 @@ #else // Support only one LCD controller _writeCommand(0x01); // cls, and set cursor to 0 - wait_ms(20); // The CLS command takes 1.64 ms. + ThisThread::sleep_for(20); // The CLS command takes 1.64 ms. // Since we are not using the Busy flag, Lets be safe and take 10 ms #endif @@ -2405,7 +2406,7 @@ case WS0010: _writeCommand(0x17); // Char mode, DC/DC on - wait_ms(10); // Wait 10ms to ensure powered up + ThisThread::sleep_for(10); // Wait 10ms to ensure powered up break; case KS0073: @@ -2503,7 +2504,7 @@ _writeCommand(0x40 | 0x00); // COM/SEG directions 0 1 0 0 C1, C2, S1, S2 (Instr Set 1) // C1=1: Com1-8 -> Com8-1; C2=1: Com9-16 -> Com16-9 // S1=1: Seg1-40 -> Seg40-1; S2=1: Seg41-80 -> Seg80-41 - wait_ms(5); // Wait to ensure completion or ST7070 fails to set Top/Bottom after reset.. + ThisThread::sleep_for(5); // Wait to ensure completion or ST7070 fails to set Top/Bottom after reset.. _writeCommand(0x20 | _function); // Set function, EXT=0 (Select Instr Set = 0) @@ -2556,7 +2557,7 @@ _writeCommand(0x40 | 0x0F); // COM/SEG directions 0 1 0 0 C1, C2, S1, S2 (Instr Set 1) // C1=1: Com1-8 -> Com8-1; C2=1: Com9-16 -> Com16-9 // S1=1: Seg1-40 -> Seg40-1; S2=1: Seg41-80 -> Seg80-41 - wait_ms(5); // Wait to ensure completion or ST7070 fails to set Top/Bottom after reset.. + ThisThread::sleep_for(5); // Wait to ensure completion or ST7070 fails to set Top/Bottom after reset.. _writeCommand(0x20 | _function); // Set function, EXT=0 (Select Instr Set = 0) @@ -3441,7 +3442,7 @@ // Write data to MCP23008 I2C portexpander // Used for mbed I2C bus expander void TextLCD_I2C::_writeRegister (int reg, int value) { - char data[] = {reg, value}; + char data[] = {(char)reg, (char)value}; _i2c->write(_slaveAddress, data, 2); } @@ -3525,7 +3526,7 @@ _spi->frequency(500000); //_spi.frequency(1000000); - wait_ms(100); // Wait 100ms to ensure LCD powered up + ThisThread::sleep_for(100); // Wait 100ms to ensure LCD powered up // Init the portexpander bus _lcd_bus = LCD_BUS_SPI_DEF; @@ -3735,7 +3736,7 @@ // RW=0 means write to controller. RW=1 means that controller will be read from after the next command. // Many native I2C controllers dont support this option and it is not used by this lib. // - char data[] = {_controlbyte, value}; + char data[] = {(char)_controlbyte, (char)value}; #if(LCD_I2C_ACK==1) //Controllers that support ACK
--- a/TextLCD_Config.h Fri Nov 06 18:59:27 2015 +0000 +++ b/TextLCD_Config.h Tue Jan 14 11:27:31 2020 +0000 @@ -68,9 +68,9 @@ //LCD and serial portexpanders should be wired according to the tables below. // //Select Serial Port Expander Hardware module (one option only) -#define DEFAULT 1 +#define DEFAULT 0 #define ADAFRUIT 0 -#define DFROBOT 0 +#define DFROBOT 1 #define LCM1602 0 #define YWROBOT 0 #define GYLCD 0