diff options
-rw-r--r-- | libraries/MultiLCD/ILI9325D.cpp | 27 | ||||
-rw-r--r-- | libraries/MultiLCD/ILI9341.cpp | 590 | ||||
-rw-r--r-- | libraries/MultiLCD/ILI9341.h | 161 | ||||
-rw-r--r-- | libraries/MultiLCD/MultiLCD.cpp | 196 | ||||
-rw-r--r-- | libraries/MultiLCD/MultiLCD.h | 105 | ||||
-rw-r--r-- | libraries/MultiLCD/SSD1306.cpp | 8 | ||||
-rw-r--r-- | libraries/MultiLCD/SSD1306.h | 9 | ||||
-rw-r--r-- | libraries/MultiLCD/ZtLib.cpp | 607 | ||||
-rw-r--r-- | libraries/MultiLCD/ZtLib.h | 128 |
9 files changed, 853 insertions, 978 deletions
diff --git a/libraries/MultiLCD/ILI9325D.cpp b/libraries/MultiLCD/ILI9325D.cpp index 6ffd27a..f977d94 100644 --- a/libraries/MultiLCD/ILI9325D.cpp +++ b/libraries/MultiLCD/ILI9325D.cpp @@ -227,7 +227,7 @@ void LCD_ILI9325D::begin() clear(); } -void LCD_ILI9325D::SetXY(uint16_t x0,uint16_t x1,uint16_t y1,uint16_t y0) +void LCD_ILI9325D::setXY(uint16_t x0,uint16_t x1,uint16_t y1,uint16_t y0) { y1 = 319 - y1; y0 = 319 - y0; @@ -263,7 +263,7 @@ void LCD_ILI9325D::clearPixels(uint16_t pixels) void LCD_ILI9325D::clear(uint16_t x, uint16_t y, uint16_t width, uint16_t height) { unsigned long count = (unsigned long)width * height; - SetXY(y, y + height - 1, x, x + width - 1); + setXY(y, y + height - 1, x, x + width - 1); digitalWrite(RS,HIGH);//LCD_RS=0; digitalWrite(CS,LOW);//LCD_CS =0; @@ -288,17 +288,14 @@ size_t LCD_ILI9325D::write(uint8_t c) m_x += (m_font + 1) << 3; return 0; } else if (c == '\r') { - SetXY(m_x, m_x + 7, m_y, 319); - uint16_t count = (320 - m_y) * 8; - for (uint16_t i=0; i < count; i++) { - WriteData(0, 0); - } + setXY(m_x, m_x + 7, m_y, 319); + clearPixels((320 - m_y) * 8); m_y = 0; return 0; } if (m_font == FONT_SIZE_SMALL) { - SetXY(m_x, m_x + 7, m_y, m_y + 4); + setXY(m_x, m_x + 7, m_y, m_y + 4); m_y += 6; if (m_y >= 320) { m_x += (m_font + 1) << 3; @@ -321,7 +318,7 @@ size_t LCD_ILI9325D::write(uint8_t c) clearPixels(5 * 8); } } else { - SetXY(m_x, m_x + 15, m_y, m_y + 7); + setXY(m_x, m_x + 15, m_y, m_y + 7); m_y += 9; if (m_y >= 320) { m_x += (m_font + 1) << 3; @@ -352,7 +349,7 @@ size_t LCD_ILI9325D::write(uint8_t c) void LCD_ILI9325D::writeDigit(byte n) { if (m_font == FONT_SIZE_SMALL) { - SetXY(m_x, m_x + 7, m_y, m_y + 7); + setXY(m_x, m_x + 7, m_y, m_y + 7); m_y += 8; if (n <= 9) { byte pgm_buffer[8]; @@ -371,7 +368,7 @@ void LCD_ILI9325D::writeDigit(byte n) } else if (m_font == FONT_SIZE_MEDIUM) { write(n <= 9 ? ('0' + n) : ' '); } else if (m_font == FONT_SIZE_LARGE) { - SetXY(m_x, m_x + 15, m_y, m_y + 15); + setXY(m_x, m_x + 15, m_y, m_y + 15); m_y += 16; if (n <= 9) { byte pgm_buffer[32]; @@ -390,7 +387,7 @@ void LCD_ILI9325D::writeDigit(byte n) clearPixels(16 * 16); } } else if (m_font == FONT_SIZE_XLARGE) { - SetXY(m_x, m_x + 23, m_y, m_y + 15); + setXY(m_x, m_x + 23, m_y, m_y + 15); m_y += 18; if (n <= 9) { byte pgm_buffer[48]; @@ -418,7 +415,7 @@ void LCD_ILI9325D::writeDigit(byte n) void LCD_ILI9325D::draw(const PROGMEM byte* buffer, uint16_t x, uint16_t y, uint16_t width, uint16_t height) { byte rows = height >> 3; - SetXY(y, y + height - 1, x, x + width - 1); + setXY(y, y + height - 1, x, x + width - 1); uint16_t i = width - 1; do { for (uint8_t h = 0; h < rows; h++) { @@ -434,7 +431,7 @@ void LCD_ILI9325D::draw2x(const PROGMEM byte* buffer, uint16_t x, uint16_t y, by { char buf[240]; uint16_t pixels = (uint16_t)width * height; - SetXY(y, y + height * 2 - 1, x, x + width * 2- 1); + setXY(y, y + height * 2 - 1, x, x + width * 2- 1); uint16_t i = width - 1; do { memcpy_P(buf, buffer + (uint16_t)i * height * 2, height * 2); @@ -451,7 +448,7 @@ void LCD_ILI9325D::draw2x(const PROGMEM byte* buffer, uint16_t x, uint16_t y, by void LCD_ILI9325D::draw4bpp(const PROGMEM byte* buffer, uint16_t x, uint16_t y, uint16_t width, uint16_t height) { - SetXY(y, y + height - 1, x, x + width - 1); + setXY(y, y + height - 1, x, x + width - 1); uint16_t i = (uint16_t)width * height / 2 - 1; do { byte d = pgm_read_byte_far(buffer + i); diff --git a/libraries/MultiLCD/ILI9341.cpp b/libraries/MultiLCD/ILI9341.cpp new file mode 100644 index 0000000..61bf7f9 --- /dev/null +++ b/libraries/MultiLCD/ILI9341.cpp @@ -0,0 +1,590 @@ +#include <Arduino.h> +#include <SPI.h> +#include "MultiLCD.h" + +/* Pins +D4 : RESET +D5 : CS +D6 : D/C +D7 : LED +D11 : MOSI +D12 : MISO +D13 : SCK +*/ + +#define PIN_RESET 4 +#define PIN_CS 5 +#define PIN_DC 6 +#define PIN_LED 7 + +//Basic Colors +#define RED 0xf800 +#define GREEN 0x07e0 +#define BLUE 0x001f +#define BLACK 0x0000 +#define YELLOW 0xffe0 +#define WHITE 0xffff + +//Other Colors +#define CYAN 0x07ff +#define BRIGHT_RED 0xf810 +#define GRAY1 0x8410 +#define GRAY2 0x4208 + +//TFT resolution 240*320 +#define MIN_X 0 +#define MIN_Y 0 +#define MAX_X 239 +#define MAX_Y 319 + +#define TFT_CS_LOW digitalWrite(PIN_CS, LOW) +#define TFT_CS_HIGH digitalWrite(PIN_CS, HIGH) +#define TFT_DC_LOW digitalWrite(PIN_DC, LOW) +#define TFT_DC_HIGH digitalWrite(PIN_DC, HIGH) +#define TFT_RST_OFF digitalWrite(PIN_RESET, HIGH) +#define TFT_RST_ON digitalWrite(PIN_RESET, LOW) + + +#define YP A2 // must be an analog pin, use "An" notation! +#define XM A1 // must be an analog pin, use "An" notation! +#define YM 14 // can be a digital pin, this is A0 +#define XP 17 // can be a digital pin, this is A3 + +#define TS_MINX 116*2 +#define TS_MAXX 890*2 +#define TS_MINY 83*2 +#define TS_MAXY 913*2 + +void LCD_ILI9341::sendCMD(uint8_t index) +{ + TFT_DC_LOW; + TFT_CS_LOW; + SPI.transfer(index); + TFT_CS_HIGH; +} + +void LCD_ILI9341::WRITE_DATA(uint8_t data) +{ + TFT_DC_HIGH; + TFT_CS_LOW; + SPI.transfer(data); + TFT_CS_HIGH; +} + +void LCD_ILI9341::sendData(uint16_t data) +{ + uint8_t data1 = data>>8; + uint8_t data2 = data&0xff; + TFT_DC_HIGH; + TFT_CS_LOW; + SPI.transfer(data1); + SPI.transfer(data2); + TFT_CS_HIGH; +} + +void LCD_ILI9341::WRITE_Package(uint16_t *data, uint8_t howmany) +{ + uint16_t data1 = 0; + uint8_t data2 = 0; + + TFT_DC_HIGH; + TFT_CS_LOW; + uint8_t count=0; + for(count=0;count<howmany;count++) + { + data1 = data[count]>>8; + data2 = data[count]&0xff; + SPI.transfer(data1); + SPI.transfer(data2); + } + TFT_CS_HIGH; +} + +uint8_t LCD_ILI9341::Read_Register(uint8_t Addr, uint8_t xParameter) +{ + uint8_t data=0; + sendCMD(0xd9); /* ext command */ + WRITE_DATA(0x10+xParameter); /* 0x11 is the first Parameter */ + TFT_DC_LOW; + TFT_CS_LOW; + SPI.transfer(Addr); + TFT_DC_HIGH; + data = SPI.transfer(0); + TFT_CS_HIGH; + return data; +} + +void LCD_ILI9341::begin (void) +{ + pinMode(PIN_CS, OUTPUT); + pinMode(PIN_DC, OUTPUT); + pinMode(PIN_LED, OUTPUT); + pinMode(PIN_RESET, OUTPUT); + + SPI.begin(); + TFT_CS_HIGH; + TFT_DC_HIGH; + uint8_t i=0, TFTDriver=0; + + TFT_RST_ON; + delay(10); + TFT_RST_OFF; + + for(i=0;i<3;i++) + { + TFTDriver = readID(); + } + + sendCMD(0xCB); + WRITE_DATA(0x39); + WRITE_DATA(0x2C); + WRITE_DATA(0x00); + WRITE_DATA(0x34); + WRITE_DATA(0x02); + + sendCMD(0xCF); + WRITE_DATA(0x00); + WRITE_DATA(0XC1); + WRITE_DATA(0X30); + + sendCMD(0xE8); + WRITE_DATA(0x85); + WRITE_DATA(0x00); + WRITE_DATA(0x78); + + sendCMD(0xEA); + WRITE_DATA(0x00); + WRITE_DATA(0x00); + + sendCMD(0xED); + WRITE_DATA(0x64); + WRITE_DATA(0x03); + WRITE_DATA(0X12); + WRITE_DATA(0X81); + + sendCMD(0xF7); + WRITE_DATA(0x20); + + sendCMD(0xC0); //Power control + WRITE_DATA(0x23); //VRH[5:0] + + sendCMD(0xC1); //Power control + WRITE_DATA(0x10); //SAP[2:0];BT[3:0] + + sendCMD(0xC5); //VCM control + WRITE_DATA(0x3e); //Contrast + WRITE_DATA(0x28); + + sendCMD(0xC7); //VCM control2 + WRITE_DATA(0x86); //-- + + sendCMD(0x36); // Memory Access Control + WRITE_DATA(0x48); //C8 + + sendCMD(0x3A); + WRITE_DATA(0x55); + + sendCMD(0xB1); + WRITE_DATA(0x00); + WRITE_DATA(0x18); + + sendCMD(0xB6); // Display Function Control + WRITE_DATA(0x08); + WRITE_DATA(0x82); + WRITE_DATA(0x27); + + sendCMD(0xF2); // 3Gamma Function Disable + WRITE_DATA(0x00); + + sendCMD(0x26); //Gamma curve selected + WRITE_DATA(0x01); + + sendCMD(0xE0); //Set Gamma + WRITE_DATA(0x0F); + WRITE_DATA(0x31); + WRITE_DATA(0x2B); + WRITE_DATA(0x0C); + WRITE_DATA(0x0E); + WRITE_DATA(0x08); + WRITE_DATA(0x4E); + WRITE_DATA(0xF1); + WRITE_DATA(0x37); + WRITE_DATA(0x07); + WRITE_DATA(0x10); + WRITE_DATA(0x03); + WRITE_DATA(0x0E); + WRITE_DATA(0x09); + WRITE_DATA(0x00); + + sendCMD(0XE1); //Set Gamma + WRITE_DATA(0x00); + WRITE_DATA(0x0E); + WRITE_DATA(0x14); + WRITE_DATA(0x03); + WRITE_DATA(0x11); + WRITE_DATA(0x07); + WRITE_DATA(0x31); + WRITE_DATA(0xC1); + WRITE_DATA(0x48); + WRITE_DATA(0x08); + WRITE_DATA(0x0F); + WRITE_DATA(0x0C); + WRITE_DATA(0x31); + WRITE_DATA(0x36); + WRITE_DATA(0x0F); + + sendCMD(0x11); //Exit Sleep + delay(120); + + sendCMD(0x29); //Display on + sendCMD(0x2c); + clear(); +} + +uint8_t LCD_ILI9341::readID(void) +{ + uint8_t i=0; + uint8_t data[3] ; + uint8_t ID[3] = {0x00, 0x93, 0x41}; + uint8_t ToF=1; + for(i=0;i<3;i++) + { + data[i]=Read_Register(0xd3,i+1); + if(data[i] != ID[i]) + { + ToF=0; + } + } + if(!ToF) /* data!=ID */ + { +#if 0 + Serial.print("Read TFT ID failed, ID should be 0x09341, but read ID = 0x"); + for(i=0;i<3;i++) + { + Serial.print(data[i],HEX); + } + Serial.println(); +#endif + } + return ToF; +} + +void LCD_ILI9341::setCol(uint16_t StartCol,uint16_t EndCol) +{ + sendCMD(0x2A); /* Column Command address */ + sendData(StartCol); + sendData(EndCol); +} + +void LCD_ILI9341::setPage(uint16_t StartPage,uint16_t EndPage) +{ + sendCMD(0x2B); /* Column Command address */ + sendData(StartPage); + sendData(EndPage); +} + +void LCD_ILI9341::clear(uint16_t XL, uint16_t XR, uint16_t YU, uint16_t YD, uint16_t color) +{ + unsigned long XY=0; + unsigned long i=0; + + if(XL > XR) + { + XL = XL^XR; + XR = XL^XR; + XL = XL^XR; + } + if(YU > YD) + { + YU = YU^YD; + YD = YU^YD; + YU = YU^YD; + } + XL = constrain(XL, MIN_X,MAX_X); + XR = constrain(XR, MIN_X,MAX_X); + YU = constrain(YU, MIN_Y,MAX_Y); + YD = constrain(YD, MIN_Y,MAX_Y); + + XY = (XR-XL+1); + XY = XY*(YD-YU+1); + + setCol(XL,XR); + setPage(YU, YD); + sendCMD(0x2c); /* start to write to display ra */ + /* m */ + + TFT_DC_HIGH; + TFT_CS_LOW; + + uint8_t Hcolor = color>>8; + uint8_t Lcolor = color&0xff; + for(i=0; i < XY; i++) + { + SPI.transfer(Hcolor); + SPI.transfer(Lcolor); + } + + TFT_CS_HIGH; +} + +void LCD_ILI9341::clear(void) +{ + setCol(0, 239); + setPage(0, 319); + sendCMD(0x2c); /* start to write to display ra */ + /* m */ + + TFT_DC_HIGH; + TFT_CS_LOW; + for(uint16_t i=0; i<38400; i++) + { + SPI.transfer(0); + SPI.transfer(0); + SPI.transfer(0); + SPI.transfer(0); + } + TFT_CS_HIGH; + + m_x = 0; + m_y = 0; +} + + +void LCD_ILI9341::setXY(uint16_t x0, uint16_t x1, uint16_t y0, uint16_t y1) +{ + setCol(x0, x1); + setPage(319 - y1, 319 - y0); + sendCMD(0x2c); +} + +void LCD_ILI9341::setPixel(uint16_t poX, uint16_t poY,uint16_t color) +{ + setXY(poX, poY, poX, poY); + sendData(color); +} + +void LCD_ILI9341::backlight(bool on) +{ + digitalWrite(PIN_LED, on); +} + +void LCD_ILI9341::clearPixels(uint16_t pixels) +{ + TFT_DC_HIGH; + TFT_CS_LOW; + for(uint16_t i = 0; i < pixels; i++) + { + SPI.transfer(0); + SPI.transfer(0); + SPI.transfer(0); + SPI.transfer(0); + } + TFT_CS_HIGH; +} + +size_t LCD_ILI9341::write(uint8_t c) +{ + if (c == '\n') { + m_x += (m_font + 1) << 3; + return 0; + } else if (c == '\r') { + setXY(m_x, m_x + 7, m_y, 319); + clearPixels((320 - m_y) * 8); + m_y = 0; + return 0; + } + + if (m_font == FONT_SIZE_SMALL) { + setXY(m_x, m_x + 7, m_y, m_y + 4); + m_y += 6; + if (m_y >= 320) { + m_x += (m_font + 1) << 3; + m_y = 0; + if (m_x >= 240) { + m_x = 0; + } + } + if (c > 0x20 && c < 0x7f) { + byte pgm_buffer[5]; + memcpy_P(pgm_buffer, &font5x8[c - 0x21], 5); + byte i = 4; + TFT_DC_HIGH; + TFT_CS_LOW; + do { + unsigned char d = pgm_buffer[i]; + for (byte j = 0; j < 8; j++, d >>= 1) { + SPI.transfer(m_color[d & 1][1]); + SPI.transfer(m_color[d & 1][0]); + } + } while (i--); + TFT_CS_HIGH; + } else { + clearPixels(5 * 8); + } + } else { + setXY(m_x, m_x + 15, m_y, m_y + 7); + m_y += 9; + if (m_y >= 320) { + m_x += (m_font + 1) << 3; + m_y = 0; + if (m_x >= 240) { + m_x = 0; + } + } + if (c > 0x20 && c < 0x7f) { + byte pgm_buffer[16]; + memcpy_P(pgm_buffer, &font8x16_terminal[c - 0x21], 16); + TFT_DC_HIGH; + TFT_CS_LOW; + for (byte i = 0; i < 16; i += 2) { + unsigned char d = pgm_buffer[14 - i]; + for (byte j = 0; j < 8; j++, d >>= 1) { + SPI.transfer(m_color[d & 1][1]); + SPI.transfer(m_color[d & 1][0]); + } + d = pgm_buffer[15 - i]; + for (byte j = 0; j < 8; j++, d >>= 1) { + SPI.transfer(m_color[d & 1][1]); + SPI.transfer(m_color[d & 1][0]); + } + } + TFT_CS_HIGH; + } else { + clearPixels(8 * 16); + } + } +} + +void LCD_ILI9341::writeDigit(byte n) +{ + if (m_font == FONT_SIZE_SMALL) { + setXY(m_x, m_x + 7, m_y, m_y + 7); + sendCMD(0x2c); + if (n <= 9) { + byte pgm_buffer[8]; + memcpy_P(pgm_buffer, &digits8x8[n], 8); + byte i = 7; + TFT_DC_HIGH; + TFT_CS_LOW; + do { + unsigned char d = pgm_buffer[i]; + for (byte j = 0; j < 8; j++, d >>= 1) { + SPI.transfer(m_color[d & 1][1]); + SPI.transfer(m_color[d & 1][0]); + } + } while (i--); + TFT_CS_HIGH; + m_y += 8; + } else { + clearPixels(8 * 8); + } + } else if (m_font == FONT_SIZE_MEDIUM) { + write(n <= 9 ? ('0' + n) : ' '); + } else if (m_font == FONT_SIZE_LARGE) { + setXY(m_x, m_x + 15, m_y, m_y + 15); + m_y += 16; + if (n <= 9) { + byte pgm_buffer[32]; + memcpy_P(pgm_buffer, &digits16x16[n], sizeof(pgm_buffer)); + TFT_DC_HIGH; + TFT_CS_LOW; + for (byte i = 0; i < 16; i++) { + unsigned char d = pgm_buffer[15 - i]; + for (byte j = 0; j < 8; j++, d >>= 1) { + SPI.transfer(m_color[d & 1][1]); + SPI.transfer(m_color[d & 1][0]); + } + d = pgm_buffer[31 - i]; + for (byte j = 0; j < 8; j++, d >>= 1) { + SPI.transfer(m_color[d & 1][1]); + SPI.transfer(m_color[d & 1][0]); + } + } + TFT_CS_HIGH; + } else { + clearPixels(16 * 16); + } + } else if (m_font == FONT_SIZE_XLARGE) { + setXY(m_x, m_x + 23, m_y, m_y + 15); + m_y += 18; + if (n <= 9) { + byte pgm_buffer[48]; + memcpy_P(pgm_buffer, &digits16x24[n], sizeof(pgm_buffer)); + TFT_DC_HIGH; + TFT_CS_LOW; + for (int i = 0; i < 48; i += 3) { + unsigned char d = pgm_buffer[45 - i]; + for (int j = 0; j < 8; j++, d >>= 1) { + SPI.transfer(m_color[d & 1][1]); + SPI.transfer(m_color[d & 1][0]); + } + d = pgm_buffer[46 - i]; + for (int j = 0; j < 8; j++, d >>= 1) { + SPI.transfer(m_color[d & 1][1]); + SPI.transfer(m_color[d & 1][0]); + } + d = pgm_buffer[47 - i]; + for (int j = 0; j < 8; j++, d >>= 1) { + SPI.transfer(m_color[d & 1][1]); + SPI.transfer(m_color[d & 1][0]); + } + } + TFT_CS_HIGH; + } else { + clearPixels(16 * 24); + } + } +} + +void LCD_ILI9341::draw(const PROGMEM byte* buffer, uint16_t x, uint16_t y, uint16_t width, uint16_t height) +{ + byte rows = height >> 3; + setXY(y, y + height - 1, x, x + width - 1); + uint16_t i = width - 1; + TFT_DC_HIGH; + TFT_CS_LOW; + do { + for (uint8_t h = 0; h < rows; h++) { + byte d = pgm_read_byte(buffer + i + width * h); + for (byte j = 0; j < 8; j++, d >>= 1) { + SPI.transfer(m_color[d & 1][1]); + SPI.transfer(m_color[d & 1][0]); + } + } + } while (i--); + TFT_CS_HIGH; +} + +void LCD_ILI9341::draw2x(const PROGMEM byte* buffer, uint16_t x, uint16_t y, byte width, byte height) +{ + byte rows = height >> 3; + setXY(y, y + height * 2 - 1, x, x + width * 2 - 1); + uint16_t i = width - 1; + TFT_DC_HIGH; + TFT_CS_LOW; + do { + for (uint8_t h = 0; h < rows; h++) { + byte d = pgm_read_byte(buffer + i + width * h); + for (byte j = 0; j < 8; j++, d >>= 1) { + byte h = m_color[d & 1][1]; + byte l = m_color[d & 1][0]; + SPI.transfer(h); + SPI.transfer(l); + SPI.transfer(h); + SPI.transfer(l); + } + } + for (uint8_t h = 0; h < rows; h++) { + byte d = pgm_read_byte(buffer + i + width * h); + for (byte j = 0; j < 8; j++, d >>= 1) { + byte h = m_color[d & 1][1]; + byte l = m_color[d & 1][0]; + SPI.transfer(h); + SPI.transfer(l); + SPI.transfer(h); + SPI.transfer(l); + } + } + } while (i--); + TFT_CS_HIGH; +} diff --git a/libraries/MultiLCD/ILI9341.h b/libraries/MultiLCD/ILI9341.h new file mode 100644 index 0000000..e0075c4 --- /dev/null +++ b/libraries/MultiLCD/ILI9341.h @@ -0,0 +1,161 @@ +/* + 2012 Copyright (c) Seeed Technology Inc. + + Authors: Albert.Miao & Loovee, + Visweswara R (with initializtion code from TFT vendor) + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +*/ +#ifndef TFTv2_h +#define TFTv2_h + +#if defined(ARDUINO) && ARDUINO >= 100 +#define SEEEDUINO +#include <Arduino.h> +#else +#include <WProgram.h> +#endif +#include <avr/pgmspace.h> + +#include <SPI.h> + +//Basic Colors +#define RED 0xf800 +#define GREEN 0x07e0 +#define BLUE 0x001f +#define BLACK 0x0000 +#define YELLOW 0xffe0 +#define WHITE 0xffff + +//Other Colors +#define CYAN 0x07ff +#define BRIGHT_RED 0xf810 +#define GRAY1 0x8410 +#define GRAY2 0x4208 + +//TFT resolution 240*320 +#define MIN_X 0 +#define MIN_Y 0 +#define MAX_X 239 +#define MAX_Y 319 + +#if defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__) + +#define TFT_CS_LOW {DDRE |= 0x08;PORTE &=~ 0x08;} +#define TFT_CS_HIGH {DDRE |= 0x08;PORTE |= 0x08;} +#define TFT_DC_LOW {DDRH |= 0x08;PORTH &=~ 0x08;} +#define TFT_DC_HIGH {DDRH |= 0x08;PORTH |= 0x08;} +#define TFT_BL_OFF {DDRH |= 0x10;PORTH &=~ 0x10;} +#define TFT_BL_ON {DDRH |= 0x10;PORTH |= 0x10;} +#define TFT_RST_OFF {DDRD |= 0x10;PORTD |= 0x10;} +#define TFT_RST_ON {DDRD |= 0x10;PORTD &=~ 0x10;} + +#define YP A2 // must be an analog pin, use "An" notation! +#define XM A1 // must be an analog pin, use "An" notation! +#define YM 54 // can be a digital pin, this is A0 +#define XP 57 // can be a digital pin, this is A3 + +#elif defined(__AVR_ATmega32U4__) + +#define TFT_CS_LOW {DDRC |= 0x40;PORTC &=~ 0x40;} +#define TFT_CS_HIGH {DDRC |= 0x40;PORTC |= 0x40;} +#define TFT_DC_LOW {DDRD |= 0x80;PORTD &=~ 0x80;} +#define TFT_DC_HIGH {DDRD |= 0x80;PORTD |= 0x80;} +#define TFT_BL_OFF {DDRE |= 0x40;PORTE &=~ 0x40;} +#define TFT_BL_ON {DDRE |= 0x40;PORTE |= 0x40;} +#define TFT_RST_OFF {DDRD |= 0x10;PORTD |= 0x10;} +#define TFT_RST_ON {DDRD |= 0x10;PORTD &=~ 0x10;} + +#define YP A2 // must be an analog pin, use "An" notation! +#define XM A1 // must be an analog pin, use "An" notation! +#define YM 18 // can be a digital pin, this is A0 +#define XP 21 // can be a digital pin, this is A3 + +#else +#define TFT_CS_LOW {DDRD |= 0x20;PORTD &=~ 0x20;} +#define TFT_CS_HIGH {DDRD |= 0x20;PORTD |= 0x20;} +#define TFT_DC_LOW {DDRD |= 0x40;PORTD &=~ 0x40;} +#define TFT_DC_HIGH {DDRD |= 0x40;PORTD |= 0x40;} +#define TFT_BL_OFF {DDRD |= 0x80;PORTD &=~ 0x80;} +#define TFT_BL_ON {DDRD |= 0x80;PORTD |= 0x80;} +#define TFT_RST_OFF {DDRD |= 0x10;PORTD |= 0x10;} +#define TFT_RST_ON {DDRD |= 0x10;PORTD &=~ 0x10;} + + +#define YP A2 // must be an analog pin, use "An" notation! +#define XM A1 // must be an analog pin, use "An" notation! +#define YM 14 // can be a digital pin, this is A0 +#define XP 17 // can be a digital pin, this is A3 + +#endif + +#define TS_MINX 116*2 +#define TS_MAXX 890*2 +#define TS_MINY 83*2 +#define TS_MAXY 913*2 + +#ifndef INT8U +#define INT8U unsigned char +#endif +#ifndef INT16U +#define INT16U unsigned int +#endif + +extern const PROGMEM unsigned char simpleFont[][8]; + +class TFT +{ +public: + void TFTinit (void); + void setCol(INT16U StartCol,INT16U EndCol); + void setPage(INT16U StartPage,INT16U EndPage); + void setXY(INT16U poX, INT16U poY); + void setPixel(INT16U poX, INT16U poY,INT16U color); + void sendCMD(INT8U index); + void WRITE_Package(INT16U *data,INT8U howmany); + void WRITE_DATA(INT8U data); + void sendData(INT16U data); + INT8U Read_Register(INT8U Addr,INT8U xParameter); + void fillScreen(INT16U XL,INT16U XR,INT16U YU,INT16U YD,INT16U color); + void fillScreen(void); + INT8U readID(void); + + void drawChar(INT8U ascii,INT16U poX, INT16U poY,INT16U size, INT16U fgcolor); + void drawString(char *string,INT16U poX, INT16U poY,INT16U size,INT16U fgcolor); + void fillRectangle(INT16U poX, INT16U poY, INT16U length, INT16U width, INT16U color); + + void drawLine(INT16U x0,INT16U y0,INT16U x1,INT16U y1,INT16U color); + void drawVerticalLine(INT16U poX, INT16U poY,INT16U length,INT16U color); + void drawHorizontalLine(INT16U poX, INT16U poY,INT16U length,INT16U color); + void drawRectangle(INT16U poX, INT16U poY, INT16U length,INT16U width,INT16U color); + + void drawCircle(int poX, int poY, int r,INT16U color); + void fillCircle(int poX, int poY, int r,INT16U color); + + void drawTraingle(int poX1, int poY1, int poX2, int poY2, int poX3, int poY3, INT16U color); + INT8U drawNumber(long long_num,INT16U poX, INT16U poY,INT16U size,INT16U fgcolor); + INT8U drawFloat(float floatNumber,INT8U decimal,INT16U poX, INT16U poY,INT16U size,INT16U fgcolor); + INT8U drawFloat(float floatNumber,INT16U poX, INT16U poY,INT16U size,INT16U fgcolor); + +}; + +extern TFT Tft; + +#endif + +/********************************************************************************************************* + END FILE +*********************************************************************************************************/ diff --git a/libraries/MultiLCD/MultiLCD.cpp b/libraries/MultiLCD/MultiLCD.cpp index 2d46b59..cb3c3a5 100644 --- a/libraries/MultiLCD/MultiLCD.cpp +++ b/libraries/MultiLCD/MultiLCD.cpp @@ -9,10 +9,10 @@ #include <Wire.h> #include "MultiLCD.h" -void LCD_Common::printInt(unsigned int value, char padding) +void LCD_Common::printInt(uint16_t value, int8_t padding) { - unsigned int den = 10000; - for (byte i = 5; i > 0; i--) { + uint16_t den = 10000; + for (int8_t i = 5; i > 0; i--) { byte v = (byte)(value / den); value -= v * den; den /= 10; @@ -27,10 +27,10 @@ void LCD_Common::printInt(unsigned int value, char padding) } } -void LCD_Common::printLong(unsigned long value, char padding) +void LCD_Common::printLong(uint32_t value, int8_t padding) { - unsigned long den = 1000000000; - for (byte i = 10; i > 0; i--) { + uint32_t den = 1000000000; + for (int8_t i = 10; i > 0; i--) { byte v = (byte)(value / den); value -= v * den; den /= 10; @@ -45,98 +45,6 @@ void LCD_Common::printLong(unsigned long value, char padding) } } -void LCD_ZTOLED::setCursor(byte column, byte line) -{ - m_column = column; - m_page = line; - ScI2cMxSetLocation(OLED_ADDRESS, m_page, m_column); - delay(1); -} - -size_t LCD_ZTOLED::write(uint8_t c) -{ - if (c == '\n') { - m_column = 0; - m_page += (m_font == FONT_SIZE_SMALL) ? 1 : 2; - return 0; - } else if (c == '\r') { - m_column = 0; - return 0; - } - if (m_font == FONT_SIZE_SMALL) { - if (c <= 0x20 || c >= 0x7f) { - ScI2cMxFillArea(OLED_ADDRESS, m_column, m_column + 5, m_page, m_page, 0); - } else { - ScI2cMxDisplayDot(OLED_ADDRESS, font5x8[c - 0x21], 5); - } - m_column += 6; - ScI2cMxSetLocation(OLED_ADDRESS, m_page, m_column); - } else { - char s[2] = {c}; - ScI2cMxDisplay8x16Str(OLED_ADDRESS, m_page, m_column, s); - m_column += 8; - ScI2cMxSetLocation(OLED_ADDRESS, m_page, m_column); - } - return 1; -} - -/* -void LCD_ZTOLED::print(const char* s) -{ - ScI2cMxDisplay8x16Str(OLED_ADDRESS, m_page, m_column, s); - m_column += (strlen(s) << 3); - m_page += (m_column >> 7) << 1; - m_column %= 0x7f; -} -*/ - -void LCD_ZTOLED::writeDigit(byte n) -{ - if (m_font == FONT_SIZE_SMALL) { - if (n <= 9) - ScI2cMxDisplayDot(OLED_ADDRESS, font5x8[n + ('0' - 0x21)], 5); - else - ScI2cMxFillArea(OLED_ADDRESS, m_column, m_column + 5, m_page, m_page, 0); - m_column += 6; - ScI2cMxSetLocation(OLED_ADDRESS, m_page, m_column); - } else if (m_font == FONT_SIZE_MEDIUM) { - if (n <= 9) { - ScI2cMxDisplayDot(OLED_ADDRESS, digits8x8[n], 8); - } else { - ScI2cMxFillArea(OLED_ADDRESS, m_column, m_column + 7, m_page, m_page, 0); - - } - m_column += 8; - ScI2cMxSetLocation(OLED_ADDRESS, m_page, m_column); - } else if (m_font == FONT_SIZE_LARGE) { - write('0' + n); - } else { - unsigned char data[32]; - if (n <= 9) { - memcpy_P(data, digits16x16[n], 32); - } else { - memset(data, 0, sizeof(data)); - } - ScI2cMxDisplayDot16x16(OLED_ADDRESS, m_page, m_column, data); - m_column += 16; - ScI2cMxSetLocation(OLED_ADDRESS, m_page, m_column); - } -} - -void LCD_ZTOLED::clear() -{ - ScI2cMxFillArea(OLED_ADDRESS, 0, 7, 0, 127, 0); - delay(10); - setCursor(0, 0); -} - -void LCD_ZTOLED::begin() -{ - I2cInit(); - ScI2cMxReset(OLED_ADDRESS); - clear(); -} - void LCD_PCD8544::writeDigit(byte n) { if (m_font == FONT_SIZE_SMALL) { @@ -280,8 +188,8 @@ size_t LCD_SSD1306::write(uint8_t c) void LCD_SSD1306::writeDigit(byte n) { - uint8_t twbrbackup = TWBR; - TWBR = 18; // upgrade to 400KHz! + //uint8_t twbrbackup = TWBR; + //TWBR = 18; // upgrade to 400KHz! if (m_font == FONT_SIZE_SMALL) { Wire.beginTransmission(_i2caddr); Wire.write(0x40); @@ -299,73 +207,7 @@ void LCD_SSD1306::writeDigit(byte n) Wire.endTransmission(); m_col += 6; } else if (m_font == FONT_SIZE_MEDIUM) { -#ifndef MEMORY_SAVING - if (n <= 9) { - n += '0' - 0x21; - ssd1306_command(0xB0 + m_row);//set page address - ssd1306_command(m_col & 0xf);//set lower column address - ssd1306_command(0x10 | (m_col >> 4));//set higher column address - - Wire.beginTransmission(_i2caddr); - Wire.write(0x40); - for (byte i = 0; i <= 14; i += 2) { - byte d = pgm_read_byte(&font8x16_terminal[n][i]); - Wire.write(d); - if (m_flags & FLAG_PIXEL_DOUBLE_H) Wire.write(d); - } - Wire.endTransmission(); - - ssd1306_command(0xB0 + m_row + 1);//set page address - ssd1306_command(m_col & 0xf);//set lower column address - ssd1306_command(0x10 | (m_col >> 4));//set higher column address - - Wire.beginTransmission(_i2caddr); - Wire.write(0x40); - for (byte i = 1; i <= 15; i += 2) { - byte d = pgm_read_byte(&font8x16_terminal[n][i]); - Wire.write(d); - if (m_flags & FLAG_PIXEL_DOUBLE_H) Wire.write(d); - } - Wire.endTransmission(); - } else { - ssd1306_command(0xB0 + m_row);//set page address - ssd1306_command(m_col & 0xf);//set lower column address - ssd1306_command(0x10 | (m_col >> 4));//set higher column address - - Wire.beginTransmission(_i2caddr); - Wire.write(0x40); - for (byte i = (m_flags & FLAG_PIXEL_DOUBLE_H) ? 16 : 8; i > 0; i--) { - Wire.write(0); - } - Wire.endTransmission(); - - ssd1306_command(0xB0 + m_row + 1);//set page address - ssd1306_command(m_col & 0xf);//set lower column address - ssd1306_command(0x10 | (m_col >> 4));//set higher column address - - Wire.beginTransmission(_i2caddr); - Wire.write(0x40); - for (byte i = (m_flags & FLAG_PIXEL_DOUBLE_H) ? 16 : 8; i > 0; i--) { - Wire.write(0); - } - Wire.endTransmission(); - } - m_col += (m_flags & FLAG_PIXEL_DOUBLE_H) ? 17 : 9; -#else - Wire.beginTransmission(_i2caddr); - Wire.write(0x40); - if (n <= 9) { - for (byte i = 0; i < 8; i++) { - Wire.write(pgm_read_byte(&digits8x8[n][i])); - } - } else { - for (byte i = 0; i < 8; i++) { - Wire.write(0); - } - } - Wire.endTransmission(); - m_col += 8; -#endif + write(n <= 9 ? ('0' + n) : ' '); } else if (m_font == FONT_SIZE_LARGE) { if (n <= 9) { byte i; @@ -495,7 +337,7 @@ void LCD_SSD1306::writeDigit(byte n) } m_col += (m_flags & FLAG_PIXEL_DOUBLE_H) ? 30 : 16; } - TWBR = twbrbackup; + //TWBR = twbrbackup; } void LCD_SSD1306::draw(const PROGMEM byte* buffer, byte x, byte y, byte width, byte height) @@ -505,8 +347,8 @@ void LCD_SSD1306::draw(const PROGMEM byte* buffer, byte x, byte y, byte width, b ssd1306_command(SSD1306_SETSTARTLINE | 0x0); // line #0 // save I2C bitrate - uint8_t twbrbackup = TWBR; - TWBR = 18; // upgrade to 400KHz! + //uint8_t twbrbackup = TWBR; + //TWBR = 18; // upgrade to 400KHz! const PROGMEM byte *p = buffer; height >>= 3; @@ -527,7 +369,7 @@ void LCD_SSD1306::draw(const PROGMEM byte* buffer, byte x, byte y, byte width, b Wire.endTransmission(); } } - TWBR = twbrbackup; + //TWBR = twbrbackup; } void LCD_SSD1306::clearLine(byte line) @@ -537,8 +379,8 @@ void LCD_SSD1306::clearLine(byte line) ssd1306_command(SSD1306_SETSTARTLINE | 0x0); // line #0 // save I2C bitrate - uint8_t twbrbackup = TWBR; - TWBR = 18; // upgrade to 400KHz! + //uint8_t twbrbackup = TWBR; + //TWBR = 18; // upgrade to 400KHz! // send a bunch of data in one xmission ssd1306_command(0xB0 + line);//set page address @@ -554,7 +396,7 @@ void LCD_SSD1306::clearLine(byte line) Wire.endTransmission(); } - TWBR = twbrbackup; + //TWBR = twbrbackup; } void LCD_SSD1306::clear(byte x, byte y, byte width, byte height) @@ -564,8 +406,8 @@ void LCD_SSD1306::clear(byte x, byte y, byte width, byte height) ssd1306_command(SSD1306_SETSTARTLINE | 0x0); // line #0 // save I2C bitrate - uint8_t twbrbackup = TWBR; - TWBR = 18; // upgrade to 400KHz! + //uint8_t twbrbackup = TWBR; + //TWBR = 18; // upgrade to 400KHz! height >>= 3; width >>= 3; @@ -587,5 +429,5 @@ void LCD_SSD1306::clear(byte x, byte y, byte width, byte height) } setCursor(0, 0); - TWBR = twbrbackup; + //TWBR = twbrbackup; } diff --git a/libraries/MultiLCD/MultiLCD.h b/libraries/MultiLCD/MultiLCD.h index 7799a19..126ca0e 100644 --- a/libraries/MultiLCD/MultiLCD.h +++ b/libraries/MultiLCD/MultiLCD.h @@ -33,8 +33,8 @@ public: void setFlags(byte flags) { m_flags = flags; } virtual void backlight(bool on) {} virtual void draw(const PROGMEM byte* buffer, byte x, byte y, byte width, byte height) {} - void printInt(uint16_t value, char padding = -1); - void printLong(unsigned long value, char padding = -1); + void printInt(uint16_t value, int8_t padding = -1); + void printLong(uint32_t value, int8_t padding = -1); protected: virtual void writeDigit(byte n) {} byte m_font; @@ -73,32 +73,6 @@ private: void writeDigit(byte n); }; -#include "ZtLib.h" - -#define OLED_ADDRESS 0x27 - -class LCD_ZTOLED : public LCD_Common, public ZtLib, public Print -{ -public: - byte getLines() { return 4; } - byte getCols() { return 16; } - void setCursor(byte column, byte line); - size_t write(uint8_t c); - //void print(const char* s); - void writeDigit(byte n); - void clear(); - void begin(); - void backlight(bool on) {} - void clearLine(byte line) - { - setCursor(0, line); - for (byte i = 16; i > 0; i--) write(' '); - } -private: - unsigned char m_column; - unsigned char m_page; -}; - #include "LCD4Bit_mod.h" class LCD_1602 : public LCD_Common, public LCD4Bit_mod { @@ -134,19 +108,24 @@ private: byte m_row; }; +#define TFT_LINE_HEIGHT 10 + class LCD_ILI9325D : public LCD_Common, public Print { public: - LCD_ILI9325D():m_lineHeight(10) { m_font = FONT_SIZE_MEDIUM; } + LCD_ILI9325D() { m_font = FONT_SIZE_MEDIUM; } void setCursor(uint16_t column, uint16_t line) { m_y = column; - m_x = line * m_lineHeight; + m_x = line * TFT_LINE_HEIGHT; } - void setColor(uint16_t textColor, uint16_t bgColor = 0) + void setTextColor(uint8_t R, uint8_t G, uint8_t B) { - m_color[0] = bgColor; - m_color[1] = textColor; + m_color[1] = ((uint16_t)R << 11) | ((uint16_t)G << 5) | B; + } + void SetBGColor(uint8_t R, uint8_t G, uint8_t B) + { + m_color[0] = ((uint16_t)R << 11) | ((uint16_t)G << 5) | B; } void begin(); void clear(uint16_t x = 0, uint16_t y = 0, uint16_t width = 320, uint16_t height = 240); @@ -156,15 +135,14 @@ public: size_t write(uint8_t); void clearLine(byte line) { - clear(0, line * m_lineHeight, 320, 8); + clear(0, line * TFT_LINE_HEIGHT, 320, 8); } - void setLineHeight(byte lineHeight) { m_lineHeight = lineHeight; } byte getLines() { return 53; } byte getCols() { return 30; } private: void writeDigit(byte n); void clearPixels(uint16_t pixels); - void SetXY(uint16_t x0,uint16_t x1,uint16_t y0,uint16_t y1); + void setXY(uint16_t x0,uint16_t x1,uint16_t y0,uint16_t y1); void WriteData(uint16_t c); void WriteData(byte l, byte h); void WriteCommandData(uint16_t cmd,uint16_t dat); @@ -172,9 +150,58 @@ private: void Disable(); void SetCommandMode(); void SetDataMode(); - int m_x; - int m_y; + uint16_t m_x; + uint16_t m_y; uint16_t m_color[2]; - byte m_lineHeight; byte lastData; }; + +class LCD_ILI9341 : public LCD_Common, public Print +{ +public: + LCD_ILI9341() { m_font = FONT_SIZE_MEDIUM; } + void setCursor(uint16_t column, uint16_t line) + { + m_y = column; + m_x = line * TFT_LINE_HEIGHT; + } + void setTextColor(uint8_t R, uint8_t G, uint8_t B) + { + uint16_t color = ((uint16_t)R << 11) | ((uint16_t)G << 5) | B; + m_color[1][0] = color & 0xff; + m_color[1][1] = color >> 8; + } + void SetBGColor(uint8_t R, uint8_t G, uint8_t B) + { + uint16_t color = ((uint16_t)R << 11) | ((uint16_t)G << 5) | B; + m_color[0][0] = color & 0xff; + m_color[0][1] = color >> 8; + } + void clearLine(byte line) + { + clear(0, line * TFT_LINE_HEIGHT, 320, 8); + } + void begin (void); + void setXY(uint16_t x0, uint16_t x1, uint16_t y0, uint16_t y1); + void setPixel(uint16_t poX, uint16_t poY,uint16_t color); + void clear(uint16_t XL,uint16_t XR,uint16_t YU,uint16_t YD,uint16_t color = 0); + void clear(void); + size_t write(uint8_t); + void backlight(bool on); + void draw(const PROGMEM byte* buffer, uint16_t x, uint16_t y, uint16_t width, uint16_t height); + void draw2x(const PROGMEM byte* buffer, uint16_t x, uint16_t y, byte width, byte height); +private: + void writeDigit(byte n); + void clearPixels(uint16_t pixels); + void setCol(uint16_t StartCol,uint16_t EndCol); + void setPage(uint16_t StartPage,uint16_t EndPage); + void sendCMD(uint8_t index); + void WRITE_Package(uint16_t *data,uint8_t howmany); + void WRITE_DATA(uint8_t data); + void sendData(uint16_t data); + 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; +}; diff --git a/libraries/MultiLCD/SSD1306.cpp b/libraries/MultiLCD/SSD1306.cpp index 7f7b8e8..5fc1ba0 100644 --- a/libraries/MultiLCD/SSD1306.cpp +++ b/libraries/MultiLCD/SSD1306.cpp @@ -1,5 +1,5 @@ #include <avr/pgmspace.h> -#include <util/delay.h> +//#include <util/delay.h> #include <stdlib.h> #include <Wire.h> #include "SSD1306.h" @@ -238,8 +238,8 @@ void SSD1306::fill(unsigned char dat) ssd1306_command(0x10);//set higher column address ssd1306_command(0xB0);//set page address - uint8_t twbrbackup = TWBR; - TWBR = 18; // upgrade to 400KHz! + //uint8_t twbrbackup = TWBR; + //TWBR = 18; // upgrade to 400KHz! for (byte i=0; i<(SSD1306_LCDHEIGHT/8); i++) { // send a bunch of data in one xmission @@ -256,7 +256,7 @@ void SSD1306::fill(unsigned char dat) Wire.endTransmission(); } } - TWBR = twbrbackup; + //TWBR = twbrbackup; } void SSD1306::draw8x8(byte* buffer, uint8_t x, uint8_t y) diff --git a/libraries/MultiLCD/SSD1306.h b/libraries/MultiLCD/SSD1306.h index aaa3534..ae7f339 100644 --- a/libraries/MultiLCD/SSD1306.h +++ b/libraries/MultiLCD/SSD1306.h @@ -1,11 +1,4 @@ -#if ARDUINO >= 100 - #include "Arduino.h" -#else - #include "WProgram.h" -#endif - -#define BLACK 0 -#define WHITE 1 +#include "Arduino.h" #define SSD1306_I2C_ADDRESS 0x3C // 011110+SA0+RW - 0x3C or 0x3D // Address for 128x32 is 0x3C diff --git a/libraries/MultiLCD/ZtLib.cpp b/libraries/MultiLCD/ZtLib.cpp deleted file mode 100644 index ecda4c4..0000000 --- a/libraries/MultiLCD/ZtLib.cpp +++ /dev/null @@ -1,607 +0,0 @@ -/* - ZtLib.cpp - ZT module Drive Library for Wiring & Arduino - Copyright (c) 2012 Alvin Li(Kozig/www.kozig.com). All right reserved. - This library is free software; - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - Version:V1.1 -*/ - -#include <Arduino.h> -extern "C" { - #include "../Wire/utility/twi.h" -} - -#include "ZtLib.h" - -///ZT.SEG8B4A036A PART///-------------------------------------------------------------------s -unsigned char codetable[] = -{ - 0x3F,0x06,0x5B,0x4F,0x66,0x6D,0x7D,0x07,0x7F,0x6F, 0x77, 0x7C,0x39,0x5E,0x79,0x71,0x00 -}; - -// Public Methods ////////////////////////////////////////////////////////////// -/* - * Function I2cInit - * Desc TWI/I2C init - * Input none - * Output none - */ -void ZtLib::I2cInit(void) -{ - twi_init(); -} -/* - * Function Seg8b4a036aSleep - * Desc Set ZT.SEG8B4A036A Go to Sleep - * Input addr:ZT.SEG8B4A036A Address - * Output 0 .. success - * 1 .. length to long for buffer - * 2 .. address send, NACK received - * 3 .. data send, NACK received - * 4 .. other twi error (lost bus arbitration, bus error, ..) - */ -int ZtLib::Seg8b4a036aSleep(uint8_t addr) -{ - uint8_t buff[5]={REG_SLEEP, SLEEP_ON, 0, 0, 0}; - - return twi_writeTo(addr, buff, 5, 1, 1); -} -/* - * Function Seg8b4a036aUnSleep - * Desc Set ZT.SEG8B4A036A Wait Up From Sleep - * Input addr:ZT.SEG8B4A036A Address - * Output 0 .. success - * 1 .. length to long for buffer - * 2 .. address send, NACK received - * 3 .. data send, NACK received - * 4 .. other twi error (lost bus arbitration, bus error, ..) - */ -int ZtLib::Seg8b4a036aUnSleep(uint8_t addr) -{ - uint8_t buff[5]={REG_SLEEP, SLEEP_OFF, 0, 0, 0}; - - return twi_writeTo(addr, buff, 5, 1, 1); -} -/* - * Function Seg8b4a036aReadState - * Desc Read ZT.SEG8B4A036A Status - * Input addr:ZT.SEG8B4A036A Address - * Output !=0xFF ZT.SC-I2CMx Status - * 0xFF .. other twi error (lost bus arbitration, bus error, ..) - */ -int ZtLib::Seg8b4a036aReadState(uint8_t addr) -{ - uint8_t state = 0xFF; - uint8_t temp; - uint8_t buff[1] = {REG_STATUS}; - temp = twi_writeTo(addr, buff, 1, 1, 0); // no stop - if (temp ==0) - { - temp = twi_readFrom(addr, buff, 1, 1); - } - if (temp==1) - { - state = buff[0]; - } - - return state; -} -/* - * Function Seg8b4a036aReadVersion - * Desc Read ZT.SEG8B4A036A Fireware Version - * Input addr:ZT.SEG8B4A036A Address - *buf:Version Buffer - * Output .. number bytes of Version Read out - */ -int ZtLib::Seg8b4a036aReadVersion(uint8_t addr, uint8_t *buf) -{ - uint8_t state = 0xFF; - uint8_t temp; - uint8_t regv[1] = {REG_VERSION}; - temp = twi_writeTo(addr, regv, 1, 1, 0); // no stop - if (temp ==0) - { - temp = twi_readFrom(addr, &(*buf), 19, 1); - } - return temp; -} -/* - * Function Seg8b4a036aDisplayDec - * Desc ZT.SEG8B4A036A Display decimal numeral - * Input addr:ZT.SEG8B4A036A Address - val: Display Val - bitnum:Display Bit Number - dotbit: Dot Display - * Output 0 .. success - * 1 .. length to long for buffer - * 2 .. address send, NACK received - * 3 .. data send, NACK received - * 4 .. other twi error (lost bus arbitration, bus error, ..) - */ -int ZtLib::Seg8b4a036aDisplayDec(uint8_t addr,unsigned short val, uint8_t bitnum, uint8_t dotbit) -{ - uint8_t i; - uint8_t segnum[5]; - if (val>9999) return 0xFF; - - segnum[0] = REG_DAT; - segnum[1] = val%10; - segnum[2] = (val%100)/10; - segnum[3] = (val/100)%10; - segnum[4] = val/1000; - for (i=1; i<5; i++) - { - segnum[i] = codetable[segnum[i]]; - if (dotbit&0x01) - { - segnum[i] |= 0x80; - } - dotbit >>= 1; - } - - if (bitnum==DISP_0BIT) {segnum[4] = 0;segnum[3] = 0;segnum[2] = 0;segnum[1] = 0;} - else if (bitnum==DISP_1BIT) {segnum[4] = 0;segnum[3] = 0;segnum[2] = 0;} - else if (bitnum==DISP_2BIT) {segnum[4] = 0;segnum[3] = 0;} - else if (bitnum==DISP_3BIT) {segnum[4] = 0;} - else if (bitnum==DISP_AUTO) - { - if (val<10) {segnum[4] = 0;segnum[3] = 0;segnum[2] = 0;} - else if (val<100) {segnum[4] = 0;segnum[3] = 0;} - else if (val<1000) {segnum[4] = 0;} - } - - return twi_writeTo(addr, segnum, 5, 1, 1); -} -/* - * Function Seg8b4a036aDisplayHex - * Desc Read ZT.SEG8B4A036A Display hexadecimal number - * Input addr:ZT.SEG8B4A036A Address - val: Display Val - bitnum:Display Bit Number - dotbit: Dot Display - * Output 0 .. success - * 1 .. length to long for buffer - * 2 .. address send, NACK received - * 3 .. data send, NACK received - * 4 .. other twi error (lost bus arbitration, bus error, ..) - */ -int ZtLib::Seg8b4a036aDisplayHex(uint8_t addr,unsigned short val, uint8_t bitnum, uint8_t dotbit) -{ - uint8_t i; - unsigned short temp; - uint8_t segnum[5]; - segnum[0] = REG_DAT; - temp = val; - for (i=1; i<5; i++) - { - segnum[i] = temp&0x000F; - temp >>= 4; - segnum[i] = codetable[segnum[i]]; - if (dotbit&0x01) - { - segnum[i] |= 0x80; - } - dotbit >>= 1; - } - - if (bitnum==DISP_0BIT) {segnum[4] = 0;segnum[3] = 0;segnum[2] = 0;segnum[1] = 0;} - else if (bitnum==DISP_1BIT) {segnum[4] = 0;segnum[3] = 0;segnum[2] = 0;} - else if (bitnum==DISP_2BIT) {segnum[4] = 0;segnum[3] = 0;} - else if (bitnum==DISP_3BIT) {segnum[4] = 0;} - else if (bitnum==DISP_AUTO) - { - if (!(val&0xFFF0)) {segnum[4] = 0;segnum[3] = 0;segnum[2] = 0;} - else if (!(val&0xFF00)) {segnum[4] = 0;segnum[3] = 0;} - else if (!(val&0xF000)) {segnum[4] = 0;} - } - - return twi_writeTo(addr, segnum, 5, 1, 1); -} -/* - * Function Seg8b4a036aSetBrightness - * Desc Set ZT.SEG8B4A036A Brightness - * Input addr:ZT.SEG8B4A036A Address - OnDelay: - OffDelay: - * Output 0 .. success - * 1 .. length to long for buffer - * 2 .. address send, NACK received - * 3 .. data send, NACK received - * 4 .. other twi error (lost bus arbitration, bus error, ..) - */ -int ZtLib::Seg8b4a036aSetBrightness(uint8_t addr, uint8_t OnDelay, uint8_t OffDelay) -{ - uint8_t buff[5] = {REG_BRIGHTNESS, OnDelay, OffDelay, 0, 0}; - return twi_writeTo(addr, buff, 5, 1, 1); -} -/* - * Function Seg8b4a036aSetAddress - * Desc Set ZT.SEG8B4A036A New Address - * Input val:ZT.SEG8B4A036A Address New Address - * Output 0 .. success - * 1 .. length to long for buffer - * 2 .. address send, NACK received - * 3 .. data send, NACK received - * 4 .. other twi error (lost bus arbitration, bus error, ..) - */ -int ZtLib::Seg8b4a036aSetAddress(uint8_t val) -{ - uint8_t buff[2] = {REG_ADDRESS, val}; - return twi_writeTo(ZTSEG8B4A036A_DADDR, buff, 2, 1, 1); -} -/* - * Function Seg8b4a036aDisplayBuff - * Desc Set ZT.SEG8B4A036A Brightness - * Input addr:ZT.SEG8B4A036A Address - *buf: Display buffer - * Output 0 .. success - * 1 .. length to long for buffer - * 2 .. address send, NACK received - * 3 .. data send, NACK received - * 4 .. other twi error (lost bus arbitration, bus error, ..) - */ -int ZtLib::Seg8b4a036aDisplayBuff(uint8_t addr,uint8_t *buf) -{ - uint8_t buff[5]={REG_DAT, buf[0], buf[1], buf[2], buf[3]}; - - return twi_writeTo(addr, buff, 5, 1, 1); -} - - -///ZT.ScI2cMx PART///------------------------------------------------------------------- -/* - * Function ScI2cMxReadState - * Desc Read ZT.SC-I2CMx Status - * Input addr:ZT.SC-I2CMx Address - * Output !=0xFF ZT.SC-I2CMx Status - * 0xFF .. other twi error (lost bus arbitration, bus error, ..) - */ -int ZtLib::ScI2cMxReadState(uint8_t addr) -{ - uint8_t state = 0xFF; - uint8_t temp; - uint8_t buff[1] = {REG_STATUS}; - temp = twi_writeTo(addr, buff, 1, 1, 0); // no stop - if (temp ==0) - { - temp = twi_readFrom(addr, buff, 1, 1); - } - if (temp==1) - { - state = buff[0]; - } - - return state; -} - -/* - * Function ScI2cMxReadVersion - * Desc Read ZT.SC-I2CMx Fireware Version - * Input addr:ZT.SC-I2CMx Address - *buf:Version Buffer - * Output !=0xFF ZT.SC-I2CMx Status - * othe .. number bytes of Version Read out - */ -int ZtLib::ScI2cMxReadVersion(uint8_t addr, uint8_t *buf) -{ - uint8_t state = 0xFF; - uint8_t temp; - uint8_t regv[1] = {REG_VERSION}; - temp = twi_writeTo(addr, regv, 1, 1, 0); // no stop - if (temp ==0) - { - temp = twi_readFrom(addr, &(*buf), 16, 1); - } - return temp; -} -/* - * Function ScI2cMxSetAddress - * Desc Set ZT.SC-I2CMx New Address - * Input val:ZT.SC-I2CMx Address New Address - * Output 0 .. success - * 1 .. length to long for buffer - * 2 .. address send, NACK received - * 3 .. data send, NACK received - * 4 .. other twi error (lost bus arbitration, bus error, ..) - */ -int ZtLib::ScI2cMxSetAddress(uint8_t newaddr) -{ - uint8_t buff[2] = {REG_ADDRESS, newaddr}; - return twi_writeTo(ZTSCI2CMX_DADDRESS, buff, 2, 1, 1); -} - -/* - * Function ScI2cMxSetBrightness - * Desc Set ZT.SC-I2CMx Brightness - * Input addr:ZT.SC-I2CMx Address - val: Brightness 0~0xFF - * Output 0 .. success - * 1 .. length to long for buffer - * 2 .. address send, NACK received - * 3 .. data send, NACK received - * 4 .. other twi error (lost bus arbitration, bus error, ..) - */ -int ZtLib::ScI2cMxSetBrightness(uint8_t addr, uint8_t val) -{ - uint8_t buff[2] = {REG_BRIGHTNESS, val}; - return twi_writeTo(addr, buff, 2, 1, 1); -} -/* - * Function ScI2cMxSetVcomH - * Desc Set ZT.SC-I2CMx VcomH - * Input addr:ZT.SC-I2CMx Address - val: Brightness 0~7 - * Output 0 .. success - * 1 .. length to long for buffer - * 2 .. address send, NACK received - * 3 .. data send, NACK received - * 4 .. other twi error (lost bus arbitration, bus error, ..) - */ -int ZtLib::ScI2cMxSetVcomH(uint8_t addr, uint8_t val) -{ - uint8_t buff[2] = {REG_VCOMH, val}; - return twi_writeTo(addr, buff, 2, 1, 1); -} - -/* - * Function ScI2cMxDisplay8x16Str - * Desc ZT.SC-I2CMx Display 8x16 English String - * Input addr:ZT.SC-I2CMx Address - page: location page - column: location column - *str: 8X16 English String - * Output 0 .. success - * 1 .. length to long for buffer - * 2 .. address send, NACK received - * 3 .. data send, NACK received - * 4 .. other twi error (lost bus arbitration, bus error, ..) - */ -int ZtLib::ScI2cMxDisplay8x16Str(uint8_t addr, uint8_t page, uint8_t column, const char *str) -{ - uint8_t i=0; - uint8_t buff[19]; - buff[0] = REG_8X16STR; - buff[1] = page; - buff[2] = column; - i=0; - while ((*str != '\0') && (i<16)) - { - buff[i+3] = (uint8_t)*str++; - i++; - } - return twi_writeTo(addr, buff, i+3, 1, 1); -} -/* - * Function ScI2cMxFillArea - * Desc ZT.SC-I2CMx Fill Area - * Input addr:ZT.SC-I2CMx Address - spage: start page - epage: end page - scolumn: start column - ecolumn: end column - filldata: fill data - * Output 0 .. success - * 1 .. length to long for buffer - * 2 .. address send, NACK received - * 3 .. data send, NACK received - * 4 .. other twi error (lost bus arbitration, bus error, ..) - */ -int ZtLib::ScI2cMxFillArea(uint8_t addr, uint8_t spage, uint8_t epage,uint8_t scolumn, uint8_t ecolumn,uint8_t filldata) -{ - uint8_t buff[6] = {REG_FILL_AREA, spage, epage, scolumn, ecolumn, filldata}; - return twi_writeTo(addr, buff, 6, 1, 1); -} -/* - * Function ScI2cMxScrollingHorizontal - * Desc ZT.SC-I2CMx Scrolling Horizontal - * Input addr:ZT.SC-I2CMx Address - lr: Scroll direction - spage: start page - epage: end page - frames: Scroll fram - * Output 0 .. success - * 1 .. length to long for buffer - * 2 .. address send, NACK received - * 3 .. data send, NACK received - * 4 .. other twi error (lost bus arbitration, bus error, ..) - */ -int ZtLib::ScI2cMxScrollingHorizontal(uint8_t addr, uint8_t lr, uint8_t spage, uint8_t epage,uint8_t frames) -{ - uint8_t buff[9] = {REG_CMD, 0x2E, 0x00, spage, frames, epage, 0x00, 0xFF, 0x2F}; - twi_writeTo(addr, buff, 2, 1, 1); - buff[0] = REG_CMD; - buff[1] = lr; - for (int i=0; i<10; i++); - return twi_writeTo(addr, buff, 9, 1, 1); -} -/* - * Function ScI2cMxScrollingHorizontal - * Desc ZT.SC-I2CMx Scrolling Vertical - * Input addr:ZT.SC-I2CMx Address - lr: Scroll direction - rowsfixed: rows fixed - rowsscroll: rows scroll - scrollstep: scroll step - stepdelay: step delay - * Output 0 .. success - * 1 .. length to long for buffer - * 2 .. address send, NACK received - * 3 .. data send, NACK received - * 4 .. other twi error (lost bus arbitration, bus error, ..) - */ -int ZtLib::ScI2cMxScrollingVertical(uint8_t addr, uint8_t scrollupdown, uint8_t rowsfixed, uint8_t rowsscroll, uint8_t scrollstep, uint8_t stepdelay) -{ - uint8_t buff[6] = {REG_SCROVER, scrollupdown, rowsfixed, rowsscroll, scrollstep, stepdelay}; - return twi_writeTo(addr, buff, 6, 1, 1); -} -/* - * function ScI2cMxScrollingVerticalHorizontal - * Desc Continuous Vertical / Horizontal / Diagonal Scrolling (Partial or Full Screen) - * input : - Sdirection: Scrolling Direction - "0x00" (Vertical & Rightward) - "0x01" (Vertical & Leftward) - spage: Define Start Page Address (Horizontal / Diagonal Scrolling) - epage: Define End Page Address (Horizontal / Diagonal Scrolling) - fixedarea: Set Top Fixed Area (Vertical Scrolling) - scrollarea: Set Vertical Scroll Area (Vertical Scrolling) - frames: Set Time Interval between Each Scroll Step in Terms of Frame Frequency - offset: Set Numbers of Row Scroll per Step (Vertical / Diagonal Scrolling) - * Output 0 .. success - * 1 .. length to long for buffer - * 2 .. address send, NACK received - * 3 .. data send, NACK received - * 4 .. other twi error (lost bus arbitration, bus error, ..) - */ -int ZtLib::ScI2cMxScrollingVerticalHorizontal(uint8_t addr, uint8_t Sdirection, uint8_t spage, uint8_t epage, uint8_t fixedarea, uint8_t scrollarea, uint8_t offset, uint8_t frames) -{ - uint8_t buff[8] = {REG_SCROVERHOR, Sdirection, spage, epage, fixedarea, scrollarea, offset, frames}; - return twi_writeTo(addr, buff, 8, 1, 1); -} -/* - * Function ScI2cMxDeactivateScroll - * Desc ZT.SC-I2CMx Deactivate Scroll - * Input addr:ZT.SC-I2CMx Address - * Output 0 .. success - * 1 .. length to long for buffer - * 2 .. address send, NACK received - * 3 .. data send, NACK received - * 4 .. other twi error (lost bus arbitration, bus error, ..) - */ -int ZtLib::ScI2cMxDeactivateScroll(uint8_t addr) -{ - uint8_t buff[2] = {REG_CMD, 0x2E}; - return twi_writeTo(addr, buff, 2, 1, 1); -} - -/* - * Function ScI2cMxReset - * Desc ZT.SC-I2CMx Reset OLED - * Input addr:ZT.SC-I2CMx Address - * Output 0 .. success - * 1 .. length to long for buffer - * 2 .. address send, NACK received - * 3 .. data send, NACK received - * 4 .. other twi error (lost bus arbitration, bus error, ..) - */ -int ZtLib::ScI2cMxReset(uint8_t addr) -{ - uint8_t buff[2] = {REG_RESET,RESET_OLED}; - return twi_writeTo(addr, buff, 2, 1, 1); -} - -/* - * Function ScI2cMxSetLocation - * Desc Set ZT.SC-I2CMx SetLocation - * Input addr:ZT.SC-I2CMx Address - * Output 0 .. success - * 1 .. length to long for buffer - * 2 .. address send, NACK received - * 3 .. data send, NACK received - * 4 .. other twi error (lost bus arbitration, bus error, ..) - */ -int ZtLib::ScI2cMxSetLocation(uint8_t addr, uint8_t page,uint8_t column) -{ - uint8_t buff[4] = {REG_CMD, (0xB0|page), (column%16), (column/16+0x10)}; - return twi_writeTo(addr, buff, 4, 1, 1); -} -/* - * Function ScI2cMxDisplayDot16x16 - * Desc Set ZT.SC-I2CMx Display 16*16 Dot - * Input addr:ZT.SC-I2CMx Address - page:page - column:column - *str:16*16 Dot Data - * Output 0 .. success - * 1 .. length to long for buffer - * 2 .. address send, NACK received - * 3 .. data send, NACK received - * 4 .. other twi error (lost bus arbitration, bus error, ..) - */ -void ZtLib::ScI2cMxDisplayDot16x16(uint8_t addr, uint8_t page, uint8_t column, unsigned char *str) -{ - uint8_t buff[17]; - buff[0] = REG_DAT; - ScI2cMxSetLocation(addr, page, column); - for (int i=0; i<16; i++) - { - buff[i+1] = str[i]; - } - twi_writeTo(addr, buff, 17, 1, 1); - ScI2cMxSetLocation(addr, page+1, column); - for (int i=0; i<16; i++) - { - buff[i+1] = str[i+16]; - } - twi_writeTo(addr, buff, 17, 1, 1); -} - -void ZtLib::ScI2cMxDisplayDot(uint8_t addr, const PROGMEM uint8_t* buffer, uint8_t len) -{ - uint8_t buff[9] = {REG_DAT}; - memcpy_P(buff + 1, buffer, len); - twi_writeTo(addr, buff, 9, 1, 1); -} - -/* - * Function ScI2cMxDisplayArea - * Desc Set ZT.SC-I2CMx Display Area - * Input addr:ZT.SC-I2CMx Address - spage: start page - epage: end page - scolumn: start column - ecolumn: end column - *pt: Data - * Output 0 .. success - * 1 .. length to long for buffer - * 2 .. address send, NACK received - * 3 .. data send, NACK received - * 4 .. other twi error (lost bus arbitration, bus error, ..) - */ -void ZtLib::ScI2cMxDisplayArea(uint8_t addr, uint8_t spage, uint8_t epage, uint8_t scolumn, uint8_t ecolumn, const char *pt) -{ - uint8_t i = 0; - uint8_t j = 0; - uint8_t h = 0; - uint8_t w = 0; - uint16_t cnt = 0; - uint8_t buff[32]; - buff[0] = REG_DAT; - - h = epage - spage; - w = ecolumn - scolumn; - - while ( j<h ) - { - ScI2cMxSetLocation(addr, spage + j, scolumn); - uint8_t p=w; - while(p) - { - if(p>=31) - { - for (int n=0; n<31; n++) - { - buff[1+n] = pt[cnt++]; - } - twi_writeTo(addr, buff, 32, 1, 1); - p -= 31; - } - else - { - int n; - for (n=0; n<p; n++) - { - buff[1+n] = pt[cnt++]; - } - twi_writeTo(addr, buff, n+1, 1, 1); - p -= n; - } - } - j++; - } -} - -// Preinstantiate Objects ////////////////////////////////////////////////////// - diff --git a/libraries/MultiLCD/ZtLib.h b/libraries/MultiLCD/ZtLib.h deleted file mode 100644 index dd7dd5a..0000000 --- a/libraries/MultiLCD/ZtLib.h +++ /dev/null @@ -1,128 +0,0 @@ -/* - ZtLib.cpp - ZT module Drive Library for Wiring & Arduino - Copyright (c) 2012 Alvin Li(Kozig/www.kozig.com). All right reserved. - This library is free software; - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - Version:V1.1 -*/ - -#ifndef __ZTLIB_H__ -#define __ZTLIB_H__ - -#include <inttypes.h> - -////////////////// -#define ZTSEG8B4A036A_DADDR 0x51 -#define SET_ADDR 0x61 -#define WRITE_CODE 0xAA -#define WRITE_CMD 0x55 - -#define DOT_NONE (0) -#define DOT_BIT1 (1<<0) -#define DOT_BIT2 (1<<1) -#define DOT_BIT3 (1<<2) -#define DOT_BIT4 (1<<3) - -#define DISP_0BIT (0) -#define DISP_1BIT (1) -#define DISP_2BIT (2) -#define DISP_3BIT (3) -#define DISP_4BIT (4) -#define DISP_AUTO (5) -/////////////////////////////////// - -#define ZTSCI2CMX_DADDRESS 0x51 -// Ä£¿é¼Ä´æÆ÷µØÖ· -#define REG_CMD 0x01 -#define REG_DAT 0x02 -#define REG_RESET 0x03 - #define RESET_OLED 0x06 -#define REG_VERSION 0x1F -#define REG_SLEEP 0x04 - #define SLEEP_ON 0xA5 - #define SLEEP_OFF 0xA1 -#define REG_VCOMH 0x05 -#define REG_STATUS 0x06 - #define STATUS_RUN 0x00 - #define STATUS_RUN 0x00 - #define STATUS_SLEEP 0x01 - #define STATUS_SET_ADDRESS 0x02 - #define STATUS_TEST 0x04 - #define STATUS_BUSY 0x10 - -#define REG_ADDRESS 0x08 -#define REG_BRIGHTNESS 0x0A -#define REG_8X16STR 0x52 -#define REG_OLED_XY 0x60 -#define REG_FILL_AREA 0x61 -#define REG_SCROHOR 0x62 -#define REG_SCROVER 0x63 -#define REG_SCROVERHOR 0x64 - -#define PAGE0 0x00 -#define PAGE1 0x01 -#define PAGE2 0x02 -#define PAGE3 0x03 -#define PAGE4 0x04 -#define PAGE5 0x05 -#define PAGE6 0x06 -#define PAGE7 0x07 - -#define SCROLL_UP 0x01 -#define SCROLL_DOWN 0x00 -#define SCROLL_RIGHT 0x26 -#define SCROLL_LEFT 0x27 -#define SCROLL_VR 0x29 -#define SCROLL_VL 0x2A - -#define FRAMS_2 0x07 -#define FRAMS_3 0x04 -#define FRAMS_4 0x05 -#define FRAMS_5 0x00 -#define FRAMS_25 0x06 -#define FRAMS_64 0x01 -#define FRAMS_128 0x02 -#define FRAMS_256 0x03 - -class ZtLib -{ - private: - - public: - void I2cInit(void); -// Module ZT.SEG8B4A036A FUNCTION - int Seg8b4a036aSleep(uint8_t); - int Seg8b4a036aUnSleep(uint8_t); - int Seg8b4a036aReadState(uint8_t addr); - int Seg8b4a036aReadVersion(uint8_t addr, uint8_t *buf); - int Seg8b4a036aDisplayDec(uint8_t,unsigned short, uint8_t, uint8_t); - int Seg8b4a036aDisplayHex(uint8_t,unsigned short, uint8_t, uint8_t); - int Seg8b4a036aSetBrightness(uint8_t, uint8_t, uint8_t); - int Seg8b4a036aSetAddress(uint8_t); - int Seg8b4a036aDisplayBuff(uint8_t,uint8_t *); -// Module ZT.SC-I2CMx - int ScI2cMxReadState(uint8_t); - int ScI2cMxReadVersion(uint8_t, uint8_t *); - int ScI2cMxSetAddress(uint8_t); - int ScI2cMxSetBrightness(uint8_t, uint8_t); - int ScI2cMxSetVcomH(uint8_t, uint8_t); - int ScI2cMxDisplay8x16Str(uint8_t, uint8_t, uint8_t, const char *); - int ScI2cMxFillArea(uint8_t, uint8_t, uint8_t,uint8_t, uint8_t,uint8_t); - int ScI2cMxScrollingHorizontal(uint8_t, uint8_t, uint8_t, uint8_t,uint8_t); - int ScI2cMxScrollingVertical(uint8_t, uint8_t, uint8_t, uint8_t, uint8_t, uint8_t); - int ScI2cMxScrollingVerticalHorizontal(uint8_t, uint8_t, uint8_t, uint8_t, uint8_t, uint8_t, uint8_t, uint8_t); - int ScI2cMxDeactivateScroll(uint8_t); - int ScI2cMxReset(uint8_t); - int ScI2cMxSetLocation(uint8_t, uint8_t, uint8_t); - void ScI2cMxDisplayDot(uint8_t, const PROGMEM uint8_t* buffer, uint8_t len); - void ScI2cMxDisplayDot16x16(uint8_t, uint8_t, uint8_t, unsigned char *); - void ScI2cMxDisplayArea(uint8_t, uint8_t, uint8_t, uint8_t, uint8_t, const char *); -}; - - -extern ZtLib ZT; - -#endif - |