diff options
author | Stanley Huang <stanleyhuangyc@gmail.com> | 2015-11-01 21:19:19 +1100 |
---|---|---|
committer | Stanley Huang <stanleyhuangyc@gmail.com> | 2015-11-01 21:19:19 +1100 |
commit | 1b496fb2a89b1af1f4090b2910fdc5fd9f5a1c5a (patch) | |
tree | 8d113e60f7e67ca3b5c56d3eb90daef166032f12 | |
parent | ad12f674c507f425f72d062253deb1f56d94ebff (diff) | |
download | 2021-arduino-obd-1b496fb2a89b1af1f4090b2910fdc5fd9f5a1c5a.tar.gz 2021-arduino-obd-1b496fb2a89b1af1f4090b2910fdc5fd9f5a1c5a.tar.bz2 2021-arduino-obd-1b496fb2a89b1af1f4090b2910fdc5fd9f5a1c5a.zip |
Add R61581 3.5" LCD support
-rw-r--r-- | libraries/MultiLCD/MultiLCD.h | 70 | ||||
-rw-r--r-- | libraries/MultiLCD/R61581.cpp | 416 | ||||
-rw-r--r-- | libraries/MultiLCD/SSD1289.cpp | 62 | ||||
-rw-r--r-- | libraries/MultiLCD/UTFT.cpp | 636 | ||||
-rw-r--r-- | libraries/MultiLCD/UTFT.h | 83 | ||||
-rw-r--r-- | libraries/MultiLCD/hardware/arm/HW_ARM_defines.h | 9 | ||||
-rw-r--r-- | libraries/MultiLCD/memorysaver.h | 3 |
7 files changed, 934 insertions, 345 deletions
diff --git a/libraries/MultiLCD/MultiLCD.h b/libraries/MultiLCD/MultiLCD.h index 03737e6..ddda23d 100644 --- a/libraries/MultiLCD/MultiLCD.h +++ b/libraries/MultiLCD/MultiLCD.h @@ -27,7 +27,7 @@ typedef enum { #define FLAG_PIXEL_DOUBLE_V 4 #define FLAG_PIXEL_DOUBLE (FLAG_PIXEL_DOUBLE_H | FLAG_PIXEL_DOUBLE_V) -#define RGB16(r,g,b) (((uint16_t)(r >> 3) << 11) | ((uint16_t)(g >> 2) << 5) | (b >> 2)) +#define RGB16(r,g,b) (((uint16_t)(r >> 3) << 11) | ((uint16_t)(g >> 2) << 5) | (b >> 3)) #define RGB16_RED 0xF800 #define RGB16_GREEN 0x7E0 @@ -72,6 +72,8 @@ protected: virtual void writeDigit(byte n) {} byte m_font; byte m_flags; + uint16_t m_x; + uint16_t m_y; }; #define TFT_LINE_HEIGHT 8 @@ -197,11 +199,9 @@ private: uint8_t Read_Register(uint8_t Addr,uint8_t xParameter); uint8_t readID(void); uint8_t m_color[2][2]; - uint16_t m_x; - uint16_t m_y; }; -class LCD_SSD1289 : public UTFT, public LCD_Common +class LCD_SSD1289 : public UTFT, public LCD_Common, public Print { public: LCD_SSD1289() @@ -209,6 +209,7 @@ public: m_font = FONT_SIZE_MEDIUM; disp_x_size = 239; disp_y_size = 319; + orient = LANDSCAPE; display_transfer_mode = 16; display_model = ITDB32S; __p1 = 38; @@ -237,20 +238,75 @@ public: m_y = y; } void begin(); - void clear(); + void clear(uint16_t x = 0, uint16_t y = 0, uint16_t width = 319, uint16_t height = 239); void draw(const PROGMEM byte* buffer, uint16_t width, uint16_t height); void draw(const PROGMEM byte* buffer, uint16_t width, uint16_t height, byte scaleX, byte scaleY = 0); void draw4bpp(const PROGMEM byte* buffer, uint16_t width, uint16_t height); size_t write(uint8_t); void clearLine(byte line) { - //clear(0, line * TFT_LINE_HEIGHT, 320, 8); + clear(0, line * TFT_LINE_HEIGHT, disp_y_size, 8); } void setBackLight(byte brightness); private: void setXY(uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2); void writeDigit(byte n); - void clearPixels(uint16_t pixels); + void clearPixels(uint32_t pixels); + void Enable(); + void Disable(); +}; + +class LCD_R61581 : public UTFT, public LCD_Common, public Print +{ +public: + LCD_R61581() + { + m_font = FONT_SIZE_MEDIUM; + disp_x_size = 319; + disp_y_size = 479; + orient = LANDSCAPE; + display_transfer_mode = 16; + display_model = CTE35IPS; + __p1 = 38; + __p2 = 39; + __p3 = 40; + __p4 = 41; + __p5 = 0; + + P_RS = portOutputRegister(digitalPinToPort(38)); + B_RS = digitalPinToBitMask(38); + P_WR = portOutputRegister(digitalPinToPort(39)); + B_WR = digitalPinToBitMask(39); + P_CS = portOutputRegister(digitalPinToPort(40)); + B_CS = digitalPinToBitMask(40); + P_RST = portOutputRegister(digitalPinToPort(41)); + B_RST = digitalPinToBitMask(41); + } + void setCursor(uint16_t column, uint8_t line) + { + m_x = column; + m_y = (uint16_t)line * TFT_LINE_HEIGHT; + } + void setXY(uint16_t x, uint16_t y) + { + m_x = x; + m_y = y; + } + void begin(); + void clear(uint16_t x = 0, uint16_t y = 0, uint16_t width = 479, uint16_t height = 319); + void draw(const PROGMEM byte* buffer, uint16_t width, uint16_t height); + void draw(const PROGMEM byte* buffer, uint16_t width, uint16_t height, byte scaleX, byte scaleY = 0); + void draw4bpp(const PROGMEM byte* buffer, uint16_t width, uint16_t height); + size_t write(uint8_t); + void clearLine(byte line) + { + clear(0, line * TFT_LINE_HEIGHT, disp_y_size, 8); + } + void setBackLight(byte brightness); +private: + void setXY(uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2); + void writeDigit(byte n); + void clearPixels(uint32_t pixels); void Enable(); void Disable(); }; diff --git a/libraries/MultiLCD/R61581.cpp b/libraries/MultiLCD/R61581.cpp new file mode 100644 index 0000000..77c3e0c --- /dev/null +++ b/libraries/MultiLCD/R61581.cpp @@ -0,0 +1,416 @@ +/************************************************************************* +* Arduino Text & Bitmap Display Library for color LCDs +* Distributed under GPL v2.0 +* Developed by Stanley Huang <stanleyhuangyc@gmail.com> +* For more information, please visit http://arduinodev.com +*************************************************************************/ + +#include <Arduino.h> +#include "MultiLCD.h" + +/********************************************** +Define zone +**********************************************/ + +#define PIN_BACKLIGHT 8 + + +/********************************************** +Standard C functions zone +**********************************************/ +void LCD_R61581::begin() +{ + delay(50); + pinMode(__p1,OUTPUT); + pinMode(__p2,OUTPUT); + pinMode(__p3,OUTPUT); + if (__p4 != NOTINUSE) + pinMode(__p4,OUTPUT); + if ((display_transfer_mode==LATCHED_16) or ((display_transfer_mode==1) and (display_serial_mode==SERIAL_5PIN))) + pinMode(__p5,OUTPUT); + if (display_transfer_mode!=1) + _set_direction_registers(display_transfer_mode); + + _hw_special_init(); + + sbi(P_RST, B_RST); + delay(5); + cbi(P_RST, B_RST); + delay(15); + sbi(P_RST, B_RST); + delay(15); + + setColor(0xffff); + setBackColor(0); + _transparent = false; + + cbi(P_CS, B_CS); + + LCD_Write_COM(0xB0); + LCD_Write_DATA(0x1E); + + LCD_Write_COM(0xB0); + LCD_Write_DATA(0x00); + + LCD_Write_COM(0xB3); + LCD_Write_DATA(0x02); + LCD_Write_DATA(0x00); + LCD_Write_DATA(0x00); + LCD_Write_DATA(0x10); + + LCD_Write_COM(0xB4); + LCD_Write_DATA(0x00);//0X10 + +// LCD_Write_COM(0xB9); //PWM Settings for Brightness Control +// LCD_Write_DATA(0x01);// Disabled by default. +// LCD_Write_DATA(0xFF); //0xFF = Max brightness +// LCD_Write_DATA(0xFF); +// LCD_Write_DATA(0x18); + + LCD_Write_COM(0xC0); + LCD_Write_DATA(0x03); + LCD_Write_DATA(0x3B);// + LCD_Write_DATA(0x00); + LCD_Write_DATA(0x00); + LCD_Write_DATA(0x00); + LCD_Write_DATA(0x01); + LCD_Write_DATA(0x00);//NW + LCD_Write_DATA(0x43); + + LCD_Write_COM(0xC1); + LCD_Write_DATA(0x08); + LCD_Write_DATA(0x15);//CLOCK + LCD_Write_DATA(0x08); + LCD_Write_DATA(0x08); + + LCD_Write_COM(0xC4); + LCD_Write_DATA(0x15); + LCD_Write_DATA(0x03); + LCD_Write_DATA(0x03); + LCD_Write_DATA(0x01); + + LCD_Write_COM(0xC6); + LCD_Write_DATA(0x02); + + LCD_Write_COM(0xC8); + LCD_Write_DATA(0x0c); + LCD_Write_DATA(0x05); + LCD_Write_DATA(0x0A);//0X12 + LCD_Write_DATA(0x6B);//0x7D + LCD_Write_DATA(0x04); + LCD_Write_DATA(0x06);//0x08 + LCD_Write_DATA(0x15);//0x0A + LCD_Write_DATA(0x10); + LCD_Write_DATA(0x00); + LCD_Write_DATA(0x60);//0x23 + + LCD_Write_COM(0x36); + LCD_Write_DATA(0x0A); + + LCD_Write_COM(0x0C); + LCD_Write_DATA(0x55); + + LCD_Write_COM(0x3A); + LCD_Write_DATA(0x55); + + LCD_Write_COM(0x38); + + LCD_Write_COM(0xD0); + LCD_Write_DATA(0x07); + LCD_Write_DATA(0x07);//VCI1 + LCD_Write_DATA(0x14);//VRH 0x1D + LCD_Write_DATA(0xA2);//BT 0x06 + + LCD_Write_COM(0xD1); + LCD_Write_DATA(0x03); + LCD_Write_DATA(0x5A);//VCM 0x5A + LCD_Write_DATA(0x10);//VDV + + LCD_Write_COM(0xD2); + LCD_Write_DATA(0x03); + LCD_Write_DATA(0x04);//0x24 + LCD_Write_DATA(0x04); + + LCD_Write_COM(0x11); + delay(150); + + LCD_Write_COM(0x2A); + LCD_Write_DATA(0x00); + LCD_Write_DATA(0x00); + LCD_Write_DATA(0x01); + LCD_Write_DATA(0xDF);//320 + + LCD_Write_COM(0x2B); + LCD_Write_DATA(0x00); + LCD_Write_DATA(0x00); + LCD_Write_DATA(0x01); + LCD_Write_DATA(0x3F);//480 + + + delay(100); + + LCD_Write_COM(0x29); + delay(30); + + LCD_Write_COM(0x2C); + delay(30); + + sbi (P_CS, B_CS); + + clear(); + + pinMode(PIN_BACKLIGHT, OUTPUT); + digitalWrite(PIN_BACKLIGHT, HIGH); +} + +void LCD_R61581::setXY(uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2) +{ + swap(word, x1, y1); + swap(word, x2, y2) + //y1=disp_y_size-y1; + //y2=disp_y_size-y2; + //swap(word, y1, y2) + // begin hardware specific code + LCD_Write_COM(0x2a); + LCD_Write_DATA(x1>>8); + LCD_Write_DATA(x1); + LCD_Write_DATA(x2>>8); + LCD_Write_DATA(x2); + LCD_Write_COM(0x2b); + LCD_Write_DATA(y1>>8); + LCD_Write_DATA(y1); + LCD_Write_DATA(y2>>8); + LCD_Write_DATA(y2); + LCD_Write_COM(0x2c); +} + +void LCD_R61581::setBackLight(byte brightness) +{ + analogWrite(PIN_BACKLIGHT, brightness); +} + +void LCD_R61581::Enable() +{ + cbi(P_CS, B_CS); +} +void LCD_R61581::Disable() +{ + sbi(P_CS, B_CS); +} + +void LCD_R61581::clearPixels(uint32_t pixels) +{ + Enable(); + do { + setPixel(bch, bcl); + } while(--pixels); + Disable(); +} + +void LCD_R61581::clear(uint16_t x, uint16_t y, uint16_t width, uint16_t height) +{ + setColor(0); + fillRect(x, y, x + width, y + height); + setColor(0xffff); + m_x = 0; + m_y = 0; +} + +size_t LCD_R61581::write(uint8_t c) +{ + if (c == '\n') { + m_y += (m_font + 1) << 3; + return 0; + } else if (c == '\r') { + m_x = 0; + return 0; + } + if (m_x > disp_y_size) return 0; + Enable(); + if (m_font == FONT_SIZE_SMALL) { + setXY(m_x, m_y, m_x + 4, m_y + 7); + if (c > 0x20 && c < 0x7f) { + for (byte i = 0; i < 5; i++) { + unsigned char d = pgm_read_byte(&font5x8[c - 0x21][i]); + for (byte j = 0; j < 8; j++, d >>= 1) { + if (d & 1) + setPixel(fch, fcl); + else + setPixel(bch, bcl); + } + } + } else { + clearPixels(5 * 8); + } + m_x += 6; + } else { + setXY(m_x, m_y, m_x + 7, m_y + 15); + if (c > 0x20 && c < 0x7f) { + byte pgm_buffer[16]; + memcpy_P(pgm_buffer, &font8x16_terminal[c - 0x21], 16); + for (byte i = 0; i < 16; i += 2) { + unsigned char d = pgm_buffer[i]; + for (byte j = 0; j < 8; j++, d >>= 1) { + if (d & 1) + setPixel(fch, fcl); + else + setPixel(bch, bcl); + } + d = pgm_buffer[i + 1]; + for (byte j = 0; j < 8; j++, d >>= 1) { + if (d & 1) + setPixel(fch, fcl); + else + setPixel(bch, bcl); + } + } + } else { + clearPixels(16 * 8); + } + m_x += 9; + } + Disable(); +} + +void LCD_R61581::writeDigit(byte n) +{ + Enable(); + if (m_font == FONT_SIZE_LARGE) { + setXY(m_x, m_y, m_x + 15, m_y + 15); + if (n <= 9) { + byte pgm_buffer[32]; + memcpy_P(pgm_buffer, &digits16x16[n], sizeof(pgm_buffer)); + for (byte i = 0; i < 16; i++) { + unsigned char d = pgm_buffer[i]; + for (byte j = 0; j < 8; j++, d >>= 1) { + if (d & 1) + setPixel(fch, fcl); + else + setPixel(bch, bcl); + } + d = pgm_buffer[i + 16]; + for (byte j = 0; j < 8; j++, d >>= 1) { + if (d & 1) + setPixel(fch, fcl); + else + setPixel(bch, bcl); + } + } + } else { + clearPixels(16 * 16); + } + m_x += 16; + } else if (m_font == FONT_SIZE_XLARGE) { + setXY(m_x, m_y, m_x + 15, m_y + 23); + if (n <= 9) { + byte pgm_buffer[48]; + memcpy_P(pgm_buffer, &digits16x24[n], sizeof(pgm_buffer)); + for (int i = 0; i < 48; i += 3) { + unsigned char d = pgm_buffer[i]; + for (int j = 0; j < 8; j++, d >>= 1) { + if (d & 1) + setPixel(fch, fcl); + else + setPixel(bch, bcl); + } + d = pgm_buffer[i + 1]; + for (int j = 0; j < 8; j++, d >>= 1) { + if (d & 1) + setPixel(fch, fcl); + else + setPixel(bch, bcl); + } + d = pgm_buffer[i + 2]; + for (int j = 0; j < 8; j++, d >>= 1) { + if (d & 1) + setPixel(fch, fcl); + else + setPixel(bch, bcl); + } + } + } else { + clearPixels(16 * 24); + } + m_x += 18; + } else { + write(n <= 9 ? ('0' + n) : ' '); + } + Disable(); +} + +void LCD_R61581::draw(const PROGMEM byte* buffer, uint16_t width, uint16_t height) +{ + byte rows = height >> 3; + Enable(); + setXY(m_x, m_y, m_x + width - 1, m_y + height - 1); + for (int16_t i = 0; i < width; i++) { + for (uint8_t h = 0; h < rows; h++) { +#ifndef __arm__ + byte d = pgm_read_byte(buffer + i + width * h); +#else + byte d = buffer[i + width * h]; +#endif + for (byte j = 0; j < 8; j++, d >>= 1) { + if (d & 1) { + setPixel(fch, fcl); + } else { + setPixel(bch, bcl); + } + } + } + } + Disable(); + m_x += width; +} + +void LCD_R61581::draw(const PROGMEM byte* buffer, uint16_t width, uint16_t height, byte scaleX, byte scaleY) +{ + byte rows = height >> 3; + if (scaleY == 0) scaleY = scaleX; + Enable(); + setXY(m_x, m_y, m_x + width * scaleX - 1, m_y + height * scaleY - 1); + for (int16_t i = 0; i < width; i++) { + for (byte n = 0; n < scaleX; n++) { + for (uint8_t h = 0; h < rows; h++) { +#ifndef __arm__ + byte d = pgm_read_byte(buffer + i + width * h); +#else + byte d = buffer[i + width * h]; +#endif + for (byte j = 0; j < 8; j++, d >>= 1) { + if (d & 1) { + for (byte m = 0; m < scaleY; m++) { + setPixel(fch, fcl); + } + } else { + for (byte m = 0; m < scaleY; m++) { + setPixel(bch, bcl); + } + } + } + } + } + } + Disable(); + m_x += width * scaleX; +} + +void LCD_R61581::draw4bpp(const PROGMEM byte* buffer, uint16_t width, uint16_t height) +{ + char buf[240]; + Enable(); + setXY(m_x, m_y, m_x + width * 2 - 1, m_y + height * 2 - 1); + for (uint16_t i = 0; i < width; i++) { + memcpy_P(buf, buffer + i * height * 2, height * 2); + for (byte j = 0; j < height * 2; j += 2) { + setPixel(buf[j + 1], buf[j]); + setPixel(buf[j + 1], buf[j]); + } + for (byte j = 0; j < height * 2; j += 2) { + setPixel(buf[j + 1], buf[j]); + setPixel(buf[j + 1], buf[j]); + } + } + Disable(); + m_x += width * 2; +} diff --git a/libraries/MultiLCD/SSD1289.cpp b/libraries/MultiLCD/SSD1289.cpp index 5c5a073..2fc8d8e 100644 --- a/libraries/MultiLCD/SSD1289.cpp +++ b/libraries/MultiLCD/SSD1289.cpp @@ -12,49 +12,15 @@ Define zone **********************************************/ -#define RS 59 -#define WR 58 -#define CS 57 -#define RST 56 - #define PIN_BACKLIGHT 8 -#define X_CONST 240 -#define Y_CONST 320 - -#define PREC_TOUCH_CONST 10 - -#define PixSizeX 13.78 -#define PixOffsX 411 - -#define PixSizeY 11.01 -#define PixOffsY 378 - -#define WINDOW_XADDR_START 0x0050 // Horizontal Start Address Set -#define WINDOW_XADDR_END 0x0051 // Horizontal End Address Set -#define WINDOW_YADDR_START 0x0052 // Vertical Start Address Set -#define WINDOW_YADDR_END 0x0053 // Vertical End Address Set -#define GRAM_XADDR 0x0020 // GRAM Horizontal Address Set -#define GRAM_YADDR 0x0021 // GRAM Vertical Address Set -#define GRAMWR 0x0022 // memory write - -/* LCD color */ -#define White 0xFFFF -#define Black 0x0000 -#define Blue 0x001F -#define Blue2 0x051F -#define Red 0xF800 -#define Magenta 0xF81F -#define Green 0x07E0 -#define Cyan 0x7FFF -#define Yellow 0xFFE0 - /********************************************** Standard C functions zone **********************************************/ void LCD_SSD1289::begin() { - delay(50); + _hw_special_init(); + pinMode(__p1,OUTPUT); pinMode(__p2,OUTPUT); pinMode(__p3,OUTPUT); @@ -65,10 +31,8 @@ void LCD_SSD1289::begin() if (display_transfer_mode!=1) _set_direction_registers(display_transfer_mode); - _hw_special_init(); - sbi(P_RST, B_RST); - delay(5); + delay(5); cbi(P_RST, B_RST); delay(15); sbi(P_RST, B_RST); @@ -121,9 +85,9 @@ void LCD_SSD1289::begin() LCD_Write_COM_DATA(0x25,0x8000); LCD_Write_COM_DATA(0x4f,0x0000); LCD_Write_COM_DATA(0x4e,0x0000); - LCD_Write_COM(0x22); + LCD_Write_COM(0x22); - sbi (P_CS, B_CS); + sbi (P_CS, B_CS); clear(); @@ -144,7 +108,7 @@ void LCD_SSD1289::setXY(uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2) LCD_Write_COM_DATA(0x46,y2); LCD_Write_COM_DATA(0x4e,x1); LCD_Write_COM_DATA(0x4f,y1); - LCD_Write_COM(0x22); + LCD_Write_COM(0x22); } void LCD_SSD1289::setBackLight(byte brightness) @@ -161,18 +125,20 @@ void LCD_SSD1289::Disable() sbi(P_CS, B_CS); } -void LCD_SSD1289::clearPixels(uint16_t pixels) +void LCD_SSD1289::clearPixels(uint32_t pixels) { + Enable(); do { setPixel(bch, bcl); } while(--pixels); + Disable(); } -void LCD_SSD1289::clear() +void LCD_SSD1289::clear(uint16_t x, uint16_t y, uint16_t width, uint16_t height) { - setColor(0); - fillRect(0, 0, 319, 239); - setColor(0xffff); + setColor(0); + fillRect(x, y, x + width, y + height); + setColor(0xffff); m_x = 0; m_y = 0; } @@ -186,7 +152,7 @@ size_t LCD_SSD1289::write(uint8_t c) m_x = 0; return 0; } - if (m_x >= 320) return 0; + if (m_x > disp_y_size) return 0; Enable(); if (m_font == FONT_SIZE_SMALL) { setXY(m_x, m_y, m_x + 4, m_y + 7); diff --git a/libraries/MultiLCD/UTFT.cpp b/libraries/MultiLCD/UTFT.cpp index 59710e9..c46561e 100644 --- a/libraries/MultiLCD/UTFT.cpp +++ b/libraries/MultiLCD/UTFT.cpp @@ -1,6 +1,6 @@ /* - UTFT.cpp - Arduino/chipKit library support for Color TFT LCD Boards - Copyright (C)2010-2014 Henning Karlsen. All right reserved + UTFT.cpp - Multi-Platform library support for Color TFT LCD Boards + Copyright (C)2015 Rinky-Dink Electronics, Henning Karlsen. All right reserved This library is the continuation of my ITDB02_Graph, ITDB02_Graph16 and RGB_GLCD libraries for Arduino and chipKit. As the number of @@ -13,22 +13,17 @@ NKC Electronics (for the RGB GLCD module/shield). This library supports a number of 8bit, 16bit and serial graphic - displays, and will work with both Arduino and chipKit boards. For a - full list of tested display modules and controllers, see the - document UTFT_Supported_display_modules_&_controllers.pdf. + displays, and will work with both Arduino, chipKit boards and select + TI LaunchPads. For a full list of tested display modules and controllers, + see the document UTFT_Supported_display_modules_&_controllers.pdf. When using 8bit and 16bit display modules there are some requirements you must adhere to. These requirements can be found in the document UTFT_Requirements.pdf. There are no special requirements when using serial displays. - You can always find the latest version of the library at - http://electronics.henningkarlsen.com/ - - If you make any modifications or improvements to the code, I would - appreciate that you share the code with me so that I might include - it in the next release. I can be contacted through - http://electronics.henningkarlsen.com/contact.php. + You can find the latest version of the library at + http://www.RinkyDinkElectronics.com/ This library is free software; you can redistribute it and/or modify it under the terms of the CC BY-NC-SA 3.0 license. @@ -43,7 +38,6 @@ */ #include "UTFT.h" -#include <pins_arduino.h> // Include hardware-specific functions for the correct MCU #if defined(__AVR__) @@ -84,6 +78,9 @@ #elif defined(__MK20DX128__) || defined(__MK20DX256__) #pragma message("Compiling for Teensy 3.x (MK20DX128VLH7 / MK20DX256VLH7)...") #include "hardware/arm/HW_MX20DX256.h" + #elif defined(__CC3200R1M1RGC__) + #pragma message("Compiling for TI CC3200 LaunchPad...") + #include "hardware/arm/HW_CC3200.h" #else #error "Unsupported ARM MCU!" #endif @@ -96,9 +93,9 @@ UTFT::UTFT() UTFT::UTFT(byte model, int RS, int WR, int CS, int RST, int SER) { - word dsx[] = {239, 239, 239, 239, 239, 239, 175, 175, 239, 127, 127, 239, 271, 479, 239, 239, 239, 239, 239, 239, 479, 319, 239, 175, 127, 239, 239, 319, 319, 799, 127}; - word dsy[] = {319, 399, 319, 319, 319, 319, 219, 219, 399, 159, 127, 319, 479, 799, 319, 319, 319, 319, 319, 319, 799, 479, 319, 219, 159, 319, 319, 479, 479, 479, 159}; - byte dtm[] = {16, 16, 16, 8, 8, 16, 8, SERIAL_4PIN, 16, SERIAL_5PIN, SERIAL_5PIN, 16, 16, 16, 8, 16, LATCHED_16, 8, 16, 8, 16, 16, 16, 8, SERIAL_5PIN, SERIAL_5PIN, SERIAL_4PIN, 16, 16, 16, SERIAL_5PIN}; + word dsx[] = {239, 239, 239, 239, 239, 239, 175, 175, 239, 127, 127, 239, 271, 479, 239, 239, 239, 0, 0, 239, 479, 319, 239, 175, 127, 239, 239, 319, 319, 799, 127, 127}; + word dsy[] = {319, 399, 319, 319, 319, 319, 219, 219, 399, 159, 127, 319, 479, 799, 319, 319, 319, 0, 0, 319, 799, 479, 319, 219, 159, 319, 319, 479, 479, 479, 159, 159}; + byte dtm[] = {16, 16, 16, 8, 8, 16, 8, SERIAL_4PIN, 16, SERIAL_5PIN, SERIAL_5PIN, 16, 16, 16, 8, 16, LATCHED_16, 0, 0, 8, 16, 16, 16, 8, SERIAL_5PIN, SERIAL_5PIN, SERIAL_4PIN, 16, 16, 16, SERIAL_5PIN, SERIAL_5PIN}; disp_x_size = dsx[model]; disp_y_size = dsy[model]; @@ -124,6 +121,7 @@ UTFT::UTFT(byte model, int RS, int WR, int CS, int RST, int SER) if (display_transfer_mode!=1) { + _set_direction_registers(display_transfer_mode); P_RS = portOutputRegister(digitalPinToPort(RS)); B_RS = digitalPinToBitMask(RS); P_WR = portOutputRegister(digitalPinToPort(WR)); @@ -204,212 +202,11 @@ void UTFT::LCD_Write_COM_DATA(char com1,int dat1) LCD_Write_DATA(dat1>>8,dat1); } -void UTFT::InitLCD() -{ - pinMode(__p1,OUTPUT); - pinMode(__p2,OUTPUT); - pinMode(__p3,OUTPUT); - if (__p4 != NOTINUSE) - pinMode(__p4,OUTPUT); - if ((display_transfer_mode==LATCHED_16) or ((display_transfer_mode==1) and (display_serial_mode==SERIAL_5PIN))) - pinMode(__p5,OUTPUT); - if (display_transfer_mode!=1) - _set_direction_registers(display_transfer_mode); - - _hw_special_init(); - - sbi(P_RST, B_RST); - delay(5); - cbi(P_RST, B_RST); - delay(15); - sbi(P_RST, B_RST); - delay(15); - - cbi(P_CS, B_CS); - - switch(display_model) - { -#ifndef DISABLE_HX8347A - #include "tft_drivers/hx8347a/initlcd.h" -#endif -#ifndef DISABLE_ILI9327 - #include "tft_drivers/ili9327/initlcd.h" -#endif -#ifndef DISABLE_SSD1289 - #include "tft_drivers/ssd1289/initlcd.h" -#endif -#ifndef DISABLE_ILI9325C - #include "tft_drivers/ili9325c/initlcd.h" -#endif -#ifndef DISABLE_ILI9325D - #include "tft_drivers/ili9325d/default/initlcd.h" -#endif -#ifndef DISABLE_ILI9325D_ALT - #include "tft_drivers/ili9325d/alt/initlcd.h" -#endif -#ifndef DISABLE_HX8340B_8 - #include "tft_drivers/hx8340b/8/initlcd.h" -#endif -#ifndef DISABLE_HX8340B_S - #include "tft_drivers/hx8340b/s/initlcd.h" -#endif -#ifndef DISABLE_ST7735 - #include "tft_drivers/st7735/initlcd.h" -#endif -#ifndef DISABLE_PCF8833 - #include "tft_drivers/pcf8833/initlcd.h" -#endif -#ifndef DISABLE_S1D19122 - #include "tft_drivers/s1d19122/initlcd.h" -#endif -#ifndef DISABLE_HX8352A - #include "tft_drivers/hx8352a/initlcd.h" -#endif -#ifndef DISABLE_SSD1963_480 - #include "tft_drivers/ssd1963/480/initlcd.h" -#endif -#ifndef DISABLE_SSD1963_800 - #include "tft_drivers/ssd1963/800/initlcd.h" -#endif -#ifndef DISABLE_SSD1963_800_ALT - #include "tft_drivers/ssd1963/800alt/initlcd.h" -#endif -#ifndef DISABLE_S6D1121 - #include "tft_drivers/s6d1121/initlcd.h" -#endif -#ifndef DISABLE_ILI9320 - #include "tft_drivers/ili9320/initlcd.h" -#endif -#ifndef DISABLE_ILI9481 - #include "tft_drivers/ili9481/initlcd.h" -#endif -#ifndef DISABLE_S6D0164 - #include "tft_drivers/s6d0164/initlcd.h" -#endif -#ifndef DISABLE_ST7735S - #include "tft_drivers/st7735s/initlcd.h" -#endif -#ifndef DISABLE_ILI9341_S4P - #include "tft_drivers/ili9341/s4p/initlcd.h" -#endif -#ifndef DISABLE_ILI9341_S5P - #include "tft_drivers/ili9341/s5p/initlcd.h" -#endif -#ifndef DISABLE_R61581 - #include "tft_drivers/r61581/initlcd.h" -#endif -#ifndef DISABLE_ILI9486 - #include "tft_drivers/ili9486/initlcd.h" -#endif -#ifndef DISABLE_CPLD - #include "tft_drivers/cpld/initlcd.h" -#endif -#ifndef DISABLE_HX8353C - #include "tft_drivers/hx8353c/initlcd.h" -#endif - } - - sbi (P_CS, B_CS); - - setColor(0xffff); - setBackColor(0); - cfont.font=0; - _transparent = false; -} - -void UTFT::setXY(word x1, word y1, word x2, word y2) -{ - swap(word, x1, y1); - swap(word, x2, y2) - y1=disp_y_size-y1; - y2=disp_y_size-y2; - swap(word, y1, y2) - - switch(display_model) - { -#ifndef DISABLE_HX8347A - #include "tft_drivers/hx8347a/setxy.h" -#endif -#ifndef DISABLE_HX8352A - #include "tft_drivers/hx8352a/setxy.h" -#endif -#ifndef DISABLE_ILI9327 - #include "tft_drivers/ili9327/setxy.h" -#endif -#ifndef DISABLE_SSD1289 - #include "tft_drivers/ssd1289/setxy.h" -#endif -#ifndef DISABLE_ILI9325C - #include "tft_drivers/ili9325c/setxy.h" -#endif -#ifndef DISABLE_ILI9325D - #include "tft_drivers/ili9325d/default/setxy.h" -#endif -#ifndef DISABLE_ILI9325D_ALT - #include "tft_drivers/ili9325d/alt/setxy.h" -#endif -#ifndef DISABLE_HX8340B_8 - #include "tft_drivers/hx8340b/8/setxy.h" -#endif -#ifndef DISABLE_HX8340B_S - #include "tft_drivers/hx8340b/s/setxy.h" -#endif -#ifndef DISABLE_ST7735 - #include "tft_drivers/st7735/setxy.h" -#endif -#ifndef DISABLE_S1D19122 - #include "tft_drivers/s1d19122/setxy.h" -#endif -#ifndef DISABLE_PCF8833 - #include "tft_drivers/pcf8833/setxy.h" -#endif -#ifndef DISABLE_SSD1963_480 - #include "tft_drivers/ssd1963/480/setxy.h" -#endif -#ifndef DISABLE_SSD1963_800 - #include "tft_drivers/ssd1963/800/setxy.h" -#endif -#ifndef DISABLE_SSD1963_800_ALT - #include "tft_drivers/ssd1963/800alt/setxy.h" -#endif -#ifndef DISABLE_S6D1121 - #include "tft_drivers/s6d1121/setxy.h" -#endif -#ifndef DISABLE_ILI9320 - #include "tft_drivers/ili9320/setxy.h" -#endif -#ifndef DISABLE_ILI9481 - #include "tft_drivers/ili9481/setxy.h" -#endif -#ifndef DISABLE_S6D0164 - #include "tft_drivers/s6d0164/setxy.h" -#endif -#ifndef DISABLE_ST7735S - #include "tft_drivers/st7735s/setxy.h" -#endif -#ifndef DISABLE_ILI9341_S4P - #include "tft_drivers/ili9341/s4p/setxy.h" -#endif -#ifndef DISABLE_ILI9341_S5P - #include "tft_drivers/ili9341/s5p/setxy.h" -#endif -#ifndef DISABLE_R61581 - #include "tft_drivers/r61581/setxy.h" -#endif -#ifndef DISABLE_ILI9486 - #include "tft_drivers/ili9486/setxy.h" -#endif -#ifndef DISABLE_CPLD - #include "tft_drivers/cpld/setxy.h" -#endif -#ifndef DISABLE_HX8353C - #include "tft_drivers/hx8353c/setxy.h" -#endif - } -} - void UTFT::clrXY() { + if (orient==PORTRAIT) + setXY(0,0,disp_x_size,disp_y_size); + else setXY(0,0,disp_y_size,disp_x_size); } @@ -481,12 +278,22 @@ void UTFT::fillRect(int x1, int y1, int x2, int y2) } else { - + if (orient==PORTRAIT) + { + for (int i=0; i<((y2-y1)/2)+1; i++) + { + drawHLine(x1, y1+i, x2-x1); + drawHLine(x1, y2-i, x2-x1); + } + } + else + { for (int i=0; i<((x2-x1)/2)+1; i++) { drawVLine(x1+i, y1, y2-y1); drawVLine(x2-i, y1, y2-y1); } + } } } @@ -675,11 +482,16 @@ void UTFT::setBackColor(byte r, byte g, byte b) _transparent=false; } -void UTFT::setBackColor(word color) +void UTFT::setBackColor(uint32_t color) { - bch=byte(color>>8); - bcl=byte(color & 0xFF); - _transparent=false; + if (color==VGA_TRANSPARENT) + _transparent=true; + else + { + bch=byte(color>>8); + bcl=byte(color & 0xFF); + _transparent=false; + } } word UTFT::getBackColor() @@ -692,18 +504,18 @@ void UTFT::setPixel(word color) LCD_Write_DATA((color>>8),(color&0xFF)); // rrrrrggggggbbbbb } -void UTFT::setPixel(char ch, char cl) +void UTFT::setPixel(byte h, byte l) { - LCD_Write_DATA(ch,cl); // rrrrrggggggbbbbb + LCD_Write_DATA(h, l); // rrrrrggggggbbbbb } void UTFT::drawPixel(int x, int y) { cbi(P_CS, B_CS); setXY(x, y, x, y); - setPixel(fch, fcl); + setPixel((fch<<8)|fcl); sbi(P_CS, B_CS); - //clrXY(); + clrXY(); } void UTFT::drawLine(int x1, int y1, int x2, int y2) @@ -822,30 +634,45 @@ void UTFT::drawVLine(int x, int y, int l) clrXY(); } -size_t UTFT::write(byte c) +void UTFT::printChar(byte c, int x, int y) { byte i,ch; word j; word temp; - if (c < ' ') { - if (c == '\r') { - m_x = 0; - } else if (c == '\n') { - m_y += cfont.y_size; - } - return 1; - } - cbi(P_CS, B_CS); if (!_transparent) { + if (orient==PORTRAIT) + { + setXY(x,y,x+cfont.x_size-1,y+cfont.y_size-1); + + temp=((c-cfont.offset)*((cfont.x_size/8)*cfont.y_size))+4; + for(j=0;j<((cfont.x_size/8)*cfont.y_size);j++) + { + ch=pgm_read_byte(&cfont.font[temp]); + for(i=0;i<8;i++) + { + if((ch&(1<<(7-i)))!=0) + { + setPixel((fch<<8)|fcl); + } + else + { + setPixel((bch<<8)|bcl); + } + } + temp++; + } + } + else + { temp=((c-cfont.offset)*((cfont.x_size/8)*cfont.y_size))+4; for(j=0;j<((cfont.x_size/8)*cfont.y_size);j+=(cfont.x_size/8)) { - setXY(m_x,m_y+(j/(cfont.x_size/8)),m_x+cfont.x_size-1,m_y+(j/(cfont.x_size/8))); + setXY(x,y+(j/(cfont.x_size/8)),x+cfont.x_size-1,y+(j/(cfont.x_size/8))); for (int zz=(cfont.x_size/8)-1; zz>=0; zz--) { ch=pgm_read_byte(&cfont.font[temp+zz]); @@ -853,16 +680,17 @@ size_t UTFT::write(byte c) { if((ch&(1<<i))!=0) { - setPixel(fch, fcl); + setPixel((fch<<8)|fcl); } else { - setPixel(bch, bcl); + setPixel((bch<<8)|bcl); } } } temp+=(cfont.x_size/8); } + } } else { @@ -874,11 +702,11 @@ size_t UTFT::write(byte c) ch=pgm_read_byte(&cfont.font[temp+zz]); for(i=0;i<8;i++) { - setXY(m_x+i+(zz*8),m_y+j,m_x+i+(zz*8)+1,m_y+j+1); if((ch&(1<<(7-i)))!=0) { - setPixel(fch, fcl); + setXY(x+i+(zz*8),y+j,x+i+(zz*8)+1,y+j+1); + setPixel((fch<<8)|fcl); } } } @@ -888,8 +716,187 @@ size_t UTFT::write(byte c) sbi(P_CS, B_CS); clrXY(); - m_x += cfont.x_size; - return 1; +} + +void UTFT::rotateChar(byte c, int x, int y, int pos, int deg) +{ + byte i,j,ch; + word temp; + int newx,newy; + double radian; + radian=deg*0.0175; + + cbi(P_CS, B_CS); + + temp=((c-cfont.offset)*((cfont.x_size/8)*cfont.y_size))+4; + for(j=0;j<cfont.y_size;j++) + { + for (int zz=0; zz<(cfont.x_size/8); zz++) + { + ch=pgm_read_byte(&cfont.font[temp+zz]); + for(i=0;i<8;i++) + { + newx=x+(((i+(zz*8)+(pos*cfont.x_size))*cos(radian))-((j)*sin(radian))); + newy=y+(((j)*cos(radian))+((i+(zz*8)+(pos*cfont.x_size))*sin(radian))); + + setXY(newx,newy,newx+1,newy+1); + + if((ch&(1<<(7-i)))!=0) + { + setPixel((fch<<8)|fcl); + } + else + { + if (!_transparent) + setPixel((bch<<8)|bcl); + } + } + } + temp+=(cfont.x_size/8); + } + sbi(P_CS, B_CS); + clrXY(); +} + +void UTFT::print2(char *st, int x, int y, int deg) +{ + int stl, i; + + stl = strlen(st); + + if (orient==PORTRAIT) + { + if (x==RIGHT) + x=(disp_x_size+1)-(stl*cfont.x_size); + if (x==CENTER) + x=((disp_x_size+1)-(stl*cfont.x_size))/2; + } + else + { + if (x==RIGHT) + x=(disp_y_size+1)-(stl*cfont.x_size); + if (x==CENTER) + x=((disp_y_size+1)-(stl*cfont.x_size))/2; + } + + for (i=0; i<stl; i++) + if (deg==0) + printChar(*st++, x + (i*(cfont.x_size)), y); + else + rotateChar(*st++, x, y, i, deg); +} + +void UTFT::print2(String st, int x, int y, int deg) +{ + char buf[st.length()+1]; + + st.toCharArray(buf, st.length()+1); + print2(buf, x, y, deg); +} + +void UTFT::printNumI(long num, int x, int y, int length, char filler) +{ + char buf[25]; + char st[27]; + boolean neg=false; + int c=0, f=0; + + if (num==0) + { + if (length!=0) + { + for (c=0; c<(length-1); c++) + st[c]=filler; + st[c]=48; + st[c+1]=0; + } + else + { + st[0]=48; + st[1]=0; + } + } + else + { + if (num<0) + { + neg=true; + num=-num; + } + + while (num>0) + { + buf[c]=48+(num % 10); + c++; + num=(num-(num % 10))/10; + } + buf[c]=0; + + if (neg) + { + st[0]=45; + } + + if (length>(c+neg)) + { + for (int i=0; i<(length-c-neg); i++) + { + st[i+neg]=filler; + f++; + } + } + + for (int i=0; i<c; i++) + { + st[i+neg+f]=buf[c-i-1]; + } + st[c+neg+f]=0; + + } + + print2(st,x,y); +} + +void UTFT::printNumF(double num, byte dec, int x, int y, char divider, int length, char filler) +{ + char st[27]; + boolean neg=false; + + if (dec<1) + dec=1; + else if (dec>5) + dec=5; + + if (num<0) + neg = true; + + _convert_float(st, num, length, dec); + + if (divider != '.') + { + for (int i=0; i<sizeof(st); i++) + if (st[i]=='.') + st[i]=divider; + } + + if (filler != ' ') + { + if (neg) + { + st[0]='-'; + for (int i=1; i<sizeof(st); i++) + if ((st[i]==' ') || (st[i]=='-')) + st[i]=filler; + } + else + { + for (int i=0; i<sizeof(st); i++) + if (st[i]==' ') + st[i]=filler; + } + } + + print2(st,x,y); } void UTFT::setFont(uint8_t* font) @@ -923,6 +930,19 @@ void UTFT::drawBitmap(int x, int y, int sx, int sy, bitmapdatatype data, int sca if (scale==1) { + if (orient==PORTRAIT) + { + cbi(P_CS, B_CS); + setXY(x, y, x+sx-1, y+sy-1); + for (tc=0; tc<(sx*sy); tc++) + { + col=pgm_read_word(&data[tc]); + LCD_Write_DATA(col>>8,col & 0xff); + } + sbi(P_CS, B_CS); + } + else + { cbi(P_CS, B_CS); for (ty=0; ty<sy; ty++) { @@ -934,9 +954,28 @@ void UTFT::drawBitmap(int x, int y, int sx, int sy, bitmapdatatype data, int sca } } sbi(P_CS, B_CS); + } } else { + if (orient==PORTRAIT) + { + cbi(P_CS, B_CS); + for (ty=0; ty<sy; ty++) + { + setXY(x, y+(ty*scale), x+((sx*scale)-1), y+(ty*scale)+scale); + for (tsy=0; tsy<scale; tsy++) + for (tx=0; tx<sx; tx++) + { + col=pgm_read_word(&data[(ty*sx)+tx]); + for (tsx=0; tsx<scale; tsx++) + LCD_Write_DATA(col>>8,col & 0xff); + } + } + sbi(P_CS, B_CS); + } + else + { cbi(P_CS, B_CS); for (ty=0; ty<sy; ty++) { @@ -952,6 +991,7 @@ void UTFT::drawBitmap(int x, int y, int sx, int sy, bitmapdatatype data, int sca } } sbi(P_CS, B_CS); + } } clrXY(); } @@ -983,3 +1023,107 @@ void UTFT::drawBitmap(int x, int y, int sx, int sy, bitmapdatatype data, int deg } clrXY(); } + +void UTFT::lcdOff() +{ + cbi(P_CS, B_CS); + switch (display_model) + { + case PCF8833: + LCD_Write_COM(0x28); + break; + case CPLD: + LCD_Write_COM_DATA(0x01,0x0000); + LCD_Write_COM(0x0F); + break; + } + sbi(P_CS, B_CS); +} + +void UTFT::lcdOn() +{ + cbi(P_CS, B_CS); + switch (display_model) + { + case PCF8833: + LCD_Write_COM(0x29); + break; + case CPLD: + LCD_Write_COM_DATA(0x01,0x0010); + LCD_Write_COM(0x0F); + break; + } + sbi(P_CS, B_CS); +} + +void UTFT::setContrast(char c) +{ + cbi(P_CS, B_CS); + switch (display_model) + { + case PCF8833: + if (c>64) c=64; + LCD_Write_COM(0x25); + LCD_Write_DATA(c); + break; + } + sbi(P_CS, B_CS); +} + +int UTFT::getDisplayXSize() +{ + if (orient==PORTRAIT) + return disp_x_size+1; + else + return disp_y_size+1; +} + +int UTFT::getDisplayYSize() +{ + if (orient==PORTRAIT) + return disp_y_size+1; + else + return disp_x_size+1; +} + +void UTFT::setBrightness(byte br) +{ + cbi(P_CS, B_CS); + switch (display_model) + { + case CPLD: + if (br>16) br=16; + LCD_Write_COM_DATA(0x01,br); + LCD_Write_COM(0x0F); + break; + } + sbi(P_CS, B_CS); +} + +void UTFT::setDisplayPage(byte page) +{ + cbi(P_CS, B_CS); + switch (display_model) + { + case CPLD: + if (page>7) page=7; + LCD_Write_COM_DATA(0x04,page); + LCD_Write_COM(0x0F); + break; + } + sbi(P_CS, B_CS); +} + +void UTFT::setWritePage(byte page) +{ + cbi(P_CS, B_CS); + switch (display_model) + { + case CPLD: + if (page>7) page=7; + LCD_Write_COM_DATA(0x05,page); + LCD_Write_COM(0x0F); + break; + } + sbi(P_CS, B_CS); +} diff --git a/libraries/MultiLCD/UTFT.h b/libraries/MultiLCD/UTFT.h index 6e0c8cb..8402e86 100644 --- a/libraries/MultiLCD/UTFT.h +++ b/libraries/MultiLCD/UTFT.h @@ -1,6 +1,6 @@ /* - UTFT.h - Arduino/chipKit library support for Color TFT LCD Boards - Copyright (C)2010-2014 Henning Karlsen. All right reserved + UTFT.h - Multi-Platform library support for Color TFT LCD Boards + Copyright (C)2015 Rinky-Dink Electronics, Henning Karlsen. All right reserved This library is the continuation of my ITDB02_Graph, ITDB02_Graph16 and RGB_GLCD libraries for Arduino and chipKit. As the number of @@ -13,22 +13,17 @@ NKC Electronics (for the RGB GLCD module/shield). This library supports a number of 8bit, 16bit and serial graphic - displays, and will work with both Arduino and chipKit boards. For a - full list of tested display modules and controllers, see the - document UTFT_Supported_display_modules_&_controllers.pdf. + displays, and will work with both Arduino, chipKit boards and select + TI LaunchPads. For a full list of tested display modules and controllers, + see the document UTFT_Supported_display_modules_&_controllers.pdf. When using 8bit and 16bit display modules there are some requirements you must adhere to. These requirements can be found in the document UTFT_Requirements.pdf. There are no special requirements when using serial displays. - You can always find the latest version of the library at - http://electronics.henningkarlsen.com/ - - If you make any modifications or improvements to the code, I would - appreciate that you share the code with me so that I might include - it in the next release. I can be contacted through - http://electronics.henningkarlsen.com/contact.php. + You can find the latest version of the library at + http://www.RinkyDinkElectronics.com/ This library is free software; you can redistribute it and/or modify it under the terms of the CC BY-NC-SA 3.0 license. @@ -45,7 +40,7 @@ #ifndef UTFT_h #define UTFT_h -#define UTFT_VERSION 276 +#define UTFT_VERSION 281 #define LEFT 0 #define RIGHT 9999 @@ -71,8 +66,8 @@ #define S6D1121_8 14 #define S6D1121_16 15 #define SSD1289LATCHED 16 -#define ILI9320_8 17 -#define ILI9320_16 18 +//#define NOT_IN_USE 17 +//#define NOT_IN_USE 18 #define SSD1289_8 19 #define SSD1963_800ALT 20 #define ILI9481 21 @@ -85,6 +80,7 @@ #define ILI9486 28 #define CPLD 29 #define HX8353C 30 +#define ST7735_ALT 31 #define ITDB32 0 // HX8347-A (16bit) #define ITDB32WC 1 // ILI9327 (16bit) @@ -92,7 +88,6 @@ #define ITDB32S 2 // SSD1289 (16bit) #define TFT01_32 2 // SSD1289 (16bit) #define CTE32 2 // SSD1289 (16bit) -#define GEEE32 2 // SSD1289 (16bit) #define ITDB24 3 // ILI9325C (8bit) #define ITDB24D 4 // ILI9325D (8bit) #define ITDB24DWOT 4 // ILI9325D (8bit) @@ -102,7 +97,6 @@ #define DMTFT28103 4 // ILI9325D (8bit) #define TFT01_24_16 5 // ILI9325D (16bit) #define ITDB22 6 // HX8340-B (8bit) -#define GEEE22 6 // HX8340-B (8bit) #define ITDB22SP 7 // HX8340-B (Serial 4Pin) #define ITDB32WD 8 // HX8352-A (16bit) #define TFT01_32WD 8 // HX8352-A (16bit) @@ -121,8 +115,8 @@ #define ITDB24E_16 15 // S6D1121 (16bit) #define INFINIT32 16 // SSD1289 (Latched 16bit) -- Legacy, will be removed later #define ELEE32_REVA 16 // SSD1289 (Latched 16bit) -#define GEEE24 17 // ILI9320 (8bit) -#define GEEE28 18 // ILI9320 (16bit) +//#define NOT_IN_USE 17 +//#define NOT_IN_USE 18 #define ELEE32_REVB 19 // SSD1289 (8bit) #define TFT01_70 20 // SSD1963 (16bit) 800x480 Alternative Init #define CTE70 20 // SSD1963 (16bit) 800x480 Alternative Init @@ -135,6 +129,8 @@ #define DMTFT22102 23 // S6D0164 (8bit) #define TFT01_18SP 24 // ST7735S (Serial 5Pin) #define TFT01_22SP 25 // ILI9341 (Serial 5Pin) +#define TFT01_24SP 25 // ILI9341 (Serial 5Pin) +#define TFT22SHLD 25 // ILI9341 (Serial 5Pin) #define DMTFT28105 25 // ILI9341 (Serial 5Pin) #define MI0283QT9 26 // ILI9341 (Serial 4Pin) #define CTE35IPS 27 // R61581 (16bit) @@ -143,7 +139,7 @@ #define CTE50CPLD 29 // CPLD (16bit) #define CTE70CPLD 29 // CPLD (16bit) #define DMTFT18101 30 // HX8353C (Serial 5Pin) - +#define TFT18SHLD 31 // ST7735 (Serial 5Pin) Alternative Init #define SERIAL_4PIN 4 #define SERIAL_5PIN 5 @@ -180,7 +176,7 @@ #include "WProgram.h" #include "hardware/pic32/HW_PIC32_defines.h" #elif defined(__arm__) - #include "Arduino.h" + #include "Arduino.h" // This will include energia.h where appropriate #include "hardware/arm/HW_ARM_defines.h" #endif @@ -193,12 +189,12 @@ struct _current_font uint8_t numchars; }; -class UTFT : public Print +class UTFT { public: UTFT(); UTFT(byte model, int RS, int WR, int CS, int RST, int SER=0); - void InitLCD(); + void InitLCD(byte orientation=LANDSCAPE); void clrScr(); void drawPixel(int x, int y); void drawLine(int x1, int y1, int x2, int y2); @@ -214,28 +210,27 @@ class UTFT : public Print void setColor(word color); word getColor(); void setBackColor(byte r, byte g, byte b); - void setBackColor(word color); + void setBackColor(uint32_t color); word getBackColor(); - void setTransparent(bool transparent) - { - _transparent = transparent; - } + void print2(char *st, int x, int y, int deg=0); + void print2(String st, int x, int y, int deg=0); + void printNumI(long num, int x, int y, int length=0, char filler=' '); + void printNumF(double num, byte dec, int x, int y, char divider='.', int length=0, char filler=' '); void setFont(uint8_t* font); uint8_t* getFont(); uint8_t getFontXsize(); uint8_t getFontYsize(); void drawBitmap(int x, int y, int sx, int sy, bitmapdatatype data, int scale=1); void drawBitmap(int x, int y, int sx, int sy, bitmapdatatype data, int deg, int rox, int roy); - virtual void setXY(int x, int y) - { - m_x = x; - m_y = y; - } - virtual size_t write(byte c); + void lcdOff(); + void lcdOn(); + void setContrast(char c); + int getDisplayXSize(); + int getDisplayYSize(); + void setBrightness(byte br); + void setDisplayPage(byte page); + void setWritePage(byte page); - int m_x; - int m_y; - /* The functions and variables below should not normally be used. They have been left publicly available for use in add-on libraries @@ -244,8 +239,9 @@ class UTFT : public Print Please note that these functions and variables are not documented and I do not provide support on how to use them. */ - byte fcl, fch, bcl, bch; - word disp_x_size, disp_y_size; + byte fch, fcl, bch, bcl; + byte orient; + long disp_x_size, disp_y_size; byte display_model, display_transfer_mode, display_serial_mode; regtype *P_RS, *P_WR, *P_CS, *P_RST, *P_SDA, *P_SCL, *P_ALE; regsize B_RS, B_WR, B_CS, B_RST, B_SDA, B_SCL, B_ALE; @@ -260,16 +256,21 @@ class UTFT : public Print void LCD_Write_COM_DATA(char com1,int dat1); void _hw_special_init(); void setPixel(word color); - void setPixel(char ch, char cl); + void setPixel(byte h, byte l); void drawHLine(int x, int y, int l); void drawVLine(int x, int y, int l); - virtual void setXY(word x1, word y1, word x2, word y2); + void printChar(byte c, int x, int y); + virtual void setXY(word x1, word y1, word x2, word y2) = 0; void clrXY(); void rotateChar(byte c, int x, int y, int pos, int deg); void _set_direction_registers(byte mode); void _fast_fill_16(int ch, int cl, long pix); void _fast_fill_8(int ch, long pix); void _convert_float(char *buf, double num, int width, byte prec); + +#if defined(ENERGIA) + volatile uint32_t* portOutputRegister(int value); +#endif }; #endif diff --git a/libraries/MultiLCD/hardware/arm/HW_ARM_defines.h b/libraries/MultiLCD/hardware/arm/HW_ARM_defines.h index 2881e17..8df5f97 100644 --- a/libraries/MultiLCD/hardware/arm/HW_ARM_defines.h +++ b/libraries/MultiLCD/hardware/arm/HW_ARM_defines.h @@ -15,8 +15,13 @@ //******************************************************************** // *** Hardwarespecific defines *** -#define cbi(reg, bitmask) *reg &= ~bitmask -#define sbi(reg, bitmask) *reg |= bitmask +#if defined(ENERGIA) + #define cbi(reg, bitmask) HWREG((uint32_t)reg + 0x3FC) &= ~bitmask + #define sbi(reg, bitmask) HWREG((uint32_t)reg + 0x3FC) |= bitmask +#else + #define cbi(reg, bitmask) *reg &= ~bitmask + #define sbi(reg, bitmask) *reg |= bitmask +#endif #define pulse_high(reg, bitmask) sbi(reg, bitmask); cbi(reg, bitmask); #define pulse_low(reg, bitmask) cbi(reg, bitmask); sbi(reg, bitmask); diff --git a/libraries/MultiLCD/memorysaver.h b/libraries/MultiLCD/memorysaver.h index 34575eb..fafed8b 100644 --- a/libraries/MultiLCD/memorysaver.h +++ b/libraries/MultiLCD/memorysaver.h @@ -32,7 +32,7 @@ #define DISABLE_PCF8833 1 // LPH9135 -#define DISABLE_R61581 1 // CTE35IPS +//#define DISABLE_R61581 1 // CTE35IPS #define DISABLE_S1D19122 1 // ITDB25H #define DISABLE_S6D0164 1 // CTE22 / DMTFT22102 @@ -43,3 +43,4 @@ #define DISABLE_SSD1963_800_ALT 1 // TFT01_70 / CTE70 / EHOUSE70 #define DISABLE_ST7735 1 // ITDB18SP #define DISABLE_ST7735S 1 // TFT01_18SP +#define DISABLE_ST7735_ALT 1
\ No newline at end of file |