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.
Dependents: TouchScreenCalibrate TouchScreenGUIDemo
Fork of UniGraphic by
Revision 34:091b954c3205, committed 2020-06-21
- Comitter:
- Duncan McIntyre
- Date:
- Sun Jun 21 15:23:02 2020 +0100
- Parent:
- 33:5743f9c16aa2
- Commit message:
- Updated to include latest changes from upstream
Added a class to provide an interface for my MINI-STM32-V3.0 board.
This class uses direct GPIO access to achieve decent update speeds.
Changed in this revision
--- a/Display/LCD.cpp Mon Apr 11 16:54:35 2016 +0000
+++ b/Display/LCD.cpp Sun Jun 21 15:23:02 2020 +0100
@@ -95,6 +95,24 @@
// locate(0,0);
}
+LCD::LCD(proto_t displayproto, int Hz, int address, PinName sda, PinName scl, const int lcdsize_x, const int lcdsize_y, const int ic_x_segs, const int ic_y_coms, const char* name)
+ : GraphicsDisplay(name), screensize_X(lcdsize_x), screensize_Y(lcdsize_y), _LCDPAGES(lcdsize_y>>3), _IC_X_SEGS(ic_x_segs), _IC_Y_COMS(ic_y_coms), _IC_PAGES(ic_y_coms>>3)
+{
+ if(displayproto==I2C_){
+ proto = new I2C_bus(Hz,address,sda,scl);
+ useNOP=false;
+ }
+ buffer = (unsigned char*) malloc (screensize_X*_LCDPAGES);
+ buffer16 = (unsigned short*)buffer;
+ draw_mode = NORMAL;
+ // cls();
+ set_orientation(1);
+ foreground(White);
+ background(Black);
+ set_auto_up(true);
+ tftID=0;
+}
+
LCD::~LCD()
{
free(buffer);
--- a/Display/LCD.h Mon Apr 11 16:54:35 2016 +0000
+++ b/Display/LCD.h Sun Jun 21 15:23:02 2020 +0100
@@ -10,6 +10,7 @@
#include "BUS8.h"
#include "SPI8.h"
#include "SPI16.h"
+#include "I2C_bus.h"
#include "Protocols.h"
#include "GraphicsDisplay.h"
@@ -51,6 +52,12 @@
*/
LCD(proto_t displayproto, int Hz, PinName mosi, PinName miso, PinName sclk, PinName CS, PinName reset, PinName DC, const int lcdsize_x, const int lcdsize_y, const int ic_x_segs, const int ic_y_coms, const char* name);
+ /** Create a monochrome LCD I2C interface
+ * @param name The name used by the parent class to access the interface
+ */
+ LCD(proto_t displayproto, int Hz, int address,PinName sda, PinName scl, const int lcdsize_x, const int lcdsize_y, const int ic_x_segs, const int ic_y_coms, const char* name);
+
+
/** Destructor
* will free framebuffer
*/
--- a/Display/TFT.cpp Mon Apr 11 16:54:35 2016 +0000
+++ b/Display/TFT.cpp Sun Jun 21 15:23:02 2020 +0100
@@ -32,8 +32,8 @@
scrollbugfix=0;
mipistd=false;
set_orientation(0);
- setForeground(White);
- setBackground(Black);
+ foreground(White);
+ background(Black);
set_auto_up(false); //we don't have framebuffer
topfixedareasize=0;
scrollareasize=0;
@@ -64,8 +64,8 @@
scrollbugfix=0;
mipistd=false;
set_orientation(0);
- setForeground(White);
- setBackground(Black);
+ foreground(White);
+ background(Black);
set_auto_up(false); //we don't have framebuffer
topfixedareasize=0;
scrollareasize=0;
@@ -92,8 +92,8 @@
scrollbugfix=0;
mipistd=false;
set_orientation(0);
- setForeground(White);
- setBackground(Black);
+ foreground(White);
+ background(Black);
set_auto_up(false);
topfixedareasize=0;
scrollareasize=0;
--- a/Display/TFT932x.cpp Mon Apr 11 16:54:35 2016 +0000
+++ b/Display/TFT932x.cpp Sun Jun 21 15:23:02 2020 +0100
@@ -9,6 +9,7 @@
#if DEVICE_PORTINOUT
#include "PAR8.h"
#include "PAR16.h"
+#include "MINISTM32.h"
#endif
//#include "mbed_debug.h"
@@ -41,6 +42,23 @@
// cls();
// locate(0,0);
}
+
+TFT932x::TFT932x(const char *name)
+ : GraphicsDisplay(name), screensize_X(240), screensize_Y(320)
+{
+ proto = new MINISTM32();
+ // set_orientation(0);
+ setForeground(White);
+ setBackground(Black);
+ set_auto_up(false); //we don't have framebuffer
+ usefastwindow=false;
+ fastwindowready=false;
+ is18bit=false;
+ isBGR=false;
+ flipped=0;
+ // cls();
+ // locate(0,0);
+}
#endif
TFT932x::TFT932x(proto_t displayproto, PinName* buspins, PinName CS, PinName reset, PinName DC, PinName WR, PinName RD, const int lcdsize_x, const int lcdsize_y, const char *name)
--- a/Display/TFT932x.h Mon Apr 11 16:54:35 2016 +0000
+++ b/Display/TFT932x.h Sun Jun 21 15:23:02 2020 +0100
@@ -26,6 +26,9 @@
* @param name The name used by the parent class to access the interface
*/
TFT932x(proto_t displayproto, PortName port, PinName CS, PinName reset, PinName DC, PinName WR, PinName RD, const int lcdsize_x, const int lcdsize_y, const char* name);
+
+ /** Create interface for MINI-STM32 board */
+ TFT932x(const char* name);
#endif
/** Create TFT Parallel Bus interface
@@ -38,7 +41,8 @@
* @param name The name used by the parent class to access the interface
*/
TFT932x(proto_t displayproto, int Hz, PinName mosi, PinName miso, PinName sclk, PinName CS, PinName reset, const int lcdsize_x, const int lcdsize_y, const char* name);
-
+
+
/////// functions that come for free, but can be overwritten///////////////////////////////////////////////////
/////// ----------------------------------------------------///////////////////////////////////////////////////
--- a/Font/Arial12x12.h Mon Apr 11 16:54:35 2016 +0000
+++ b/Font/Arial12x12.h Sun Jun 21 15:23:02 2020 +0100
@@ -8,7 +8,7 @@
#ifdef TOOLCHAIN_GCC
const unsigned char Arial12x12[] __attribute__((aligned (2))) = {
#else
-__align(2)
+//__align(2)
const unsigned char Arial12x12[] = {
#endif
0xFF/*unused*/,12,12,0xFF/*unused*/, // Length,horz,vert,byte/vert
--- a/Font/Arial24x23.h Mon Apr 11 16:54:35 2016 +0000
+++ b/Font/Arial24x23.h Sun Jun 21 15:23:02 2020 +0100
@@ -10,7 +10,7 @@
#ifdef TOOLCHAIN_GCC
const unsigned char Arial24x23[] __attribute__((aligned (2))) = {
#else
-__align(2)
+//__align(2)
const unsigned char Arial24x23[] = {
#endif
0xFF/*unused*/,24,23,0xFF/*unused*/,
--- a/Font/Arial28x28.h Mon Apr 11 16:54:35 2016 +0000
+++ b/Font/Arial28x28.h Sun Jun 21 15:23:02 2020 +0100
@@ -10,7 +10,7 @@
#ifdef TOOLCHAIN_GCC
const unsigned char Arial28x28[] __attribute__((aligned (2))) = {
#else
-__align(2)
+//__align(2)
const unsigned char Arial28x28[] = {
#endif
0xFF/*unused*/,28,28,0xFF/*unused*/,
--- a/Font/Arial43x48_numb.h Mon Apr 11 16:54:35 2016 +0000
+++ b/Font/Arial43x48_numb.h Sun Jun 21 15:23:02 2020 +0100
@@ -9,7 +9,7 @@
#ifdef TOOLCHAIN_GCC
const unsigned char Arial43x48_numb[] __attribute__((aligned (2))) = {
#else
-__align(2)
+//__align(2)
const unsigned char Arial43x48_numb[] = {
#endif
0xFF/*unused*/, 43, 48, 0xFF/*unused*/,
--- a/Font/Terminal6x8.h Mon Apr 11 16:54:35 2016 +0000
+++ b/Font/Terminal6x8.h Sun Jun 21 15:23:02 2020 +0100
@@ -7,7 +7,7 @@
#ifdef TOOLCHAIN_GCC
const unsigned char Terminal6x8[] __attribute__((aligned (2))) = {
#else
-__align(2)
+//__align(2)
const unsigned char Terminal6x8[] = {
#endif
0xFF/*unused*/,6,8,0xFF/*unused*/,
--- a/Graphics/GraphicsDisplay.cpp Mon Apr 11 16:54:35 2016 +0000
+++ b/Graphics/GraphicsDisplay.cpp Sun Jun 21 15:23:02 2020 +0100
@@ -291,23 +291,30 @@
}
}
window(char_x, char_y,fonthor*fontzoomhor,fontvert*fontzoomver); // char box
- zeichen = &font[((c-firstch) * fontoffset) + 4]; // start of char bitmap
- w = zeichen[0]; // width of actual char
- // construct the char into the buffer
- for (j=0; j<fontvert; j++) { // vert line
- for (v=0; v<fontzoomver; v++) { // repeat horiz line for vertical zooming
- for (i=0; i<fonthor; i++) { // horz line
- z = zeichen[(fontbpl * i) + ((j & 0xF8) >> 3)+1];
- b = 1 << (j & 0x07);
- if (( z & b ) == 0x00) {
- // pixel(char_x+i,char_y+j,0);
- window_pushpixel(_background, fontzoomhor); //(color, howmany)
- } else {
- // pixel(char_x+i,char_y+j,1);
- window_pushpixel(_foreground, fontzoomhor);
- }
- }
- } //for each zoomed vert
+ if ((c < firstch) || (c > lastch)) { // test char range - if not exist fill with blank
+ for (i = 0; i < fonthor*fontvert*fontzoomver;i++){
+ window_pushpixel(_background, fontzoomhor); //(color, howmany)
+ }
+ }
+ else{
+ zeichen = &font[((c-firstch) * fontoffset) + 4]; // start of char bitmap
+ w = zeichen[0]; // width of actual char
+ // construct the char into the buffer
+ for (j=0; j<fontvert; j++) { // vert line
+ for (v=0; v<fontzoomver; v++) { // repeat horiz line for vertical zooming
+ for (i=0; i<fonthor; i++) { // horz line
+ z = zeichen[(fontbpl * i) + ((j & 0xF8) >> 3)+1];
+ b = 1 << (j & 0x07);
+ if (( z & b ) == 0x00) {
+ // pixel(char_x+i,char_y+j,0);
+ window_pushpixel(_background, fontzoomhor); //(color, howmany)
+ } else {
+ // pixel(char_x+i,char_y+j,1);
+ window_pushpixel(_foreground, fontzoomhor);
+ }
+ }
+ } //for each zoomed vert
+ }
}
if(fontprop)
{
--- a/Graphics/TextDisplay.h Mon Apr 11 16:54:35 2016 +0000 +++ b/Graphics/TextDisplay.h Sun Jun 21 15:23:02 2020 +0100 @@ -17,6 +17,7 @@ #define MBED_TEXTDISPLAY_H #include "mbed.h" +#include "Stream.h" /** A common base class for Text displays */
--- a/Inits/ILI9327.cpp Mon Apr 11 16:54:35 2016 +0000
+++ b/Inits/ILI9327.cpp Sun Jun 21 15:23:02 2020 +0100
@@ -68,7 +68,7 @@
void ILI9327::init()
{
wr_cmd8(0x11);
- wait_ms(150);
+ ThisThread::sleep_for(150);
wr_cmd8(0xF3); //Set EQ
wr_data8(0x08);
@@ -148,6 +148,6 @@
wr_data8(0x80); // enable
wr_cmd8(0x29); // Set_display_on
- wait_ms(150);
+ ThisThread::sleep_for(150);
}
\ No newline at end of file
--- a/Inits/ILI932x.cpp Mon Apr 11 16:54:35 2016 +0000
+++ b/Inits/ILI932x.cpp Sun Jun 21 15:23:02 2020 +0100
@@ -17,7 +17,7 @@
hw_reset();
BusEnable(true); //set CS low, will stay low untill manually set high with BusEnable(false);
identify(); // will collect tftID
- if(tftID==0x9325 || tftID==0x9328) init9325();
+ if(tftID==0x9325) init9325();
else if(tftID==0x9320) init9320();
auto_gram_read_format();// try to get read gram pixel format, could be 16bit or 18bit, RGB or BGR. Will set flags accordingly
set_orientation(0);
@@ -53,6 +53,22 @@
cls();
locate(0,0);
}
+
+ILI932x::ILI932x(const char *name)
+ : TFT932x(name)
+{
+ hw_reset(); //TFT class forwards to Protocol class
+ BusEnable(true); //set CS low, TFT932x class will toggle CS every transfer
+ identify(); // will collect tftID
+ if(tftID==0x9325) init9325();
+ else if(tftID==0x9320) init9320();
+ auto_gram_read_format();// try to get read gram pixel format, could be 16bit or 18bit, RGB or BGR. Will set flags accordingly
+ set_orientation(0);
+ FastWindow(true); // most but not all controllers support this, even if datasheet tells they should.
+ cls();
+ locate(0,0);
+}
+
// reset and init the lcd controller
void ILI932x::init9325()
@@ -77,21 +93,21 @@
reg_write(0x0012,0x0000);
reg_write(0x0013,0x0000);
reg_write(0x0007,0x0001);
-wait_ms(200);
+ThisThread::sleep_for(200ms);
//vgh
reg_write(0x0010,0x1290);
reg_write(0x0011,0x0227);
-wait_ms(50);
+ThisThread::sleep_for(50ms);
//vregiout
reg_write(0x0012,0x001d); //0x001b
- wait_ms(50);
+ ThisThread::sleep_for(50ms);
//vom amplitude
reg_write(0x0013,0x1500);
- wait_ms(50);
+ ThisThread::sleep_for(50ms);
//vom H
reg_write(0x0029,0x0018);
reg_write(0x002B,0x000D);
-wait_ms(50);
+ThisThread::sleep_for(50ms);
//gamma
reg_write(0x0030,0x0004);
reg_write(0x0031,0x0307);
@@ -151,21 +167,21 @@
reg_write(0x0012,0x0000);
reg_write(0x0013,0x0000);
reg_write(0x0007,0x0001);
-wait_ms(200);
+ThisThread::sleep_for(200ms);
reg_write(0x0010,0x10C0);
reg_write(0x0011,0x0007);
-wait_ms(50);
+ThisThread::sleep_for(50ms);
reg_write(0x0012,0x0110);
- wait_ms(50);
+ ThisThread::sleep_for(50ms);
reg_write(0x0013,0x0b00);
- wait_ms(50);
+ ThisThread::sleep_for(50ms);
reg_write(0x0029,0x0000);
reg_write(0x002B,0x4010); // bit 14???
-wait_ms(50);
+ThisThread::sleep_for(50ms);
//gamma
/*
reg_write(0x0030,0x0004);
--- a/Inits/ILI932x.h Mon Apr 11 16:54:35 2016 +0000
+++ b/Inits/ILI932x.h Sun Jun 21 15:23:02 2020 +0100
@@ -57,7 +57,8 @@
*/
ILI932x(proto_t displayproto, int Hz, PinName mosi, PinName miso, PinName sclk, PinName CS, PinName reset, const char* name, unsigned int LCDSIZE_X = 240, unsigned int LCDSIZE_Y= 320);
-
+ /** Create a MINISTM32 interface */
+ ILI932x(const char* name);
protected:
--- a/Inits/ILI9341.cpp Mon Apr 11 16:54:35 2016 +0000
+++ b/Inits/ILI9341.cpp Sun Jun 21 15:23:02 2020 +0100
@@ -171,9 +171,9 @@
wr_cmd8(0x13); // Nomal Displaymode
wr_cmd8(0x11); // sleep out
- wait_ms(150);
+ ThisThread::sleep_for(150);
wr_cmd8(0x29); // display on
- wait_ms(150);
+ ThisThread::sleep_for(150);
}
\ No newline at end of file
--- a/Inits/ILI9486.cpp Mon Apr 11 16:54:35 2016 +0000
+++ b/Inits/ILI9486.cpp Sun Jun 21 15:23:02 2020 +0100
@@ -146,8 +146,8 @@
wr_cmd8(0x13); // Nomal Displaymode
wr_cmd8(0x11); // sleep out
- wait_ms(150);
+ ThisThread::sleep_for(150);
wr_cmd8(0x29); // display on
- wait_ms(150);
+ ThisThread::sleep_for(150);
}
\ No newline at end of file
--- a/Inits/IST3020.cpp Mon Apr 11 16:54:35 2016 +0000
+++ b/Inits/IST3020.cpp Sun Jun 21 15:23:02 2020 +0100
@@ -45,7 +45,7 @@
/* Start Initial Sequence ----------------------------------------------------*/
wr_cmd8(0xE2); // sw reset
- wait_ms(10);
+ ThisThread::sleep_for(10);
wr_cmd8(0xAE); // display off
wr_cmd8(0xAB); // built-in OSC on
@@ -58,11 +58,11 @@
//wr_cmd8(0xC0); // SHL select com0-com63
wr_cmd8(0x2C); // Internal Voltage Converter ON
- wait_ms(10);
+ ThisThread::sleep_for(10);
wr_cmd8(0x2E); // Internal Voltage Regulator ON
- wait_ms(10);
+ ThisThread::sleep_for(10);
wr_cmd8(0x2F); // Internal Voltage Follower ON
- wait_ms(10);
+ ThisThread::sleep_for(10);
wr_cmd8(0x20); // Regulor_Resistor_Select resistor ratio 20-27 20=4.5(default) 27=8.0, 0.5 steps
set_contrast(46);
//wr_cmd8(0x81); // set contrast (reference voltage register set)
--- a/Inits/S6D04D1.cpp Mon Apr 11 16:54:35 2016 +0000
+++ b/Inits/S6D04D1.cpp Sun Jun 21 15:23:02 2020 +0100
@@ -72,7 +72,7 @@
wr_data8(0x01);
wr_cmd8(0x11);
-wait_ms(150);
+ThisThread::sleep_for(150);
wr_cmd8(0xF3);
wr_data8(0x01);
@@ -98,23 +98,23 @@
wr_data8(0xF0);
wr_data8(0x70);
wr_data8(0x1F);
-wait_ms(30);
+ThisThread::sleep_for(30);
wr_cmd8(0xF3);
wr_data8(0x03);
-wait_ms(30);
+ThisThread::sleep_for(30);
wr_cmd8(0xF3);
wr_data8(0x07);
-wait_ms(30);
+ThisThread::sleep_for(30);
wr_cmd8(0xF3);
wr_data8(0x0F);
-wait_ms(30);
+ThisThread::sleep_for(30);
wr_cmd8(0xF3);
wr_data8(0x1F);
-wait_ms(30);
+ThisThread::sleep_for(30);
wr_cmd8(0xF3);
wr_data8(0x7F);
-wait_ms(30);
+ThisThread::sleep_for(30);
wr_cmd8(0xF7);
@@ -253,8 +253,8 @@
wr_data8(0x02);
wr_data8(0x01);//240*400
-wait_ms(20);
+ThisThread::sleep_for(20);
wr_cmd8(0x29); // display on
-wait_ms(20);
+ThisThread::sleep_for(20);
}
--- a/Inits/SEPS225.cpp Mon Apr 11 16:54:35 2016 +0000
+++ b/Inits/SEPS225.cpp Sun Jun 21 15:23:02 2020 +0100
@@ -75,8 +75,8 @@
#define COLOR_BLACK 0x0000
#define COLOR_WHITE 0xFFFF
-#define OLED_WIDTH 0x7F
-#define OLED_HEIGHT 0x7F
+#define OLED_WIDTH 0x80
+#define OLED_HEIGHT 0x80
#endif /* OLED_LCD_REG_H_ */
@@ -134,8 +134,8 @@
oled->frequency(1000000) ;
#endif
- reg_write(CMD_REDUCE_CURRENT, 0x01) ; wait(0.01) ; // oled_delay(100000) ;
- reg_write(CMD_REDUCE_CURRENT, 0x00) ; wait(0.01) ; // oled_delay(100000) ;
+ reg_write(CMD_REDUCE_CURRENT, 0x01) ; ThisThread::sleep_for(10) ; // oled_delay(100000) ;
+ reg_write(CMD_REDUCE_CURRENT, 0x00) ; ThisThread::sleep_for(10) ; // oled_delay(100000) ;
reg_write(CMD_OSC_CTL, 0x01) ;
reg_write(CMD_CLOCK_DIV, 0x30) ;
@@ -245,24 +245,24 @@
void SEPS225::rect(int x0, int y0, int x1, int y1, unsigned short color)
{
- float interval = 0.01 ;
+ uint32_t interval = 10 ;
// window(x0, y0, x1-x0+1, y1-y0+1) ;
*_cs = 0 ;
- wait(interval) ;
+ ThisThread::sleep_for(interval) ;
line(x0, y0, x1, y0, color) ;
*_cs = 1 ;
- wait(interval) ;
+ ThisThread::sleep_for(interval) ;
*_cs = 0 ;
line(x1, y0, x1, y1, color) ;
*_cs = 1 ;
- wait(interval) ;
+ ThisThread::sleep_for(interval) ;
*_cs = 0 ;
line(x0, y0, x0, y1, color) ;
*_cs = 1 ;
- wait(interval) ;
+ ThisThread::sleep_for(interval) ;
*_cs = 0 ;
line(x0, y1, x1, y1, color) ;
- wait(interval) ;
+ ThisThread::sleep_for(interval) ;
*_cs = 1 ;
// *_cs = 1 ;
}
--- a/Inits/SSD1306.cpp Mon Apr 11 16:54:35 2016 +0000
+++ b/Inits/SSD1306.cpp Sun Jun 21 15:23:02 2020 +0100
@@ -56,13 +56,24 @@
set_orientation(1);
locate(0,0);
}
+
+SSD1306::SSD1306(proto_t displayproto, int Hz, int address, PinName sda, PinName scl, const char* name , unsigned int LCDSIZE_X, unsigned int LCDSIZE_Y)
+ : LCD(displayproto, Hz, address, sda, scl, LCDSIZE_X, LCDSIZE_Y, IC_X_SEGS, IC_Y_COMS, name)
+{
+ init();
+ cls();
+ set_orientation(1);
+ locate(0,0);
+}
+
+
// reset and init the lcd controller
void SSD1306::init()
{
/* Start Initial Sequence ----------------------------------------------------*/
// wr_cmd8(0xE2); // sw reset
- wait_ms(15);
+ ThisThread::sleep_for(15);
wr_cmd8(SSD1306_DISPLAYOFF); // no problem in SPI_16 for single byte cmds
wr_cmd16((SSD1306_SETDISPLAYCLOCKDIV<<8)|0x80); // wr_cmd16 for multibyte cmds issue in SPI16 mode
--- a/Inits/SSD1306.h Mon Apr 11 16:54:35 2016 +0000
+++ b/Inits/SSD1306.h Sun Jun 21 15:23:02 2020 +0100
@@ -41,6 +41,20 @@
*/
SSD1306(proto_t displayproto, int Hz, PinName mosi, PinName miso, PinName sclk, PinName CS, PinName reset, PinName DC, const char* name , unsigned int LCDSIZE_X = 128, unsigned int LCDSIZE_Y = 64);
+ /** Create an I2C display interface
+ * @param displayproto I2C_
+ * @param Hz I2C speed in Hz
+ * @param address I2C address
+ * @param sda I2C pin
+ * @param scl I2C pin
+ * @param name The name used by the parent class to access the interface
+ * @param LCDSIZE_X x size in pixel - optional
+ * @param LCDSIZE_Y y size in pixel - optional
+ */
+ SSD1306(proto_t displayproto, int Hz, int address, PinName sda, PinName scl, const char* name , unsigned int LCDSIZE_X = 128, unsigned int LCDSIZE_Y = 64);
+
+
+
/** set the contrast of the screen
* @note here overrided because of not standard value range
* @param o contrast 0-255
--- a/Inits/ST7565.cpp Mon Apr 11 16:54:35 2016 +0000
+++ b/Inits/ST7565.cpp Sun Jun 21 15:23:02 2020 +0100
@@ -55,7 +55,7 @@
/* Start Initial Sequence ----------------------------------------------------*/
wr_cmd8(0xE2); // sw reset
- wait_ms(10);
+ ThisThread::sleep_for(10);
wr_cmd8(0xAE); // display off
@@ -68,11 +68,11 @@
wr_cmd8(0xC0); // SHL select com0-com63
wr_cmd8(0x2C); // Boost ON
- wait_ms(10);
+ ThisThread::sleep_for(10);
wr_cmd8(0x2E); // Voltage Regulator ON
- wait_ms(10);
+ ThisThread::sleep_for(10);
wr_cmd8(0x2F); // Voltage Follower ON
- wait_ms(10);
+ ThisThread::sleep_for(10);
wr_cmd8(0x20|0x05); // Regulor_Resistor_Select resistor ratio 20-27, look at your display specific init code
set_contrast(0x20);
//wr_cmd8(0x81); // set contrast (reference voltage register set)
--- a/Inits/TFT_MIPI.cpp Mon Apr 11 16:54:35 2016 +0000
+++ b/Inits/TFT_MIPI.cpp Sun Jun 21 15:23:02 2020 +0100
@@ -101,9 +101,9 @@
wr_cmd8(0x13); // Nomal Displaymode
wr_cmd8(0x11); // sleep out
- wait_ms(150);
+ ThisThread::sleep_for(150);
wr_cmd8(0x29); // display on
- wait_ms(150);
+ ThisThread::sleep_for(150);
}
\ No newline at end of file
--- a/Inits/UC1608.cpp Mon Apr 11 16:54:35 2016 +0000
+++ b/Inits/UC1608.cpp Sun Jun 21 15:23:02 2020 +0100
@@ -41,7 +41,7 @@
/* Start Initial Sequence ----------------------------------------------------*/
// wr_cmd8(0xE2); // sw reset
- wait_ms(15);
+ ThisThread::sleep_for(15);
wr_cmd8(0x27); // Multiplex rate :128 set temperature consenpation 0%
wr_cmd8(0xEA); //set bias:1/12bias
@@ -53,7 +53,7 @@
//wr_cmd8(0xC0); // SHL select com0-com63
wr_cmd8(0x2F); // //Power Control:internal, LCD capacitance 60nf-90nf
- wait_ms(10);
+ ThisThread::sleep_for(10);
// wr_cmd8(0x81);//Set Gain and Potentiometer
// wr_cmd8(0x40|26);//Set Gain and Potentiometer xx xxxxxx
--- a/Protocols/BUS16.cpp Mon Apr 11 16:54:35 2016 +0000
+++ b/Protocols/BUS16.cpp Sun Jun 21 15:23:02 2020 +0100
@@ -211,15 +211,15 @@
}
void BUS16::hw_reset()
{
- wait_ms(15);
+ ThisThread::sleep_for(15);
_DC = 1;
_CS = 1;
_WR = 1;
_RD = 1;
_reset = 0; // display reset
- wait_ms(2);
+ ThisThread::sleep_for(2);
_reset = 1; // end reset
- wait_ms(100);
+ ThisThread::sleep_for(100);
}
void BUS16::BusEnable(bool enable)
{
--- a/Protocols/BUS8.cpp Mon Apr 11 16:54:35 2016 +0000
+++ b/Protocols/BUS8.cpp Sun Jun 21 15:23:02 2020 +0100
@@ -259,15 +259,15 @@
}
void BUS8::hw_reset()
{
- wait_ms(15);
+ ThisThread::sleep_for(15);
_DC = 1;
_CS = 1;
_WR = 1;
_RD = 1;
_reset = 0; // display reset
- wait_ms(2);
+ ThisThread::sleep_for(2);
_reset = 1; // end reset
- wait_ms(100);
+ ThisThread::sleep_for(100);
}
void BUS8::BusEnable(bool enable)
{
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Protocols/I2C_bus.cpp Sun Jun 21 15:23:02 2020 +0100
@@ -0,0 +1,132 @@
+/* mbed UniGraphic library - I2C protocol class
+ * Copyright (c) 2017 Peter Drescher
+ * Released under the MIT License: http://mbed.org/license/mit
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+#include "I2C_bus.h"
+
+I2C_bus::I2C_bus(int Hz, int address, PinName sda, PinName scl)
+ : _i2c(sda,scl)
+{
+ _i2c.frequency(Hz);
+ _address = address;
+ //hw_reset();
+}
+
+void I2C_bus::wr_cmd8(unsigned char cmd)
+{
+ char tmp[2];
+ tmp[0] = 0x00; //command
+ tmp[1] = cmd;
+ _i2c.write(_address,tmp,2);
+}
+void I2C_bus::wr_data8(unsigned char data)
+{
+ _i2c.write(data); // write 8bit
+}
+void I2C_bus::wr_cmd16(unsigned short cmd)
+{
+ char tmp[3];
+ tmp[0] = 00; //command
+ tmp[1] = cmd>>8;
+ tmp[2] = cmd&0xFF;
+
+ _i2c.write(_address,tmp,3);
+}
+void I2C_bus::wr_data16(unsigned short data)
+{
+ _i2c.write(data>>8); // write 8bit
+ _i2c.write(data&0xFF); // write 8bit
+}
+void I2C_bus::wr_gram(unsigned short data)
+{
+ _i2c.write(data>>8); // write 8bit
+ _i2c.write(data&0xFF); // write 8bit
+}
+void I2C_bus::wr_gram(unsigned short data, unsigned int count)
+{
+ _i2c.start();
+ _i2c.write(_address);
+ _i2c.write(0x40); // data continue
+ if((data>>8)==(data&0xFF))
+ {
+ count<<=1;
+ while(count)
+ {
+ _i2c.write(data); // write 8bit
+ count--;
+ }
+ }
+ else
+ {
+ while(count)
+ {
+ _i2c.write(data>>8); // write 8bit
+ _i2c.write(data&0xFF); // write 8bit
+ count--;
+ }
+ }
+ _i2c.stop();
+}
+void I2C_bus::wr_grambuf(unsigned short* data, unsigned int lenght)
+{
+ _i2c.start();
+ _i2c.write(_address);
+ _i2c.write(0x40); // data continue
+ while(lenght)
+ {
+ _i2c.write((*data)>>8); // write 8bit
+ _i2c.write((*data)&0xFF); // write 8bit
+ data++;
+ lenght--;
+ }
+ _i2c.stop();
+}
+
+void I2C_bus::hw_reset()
+{
+
+}
+void I2C_bus::BusEnable(bool enable)
+{
+}
+
+void I2C_bus::reg_select(unsigned char reg, bool forread)
+{
+}
+
+unsigned int I2C_bus::rd_reg_data32(unsigned char reg)
+{
+ return 0;
+}
+
+unsigned int I2C_bus::rd_extcreg_data32(unsigned char reg, unsigned char SPIreadenablecmd)
+{
+ return 0;
+}
+
+void I2C_bus::dummyread()
+{
+}
+
+unsigned short I2C_bus::rd_gram(bool convert)
+{
+ return (0);
+}
+
+unsigned short I2C_bus::reg_read(unsigned char reg)
+{
+ return (0);
+}
+
+void I2C_bus::reg_write(unsigned char reg, unsigned short data)
+{
+}
\ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Protocols/I2C_bus.h Sun Jun 21 15:23:02 2020 +0100
@@ -0,0 +1,139 @@
+#ifndef I2C_bus_H
+#define I2C_bus_H
+
+#include "mbed.h"
+#include "Protocols.h"
+
+/** I2C interface
+*/
+class I2C_bus : public Protocols
+{
+ public:
+
+ /** Create an I2C display interface
+ *
+ * @param I2C frquency
+ * @param I2C address
+ * @param I2C pin sda
+ * @param I2C pin scl
+ */
+ I2C_bus(int Hz, int address,PinName sda, PinName scl);
+
+protected:
+
+ /** Send 8bit command to display controller
+ *
+ * @param cmd: byte to send
+ *
+ */
+ virtual void wr_cmd8(unsigned char cmd);
+
+ /** Send 8bit data to display controller
+ *
+ * @param data: byte to send
+ *
+ */
+ virtual void wr_data8(unsigned char data);
+
+ /** Send 2x8bit command to display controller
+ *
+ * @param cmd: halfword to send
+ * @note in SPI_16 mode a single 16bit transfer will be done
+ */
+ virtual void wr_cmd16(unsigned short cmd);
+
+ /** Send 2x8bit data to display controller
+ *
+ * @param data: halfword to send
+ * @note in SPI_16 mode a single 16bit transfer will be done
+ */
+ virtual void wr_data16(unsigned short data);
+
+ /** Send 16bit pixeldata to display controller
+ *
+ * @param data: halfword to send
+ *
+ */
+ virtual void wr_gram(unsigned short data);
+
+ /** Send same 16bit pixeldata to display controller multiple times
+ *
+ * @param data: halfword to send
+ * @param count: how many
+ *
+ */
+ virtual void wr_gram(unsigned short data, unsigned int count);
+
+ /** Send array of pixeldata shorts to display controller
+ *
+ * @param data: unsigned short pixeldata array
+ * @param lenght: lenght (in shorts)
+ *
+ */
+ virtual void wr_grambuf(unsigned short* data, unsigned int lenght);
+
+ /** Read 16bit pixeldata from display controller (with dummy cycle)
+ *
+ * @param convert true/false. Convert 18bit to 16bit, some controllers returns 18bit
+ * @returns 16bit color
+ */
+ virtual unsigned short rd_gram(bool convert);
+
+ /** Read 4x8bit register data (
+ * reading from display ia I2C is not implemented in most controllers !
+ *
+ */
+ virtual unsigned int rd_reg_data32(unsigned char reg);
+
+ /** Read 3x8bit ExtendedCommands register data
+ * reading from display ia I2C is not implemented in most controllers !
+ */
+ virtual unsigned int rd_extcreg_data32(unsigned char reg, unsigned char SPIreadenablecmd);
+
+ /** ILI932x specific, does a dummy read cycle, number of bits is protocol dependent
+ * reading from display ia I2C is not implemented in most controllers !
+ */
+ virtual void dummyread ();
+
+ /** ILI932x specific, select register for a successive write or read
+ *
+ * reading from display ia I2C is not implemented in most controllers !
+ */
+ virtual void reg_select(unsigned char reg, bool forread =false);
+
+ /** ILI932x specific, write register with data
+ *
+ * @param reg register to write
+ * @param data 16bit data
+ * not implemented for I2C !
+ */
+ virtual void reg_write(unsigned char reg, unsigned short data);
+
+ /** ILI932x specific, read register
+ *
+ * @param reg register to be read
+ * @returns 16bit register value
+ * not implemented for I2C !
+ */
+ virtual unsigned short reg_read(unsigned char reg);
+
+ /** HW reset sequence (without display init commands)
+ * most I2C displays have no reset signal !
+ */
+ virtual void hw_reset();
+
+ /** Set ChipSelect high or low
+ * @param enable 0/1
+ * not implemented for I2C !
+ */
+ virtual void BusEnable(bool enable);
+
+private:
+
+ I2C _i2c;
+ int _address;
+
+};
+
+
+#endif
\ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Protocols/MINISTM32.cpp Sun Jun 21 15:23:02 2020 +0100
@@ -0,0 +1,274 @@
+ /* mbed UniGraphic library - MINISTM32 protocol class
+ * Copyright (c) 2015 Giuliano Dianda
+ * Released under the MIT License: http://mbed.org/license/mit
+ *
+ * Derived work of:
+ *
+ * mbed library for 240*320 pixel display TFT based on ILI9341 LCD Controller
+ * Copyright (c) 2013 Peter Drescher - DC2PD
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+ #if DEVICE_PORTINOUT
+#include "MINISTM32.h"
+
+MINISTM32::MINISTM32()
+ : _HI(PortB, 0x0000FF00), _LO(PortC, 0x000000FF), _CS(PC_8), _DC(PC_9), _WR(PC_10), _RD(PC_11)
+{
+ _DC=1;
+ _WR=1;
+ _RD=1;
+ _CS=1;
+ // most interaction is output, so only change to input for reading
+ _HI.output();
+ _LO.output();
+
+ hw_reset();
+}
+
+void MINISTM32::wr_cmd8(unsigned char cmd)
+{
+ _DC = 0; // 0=cmd
+ GPIOC->BSRR = cmd | (~(cmd << 16) & 0x00FF0000) | (1 << 26);
+ GPIOC->BSRR = 1 << 10;
+ _DC = 1; // 1=data next
+}
+void MINISTM32::wr_data8(unsigned char data)
+{
+ GPIOC->BSRR = data | (~data << 16) | (1 << 26);
+ GPIOC->BSRR = 1 << 10;
+}
+void MINISTM32::wr_cmd16(unsigned short cmd)
+{
+ _DC = 0; // 0=cmd
+ GPIOC->BSRR = cmd >> 8 | (~cmd << 8) | (1 << 26);
+ GPIOC->BSRR = 1 << 10;
+ GPIOC->BSRR = (cmd & 0xFF) | (~(cmd & 0xFF) << 8) | (1 << 26);
+ GPIOC->BSRR = 1 << 10;
+ _DC = 1; // 1=data next
+}
+void MINISTM32::wr_data16(unsigned short data)
+{
+ GPIOC->BSRR = data >> 8 | (~data << 8) | (1 << 26);
+ GPIOC->BSRR = 1 << 10;
+ GPIOC->BSRR = (data & 0xFF) | (~(data & 0xFF) << 8) | (1 << 26);
+ GPIOC->BSRR = 1 << 10;
+}
+void MINISTM32::wr_gram(unsigned short data)
+{
+ GPIOC->BSRR = (data & 0xFF) | ((~data & 0xFF) << 16) | (1 << 26);
+ GPIOB->BSRR = (data & 0xFF00) | ((~data & 0xFF00) << 16);
+ GPIOC->BSRR = 1 << 10;
+}
+void MINISTM32::wr_gram(unsigned short data, unsigned int count)
+{
+ _LO.write(data); // write 16bit
+ _HI.write(data); // write 16bit
+ // let's try direct GPIO access
+ // _WR is PC_10
+ if(count > 10) {
+ // Unroll part of the loop for speed
+ while(count)
+ {
+
+ GPIOC->BSRR = 1 << 26;
+ GPIOC->BSRR = 1 << 10;
+ GPIOC->BSRR = 1 << 10; // Acts as a NOP - too fast for the controller otherwise
+ GPIOC->BSRR = 1 << 26;
+ GPIOC->BSRR = 1 << 10;
+ GPIOC->BSRR = 1 << 10;
+ GPIOC->BSRR = 1 << 26;
+ GPIOC->BSRR = 1 << 10;
+ GPIOC->BSRR = 1 << 10;
+ GPIOC->BSRR = 1 << 26;
+ GPIOC->BSRR = 1 << 10;
+ GPIOC->BSRR = 1 << 10;
+ GPIOC->BSRR = 1 << 26;
+ GPIOC->BSRR = 1 << 10;
+ GPIOC->BSRR = 1 << 10;
+ GPIOC->BSRR = 1 << 26;
+ GPIOC->BSRR = 1 << 10;
+ GPIOC->BSRR = 1 << 10;
+ GPIOC->BSRR = 1 << 26;
+ GPIOC->BSRR = 1 << 10;
+ GPIOC->BSRR = 1 << 10;
+ GPIOC->BSRR = 1 << 26;
+ GPIOC->BSRR = 1 << 10;
+ GPIOC->BSRR = 1 << 10;
+ GPIOC->BSRR = 1 << 26;
+ GPIOC->BSRR = 1 << 10;
+ GPIOC->BSRR = 1 << 10;
+ GPIOC->BSRR = 1 << 26;
+ GPIOC->BSRR = 1 << 10;
+
+ count-=10;
+ }
+ }
+
+ while(count)
+ {
+ GPIOC->BSRR = 1 << 26;
+ GPIOC->BSRR = 1 << 10;
+ count--;
+ }
+}
+void MINISTM32::wr_grambuf(unsigned short* data, unsigned int length)
+{
+ while(length)
+ {
+ GPIOC->BSRR = (*data & 0xFF) | ((~*data & 0xFF) << 16) | (1 << 26);
+ GPIOB->BSRR = (*data & 0xFF00) | ((~*data & 0xFF00) << 16);
+ GPIOC->BSRR = 1 << 10;
+
+ data++;
+ length--;
+ }
+}
+unsigned short MINISTM32::rd_gram(bool convert)
+{
+ unsigned int r=0;
+ _LO.input();
+ _HI.input();
+
+ // dummy read
+ GPIOC->BSRR = 1 << 27;
+ GPIOC->BSRR = 1 << 11;
+
+
+ GPIOC->BSRR = 1 << 27;
+ r |= _LO.read() | _HI.read();
+ GPIOC->BSRR = 1 << 11;
+
+ if(convert)
+ {
+ r <<= 8;
+ GPIOC->BSRR = 1 << 27;
+ r |= _HI.read()>>8; //MSB of port read is blue, LSB is red of next pixel
+ GPIOC->BSRR = 1 << 11;
+ // gram is 18bit/pixel, if you set 16bit/pixel (cmd 3A), during writing the 16bits are expanded to 18bit
+ // during reading, you read the raw 18bit gram
+ r = RGB24to16((r&0xFF0000)>>16, (r&0xFF00)>>8, r&0xFF);// 18bit pixel padded to 24bits, rrrrrr00_gggggg00_bbbbbb00, converted to 16bit
+ }
+ _LO.output();
+ _HI.output();
+ return (unsigned short)r;
+}
+unsigned int MINISTM32::rd_reg_data32(unsigned char reg)
+{
+ wr_cmd8(reg);
+ unsigned int r=0;
+ // _DC = 1; // 1=data
+ _LO.input();
+ _HI.input();
+
+ // dummy read
+ GPIOC->BSRR = 1 << 27;
+ GPIOC->BSRR = 1 << 11;
+
+ GPIOC->BSRR = 1 << 27;
+ r |= (_LO.read()&0xFF);
+ r <<= 8;
+ GPIOC->BSRR = 1 << 11;
+
+ GPIOC->BSRR = 1 << 27;
+ r |= (_LO.read()&0xFF);
+ r <<= 8;
+ GPIOC->BSRR = 1 << 11;
+
+ GPIOC->BSRR = 1 << 27;
+ r |= (_LO.read()&0xFF);
+ r <<= 8;
+ GPIOC->BSRR = 1 << 11;
+
+ GPIOC->BSRR = 1 << 27;
+ r |= (_LO.read()&0xFF);
+ GPIOC->BSRR = 1 << 11;
+
+ _CS = 1; // toggle CS to interupt the cmd in case was not supported
+ _CS = 0;
+
+ _LO.output();
+ _HI.output();
+ return r;
+}
+// in Par mode EXTC regs (0xB0-0xFF) can be directly read
+unsigned int MINISTM32::rd_extcreg_data32(unsigned char reg, unsigned char SPIreadenablecmd)
+{
+ return rd_reg_data32(reg);
+}
+// ILI932x specific
+void MINISTM32::dummyread()
+{
+ _LO.input();
+ _HI.input();
+ // dummy read
+ GPIOC->BSRR = 1 << 27;
+ GPIOC->BSRR = 1 << 11;
+ _LO.output();
+ _HI.output();
+}
+// ILI932x specific
+void MINISTM32::reg_select(unsigned char reg, bool forread)
+{
+ _DC = 0;
+
+ //uint32_t r = reg;
+
+ GPIOC->BSRR = reg | (~(reg << 16) & 0x00FF0000) | (1 << 26);
+ GPIOC->BSRR = 1 << 10;
+ GPIOC->BSRR = 1 << 10;
+ _DC = 1; // 1=data next
+}
+// ILI932x specific
+void MINISTM32::reg_write(unsigned char reg, unsigned short data)
+{
+ _DC = 0;
+ GPIOC->BSRR = reg | (~(reg << 16) & 0x00FF0000) | (1 << 26);
+ GPIOB->BSRR = 0xFF000000;
+ GPIOC->BSRR = 1 << 10;
+
+ _DC = 1;
+ GPIOC->BSRR = (data & 0xFF) | (~(data << 16) & 0x00FF0000) | (1 << 26);
+ GPIOB->BSRR = (data & 0xFF00) | (~(data << 16) & 0xFF000000);
+ GPIOC->BSRR = 1 << 10;
+}
+// ILI932x specific
+unsigned short MINISTM32::reg_read(unsigned char reg)
+{
+ unsigned short r=0;
+ _DC = 0;
+ GPIOC->BSRR = reg | (~(reg << 16) & 0x00FF0000) | (1 << 26);
+ GPIOB->BSRR = 0xFF000000;
+ GPIOC->BSRR = 1 << 10;
+
+ _DC = 1;
+ _LO.input();
+ _HI.input();
+ GPIOC->BSRR = 1 << 27;
+ r |= _LO.read() | _HI.read(); // read 16bit
+ GPIOC->BSRR = 1 << 11;
+ _LO.output();
+ _HI.output();
+ return r;
+}
+void MINISTM32::hw_reset()
+{
+ ThisThread::sleep_for(15ms);
+ _DC = 1;
+ _CS = 1;
+ _WR = 1;
+ _RD = 1;
+ ThisThread::sleep_for(100ms);
+}
+void MINISTM32::BusEnable(bool enable)
+{
+ _CS = enable ? 0:1;
+}
+
+#endif
\ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Protocols/MINISTM32.h Sun Jun 21 15:23:02 2020 +0100
@@ -0,0 +1,172 @@
+#ifndef MINISTM32_H
+#define MINISTM32_H
+
+#include "mbed.h"
+#include "Protocols.h"
+//#include "GraphicsDisplay.h"
+#if DEVICE_PORTINOUT
+/**
+* My MINI-STM32-V3.0 board is wired up to the display in a bizarre way
+* Data lines are PC0-7 and PB8-15
+* Using them with BUS16 is very slow, so this wrapper does more direct port access
+*/
+class MINISTM32 : public Protocols
+{
+ public:
+
+ /**
+ * Create a MINISTM32 display interface
+ * Pins are hard-wired
+ * DB0 - PC0
+ * DB1 - PC1
+ * DB2 - PC2
+ * DB3 - PC3
+ * DB4 - PC4
+ * DB5 - PC5
+ * DB6 - PC6
+ * DB7 - PC7
+ * DB8 - N/C
+ * DB9 - N/C
+ * DB10 - PB8
+ * DB11 - PB9
+ * DB12 - PB10
+ * DB13 - PB11
+ * DB14 - PB12
+ * DB15 - PB13
+ * DB16 - PB14
+ * DB17 - PB15
+ * CS - PC8
+ * RS - PC9
+ * WR - PC10
+ * RD - PC11
+ * RESET - Connected to the board global reset line
+ * EN - PC12
+ */
+ MINISTM32();
+
+protected:
+
+ /** Send 8bit command to display controller
+ *
+ * @param cmd: byte to send
+ *
+ */
+ virtual void wr_cmd8(unsigned char cmd);
+
+ /** Send 8bit data to display controller
+ *
+ * @param data: byte to send
+ *
+ */
+ virtual void wr_data8(unsigned char data);
+
+ /** Send 2x8bit command to display controller
+ *
+ * @param cmd: halfword to send
+ * @note 2cycles using pins[7:0]
+ */
+ virtual void wr_cmd16(unsigned short cmd);
+
+ /** Send 2x8bit data to display controller
+ *
+ * @param data: halfword to send
+ * @note 2cycles using pins[7:0], only gram write cmd uses pins[15:8]
+ */
+ virtual void wr_data16(unsigned short data);
+
+ /** Send 16bit pixeldata to display controller
+ *
+ * @param data: halfword to send
+ * @note here using all pins[15:0]
+ */
+ virtual void wr_gram(unsigned short data);
+
+ /** Send same 16bit pixeldata to display controller multiple times
+ *
+ * @param data: halfword to send
+ * @param count: how many
+ * @note here using all pins[15:0]
+ */
+ virtual void wr_gram(unsigned short data, unsigned int count);
+
+ /** Send array of pixeldata shorts to display controller
+ *
+ * @param data: unsigned short pixeldata array
+ * @param lenght: lenght (in shorts)
+ * @note here using all pins[15:0]
+ */
+ virtual void wr_grambuf(unsigned short* data, unsigned int lenght);
+
+ /** Read 16bit pixeldata from display controller (with dummy cycle)
+ *
+ * @param convert true/false. Convert 18bit to 16bit, some controllers returns 18bit
+ * @returns 16bit color
+ */
+ virtual unsigned short rd_gram(bool convert);
+
+ /** Read 4x8bit register data (with dummy cycle)
+ * @param reg the register to read
+ * @returns data as uint
+ *
+ */
+ virtual unsigned int rd_reg_data32(unsigned char reg);
+
+ /** Read 3x8bit ExtendedCommands register data
+ * @param reg the register to read
+ * @returns data as uint
+ * @note EXTC regs (0xB0 to 0xFF) are read/write registers, for Parallel mode directly accessible in both directions
+ */
+ virtual unsigned int rd_extcreg_data32(unsigned char reg, unsigned char SPIreadenablecmd);
+
+ /** ILI932x specific, does a dummy read cycle, number of bits is protocol dependent
+ * for PAR protocols: a signle RD bit toggle
+ * for SPI8: 8clocks
+ * for SPI16: 16 clocks
+ */
+ virtual void dummyread ();
+
+ /** ILI932x specific, select register for a successive write or read
+ *
+ * @param reg register to be selected
+ * @param forread false = a write next (default), true = a read next
+ * @note forread only used by SPI protocols
+ */
+ virtual void reg_select(unsigned char reg, bool forread =false);
+
+ /** ILI932x specific, write register with data
+ *
+ * @param reg register to write
+ * @param data 16bit data
+ */
+ virtual void reg_write(unsigned char reg, unsigned short data);
+
+ /** ILI932x specific, read register
+ *
+ * @param reg register to be read
+ * @returns 16bit register value
+ */
+ virtual unsigned short reg_read(unsigned char reg);
+
+ /** HW reset sequence (without display init commands)
+ */
+ virtual void hw_reset();
+
+ /** Set ChipSelect high or low
+ * @param enable 0/1
+ */
+ virtual void BusEnable(bool enable);
+
+
+
+private:
+
+ PortInOut _HI;
+ PortInOut _LO;
+ DigitalOut _CS;
+ DigitalOut _DC;
+ DigitalOut _WR;
+ DigitalOut _RD;
+
+};
+#endif
+#endif
\ No newline at end of file
--- a/Protocols/PAR16.cpp Mon Apr 11 16:54:35 2016 +0000
+++ b/Protocols/PAR16.cpp Sun Jun 21 15:23:02 2020 +0100
@@ -214,15 +214,15 @@
}
void PAR16::hw_reset()
{
- wait_ms(15);
+ ThisThread::sleep_for(15);
_DC = 1;
_CS = 1;
_WR = 1;
_RD = 1;
_reset = 0; // display reset
- wait_ms(2);
+ ThisThread::sleep_for(2);
_reset = 1; // end reset
- wait_ms(100);
+ ThisThread::sleep_for(100);
}
void PAR16::BusEnable(bool enable)
{
--- a/Protocols/PAR8.cpp Mon Apr 11 16:54:35 2016 +0000
+++ b/Protocols/PAR8.cpp Sun Jun 21 15:23:02 2020 +0100
@@ -261,15 +261,15 @@
}
void PAR8::hw_reset()
{
- wait_ms(15);
+ ThisThread::sleep_for(15);
_DC = 1;
_CS = 1;
_WR = 1;
_RD = 1;
_reset = 0; // display reset
- wait_ms(2);
+ ThisThread::sleep_for(2);
_reset = 1; // end reset
- wait_ms(100);
+ ThisThread::sleep_for(100);
}
void PAR8::BusEnable(bool enable)
{
--- a/Protocols/Protocols.h Mon Apr 11 16:54:35 2016 +0000
+++ b/Protocols/Protocols.h Sun Jun 21 15:23:02 2020 +0100
@@ -31,6 +31,8 @@
,BUS_16 /**< Parallel 16bit, scattered pins */
,SPI_8 /**< SPI 8bit */
,SPI_16 /**< SPI 16bit */
+ ,I2C_ /**< I2C */
+ ,MINI_STM32 /**< Specific to this dev board */
};
#else
enum proto_t {
@@ -38,6 +40,7 @@
,BUS_16 /**< Parallel 16bit, scattered pins */
,SPI_8 /**< SPI 8bit */
,SPI_16 /**< SPI 16bit */
+ ,I2C_ /**< I2C */
};
#endif
--- a/Protocols/SPI16.cpp Mon Apr 11 16:54:35 2016 +0000
+++ b/Protocols/SPI16.cpp Sun Jun 21 15:23:02 2020 +0100
@@ -174,13 +174,13 @@
}
void SPI16::hw_reset()
{
- wait_ms(15);
+ ThisThread::sleep_for(15);
_DC = 1;
_CS = 1;
_reset = 0; // display reset
- wait_ms(2);
+ ThisThread::sleep_for(2);
_reset = 1; // end reset
- wait_ms(100);
+ ThisThread::sleep_for(100);
}
void SPI16::BusEnable(bool enable)
{
--- a/Protocols/SPI8.cpp Mon Apr 11 16:54:35 2016 +0000
+++ b/Protocols/SPI8.cpp Sun Jun 21 15:23:02 2020 +0100
@@ -194,13 +194,13 @@
}
void SPI8::hw_reset()
{
- wait_ms(15);
+ ThisThread::sleep_for(15);
_DC = 1;
_CS = 1;
_reset = 0; // display reset
- wait_ms(2);
+ ThisThread::sleep_for(2);
_reset = 1; // end reset
- wait_ms(100);
+ ThisThread::sleep_for(100);
}
void SPI8::BusEnable(bool enable)
{
