diff --git a/M5Stack.h b/M5Stack.h index 8c09945..556e7a3 100644 --- a/M5Stack.h +++ b/M5Stack.h @@ -81,11 +81,11 @@ #include "SD.h" #include "esp32-hal-dac.h" #include -#include #include #include #include -#include +#include "utility/bmp_map.h" +#include "utility/music_8bit.h" extern "C" { #include "freertos/FreeRTOS.h" diff --git a/examples/Basics/FactoryTest/FactoryTest.ino b/examples/Basics/FactoryTest/FactoryTest.ino index 570f7ed..d474a62 100644 --- a/examples/Basics/FactoryTest/FactoryTest.ino +++ b/examples/Basics/FactoryTest/FactoryTest.ino @@ -106,7 +106,7 @@ void startup_logo() { for(int i=0; i>2); delayMicroseconds(40); - brightness = (i/156); + brightness = (i/157); if(pre_b != brightness) { pre_b = brightness; m5.lcd.setBrightness(brightness); diff --git a/examples/Basics/GFX_Library/Display.cpp b/examples/Basics/GFX_Library/Display.cpp deleted file mode 100644 index 8d9b3c1..0000000 --- a/examples/Basics/GFX_Library/Display.cpp +++ /dev/null @@ -1,668 +0,0 @@ -/*************************************************** - This is our library for the Adafruit ILI9341 Breakout and Shield - ----> http://www.adafruit.com/products/1651 - - Check out the links above for our tutorials and wiring diagrams - These displays use SPI to communicate, 4 or 5 pins are required to - interface (RST is optional) - Adafruit invests time and resources providing this open source code, - please support Adafruit and open-source hardware by purchasing - products from Adafruit! - - Written by Limor Fried/Ladyada for Adafruit Industries. - MIT license, all text above must be included in any redistribution - ****************************************************/ - -#include "Display.h" -#ifndef ARDUINO_STM32_FEATHER - #include "pins_arduino.h" -#ifndef RASPI - #include "wiring_private.h" -#endif -#endif -#include - - -#define MADCTL_MY 0x80 -#define MADCTL_MX 0x40 -#define MADCTL_MV 0x20 -#define MADCTL_ML 0x10 -#define MADCTL_RGB 0x00 -#define MADCTL_BGR 0x08 -#define MADCTL_MH 0x04 - -/* - * Control Pins - * */ - -#ifdef USE_FAST_PINIO -#define SPI_DC_HIGH() *dcport |= dcpinmask -#define SPI_DC_LOW() *dcport &= ~dcpinmask -#define SPI_CS_HIGH() *csport |= cspinmask -#define SPI_CS_LOW() *csport &= ~cspinmask -#else -#define SPI_DC_HIGH() digitalWrite(_dc, HIGH) -#define SPI_DC_LOW() digitalWrite(_dc, LOW) -#define SPI_CS_HIGH() digitalWrite(_cs, HIGH) -#define SPI_CS_LOW() digitalWrite(_cs, LOW) -#endif - -/* - * Software SPI Macros - * */ - -#ifdef USE_FAST_PINIO -#define SSPI_MOSI_HIGH() *mosiport |= mosipinmask -#define SSPI_MOSI_LOW() *mosiport &= ~mosipinmask -#define SSPI_SCK_HIGH() *clkport |= clkpinmask -#define SSPI_SCK_LOW() *clkport &= ~clkpinmask -#define SSPI_MISO_READ() ((*misoport & misopinmask) != 0) -#else -#define SSPI_MOSI_HIGH() digitalWrite(_mosi, HIGH) -#define SSPI_MOSI_LOW() digitalWrite(_mosi, LOW) -#define SSPI_SCK_HIGH() digitalWrite(_sclk, HIGH) -#define SSPI_SCK_LOW() digitalWrite(_sclk, LOW) -#define SSPI_MISO_READ() digitalRead(_miso) -#endif - -#define SSPI_BEGIN_TRANSACTION() -#define SSPI_END_TRANSACTION() -#define SSPI_WRITE(v) spiWrite(v) -#define SSPI_WRITE16(s) SSPI_WRITE((s) >> 8); SSPI_WRITE(s) -#define SSPI_WRITE32(l) SSPI_WRITE((l) >> 24); SSPI_WRITE((l) >> 16); SSPI_WRITE((l) >> 8); SSPI_WRITE(l) -#define SSPI_WRITE_PIXELS(c,l) for(uint32_t i=0; i<(l); i+=2){ SSPI_WRITE(((uint8_t*)(c))[i+1]); SSPI_WRITE(((uint8_t*)(c))[i]); } - -/* - * Hardware SPI Macros - * */ -#define SPI_OBJECT _spi -#define HSPI_SET_CLOCK() SPI_OBJECT.setFrequency(_freq); - -#ifdef SPI_HAS_TRANSACTION - #define HSPI_BEGIN_TRANSACTION() SPI_OBJECT.beginTransaction(SPISettings(_freq, MSBFIRST, SPI_MODE0)) - #define HSPI_END_TRANSACTION() SPI_OBJECT.endTransaction() -#else - #define HSPI_BEGIN_TRANSACTION() HSPI_SET_CLOCK(); SPI_OBJECT.setBitOrder(MSBFIRST); SPI_OBJECT.setDataMode(SPI_MODE0) - #define HSPI_END_TRANSACTION() -#endif - -#ifdef ESP32 - #define SPI_HAS_WRITE_PIXELS -#endif -#if defined(ESP8266) || defined(ESP32) - // Optimized SPI (ESP8266 and ESP32) - #define HSPI_READ() SPI_OBJECT.transfer(0) - #define HSPI_WRITE(b) SPI_OBJECT.write(b) - #define HSPI_WRITE16(s) SPI_OBJECT.write16(s) - #define HSPI_WRITE32(l) SPI_OBJECT.write32(l) - #ifdef SPI_HAS_WRITE_PIXELS - #define SPI_MAX_PIXELS_AT_ONCE 32 - #define HSPI_WRITE_PIXELS(c,l) SPI_OBJECT.writePixels(c,l) - #else - #define HSPI_WRITE_PIXELS(c,l) for(uint32_t i=0; i<((l)/2); i++){ SPI_WRITE16(((uint16_t*)(c))[i]); } - #endif -#else - // Standard Byte-by-Byte SPI - -#if defined (__AVR__) || defined(TEENSYDUINO) -static inline uint8_t _avr_spi_read(void) __attribute__((always_inline)); -static inline uint8_t _avr_spi_read(void) { - uint8_t r = 0; - SPDR = r; - while(!(SPSR & _BV(SPIF))); - r = SPDR; - return r; -} - #define HSPI_WRITE(b) {SPDR = (b); while(!(SPSR & _BV(SPIF)));} - #define HSPI_READ() _avr_spi_read() - #else - #define HSPI_WRITE(b) SPI_OBJECT.transfer((uint8_t)(b)) - #define HSPI_READ() HSPI_WRITE(0) - #endif - #define HSPI_WRITE16(s) HSPI_WRITE((s) >> 8); HSPI_WRITE(s) - #define HSPI_WRITE32(l) HSPI_WRITE((l) >> 24); HSPI_WRITE((l) >> 16); HSPI_WRITE((l) >> 8); HSPI_WRITE(l) - #define HSPI_WRITE_PIXELS(c,l) for(uint32_t i=0; i<(l); i+=2){ HSPI_WRITE(((uint8_t*)(c))[i+1]); HSPI_WRITE(((uint8_t*)(c))[i]); } -#endif - -/* - * Final SPI Macros - * */ -#define SPI_DEFAULT_FREQ 78000000 -#define SPI_BEGIN() if(_sclk < 0){SPI_OBJECT.begin();} -#define SPI_BEGIN_TRANSACTION() if(_sclk < 0){HSPI_BEGIN_TRANSACTION();} -#define SPI_END_TRANSACTION() if(_sclk < 0){HSPI_END_TRANSACTION();} -#define SPI_WRITE16(s) if(_sclk < 0){HSPI_WRITE16(s);}else{SSPI_WRITE16(s);} -#define SPI_WRITE32(l) if(_sclk < 0){HSPI_WRITE32(l);}else{SSPI_WRITE32(l);} -#define SPI_WRITE_PIXELS(c,l) if(_sclk < 0){HSPI_WRITE_PIXELS(c,l);}else{SSPI_WRITE_PIXELS(c,l);} - -// Pass 8-bit (each) R,G,B, get back 16-bit packed color -uint16_t ILI9341::color565(uint8_t r, uint8_t g, uint8_t b) { - return ((r & 0xF8) << 8) | ((g & 0xFC) << 3) | ((b & 0xF8) >> 3); -} - -ILI9341::ILI9341(int8_t cs, int8_t dc, int8_t mosi, - int8_t sclk, int8_t rst, int8_t miso) : Adafruit_GFX(ILI9341_TFTWIDTH, ILI9341_TFTHEIGHT) { - _cs = cs; - _dc = dc; - _rst = rst; - _sclk = sclk; - _mosi = mosi; - _miso = miso; - _freq = 0; -#ifdef USE_FAST_PINIO - csport = portOutputRegister(digitalPinToPort(_cs)); - cspinmask = digitalPinToBitMask(_cs); - dcport = portOutputRegister(digitalPinToPort(_dc)); - dcpinmask = digitalPinToBitMask(_dc); - clkport = portOutputRegister(digitalPinToPort(_sclk)); - clkpinmask = digitalPinToBitMask(_sclk); - mosiport = portOutputRegister(digitalPinToPort(_mosi)); - mosipinmask = digitalPinToBitMask(_mosi); - if(miso >= 0){ - misoport = portInputRegister(digitalPinToPort(_miso)); - misopinmask = digitalPinToBitMask(_miso); - } else { - misoport = 0; - misopinmask = 0; - } -#endif -} - -ILI9341::ILI9341(int8_t cs, int8_t dc, int8_t rst) : Adafruit_GFX(ILI9341_TFTWIDTH, ILI9341_TFTHEIGHT) { - _cs = cs; - _dc = dc; - _rst = rst; - _sclk = -1; - _mosi = -1; - _miso = -1; - _freq = 0; -#ifdef USE_FAST_PINIO - csport = portOutputRegister(digitalPinToPort(_cs)); - cspinmask = digitalPinToBitMask(_cs); - dcport = portOutputRegister(digitalPinToPort(_dc)); - dcpinmask = digitalPinToBitMask(_dc); - clkport = 0; - clkpinmask = 0; - mosiport = 0; - mosipinmask = 0; - misoport = 0; - misopinmask = 0; -#endif -} - - -#ifdef ESP32 -void ILI9341::begin(uint32_t freq, SPIClass &spi) -#else -void ILI9341::begin(uint32_t freq) -#endif -{ -#ifdef ESP32 - _spi = spi; -#endif - if(!freq){ - freq = SPI_DEFAULT_FREQ; - } - _freq = freq; - - // LED Control - setBrightness(0); - - // Control Pins - pinMode(_dc, OUTPUT); - digitalWrite(_dc, LOW); - pinMode(_cs, OUTPUT); - digitalWrite(_cs, HIGH); - - // Software SPI - if(_sclk >= 0){ - pinMode(_mosi, OUTPUT); - digitalWrite(_mosi, LOW); - pinMode(_sclk, OUTPUT); - digitalWrite(_sclk, HIGH); - if(_miso >= 0){ - pinMode(_miso, INPUT); - } - } - - // Hardware SPI - SPI_BEGIN(); - - // toggle RST low to reset - if (_rst >= 0) { - pinMode(_rst, OUTPUT); - digitalWrite(_rst, HIGH); - delay(100); - digitalWrite(_rst, LOW); - delay(100); - digitalWrite(_rst, HIGH); - delay(200); - } - - startWrite(); - - writeCommand(0xEF); - spiWrite(0x03); - spiWrite(0x80); - spiWrite(0x02); - - writeCommand(0xCF); - spiWrite(0x00); - spiWrite(0XC1); - spiWrite(0X30); - - writeCommand(0xED); - spiWrite(0x64); - spiWrite(0x03); - spiWrite(0X12); - spiWrite(0X81); - - writeCommand(0xE8); - spiWrite(0x85); - spiWrite(0x00); - spiWrite(0x78); - - writeCommand(0xCB); - spiWrite(0x39); - spiWrite(0x2C); - spiWrite(0x00); - spiWrite(0x34); - spiWrite(0x02); - - writeCommand(0xF7); - spiWrite(0x20); - - writeCommand(0xEA); - spiWrite(0x00); - spiWrite(0x00); - - writeCommand(ILI9341_PWCTR1); //Power control - spiWrite(0x23); //VRH[5:0] - - writeCommand(ILI9341_PWCTR2); //Power control - spiWrite(0x10); //SAP[2:0];BT[3:0] - - writeCommand(ILI9341_VMCTR1); //VCM control - spiWrite(0x3e); - spiWrite(0x28); - - writeCommand(ILI9341_VMCTR2); //VCM control2 - spiWrite(0x86); //-- - - writeCommand(ILI9341_MADCTL); // Memory Access Control - // spiWrite(0x48); - spiWrite(0x48); - - writeCommand(ILI9341_VSCRSADD); // Vertical scroll - SPI_WRITE16(0); // Zero - - writeCommand(ILI9341_PIXFMT); - spiWrite(0x55); - - writeCommand(ILI9341_FRMCTR1); - spiWrite(0x00); - spiWrite(0x18); - - writeCommand(ILI9341_DFUNCTR); // Display Function Control - spiWrite(0x08); - spiWrite(0x82); - spiWrite(0x27); - - writeCommand(0xF2); // 3Gamma Function Disable - spiWrite(0x00); - - writeCommand(ILI9341_GAMMASET); //Gamma curve selected - spiWrite(0x01); - - writeCommand(ILI9341_GMCTRP1); //Set Gamma - spiWrite(0x0F); - spiWrite(0x31); - spiWrite(0x2B); - spiWrite(0x0C); - spiWrite(0x0E); - spiWrite(0x08); - spiWrite(0x4E); - spiWrite(0xF1); - spiWrite(0x37); - spiWrite(0x07); - spiWrite(0x10); - spiWrite(0x03); - spiWrite(0x0E); - spiWrite(0x09); - spiWrite(0x00); - - writeCommand(ILI9341_GMCTRN1); //Set Gamma - spiWrite(0x00); - spiWrite(0x0E); - spiWrite(0x14); - spiWrite(0x03); - spiWrite(0x11); - spiWrite(0x07); - spiWrite(0x31); - spiWrite(0xC1); - spiWrite(0x48); - spiWrite(0x08); - spiWrite(0x0F); - spiWrite(0x0C); - spiWrite(0x31); - spiWrite(0x36); - spiWrite(0x0F); - - writeCommand(ILI9341_SLPOUT); //Exit Sleep - delay(120); - writeCommand(ILI9341_DISPON); //Display on - delay(120); - endWrite(); - - _width = ILI9341_TFTWIDTH; - _height = ILI9341_TFTHEIGHT; - setRotation(0); -} - -void ILI9341::setRotation(uint8_t m) { - rotation = m % 4; // can't be higher than 3 - switch (rotation) { - case 0: - // m = (MADCTL_MX | MADCTL_BGR); - m = ( MADCTL_BGR); - _width = ILI9341_TFTWIDTH; - _height = ILI9341_TFTHEIGHT; - break; - case 1: - m = (MADCTL_MX | MADCTL_MV | MADCTL_BGR); - _width = ILI9341_TFTHEIGHT; - _height = ILI9341_TFTWIDTH; - break; - case 2: - m = (MADCTL_MX | MADCTL_MY | MADCTL_BGR); - _width = ILI9341_TFTWIDTH; - _height = ILI9341_TFTHEIGHT; - break; - case 3: - // m = (MADCTL_MX | MADCTL_MY | MADCTL_MV | MADCTL_BGR); - m = (MADCTL_MY | MADCTL_MV | MADCTL_BGR); - _width = ILI9341_TFTHEIGHT; - _height = ILI9341_TFTWIDTH; - break; - } - - startWrite(); - writeCommand(ILI9341_MADCTL); - spiWrite(m); - endWrite(); -} - -void ILI9341::invertDisplay(boolean i) { - startWrite(); - writeCommand(i ? ILI9341_INVON : ILI9341_INVOFF); - endWrite(); -} - -void ILI9341::scrollTo(uint16_t y) { - startWrite(); - writeCommand(ILI9341_VSCRSADD); - SPI_WRITE16(y); - endWrite(); -} - -uint8_t ILI9341::spiRead() { - if(_sclk < 0){ - return HSPI_READ(); - } - if(_miso < 0){ - return 0; - } - uint8_t r = 0; - for (uint8_t i=0; i<8; i++) { - SSPI_SCK_LOW(); - SSPI_SCK_HIGH(); - r <<= 1; - if (SSPI_MISO_READ()){ - r |= 0x1; - } - } - return r; -} - -void ILI9341::spiWrite(uint8_t b) { - if(_sclk < 0){ - HSPI_WRITE(b); - return; - } - for(uint8_t bit = 0x80; bit; bit >>= 1){ - if((b) & bit){ - SSPI_MOSI_HIGH(); - } else { - SSPI_MOSI_LOW(); - } - SSPI_SCK_LOW(); - SSPI_SCK_HIGH(); - } -} - - -/* - * Transaction API - * */ - -void ILI9341::startWrite(void){ - SPI_BEGIN_TRANSACTION(); - SPI_CS_LOW(); -} - -void ILI9341::endWrite(void){ - SPI_CS_HIGH(); - SPI_END_TRANSACTION(); -} - -void ILI9341::writeCommand(uint8_t cmd){ - SPI_DC_LOW(); - spiWrite(cmd); - SPI_DC_HIGH(); -} - -void ILI9341::setAddrWindow(uint16_t x, uint16_t y, uint16_t w, uint16_t h) { - // x = ILI9341_TFTWIDTH - x; - uint32_t xa = ((uint32_t)x << 16) | (x+w-1); - uint32_t ya = ((uint32_t)y << 16) | (y+h-1); - writeCommand(ILI9341_CASET); // Column addr set - SPI_WRITE32(xa); - writeCommand(ILI9341_PASET); // Row addr set - SPI_WRITE32(ya); - writeCommand(ILI9341_RAMWR); // write to RAM -} - -void ILI9341::pushColor(uint16_t color) { - startWrite(); - SPI_WRITE16(color); - endWrite(); -} - - -void ILI9341::writePixel(uint16_t color){ - SPI_WRITE16(color); -} - -void ILI9341::writePixels(uint16_t * colors, uint32_t len){ - SPI_WRITE_PIXELS((uint8_t*)colors , len * 2); -} - -void ILI9341::writeColor(uint16_t color, uint32_t len){ -#ifdef SPI_HAS_WRITE_PIXELS - if(_sclk >= 0){ - for (uint32_t t=0; t SPI_MAX_PIXELS_AT_ONCE)?SPI_MAX_PIXELS_AT_ONCE:len; - uint16_t tlen = 0; - - for (uint32_t t=0; tblen)?blen:len; - writePixels(temp, tlen); - len -= tlen; - } -#else - uint8_t hi = color >> 8, lo = color; - if(_sclk < 0){ //AVR Optimization - for (uint32_t t=len; t; t--){ - HSPI_WRITE(hi); - HSPI_WRITE(lo); - } - return; - } - for (uint32_t t=len; t; t--){ - spiWrite(hi); - spiWrite(lo); - } -#endif -} - -void ILI9341::writePixel(int16_t x, int16_t y, uint16_t color) { - if((x < 0) ||(x >= _width) || (y < 0) || (y >= _height)) return; - setAddrWindow(x,y,1,1); - writePixel(color); -} - -void ILI9341::writeFillRect(int16_t x, int16_t y, int16_t w, int16_t h, uint16_t color){ - if((x >= _width) || (y >= _height)) return; - int16_t x2 = x + w - 1, y2 = y + h - 1; - if((x2 < 0) || (y2 < 0)) return; - - // Clip left/top - if(x < 0) { - x = 0; - w = x2 + 1; - } - if(y < 0) { - y = 0; - h = y2 + 1; - } - - // Clip right/bottom - if(x2 >= _width) w = _width - x; - if(y2 >= _height) h = _height - y; - - int32_t len = (int32_t)w * h; - setAddrWindow(x, y, w, h); - writeColor(color, len); -} - -void ILI9341::writeFastVLine(int16_t x, int16_t y, int16_t h, uint16_t color){ - writeFillRect(x, y, 1, h, color); -} - -void ILI9341::writeFastHLine(int16_t x, int16_t y, int16_t w, uint16_t color){ - writeFillRect(x, y, w, 1, color); -} - -uint8_t ILI9341::readcommand8(uint8_t c, uint8_t index) { - uint32_t freq = _freq; - if(_freq > 24000000){ - _freq = 24000000; - } - startWrite(); - writeCommand(0xD9); // woo sekret command? - spiWrite(0x10 + index); - writeCommand(c); - uint8_t r = spiRead(); - endWrite(); - _freq = freq; - return r; -} - -void ILI9341::drawPixel(int16_t x, int16_t y, uint16_t color){ - startWrite(); - writePixel(x, y, color); - endWrite(); -} - -void ILI9341::drawFastVLine(int16_t x, int16_t y, - int16_t h, uint16_t color) { - startWrite(); - writeFastVLine(x, y, h, color); - endWrite(); -} - -void ILI9341::drawFastHLine(int16_t x, int16_t y, - int16_t w, uint16_t color) { - startWrite(); - writeFastHLine(x, y, w, color); - endWrite(); -} - -void ILI9341::fillRect(int16_t x, int16_t y, int16_t w, int16_t h, - uint16_t color) { - startWrite(); - writeFillRect(x,y,w,h,color); - endWrite(); -} - -// This code was ported/adapted from https://github.com/PaulStoffregen/ILI9341_t3 -// by Marc MERLIN. See examples/pictureEmbed to use this. -void ILI9341::drawBitmap(int16_t x, int16_t y, int16_t w, int16_t h, - const uint16_t *pcolors) { - - int16_t x2, y2; // Lower-right coord - if(( x >= _width ) || // Off-edge right - ( y >= _height) || // " top - ((x2 = (x+w-1)) < 0 ) || // " left - ((y2 = (y+h-1)) < 0) ) return; // " bottom - - int16_t bx1=0, by1=0, // Clipped top-left within bitmap - saveW=w; // Save original bitmap width value - if(x < 0) { // Clip left - w += x; - bx1 = -x; - x = 0; - } - if(y < 0) { // Clip top - h += y; - by1 = -y; - y = 0; - } - if(x2 >= _width ) w = _width - x; // Clip right - if(y2 >= _height) h = _height - y; // Clip bottom - - pcolors += by1 * saveW + bx1; // Offset bitmap ptr to clipped top-left - startWrite(); - setAddrWindow(x, y, w, h); // Clipped area - while(h--) { // For each (clipped) scanline... - writePixels((uint16_t*)pcolors, w); // Push one (clipped) row - pcolors += saveW; // Advance pointer by one full (unclipped) line - } - endWrite(); -} - -void ILI9341::drawBitmap(int16_t x, int16_t y, int16_t w, int16_t h, const uint8_t *pcolors) { - drawBitmap(x, y, w, h, (uint16_t*)pcolors); -} - -void ILI9341::progressBar(int x, int y, int w, int h, uint8_t val) { - drawRect(x, y, w, h, 0x09F1); - fillRect(x+1, y+1, w*(((float)val)/100.0), h-1, 0x09F1); -} - -void ILI9341::setBrightness(uint8_t brightness) { - ledcSetup(2, 10000, 8); - ledcAttachPin(TFT_LED_PIN, 2); - ledcWrite(2, brightness); - // pinMode(TFT_LED_PIN, OUPUT); - // digitalWrite(TFT_LED_PIN, 1); -} - -void ILI9341::putChar(int x, int y, char ch) { - setCursor(x, y); - print(ch); -} - -void ILI9341::putStr(int x, int y, String str) { - setCursor(x, y); - print(str); -} \ No newline at end of file diff --git a/examples/Basics/GFX_Library/Display.h b/examples/Basics/GFX_Library/Display.h deleted file mode 100644 index 5f99d02..0000000 --- a/examples/Basics/GFX_Library/Display.h +++ /dev/null @@ -1,231 +0,0 @@ -/****************************************************************** - This is our library for the Adafruit ILI9341 Breakout and Shield - ----> http://www.adafruit.com/products/1651 - - Check out the links above for our tutorials and wiring diagrams - These displays use SPI to communicate, 4 or 5 pins are required - to interface (RST is optional) - Adafruit invests time and resources providing this open source - code, please support Adafruit and open-source hardware by - purchasing products from Adafruit! - - Written by Limor Fried/Ladyada for Adafruit Industries. - MIT license, all text above must be included in any redistribution - *******************************************************************/ - -#ifndef _DISPLAY_H_ -#define _DISPLAY_H_ - -#if ARDUINO >= 100 - #include "Arduino.h" - #include "Print.h" -#else - #include "WProgram.h" -#endif -#include -#include -// #include -#include - -#define ILI9341_TFTWIDTH 320 -#define ILI9341_TFTHEIGHT 240 - -#define ILI9341_NOP 0x00 -#define ILI9341_SWRESET 0x01 -#define ILI9341_RDDID 0x04 -#define ILI9341_RDDST 0x09 - -#define ILI9341_SLPIN 0x10 -#define ILI9341_SLPOUT 0x11 -#define ILI9341_PTLON 0x12 -#define ILI9341_NORON 0x13 - -#define ILI9341_RDMODE 0x0A -#define ILI9341_RDMADCTL 0x0B -#define ILI9341_RDPIXFMT 0x0C -#define ILI9341_RDIMGFMT 0x0D -#define ILI9341_RDSELFDIAG 0x0F - -#define ILI9341_INVOFF 0x20 -#define ILI9341_INVON 0x21 -#define ILI9341_GAMMASET 0x26 -#define ILI9341_DISPOFF 0x28 -#define ILI9341_DISPON 0x29 - -#define ILI9341_CASET 0x2A -#define ILI9341_PASET 0x2B -#define ILI9341_RAMWR 0x2C -#define ILI9341_RAMRD 0x2E - -#define ILI9341_PTLAR 0x30 -#define ILI9341_MADCTL 0x36 -#define ILI9341_VSCRSADD 0x37 -#define ILI9341_PIXFMT 0x3A - -#define ILI9341_FRMCTR1 0xB1 -#define ILI9341_FRMCTR2 0xB2 -#define ILI9341_FRMCTR3 0xB3 -#define ILI9341_INVCTR 0xB4 -#define ILI9341_DFUNCTR 0xB6 - -#define ILI9341_PWCTR1 0xC0 -#define ILI9341_PWCTR2 0xC1 -#define ILI9341_PWCTR3 0xC2 -#define ILI9341_PWCTR4 0xC3 -#define ILI9341_PWCTR5 0xC4 -#define ILI9341_VMCTR1 0xC5 -#define ILI9341_VMCTR2 0xC7 - -#define ILI9341_RDID1 0xDA -#define ILI9341_RDID2 0xDB -#define ILI9341_RDID3 0xDC -#define ILI9341_RDID4 0xDD - -#define ILI9341_GMCTRP1 0xE0 -#define ILI9341_GMCTRN1 0xE1 -/* -#define ILI9341_PWCTR6 0xFC -*/ - -// Color definitions -#define ILI9341_BLACK 0x0000 /* 0, 0, 0 */ -#define ILI9341_NAVY 0x000F /* 0, 0, 128 */ -#define ILI9341_DARKGREEN 0x03E0 /* 0, 128, 0 */ -#define ILI9341_DARKCYAN 0x03EF /* 0, 128, 128 */ -#define ILI9341_MAROON 0x7800 /* 128, 0, 0 */ -#define ILI9341_PURPLE 0x780F /* 128, 0, 128 */ -#define ILI9341_OLIVE 0x7BE0 /* 128, 128, 0 */ -#define ILI9341_LIGHTGREY 0xC618 /* 192, 192, 192 */ -#define ILI9341_DARKGREY 0x7BEF /* 128, 128, 128 */ -#define ILI9341_BLUE 0x001F /* 0, 0, 255 */ -#define ILI9341_GREEN 0x07E0 /* 0, 255, 0 */ -#define ILI9341_CYAN 0x07FF /* 0, 255, 255 */ -#define ILI9341_RED 0xF800 /* 255, 0, 0 */ -#define ILI9341_MAGENTA 0xF81F /* 255, 0, 255 */ -#define ILI9341_YELLOW 0xFFE0 /* 255, 255, 0 */ -#define ILI9341_WHITE 0xFFFF /* 255, 255, 255 */ -#define ILI9341_ORANGE 0xFD20 /* 255, 165, 0 */ -#define ILI9341_GREENYELLOW 0xAFE5 /* 173, 255, 47 */ -#define ILI9341_PINK 0xF81F - -#define BLACK 0x0000 /* 0, 0, 0 */ -#define NAVY 0x000F /* 0, 0, 128 */ -#define DARKGREEN 0x03E0 /* 0, 128, 0 */ -#define DARKCYAN 0x03EF /* 0, 128, 128 */ -#define MAROON 0x7800 /* 128, 0, 0 */ -#define PURPLE 0x780F /* 128, 0, 128 */ -#define OLIVE 0x7BE0 /* 128, 128, 0 */ -#define LIGHTGREY 0xC618 /* 192, 192, 192 */ -#define DARKGREY 0x7BEF /* 128, 128, 128 */ -#define BLUE 0x001F /* 0, 0, 255 */ -#define GREEN 0x07E0 /* 0, 255, 0 */ -#define CYAN 0x07FF /* 0, 255, 255 */ -#define RED 0xF800 /* 255, 0, 0 */ -#define MAGENTA 0xF81F /* 255, 0, 255 */ -#define YELLOW 0xFFE0 /* 255, 255, 0 */ -#define WHITE 0xFFFF /* 255, 255, 255 */ -#define ORANGE 0xFD20 /* 255, 165, 0 */ -#define GREENYELLOW 0xAFE5 /* 173, 255, 47 */ -#define PINK 0xF81F - -#if defined(ESP8266) || defined (ESP32) -#define USE_FAST_PINIO -#endif - -class ILI9341 : public Adafruit_GFX { - protected: - - public: - ILI9341(int8_t _CS, int8_t _DC, int8_t _MOSI, int8_t _SCLK, int8_t _RST = -1, int8_t _MISO = -1); - ILI9341(int8_t _CS, int8_t _DC, int8_t _RST = -1); - -#ifndef ESP32 - void begin(uint32_t freq = 0); -#else - void begin(uint32_t freq = 0, SPIClass &spi=SPI); -#endif - void setRotation(uint8_t r); - void invertDisplay(boolean i); - void scrollTo(uint16_t y); - - // Required Non-Transaction - void drawPixel(int16_t x, int16_t y, uint16_t color); - - // Transaction API - void startWrite(void); - void endWrite(void); - void writePixel(int16_t x, int16_t y, uint16_t color); - void writeFillRect(int16_t x, int16_t y, int16_t w, int16_t h, uint16_t color); - void writeFastVLine(int16_t x, int16_t y, int16_t h, uint16_t color); - void writeFastHLine(int16_t x, int16_t y, int16_t w, uint16_t color); - - // Transaction API not used by GFX - void setAddrWindow(uint16_t x, uint16_t y, uint16_t w, uint16_t h); - void writePixel(uint16_t color); - void writePixels(uint16_t * colors, uint32_t len); - void writeColor(uint16_t color, uint32_t len); - void pushColor(uint16_t color); - - // Recommended Non-Transaction - void drawFastVLine(int16_t x, int16_t y, int16_t h, uint16_t color); - void drawFastHLine(int16_t x, int16_t y, int16_t w, uint16_t color); - void fillRect(int16_t x, int16_t y, int16_t w, int16_t h, uint16_t color); - void drawBitmap(int16_t x, int16_t y, int16_t w, int16_t h, const uint16_t *pcolors); - void drawBitmap(int16_t x, int16_t y, int16_t w, int16_t h, const uint8_t *pcolors); - - uint8_t readcommand8(uint8_t reg, uint8_t index = 0); - - uint16_t color565(uint8_t r, uint8_t g, uint8_t b); - - // via Charles Bailey on stackoverflow: - // "Functions in derived classes which don't override functions in base - // classes but which have the same name will hide other functions of the - // same name in the base class. - // "It is generally considered bad practice to have have functions in - // derived classes which have the same name as functions in the base - // class which aren't intended to override the base class functions as - // what you are seeing is not usually desirable behaviour. It is usually - // preferable to give different functions different names." - // i.e. this function in ILI9341 should not have been called this; it's - // fundamentally different from GFX's drawBitmap(). But here we are, - // painted into the proverbial corner. C++11 has the 'using' keyword - // to allow access to base class functions. This'll band-aid the issue - // for now but might be inadequate for "vintage" complier variants that - // some board support packages might possibly be using, dunno. - using Adafruit_GFX::drawBitmap; - void progressBar(int x, int y, int w, int h, uint8_t val); - void setBrightness(uint8_t brightness); - void putChar(int x, int y, char ch); - void putStr(int x, int y, String str); - - private: - SPIClass _spi; - uint32_t _freq; -#if defined (__AVR__) || defined(TEENSYDUINO) - int8_t _cs, _dc, _rst, _sclk, _mosi, _miso; -#ifdef USE_FAST_PINIO - volatile uint8_t *mosiport, *misoport, *clkport, *dcport, *csport; - uint8_t mosipinmask, misopinmask, clkpinmask, cspinmask, dcpinmask; -#endif -#elif defined (__arm__) - int32_t _cs, _dc, _rst, _sclk, _mosi, _miso; -#ifdef USE_FAST_PINIO - volatile RwReg *mosiport, *misoport, *clkport, *dcport, *csport; - uint32_t mosipinmask, misopinmask, clkpinmask, cspinmask, dcpinmask; -#endif -#elif defined (ESP8266) || defined (ESP32) - int8_t _cs, _dc, _rst, _sclk, _mosi, _miso; -#ifdef USE_FAST_PINIO - volatile uint32_t *mosiport, *misoport, *clkport, *dcport, *csport; - uint32_t mosipinmask, misopinmask, clkpinmask, cspinmask, dcpinmask; -#endif -#else - int8_t _cs, _dc, _rst, _sclk, _mosi, _miso; -#endif - - void writeCommand(uint8_t cmd); - void spiWrite(uint8_t v); - uint8_t spiRead(void); -}; - -#endif diff --git a/examples/Basics/GFX_Library/README.md b/examples/Basics/GFX_Library/README.md deleted file mode 100644 index 972c966..0000000 --- a/examples/Basics/GFX_Library/README.md +++ /dev/null @@ -1,21 +0,0 @@ -# Adafruit GFX Library - -This is the core graphics library for all our displays, providing a common set of graphics primitives (points, lines, circles, etc.). It needs to be paired with a hardware-specific library for each display device we carry (to handle the lower-level functions). - -Adafruit invests time and resources providing this open source code, please support Adafruit and open-source hardware by purchasing products from Adafruit! - -Written by Limor Fried/Ladyada for Adafruit Industries. -BSD license, check license.txt for more information. -All text above must be included in any redistribution. - -Recent Arduino IDE releases include the Library Manager for easy installation. Otherwise, to download, click the DOWNLOAD ZIP button, uncompress and rename the uncompressed folder Adafruit_GFX. Confirm that the Adafruit_GFX folder contains Adafruit_GFX.cpp and Adafruit_GFX.h. Place the Adafruit_GFX library folder your /Libraries/ folder. You may need to create the Libraries subfolder if its your first library. Restart the IDE. - -# Useful Resources - -- Image2Code: This is a handy Java GUI utility to convert a BMP file into the array code necessary to display the image with the drawBitmap function. Check out the code at ehubin's GitHub repository: https://github.com/ehubin/Adafruit-GFX-Library/tree/master/Img2Code - -- drawXBitmap function: You can use the GIMP photo editor to save a .xbm file and use the array saved in the file to draw a bitmap with the drawXBitmap function. See the pull request here for more details: https://github.com/adafruit/Adafruit-GFX-Library/pull/31 - -- 'Fonts' folder contains bitmap fonts for use with recent (1.1 and later) Adafruit_GFX. To use a font in your Arduino sketch, #include the corresponding .h file and pass address of GFXfont struct to setFont(). Pass NULL to revert to 'classic' fixed-space bitmap font. - -- 'fontconvert' folder contains a command-line tool for converting TTF fonts to Adafruit_GFX .h format. diff --git a/examples/Basics/GFX_Library/dafruit_GFX.cpp b/examples/Basics/GFX_Library/dafruit_GFX.cpp deleted file mode 100644 index b2f50ee..0000000 --- a/examples/Basics/GFX_Library/dafruit_GFX.cpp +++ /dev/null @@ -1,1347 +0,0 @@ -/* -This is the core graphics library for all our displays, providing a common -set of graphics primitives (points, lines, circles, etc.). It needs to be -paired with a hardware-specific library for each display device we carry -(to handle the lower-level functions). - -Adafruit invests time and resources providing this open source code, please -support Adafruit & open-source hardware by purchasing products from Adafruit! - -Copyright (c) 2013 Adafruit Industries. All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: - -- Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer. -- Redistributions in binary form must reproduce the above copyright notice, - this list of conditions and the following disclaimer in the documentation - and/or other materials provided with the distribution. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE -LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -POSSIBILITY OF SUCH DAMAGE. - */ - -#include "dafruit_GFX.h" -#include "glcdfont.c" -#ifdef __AVR__ - #include -#elif defined(ESP8266) || defined(ESP32) - #include -#endif - -// Many (but maybe not all) non-AVR board installs define macros -// for compatibility with existing PROGMEM-reading AVR code. -// Do our own checks and defines here for good measure... - -#ifndef pgm_read_byte - #define pgm_read_byte(addr) (*(const unsigned char *)(addr)) -#endif -#ifndef pgm_read_word - #define pgm_read_word(addr) (*(const unsigned short *)(addr)) -#endif -#ifndef pgm_read_dword - #define pgm_read_dword(addr) (*(const unsigned long *)(addr)) -#endif - -// Pointers are a peculiar case...typically 16-bit on AVR boards, -// 32 bits elsewhere. Try to accommodate both... - -#if !defined(__INT_MAX__) || (__INT_MAX__ > 0xFFFF) - #define pgm_read_pointer(addr) ((void *)pgm_read_dword(addr)) -#else - #define pgm_read_pointer(addr) ((void *)pgm_read_word(addr)) -#endif - -#ifndef min -#define min(a,b) (((a) < (b)) ? (a) : (b)) -#endif - -#ifndef _swap_int16_t -#define _swap_int16_t(a, b) { int16_t t = a; a = b; b = t; } -#endif - -Adafruit_GFX::Adafruit_GFX(int16_t w, int16_t h): -WIDTH(w), HEIGHT(h) -{ - _width = WIDTH; - _height = HEIGHT; - rotation = 0; - cursor_y = cursor_x = 0; - textsize = 1; - textcolor = textbgcolor = 0xFFFF; - wrap = true; - _cp437 = false; - gfxFont = NULL; -} - -// Bresenham's algorithm - thx wikpedia -void Adafruit_GFX::writeLine(int16_t x0, int16_t y0, int16_t x1, int16_t y1, - uint16_t color) { - int16_t steep = abs(y1 - y0) > abs(x1 - x0); - if (steep) { - _swap_int16_t(x0, y0); - _swap_int16_t(x1, y1); - } - - if (x0 > x1) { - _swap_int16_t(x0, x1); - _swap_int16_t(y0, y1); - } - - int16_t dx, dy; - dx = x1 - x0; - dy = abs(y1 - y0); - - int16_t err = dx / 2; - int16_t ystep; - - if (y0 < y1) { - ystep = 1; - } else { - ystep = -1; - } - - for (; x0<=x1; x0++) { - if (steep) { - writePixel(y0, x0, color); - } else { - writePixel(x0, y0, color); - } - err -= dy; - if (err < 0) { - y0 += ystep; - err += dx; - } - } -} - -void Adafruit_GFX::startWrite(){ - // Overwrite in subclasses if desired! -} - -void Adafruit_GFX::writePixel(int16_t x, int16_t y, uint16_t color) { - // Overwrite in subclasses if startWrite is defined! - drawPixel(x, y, color); -} - -// (x,y) is topmost point; if unsure, calling function -// should sort endpoints or call writeLine() instead -void Adafruit_GFX::writeFastVLine(int16_t x, int16_t y, - int16_t h, uint16_t color) { - // Overwrite in subclasses if startWrite is defined! - // Can be just writeLine(x, y, x, y+h-1, color); - // or writeFillRect(x, y, 1, h, color); - drawFastVLine(x, y, h, color); -} - -// (x,y) is leftmost point; if unsure, calling function -// should sort endpoints or call writeLine() instead -void Adafruit_GFX::writeFastHLine(int16_t x, int16_t y, - int16_t w, uint16_t color) { - // Overwrite in subclasses if startWrite is defined! - // Example: writeLine(x, y, x+w-1, y, color); - // or writeFillRect(x, y, w, 1, color); - drawFastHLine(x, y, w, color); -} - -void Adafruit_GFX::writeFillRect(int16_t x, int16_t y, int16_t w, int16_t h, - uint16_t color) { - // Overwrite in subclasses if desired! - fillRect(x,y,w,h,color); -} - -void Adafruit_GFX::endWrite(){ - // Overwrite in subclasses if startWrite is defined! -} - -// (x,y) is topmost point; if unsure, calling function -// should sort endpoints or call drawLine() instead -void Adafruit_GFX::drawFastVLine(int16_t x, int16_t y, - int16_t h, uint16_t color) { - // Update in subclasses if desired! - startWrite(); - writeLine(x, y, x, y+h-1, color); - endWrite(); -} - -// (x,y) is leftmost point; if unsure, calling function -// should sort endpoints or call drawLine() instead -void Adafruit_GFX::drawFastHLine(int16_t x, int16_t y, - int16_t w, uint16_t color) { - // Update in subclasses if desired! - startWrite(); - writeLine(x, y, x+w-1, y, color); - endWrite(); -} - -void Adafruit_GFX::fillRect(int16_t x, int16_t y, int16_t w, int16_t h, - uint16_t color) { - // Update in subclasses if desired! - startWrite(); - for (int16_t i=x; i y1) _swap_int16_t(y0, y1); - drawFastVLine(x0, y0, y1 - y0 + 1, color); - } else if(y0 == y1){ - if(x0 > x1) _swap_int16_t(x0, x1); - drawFastHLine(x0, y0, x1 - x0 + 1, color); - } else { - startWrite(); - writeLine(x0, y0, x1, y1, color); - endWrite(); - } -} - -// Draw a circle outline -void Adafruit_GFX::drawCircle(int16_t x0, int16_t y0, int16_t r, - uint16_t color) { - int16_t f = 1 - r; - int16_t ddF_x = 1; - int16_t ddF_y = -2 * r; - int16_t x = 0; - int16_t y = r; - - startWrite(); - writePixel(x0 , y0+r, color); - writePixel(x0 , y0-r, color); - writePixel(x0+r, y0 , color); - writePixel(x0-r, y0 , color); - - while (x= 0) { - y--; - ddF_y += 2; - f += ddF_y; - } - x++; - ddF_x += 2; - f += ddF_x; - - writePixel(x0 + x, y0 + y, color); - writePixel(x0 - x, y0 + y, color); - writePixel(x0 + x, y0 - y, color); - writePixel(x0 - x, y0 - y, color); - writePixel(x0 + y, y0 + x, color); - writePixel(x0 - y, y0 + x, color); - writePixel(x0 + y, y0 - x, color); - writePixel(x0 - y, y0 - x, color); - } - endWrite(); -} - -void Adafruit_GFX::drawCircleHelper( int16_t x0, int16_t y0, - int16_t r, uint8_t cornername, uint16_t color) { - int16_t f = 1 - r; - int16_t ddF_x = 1; - int16_t ddF_y = -2 * r; - int16_t x = 0; - int16_t y = r; - - while (x= 0) { - y--; - ddF_y += 2; - f += ddF_y; - } - x++; - ddF_x += 2; - f += ddF_x; - if (cornername & 0x4) { - writePixel(x0 + x, y0 + y, color); - writePixel(x0 + y, y0 + x, color); - } - if (cornername & 0x2) { - writePixel(x0 + x, y0 - y, color); - writePixel(x0 + y, y0 - x, color); - } - if (cornername & 0x8) { - writePixel(x0 - y, y0 + x, color); - writePixel(x0 - x, y0 + y, color); - } - if (cornername & 0x1) { - writePixel(x0 - y, y0 - x, color); - writePixel(x0 - x, y0 - y, color); - } - } -} - -void Adafruit_GFX::fillCircle(int16_t x0, int16_t y0, int16_t r, - uint16_t color) { - startWrite(); - writeFastVLine(x0, y0-r, 2*r+1, color); - fillCircleHelper(x0, y0, r, 3, 0, color); - endWrite(); -} - -// Used to do circles and roundrects -void Adafruit_GFX::fillCircleHelper(int16_t x0, int16_t y0, int16_t r, - uint8_t cornername, int16_t delta, uint16_t color) { - - int16_t f = 1 - r; - int16_t ddF_x = 1; - int16_t ddF_y = -2 * r; - int16_t x = 0; - int16_t y = r; - - while (x= 0) { - y--; - ddF_y += 2; - f += ddF_y; - } - x++; - ddF_x += 2; - f += ddF_x; - - if (cornername & 0x1) { - writeFastVLine(x0+x, y0-y, 2*y+1+delta, color); - writeFastVLine(x0+y, y0-x, 2*x+1+delta, color); - } - if (cornername & 0x2) { - writeFastVLine(x0-x, y0-y, 2*y+1+delta, color); - writeFastVLine(x0-y, y0-x, 2*x+1+delta, color); - } - } -} - -// Draw a rectangle -void Adafruit_GFX::drawRect(int16_t x, int16_t y, int16_t w, int16_t h, - uint16_t color) { - startWrite(); - writeFastHLine(x, y, w, color); - writeFastHLine(x, y+h-1, w, color); - writeFastVLine(x, y, h, color); - writeFastVLine(x+w-1, y, h, color); - endWrite(); -} - -// Draw a rounded rectangle -void Adafruit_GFX::drawRoundRect(int16_t x, int16_t y, int16_t w, - int16_t h, int16_t r, uint16_t color) { - // smarter version - startWrite(); - writeFastHLine(x+r , y , w-2*r, color); // Top - writeFastHLine(x+r , y+h-1, w-2*r, color); // Bottom - writeFastVLine(x , y+r , h-2*r, color); // Left - writeFastVLine(x+w-1, y+r , h-2*r, color); // Right - // draw four corners - drawCircleHelper(x+r , y+r , r, 1, color); - drawCircleHelper(x+w-r-1, y+r , r, 2, color); - drawCircleHelper(x+w-r-1, y+h-r-1, r, 4, color); - drawCircleHelper(x+r , y+h-r-1, r, 8, color); - endWrite(); -} - -// Fill a rounded rectangle -void Adafruit_GFX::fillRoundRect(int16_t x, int16_t y, int16_t w, - int16_t h, int16_t r, uint16_t color) { - // smarter version - startWrite(); - writeFillRect(x+r, y, w-2*r, h, color); - - // draw four corners - fillCircleHelper(x+w-r-1, y+r, r, 1, h-2*r-1, color); - fillCircleHelper(x+r , y+r, r, 2, h-2*r-1, color); - endWrite(); -} - -// Draw a triangle -void Adafruit_GFX::drawTriangle(int16_t x0, int16_t y0, - int16_t x1, int16_t y1, int16_t x2, int16_t y2, uint16_t color) { - drawLine(x0, y0, x1, y1, color); - drawLine(x1, y1, x2, y2, color); - drawLine(x2, y2, x0, y0, color); -} - -// Fill a triangle -void Adafruit_GFX::fillTriangle(int16_t x0, int16_t y0, - int16_t x1, int16_t y1, int16_t x2, int16_t y2, uint16_t color) { - - int16_t a, b, y, last; - - // Sort coordinates by Y order (y2 >= y1 >= y0) - if (y0 > y1) { - _swap_int16_t(y0, y1); _swap_int16_t(x0, x1); - } - if (y1 > y2) { - _swap_int16_t(y2, y1); _swap_int16_t(x2, x1); - } - if (y0 > y1) { - _swap_int16_t(y0, y1); _swap_int16_t(x0, x1); - } - - startWrite(); - if(y0 == y2) { // Handle awkward all-on-same-line case as its own thing - a = b = x0; - if(x1 < a) a = x1; - else if(x1 > b) b = x1; - if(x2 < a) a = x2; - else if(x2 > b) b = x2; - writeFastHLine(a, y0, b-a+1, color); - endWrite(); - return; - } - - int16_t - dx01 = x1 - x0, - dy01 = y1 - y0, - dx02 = x2 - x0, - dy02 = y2 - y0, - dx12 = x2 - x1, - dy12 = y2 - y1; - int32_t - sa = 0, - sb = 0; - - // For upper part of triangle, find scanline crossings for segments - // 0-1 and 0-2. If y1=y2 (flat-bottomed triangle), the scanline y1 - // is included here (and second loop will be skipped, avoiding a /0 - // error there), otherwise scanline y1 is skipped here and handled - // in the second loop...which also avoids a /0 error here if y0=y1 - // (flat-topped triangle). - if(y1 == y2) last = y1; // Include y1 scanline - else last = y1-1; // Skip it - - for(y=y0; y<=last; y++) { - a = x0 + sa / dy01; - b = x0 + sb / dy02; - sa += dx01; - sb += dx02; - /* longhand: - a = x0 + (x1 - x0) * (y - y0) / (y1 - y0); - b = x0 + (x2 - x0) * (y - y0) / (y2 - y0); - */ - if(a > b) _swap_int16_t(a,b); - writeFastHLine(a, y, b-a+1, color); - } - - // For lower part of triangle, find scanline crossings for segments - // 0-2 and 1-2. This loop is skipped if y1=y2. - sa = dx12 * (y - y1); - sb = dx02 * (y - y0); - for(; y<=y2; y++) { - a = x1 + sa / dy12; - b = x0 + sb / dy02; - sa += dx12; - sb += dx02; - /* longhand: - a = x1 + (x2 - x1) * (y - y1) / (y2 - y1); - b = x0 + (x2 - x0) * (y - y0) / (y2 - y0); - */ - if(a > b) _swap_int16_t(a,b); - writeFastHLine(a, y, b-a+1, color); - } - endWrite(); -} - -// BITMAP / XBITMAP / GRAYSCALE / RGB BITMAP FUNCTIONS --------------------- - -// Draw a PROGMEM-resident 1-bit image at the specified (x,y) position, -// using the specified foreground color (unset bits are transparent). -void Adafruit_GFX::drawBitmap(int16_t x, int16_t y, - const uint8_t bitmap[], int16_t w, int16_t h, uint16_t color) { - - int16_t byteWidth = (w + 7) / 8; // Bitmap scanline pad = whole byte - uint8_t byte = 0; - - startWrite(); - for(int16_t j=0; j>= 1; - else byte = pgm_read_byte(&bitmap[j * byteWidth + i / 8]); - // Nearly identical to drawBitmap(), only the bit order - // is reversed here (left-to-right = LSB to MSB): - if(byte & 0x01) writePixel(x+i, y, color); - } - } - endWrite(); -} - -// Draw a PROGMEM-resident 8-bit image (grayscale) at the specified (x,y) -// pos. Specifically for 8-bit display devices such as IS31FL3731; -// no color reduction/expansion is performed. -void Adafruit_GFX::drawGrayscaleBitmap(int16_t x, int16_t y, - const uint8_t bitmap[], int16_t w, int16_t h) { - startWrite(); - for(int16_t j=0; j= _width) || // Clip right - (y >= _height) || // Clip bottom - ((x + 6 * size - 1) < 0) || // Clip left - ((y + 8 * size - 1) < 0)) // Clip top - return; - - if(!_cp437 && (c >= 176)) c++; // Handle 'classic' charset behavior - - startWrite(); - for(int8_t i=0; i<5; i++ ) { // Char bitmap = 5 columns - uint8_t line = pgm_read_byte(&font[c * 5 + i]); - for(int8_t j=0; j<8; j++, line >>= 1) { - if(line & 1) { - if(size == 1) - writePixel(x+i, y+j, color); - else - writeFillRect(x+i*size, y+j*size, size, size, color); - } else if(bg != color) { - if(size == 1) - writePixel(x+i, y+j, bg); - else - writeFillRect(x+i*size, y+j*size, size, size, bg); - } - } - } - if(bg != color) { // If opaque, draw vertical line for last column - if(size == 1) writeFastVLine(x+5, y, 8, bg); - else writeFillRect(x+5*size, y, size, 8*size, bg); - } - endWrite(); - - } else { // Custom font - - // Character is assumed previously filtered by write() to eliminate - // newlines, returns, non-printable characters, etc. Calling - // drawChar() directly with 'bad' characters of font may cause mayhem! - - c -= (uint8_t)pgm_read_byte(&gfxFont->first); - GFXglyph *glyph = &(((GFXglyph *)pgm_read_pointer(&gfxFont->glyph))[c]); - uint8_t *bitmap = (uint8_t *)pgm_read_pointer(&gfxFont->bitmap); - - uint16_t bo = pgm_read_word(&glyph->bitmapOffset); - uint8_t w = pgm_read_byte(&glyph->width), - h = pgm_read_byte(&glyph->height); - int8_t xo = pgm_read_byte(&glyph->xOffset), - yo = pgm_read_byte(&glyph->yOffset); - uint8_t xx, yy, bits = 0, bit = 0; - int16_t xo16 = 0, yo16 = 0; - - if(size > 1) { - xo16 = xo; - yo16 = yo; - } - - // Todo: Add character clipping here - - // NOTE: THERE IS NO 'BACKGROUND' COLOR OPTION ON CUSTOM FONTS. - // THIS IS ON PURPOSE AND BY DESIGN. The background color feature - // has typically been used with the 'classic' font to overwrite old - // screen contents with new data. This ONLY works because the - // characters are a uniform size; it's not a sensible thing to do with - // proportionally-spaced fonts with glyphs of varying sizes (and that - // may overlap). To replace previously-drawn text when using a custom - // font, use the getTextBounds() function to determine the smallest - // rectangle encompassing a string, erase the area with fillRect(), - // then draw new text. This WILL infortunately 'blink' the text, but - // is unavoidable. Drawing 'background' pixels will NOT fix this, - // only creates a new set of problems. Have an idea to work around - // this (a canvas object type for MCUs that can afford the RAM and - // displays supporting setAddrWindow() and pushColors()), but haven't - // implemented this yet. - - startWrite(); - for(yy=0; yy= 100 -size_t Adafruit_GFX::write(uint8_t c) { -#else -void Adafruit_GFX::write(uint8_t c) { -#endif - if(!gfxFont) { // 'Classic' built-in font - - if(c == '\n') { // Newline? - cursor_x = 0; // Reset x to zero, - cursor_y += textsize * 8; // advance y one line - } else if(c != '\r') { // Ignore carriage returns - if(wrap && ((cursor_x + textsize * 6) > _width)) { // Off right? - cursor_x = 0; // Reset x to zero, - cursor_y += textsize * 8; // advance y one line - } - drawChar(cursor_x, cursor_y, c, textcolor, textbgcolor, textsize); - cursor_x += textsize * 6; // Advance x one char - } - - } else { // Custom font - - if(c == '\n') { - cursor_x = 0; - cursor_y += (int16_t)textsize * - (uint8_t)pgm_read_byte(&gfxFont->yAdvance); - } else if(c != '\r') { - uint8_t first = pgm_read_byte(&gfxFont->first); - if((c >= first) && (c <= (uint8_t)pgm_read_byte(&gfxFont->last))) { - GFXglyph *glyph = &(((GFXglyph *)pgm_read_pointer( - &gfxFont->glyph))[c - first]); - uint8_t w = pgm_read_byte(&glyph->width), - h = pgm_read_byte(&glyph->height); - if((w > 0) && (h > 0)) { // Is there an associated bitmap? - int16_t xo = (int8_t)pgm_read_byte(&glyph->xOffset); // sic - if(wrap && ((cursor_x + textsize * (xo + w)) > _width)) { - cursor_x = 0; - cursor_y += (int16_t)textsize * - (uint8_t)pgm_read_byte(&gfxFont->yAdvance); - } - drawChar(cursor_x, cursor_y, c, textcolor, textbgcolor, textsize); - } - cursor_x += (uint8_t)pgm_read_byte(&glyph->xAdvance) * (int16_t)textsize; - } - } - } -#if ARDUINO >= 100 - return 1; -#endif -} - -void Adafruit_GFX::setCursor(int16_t x, int16_t y) { - cursor_x = x; - cursor_y = y; -} - -int16_t Adafruit_GFX::getCursorX(void) const { - return cursor_x; -} - -int16_t Adafruit_GFX::getCursorY(void) const { - return cursor_y; -} - -void Adafruit_GFX::setTextSize(uint8_t s) { - textsize = (s > 0) ? s : 1; -} - -void Adafruit_GFX::setTextColor(uint16_t c) { - // For 'transparent' background, we'll set the bg - // to the same as fg instead of using a flag - textcolor = textbgcolor = c; -} - -void Adafruit_GFX::setTextColor(uint16_t c, uint16_t b) { - textcolor = c; - textbgcolor = b; -} - -void Adafruit_GFX::setTextWrap(boolean w) { - wrap = w; -} - -uint8_t Adafruit_GFX::getRotation(void) const { - return rotation; -} - -void Adafruit_GFX::setRotation(uint8_t x) { - rotation = (x & 3); - switch(rotation) { - case 0: - case 2: - _width = WIDTH; - _height = HEIGHT; - break; - case 1: - case 3: - _width = HEIGHT; - _height = WIDTH; - break; - } -} - -// Enable (or disable) Code Page 437-compatible charset. -// There was an error in glcdfont.c for the longest time -- one character -// (#176, the 'light shade' block) was missing -- this threw off the index -// of every character that followed it. But a TON of code has been written -// with the erroneous character indices. By default, the library uses the -// original 'wrong' behavior and old sketches will still work. Pass 'true' -// to this function to use correct CP437 character values in your code. -void Adafruit_GFX::cp437(boolean x) { - _cp437 = x; -} - -void Adafruit_GFX::setFont(const GFXfont *f) { - if(f) { // Font struct pointer passed in? - if(!gfxFont) { // And no current font struct? - // Switching from classic to new font behavior. - // Move cursor pos down 6 pixels so it's on baseline. - cursor_y += 6; - } - } else if(gfxFont) { // NULL passed. Current font struct defined? - // Switching from new to classic font behavior. - // Move cursor pos up 6 pixels so it's at top-left of char. - cursor_y -= 6; - } - gfxFont = (GFXfont *)f; -} - -// Broke this out as it's used by both the PROGMEM- and RAM-resident -// getTextBounds() functions. -void Adafruit_GFX::charBounds(char c, int16_t *x, int16_t *y, - int16_t *minx, int16_t *miny, int16_t *maxx, int16_t *maxy) { - - if(gfxFont) { - - if(c == '\n') { // Newline? - *x = 0; // Reset x to zero, advance y by one line - *y += textsize * (uint8_t)pgm_read_byte(&gfxFont->yAdvance); - } else if(c != '\r') { // Not a carriage return; is normal char - uint8_t first = pgm_read_byte(&gfxFont->first), - last = pgm_read_byte(&gfxFont->last); - if((c >= first) && (c <= last)) { // Char present in this font? - GFXglyph *glyph = &(((GFXglyph *)pgm_read_pointer( - &gfxFont->glyph))[c - first]); - uint8_t gw = pgm_read_byte(&glyph->width), - gh = pgm_read_byte(&glyph->height), - xa = pgm_read_byte(&glyph->xAdvance); - int8_t xo = pgm_read_byte(&glyph->xOffset), - yo = pgm_read_byte(&glyph->yOffset); - if(wrap && ((*x+(((int16_t)xo+gw)*textsize)) > _width)) { - *x = 0; // Reset x to zero, advance y by one line - *y += textsize * (uint8_t)pgm_read_byte(&gfxFont->yAdvance); - } - int16_t ts = (int16_t)textsize, - x1 = *x + xo * ts, - y1 = *y + yo * ts, - x2 = x1 + gw * ts - 1, - y2 = y1 + gh * ts - 1; - if(x1 < *minx) *minx = x1; - if(y1 < *miny) *miny = y1; - if(x2 > *maxx) *maxx = x2; - if(y2 > *maxy) *maxy = y2; - *x += xa * ts; - } - } - - } else { // Default font - - if(c == '\n') { // Newline? - *x = 0; // Reset x to zero, - *y += textsize * 8; // advance y one line - // min/max x/y unchaged -- that waits for next 'normal' character - } else if(c != '\r') { // Normal char; ignore carriage returns - if(wrap && ((*x + textsize * 6) > _width)) { // Off right? - *x = 0; // Reset x to zero, - *y += textsize * 8; // advance y one line - } - int x2 = *x + textsize * 6 - 1, // Lower-right pixel of char - y2 = *y + textsize * 8 - 1; - if(x2 > *maxx) *maxx = x2; // Track max x, y - if(y2 > *maxy) *maxy = y2; - if(*x < *minx) *minx = *x; // Track min x, y - if(*y < *miny) *miny = *y; - *x += textsize * 6; // Advance x one char - } - } -} - -// Pass string and a cursor position, returns UL corner and W,H. -void Adafruit_GFX::getTextBounds(char *str, int16_t x, int16_t y, - int16_t *x1, int16_t *y1, uint16_t *w, uint16_t *h) { - uint8_t c; // Current character - - *x1 = x; - *y1 = y; - *w = *h = 0; - - int16_t minx = _width, miny = _height, maxx = -1, maxy = -1; - - while((c = *str++)) - charBounds(c, &x, &y, &minx, &miny, &maxx, &maxy); - - if(maxx >= minx) { - *x1 = minx; - *w = maxx - minx + 1; - } - if(maxy >= miny) { - *y1 = miny; - *h = maxy - miny + 1; - } -} - -// Same as above, but for PROGMEM strings -void Adafruit_GFX::getTextBounds(const __FlashStringHelper *str, - int16_t x, int16_t y, int16_t *x1, int16_t *y1, uint16_t *w, uint16_t *h) { - uint8_t *s = (uint8_t *)str, c; - - *x1 = x; - *y1 = y; - *w = *h = 0; - - int16_t minx = _width, miny = _height, maxx = -1, maxy = -1; - - while((c = pgm_read_byte(s++))) - charBounds(c, &x, &y, &minx, &miny, &maxx, &maxy); - - if(maxx >= minx) { - *x1 = minx; - *w = maxx - minx + 1; - } - if(maxy >= miny) { - *y1 = miny; - *h = maxy - miny + 1; - } -} - -// Return the size of the display (per current rotation) -int16_t Adafruit_GFX::width(void) const { - return _width; -} - -int16_t Adafruit_GFX::height(void) const { - return _height; -} - -void Adafruit_GFX::invertDisplay(boolean i) { - // Do nothing, must be subclassed if supported by hardware -} - -/***************************************************************************/ -// code for the GFX button UI element - -Adafruit_GFX_Button::Adafruit_GFX_Button(void) { - _gfx = 0; -} - -// Classic initButton() function: pass center & size -void Adafruit_GFX_Button::initButton( - Adafruit_GFX *gfx, int16_t x, int16_t y, uint16_t w, uint16_t h, - uint16_t outline, uint16_t fill, uint16_t textcolor, - char *label, uint8_t textsize) -{ - // Tweak arguments and pass to the newer initButtonUL() function... - initButtonUL(gfx, x - (w / 2), y - (h / 2), w, h, outline, fill, - textcolor, label, textsize); -} - -// Newer function instead accepts upper-left corner & size -void Adafruit_GFX_Button::initButtonUL( - Adafruit_GFX *gfx, int16_t x1, int16_t y1, uint16_t w, uint16_t h, - uint16_t outline, uint16_t fill, uint16_t textcolor, - char *label, uint8_t textsize) -{ - _x1 = x1; - _y1 = y1; - _w = w; - _h = h; - _outlinecolor = outline; - _fillcolor = fill; - _textcolor = textcolor; - _textsize = textsize; - _gfx = gfx; - strncpy(_label, label, 9); -} - -void Adafruit_GFX_Button::drawButton(boolean inverted) { - uint16_t fill, outline, text; - - if(!inverted) { - fill = _fillcolor; - outline = _outlinecolor; - text = _textcolor; - } else { - fill = _textcolor; - outline = _outlinecolor; - text = _fillcolor; - } - - uint8_t r = min(_w, _h) / 4; // Corner radius - _gfx->fillRoundRect(_x1, _y1, _w, _h, r, fill); - _gfx->drawRoundRect(_x1, _y1, _w, _h, r, outline); - - _gfx->setCursor(_x1 + (_w/2) - (strlen(_label) * 3 * _textsize), - _y1 + (_h/2) - (4 * _textsize)); - _gfx->setTextColor(text); - _gfx->setTextSize(_textsize); - _gfx->print(_label); -} - -boolean Adafruit_GFX_Button::contains(int16_t x, int16_t y) { - return ((x >= _x1) && (x < (_x1 + _w)) && - (y >= _y1) && (y < (_y1 + _h))); -} - -void Adafruit_GFX_Button::press(boolean p) { - laststate = currstate; - currstate = p; -} - -boolean Adafruit_GFX_Button::isPressed() { return currstate; } -boolean Adafruit_GFX_Button::justPressed() { return (currstate && !laststate); } -boolean Adafruit_GFX_Button::justReleased() { return (!currstate && laststate); } - -// ------------------------------------------------------------------------- - -// GFXcanvas1, GFXcanvas8 and GFXcanvas16 (currently a WIP, don't get too -// comfy with the implementation) provide 1-, 8- and 16-bit offscreen -// canvases, the address of which can be passed to drawBitmap() or -// pushColors() (the latter appears only in a couple of GFX-subclassed TFT -// libraries at this time). This is here mostly to help with the recently- -// added proportionally-spaced fonts; adds a way to refresh a section of the -// screen without a massive flickering clear-and-redraw...but maybe you'll -// find other uses too. VERY RAM-intensive, since the buffer is in MCU -// memory and not the display driver...GXFcanvas1 might be minimally useful -// on an Uno-class board, but this and the others are much more likely to -// require at least a Mega or various recent ARM-type boards (recommended, -// as the text+bitmap draw can be pokey). GFXcanvas1 requires 1 bit per -// pixel (rounded up to nearest byte per scanline), GFXcanvas8 is 1 byte -// per pixel (no scanline pad), and GFXcanvas16 uses 2 bytes per pixel (no -// scanline pad). -// NOT EXTENSIVELY TESTED YET. MAY CONTAIN WORST BUGS KNOWN TO HUMANKIND. - -GFXcanvas1::GFXcanvas1(uint16_t w, uint16_t h) : Adafruit_GFX(w, h) { - uint16_t bytes = ((w + 7) / 8) * h; - if((buffer = (uint8_t *)malloc(bytes))) { - memset(buffer, 0, bytes); - } -} - -GFXcanvas1::~GFXcanvas1(void) { - if(buffer) free(buffer); -} - -uint8_t* GFXcanvas1::getBuffer(void) { - return buffer; -} - -void GFXcanvas1::drawPixel(int16_t x, int16_t y, uint16_t color) { -#ifdef __AVR__ - // Bitmask tables of 0x80>>X and ~(0x80>>X), because X>>Y is slow on AVR - static const uint8_t PROGMEM - GFXsetBit[] = { 0x80, 0x40, 0x20, 0x10, 0x08, 0x04, 0x02, 0x01 }, - GFXclrBit[] = { 0x7F, 0xBF, 0xDF, 0xEF, 0xF7, 0xFB, 0xFD, 0xFE }; -#endif - - if(buffer) { - if((x < 0) || (y < 0) || (x >= _width) || (y >= _height)) return; - - int16_t t; - switch(rotation) { - case 1: - t = x; - x = WIDTH - 1 - y; - y = t; - break; - case 2: - x = WIDTH - 1 - x; - y = HEIGHT - 1 - y; - break; - case 3: - t = x; - x = y; - y = HEIGHT - 1 - t; - break; - } - - uint8_t *ptr = &buffer[(x / 8) + y * ((WIDTH + 7) / 8)]; -#ifdef __AVR__ - if(color) *ptr |= pgm_read_byte(&GFXsetBit[x & 7]); - else *ptr &= pgm_read_byte(&GFXclrBit[x & 7]); -#else - if(color) *ptr |= 0x80 >> (x & 7); - else *ptr &= ~(0x80 >> (x & 7)); -#endif - } -} - -void GFXcanvas1::fillScreen(uint16_t color) { - if(buffer) { - uint16_t bytes = ((WIDTH + 7) / 8) * HEIGHT; - memset(buffer, color ? 0xFF : 0x00, bytes); - } -} - -GFXcanvas8::GFXcanvas8(uint16_t w, uint16_t h) : Adafruit_GFX(w, h) { - uint32_t bytes = w * h; - if((buffer = (uint8_t *)malloc(bytes))) { - memset(buffer, 0, bytes); - } -} - -GFXcanvas8::~GFXcanvas8(void) { - if(buffer) free(buffer); -} - -uint8_t* GFXcanvas8::getBuffer(void) { - return buffer; -} - -void GFXcanvas8::drawPixel(int16_t x, int16_t y, uint16_t color) { - if(buffer) { - if((x < 0) || (y < 0) || (x >= _width) || (y >= _height)) return; - - int16_t t; - switch(rotation) { - case 1: - t = x; - x = WIDTH - 1 - y; - y = t; - break; - case 2: - x = WIDTH - 1 - x; - y = HEIGHT - 1 - y; - break; - case 3: - t = x; - x = y; - y = HEIGHT - 1 - t; - break; - } - - buffer[x + y * WIDTH] = color; - } -} - -void GFXcanvas8::fillScreen(uint16_t color) { - if(buffer) { - memset(buffer, color, WIDTH * HEIGHT); - } -} - -void GFXcanvas8::writeFastHLine(int16_t x, int16_t y, - int16_t w, uint16_t color) { - - if((x >= _width) || (y < 0) || (y >= _height)) return; - int16_t x2 = x + w - 1; - if(x2 < 0) return; - - // Clip left/right - if(x < 0) { - x = 0; - w = x2 + 1; - } - if(x2 >= _width) w = _width - x; - - int16_t t; - switch(rotation) { - case 1: - t = x; - x = WIDTH - 1 - y; - y = t; - break; - case 2: - x = WIDTH - 1 - x; - y = HEIGHT - 1 - y; - break; - case 3: - t = x; - x = y; - y = HEIGHT - 1 - t; - break; - } - - memset(buffer + y * WIDTH + x, color, w); -} - -GFXcanvas16::GFXcanvas16(uint16_t w, uint16_t h) : Adafruit_GFX(w, h) { - uint32_t bytes = w * h * 2; - if((buffer = (uint16_t *)malloc(bytes))) { - memset(buffer, 0, bytes); - } -} - -GFXcanvas16::~GFXcanvas16(void) { - if(buffer) free(buffer); -} - -uint16_t* GFXcanvas16::getBuffer(void) { - return buffer; -} - -void GFXcanvas16::drawPixel(int16_t x, int16_t y, uint16_t color) { - if(buffer) { - if((x < 0) || (y < 0) || (x >= _width) || (y >= _height)) return; - - int16_t t; - switch(rotation) { - case 1: - t = x; - x = WIDTH - 1 - y; - y = t; - break; - case 2: - x = WIDTH - 1 - x; - y = HEIGHT - 1 - y; - break; - case 3: - t = x; - x = y; - y = HEIGHT - 1 - t; - break; - } - - buffer[x + y * WIDTH] = color; - } -} - -void GFXcanvas16::fillScreen(uint16_t color) { - if(buffer) { - uint8_t hi = color >> 8, lo = color & 0xFF; - if(hi == lo) { - memset(buffer, lo, WIDTH * HEIGHT * 2); - } else { - uint32_t i, pixels = WIDTH * HEIGHT; - for(i=0; i= 100 - #include "Arduino.h" - #include "Print.h" -#else - #include "WProgram.h" -#endif -#include "gfxfont.h" - -class Adafruit_GFX : public Print { - - public: - - Adafruit_GFX(int16_t w, int16_t h); // Constructor - - // This MUST be defined by the subclass: - virtual void drawPixel(int16_t x, int16_t y, uint16_t color) = 0; - - // TRANSACTION API / CORE DRAW API - // These MAY be overridden by the subclass to provide device-specific - // optimized code. Otherwise 'generic' versions are used. - virtual void startWrite(void); - virtual void writePixel(int16_t x, int16_t y, uint16_t color); - virtual void writeFillRect(int16_t x, int16_t y, int16_t w, int16_t h, uint16_t color); - virtual void writeFastVLine(int16_t x, int16_t y, int16_t h, uint16_t color); - virtual void writeFastHLine(int16_t x, int16_t y, int16_t w, uint16_t color); - virtual void writeLine(int16_t x0, int16_t y0, int16_t x1, int16_t y1, uint16_t color); - virtual void endWrite(void); - - // CONTROL API - // These MAY be overridden by the subclass to provide device-specific - // optimized code. Otherwise 'generic' versions are used. - virtual void setRotation(uint8_t r); - virtual void invertDisplay(boolean i); - - // BASIC DRAW API - // These MAY be overridden by the subclass to provide device-specific - // optimized code. Otherwise 'generic' versions are used. - virtual void - // It's good to implement those, even if using transaction API - drawFastVLine(int16_t x, int16_t y, int16_t h, uint16_t color), - drawFastHLine(int16_t x, int16_t y, int16_t w, uint16_t color), - fillRect(int16_t x, int16_t y, int16_t w, int16_t h, uint16_t color), - fillScreen(uint16_t color), - // Optional and probably not necessary to change - drawLine(int16_t x0, int16_t y0, int16_t x1, int16_t y1, uint16_t color), - drawRect(int16_t x, int16_t y, int16_t w, int16_t h, uint16_t color); - - // These exist only with Adafruit_GFX (no subclass overrides) - void - drawCircle(int16_t x0, int16_t y0, int16_t r, uint16_t color), - drawCircleHelper(int16_t x0, int16_t y0, int16_t r, uint8_t cornername, - uint16_t color), - fillCircle(int16_t x0, int16_t y0, int16_t r, uint16_t color), - fillCircleHelper(int16_t x0, int16_t y0, int16_t r, uint8_t cornername, - int16_t delta, uint16_t color), - drawTriangle(int16_t x0, int16_t y0, int16_t x1, int16_t y1, - int16_t x2, int16_t y2, uint16_t color), - fillTriangle(int16_t x0, int16_t y0, int16_t x1, int16_t y1, - int16_t x2, int16_t y2, uint16_t color), - drawRoundRect(int16_t x0, int16_t y0, int16_t w, int16_t h, - int16_t radius, uint16_t color), - fillRoundRect(int16_t x0, int16_t y0, int16_t w, int16_t h, - int16_t radius, uint16_t color), - drawBitmap(int16_t x, int16_t y, const uint8_t bitmap[], - int16_t w, int16_t h, uint16_t color), - drawBitmap(int16_t x, int16_t y, const uint8_t bitmap[], - int16_t w, int16_t h, uint16_t color, uint16_t bg), - drawBitmap(int16_t x, int16_t y, uint8_t *bitmap, - int16_t w, int16_t h, uint16_t color), - drawBitmap(int16_t x, int16_t y, uint8_t *bitmap, - int16_t w, int16_t h, uint16_t color, uint16_t bg), - drawXBitmap(int16_t x, int16_t y, const uint8_t bitmap[], - int16_t w, int16_t h, uint16_t color), - drawGrayscaleBitmap(int16_t x, int16_t y, const uint8_t bitmap[], - int16_t w, int16_t h), - drawGrayscaleBitmap(int16_t x, int16_t y, uint8_t *bitmap, - int16_t w, int16_t h), - drawGrayscaleBitmap(int16_t x, int16_t y, - const uint8_t bitmap[], const uint8_t mask[], - int16_t w, int16_t h), - drawGrayscaleBitmap(int16_t x, int16_t y, - uint8_t *bitmap, uint8_t *mask, int16_t w, int16_t h), - drawRGBBitmap(int16_t x, int16_t y, const uint16_t bitmap[], - int16_t w, int16_t h), - drawRGBBitmap(int16_t x, int16_t y, uint16_t *bitmap, - int16_t w, int16_t h), - drawRGBBitmap(int16_t x, int16_t y, - const uint16_t bitmap[], const uint8_t mask[], - int16_t w, int16_t h), - drawRGBBitmap(int16_t x, int16_t y, - uint16_t *bitmap, uint8_t *mask, int16_t w, int16_t h), - drawChar(int16_t x, int16_t y, unsigned char c, uint16_t color, - uint16_t bg, uint8_t size), - setCursor(int16_t x, int16_t y), - setTextColor(uint16_t c), - setTextColor(uint16_t c, uint16_t bg), - setTextSize(uint8_t s), - setTextWrap(boolean w), - cp437(boolean x=true), - setFont(const GFXfont *f = NULL), - getTextBounds(char *string, int16_t x, int16_t y, - int16_t *x1, int16_t *y1, uint16_t *w, uint16_t *h), - getTextBounds(const __FlashStringHelper *s, int16_t x, int16_t y, - int16_t *x1, int16_t *y1, uint16_t *w, uint16_t *h); - -#if ARDUINO >= 100 - virtual size_t write(uint8_t); -#else - virtual void write(uint8_t); -#endif - - int16_t height(void) const; - int16_t width(void) const; - - uint8_t getRotation(void) const; - - // get current cursor position (get rotation safe maximum values, using: width() for x, height() for y) - int16_t getCursorX(void) const; - int16_t getCursorY(void) const; - - protected: - void - charBounds(char c, int16_t *x, int16_t *y, - int16_t *minx, int16_t *miny, int16_t *maxx, int16_t *maxy); - const int16_t - WIDTH, HEIGHT; // This is the 'raw' display w/h - never changes - int16_t - _width, _height, // Display w/h as modified by current rotation - cursor_x, cursor_y; - uint16_t - textcolor, textbgcolor; - uint8_t - textsize, - rotation; - boolean - wrap, // If set, 'wrap' text at right edge of display - _cp437; // If set, use correct CP437 charset (default is off) - GFXfont - *gfxFont; -}; - -class Adafruit_GFX_Button { - - public: - Adafruit_GFX_Button(void); - // "Classic" initButton() uses center & size - void initButton(Adafruit_GFX *gfx, int16_t x, int16_t y, - uint16_t w, uint16_t h, uint16_t outline, uint16_t fill, - uint16_t textcolor, char *label, uint8_t textsize); - // New/alt initButton() uses upper-left corner & size - void initButtonUL(Adafruit_GFX *gfx, int16_t x1, int16_t y1, - uint16_t w, uint16_t h, uint16_t outline, uint16_t fill, - uint16_t textcolor, char *label, uint8_t textsize); - void drawButton(boolean inverted = false); - boolean contains(int16_t x, int16_t y); - - void press(boolean p); - boolean isPressed(); - boolean justPressed(); - boolean justReleased(); - - private: - Adafruit_GFX *_gfx; - int16_t _x1, _y1; // Coordinates of top-left corner - uint16_t _w, _h; - uint8_t _textsize; - uint16_t _outlinecolor, _fillcolor, _textcolor; - char _label[10]; - - boolean currstate, laststate; -}; - -class GFXcanvas1 : public Adafruit_GFX { - public: - GFXcanvas1(uint16_t w, uint16_t h); - ~GFXcanvas1(void); - void drawPixel(int16_t x, int16_t y, uint16_t color), - fillScreen(uint16_t color); - uint8_t *getBuffer(void); - private: - uint8_t *buffer; -}; - -class GFXcanvas8 : public Adafruit_GFX { - public: - GFXcanvas8(uint16_t w, uint16_t h); - ~GFXcanvas8(void); - void drawPixel(int16_t x, int16_t y, uint16_t color), - fillScreen(uint16_t color), - writeFastHLine(int16_t x, int16_t y, int16_t w, uint16_t color); - - uint8_t *getBuffer(void); - private: - uint8_t *buffer; -}; - -class GFXcanvas16 : public Adafruit_GFX { - public: - GFXcanvas16(uint16_t w, uint16_t h); - ~GFXcanvas16(void); - void drawPixel(int16_t x, int16_t y, uint16_t color), - fillScreen(uint16_t color); - uint16_t *getBuffer(void); - private: - uint16_t *buffer; -}; - -#endif // _ADAFRUIT_GFX_H diff --git a/examples/Basics/GFX_Library/fontconvert/Makefile b/examples/Basics/GFX_Library/fontconvert/Makefile deleted file mode 100644 index 47f5a0e..0000000 --- a/examples/Basics/GFX_Library/fontconvert/Makefile +++ /dev/null @@ -1,12 +0,0 @@ -all: fontconvert - -CC = gcc -CFLAGS = -Wall -I/usr/local/include/freetype2 -I/usr/include/freetype2 -I/usr/include -LIBS = -lfreetype - -fontconvert: fontconvert.c - $(CC) $(CFLAGS) $< $(LIBS) -o $@ - strip $@ - -clean: - rm -f fontconvert diff --git a/examples/Basics/GFX_Library/fontconvert/fontconvert.c b/examples/Basics/GFX_Library/fontconvert/fontconvert.c deleted file mode 100644 index c6d6498..0000000 --- a/examples/Basics/GFX_Library/fontconvert/fontconvert.c +++ /dev/null @@ -1,278 +0,0 @@ -/* -TrueType to Adafruit_GFX font converter. Derived from Peter Jakobs' -Adafruit_ftGFX fork & makefont tool, and Paul Kourany's Adafruit_mfGFX. - -NOT AN ARDUINO SKETCH. This is a command-line tool for preprocessing -fonts to be used with the Adafruit_GFX Arduino library. - -For UNIX-like systems. Outputs to stdout; redirect to header file, e.g.: - ./fontconvert ~/Library/Fonts/FreeSans.ttf 18 > FreeSans18pt7b.h - -REQUIRES FREETYPE LIBRARY. www.freetype.org - -Currently this only extracts the printable 7-bit ASCII chars of a font. -Will eventually extend with some int'l chars a la ftGFX, not there yet. -Keep 7-bit fonts around as an option in that case, more compact. - -See notes at end for glyph nomenclature & other tidbits. -*/ - -#include -#include -#include -#include -#include FT_GLYPH_H -#include "../gfxfont.h" // Adafruit_GFX font structures - -#define DPI 141 // Approximate res. of Adafruit 2.8" TFT - -// Accumulate bits for output, with periodic hexadecimal byte write -void enbit(uint8_t value) { - static uint8_t row = 0, sum = 0, bit = 0x80, firstCall = 1; - if(value) sum |= bit; // Set bit if needed - if(!(bit >>= 1)) { // Advance to next bit, end of byte reached? - if(!firstCall) { // Format output table nicely - if(++row >= 12) { // Last entry on line? - printf(",\n "); // Newline format output - row = 0; // Reset row counter - } else { // Not end of line - printf(", "); // Simple comma delim - } - } - printf("0x%02X", sum); // Write byte value - sum = 0; // Clear for next byte - bit = 0x80; // Reset bit counter - firstCall = 0; // Formatting flag - } -} - -int main(int argc, char *argv[]) { - int i, j, err, size, first=' ', last='~', - bitmapOffset = 0, x, y, byte; - char *fontName, c, *ptr; - FT_Library library; - FT_Face face; - FT_Glyph glyph; - FT_Bitmap *bitmap; - FT_BitmapGlyphRec *g; - GFXglyph *table; - uint8_t bit; - - // Parse command line. Valid syntaxes are: - // fontconvert [filename] [size] - // fontconvert [filename] [size] [last char] - // fontconvert [filename] [size] [first char] [last char] - // Unless overridden, default first and last chars are - // ' ' (space) and '~', respectively - - if(argc < 3) { - fprintf(stderr, "Usage: %s fontfile size [first] [last]\n", - argv[0]); - return 1; - } - - size = atoi(argv[2]); - - if(argc == 4) { - last = atoi(argv[3]); - } else if(argc == 5) { - first = atoi(argv[3]); - last = atoi(argv[4]); - } - - if(last < first) { - i = first; - first = last; - last = i; - } - - ptr = strrchr(argv[1], '/'); // Find last slash in filename - if(ptr) ptr++; // First character of filename (path stripped) - else ptr = argv[1]; // No path; font in local dir. - - // Allocate space for font name and glyph table - if((!(fontName = malloc(strlen(ptr) + 20))) || - (!(table = (GFXglyph *)malloc((last - first + 1) * - sizeof(GFXglyph))))) { - fprintf(stderr, "Malloc error\n"); - return 1; - } - - // Derive font table names from filename. Period (filename - // extension) is truncated and replaced with the font size & bits. - strcpy(fontName, ptr); - ptr = strrchr(fontName, '.'); // Find last period (file ext) - if(!ptr) ptr = &fontName[strlen(fontName)]; // If none, append - // Insert font size and 7/8 bit. fontName was alloc'd w/extra - // space to allow this, we're not sprintfing into Forbidden Zone. - sprintf(ptr, "%dpt%db", size, (last > 127) ? 8 : 7); - // Space and punctuation chars in name replaced w/ underscores. - for(i=0; (c=fontName[i]); i++) { - if(isspace(c) || ispunct(c)) fontName[i] = '_'; - } - - // Init FreeType lib, load font - if((err = FT_Init_FreeType(&library))) { - fprintf(stderr, "FreeType init error: %d", err); - return err; - } - if((err = FT_New_Face(library, argv[1], 0, &face))) { - fprintf(stderr, "Font load error: %d", err); - FT_Done_FreeType(library); - return err; - } - - // << 6 because '26dot6' fixed-point format - FT_Set_Char_Size(face, size << 6, 0, DPI, 0); - - // Currently all symbols from 'first' to 'last' are processed. - // Fonts may contain WAY more glyphs than that, but this code - // will need to handle encoding stuff to deal with extracting - // the right symbols, and that's not done yet. - // fprintf(stderr, "%ld glyphs\n", face->num_glyphs); - - printf("const uint8_t %sBitmaps[] PROGMEM = {\n ", fontName); - - // Process glyphs and output huge bitmap data array - for(i=first, j=0; i<=last; i++, j++) { - // MONO renderer provides clean image with perfect crop - // (no wasted pixels) via bitmap struct. - if((err = FT_Load_Char(face, i, FT_LOAD_TARGET_MONO))) { - fprintf(stderr, "Error %d loading char '%c'\n", - err, i); - continue; - } - - if((err = FT_Render_Glyph(face->glyph, - FT_RENDER_MODE_MONO))) { - fprintf(stderr, "Error %d rendering char '%c'\n", - err, i); - continue; - } - - if((err = FT_Get_Glyph(face->glyph, &glyph))) { - fprintf(stderr, "Error %d getting glyph '%c'\n", - err, i); - continue; - } - - bitmap = &face->glyph->bitmap; - g = (FT_BitmapGlyphRec *)glyph; - - // Minimal font and per-glyph information is stored to - // reduce flash space requirements. Glyph bitmaps are - // fully bit-packed; no per-scanline pad, though end of - // each character may be padded to next byte boundary - // when needed. 16-bit offset means 64K max for bitmaps, - // code currently doesn't check for overflow. (Doesn't - // check that size & offsets are within bounds either for - // that matter...please convert fonts responsibly.) - table[j].bitmapOffset = bitmapOffset; - table[j].width = bitmap->width; - table[j].height = bitmap->rows; - table[j].xAdvance = face->glyph->advance.x >> 6; - table[j].xOffset = g->left; - table[j].yOffset = 1 - g->top; - - for(y=0; y < bitmap->rows; y++) { - for(x=0;x < bitmap->width; x++) { - byte = x / 8; - bit = 0x80 >> (x & 7); - enbit(bitmap->buffer[ - y * bitmap->pitch + byte] & bit); - } - } - - // Pad end of char bitmap to next byte boundary if needed - int n = (bitmap->width * bitmap->rows) & 7; - if(n) { // Pixel count not an even multiple of 8? - n = 8 - n; // # bits to next multiple - while(n--) enbit(0); - } - bitmapOffset += (bitmap->width * bitmap->rows + 7) / 8; - - FT_Done_Glyph(glyph); - } - - printf(" };\n\n"); // End bitmap array - - // Output glyph attributes table (one per character) - printf("const GFXglyph %sGlyphs[] PROGMEM = {\n", fontName); - for(i=first, j=0; i<=last; i++, j++) { - printf(" { %5d, %3d, %3d, %3d, %4d, %4d }", - table[j].bitmapOffset, - table[j].width, - table[j].height, - table[j].xAdvance, - table[j].xOffset, - table[j].yOffset); - if(i < last) { - printf(", // 0x%02X", i); - if((i >= ' ') && (i <= '~')) { - printf(" '%c'", i); - } - putchar('\n'); - } - } - printf(" }; // 0x%02X", last); - if((last >= ' ') && (last <= '~')) printf(" '%c'", last); - printf("\n\n"); - - // Output font structure - printf("const GFXfont %s PROGMEM = {\n", fontName); - printf(" (uint8_t *)%sBitmaps,\n", fontName); - printf(" (GFXglyph *)%sGlyphs,\n", fontName); - printf(" 0x%02X, 0x%02X, %ld };\n\n", - first, last, face->size->metrics.height >> 6); - printf("// Approx. %d bytes\n", - bitmapOffset + (last - first + 1) * 7 + 7); - // Size estimate is based on AVR struct and pointer sizes; - // actual size may vary. - - FT_Done_FreeType(library); - - return 0; -} - -/* ------------------------------------------------------------------------- - -Character metrics are slightly different from classic GFX & ftGFX. -In classic GFX: cursor position is the upper-left pixel of each 5x7 -character; lower extent of most glyphs (except those w/descenders) -is +6 pixels in Y direction. -W/new GFX fonts: cursor position is on baseline, where baseline is -'inclusive' (containing the bottom-most row of pixels in most symbols, -except those with descenders; ftGFX is one pixel lower). - -Cursor Y will be moved automatically when switching between classic -and new fonts. If you switch fonts, any print() calls will continue -along the same baseline. - - ...........#####.. -- yOffset - ..........######.. - ..........######.. - .........#######.. - ........#########. - * = Cursor pos. ........#########. - .......##########. - ......#####..####. - ......#####..####. - *.#.. .....#####...####. - .#.#. ....############## - #...# ...############### - #...# ...############### - ##### ..#####......##### - #...# .#####.......##### -====== #...# ====== #*###.........#### ======= Baseline - || xOffset - -glyph->xOffset and yOffset are pixel offsets, in GFX coordinate space -(+Y is down), from the cursor position to the top-left pixel of the -glyph bitmap. i.e. yOffset is typically negative, xOffset is typically -zero but a few glyphs will have other values (even negative xOffsets -sometimes, totally normal). glyph->xAdvance is the distance to move -the cursor on the X axis after drawing the corresponding symbol. - -There's also some changes with regard to 'background' color and new GFX -fonts (classic fonts unchanged). See Adafruit_GFX.cpp for explanation. -*/ diff --git a/examples/Basics/GFX_Library/fontconvert/fontconvert_win.md b/examples/Basics/GFX_Library/fontconvert/fontconvert_win.md deleted file mode 100644 index 1932841..0000000 --- a/examples/Basics/GFX_Library/fontconvert/fontconvert_win.md +++ /dev/null @@ -1,88 +0,0 @@ -### A short guide to use fontconvert.c to create your own fonts using MinGW. - -#### STEP 1: INSTALL MinGW - -Install MinGW (Minimalist GNU for Windows) from [MinGW.org](http://www.mingw.org/). -Please read carefully the instructions found on [Getting started page](http://www.mingw.org/wiki/Getting_Started). -I suggest installing with the "Graphical User Interface Installer". -To complete your initial installation you should further install some "packages". -For our purpose you should only install the "Basic Setup" packages. -To do that: - -1. Open the MinGW Installation Manager -2. From the left panel click "Basic Setup". -3. On the right panel choose "mingw32-base", "mingw-gcc-g++", "mingw-gcc-objc" and "msys-base" -and click "Mark for installation" -4. From the Menu click "Installation" and then "Apply changes". In the pop-up window select "Apply". - - -#### STEP 2: INSTALL Freetype Library - -To read about the freetype project visit [freetype.org](https://www.freetype.org/). -To Download the latest version of freetype go to [download page](http://download.savannah.gnu.org/releases/freetype/) -and choose "freetype-2.7.tar.gz" file (or a newer version if available). -To avoid long cd commands later in the command prompt, I suggest you unzip the file in the C:\ directory. -(I also renamed the folder to "ft27") -Before you build the library it's good to read these articles: -* [Using MSYS with MinGW](http://www.mingw.org/wiki/MSYS) -* [Installation and Use of Supplementary Libraries with MinGW](http://www.mingw.org/wiki/LibraryPathHOWTO) -* [Include Path](http://www.mingw.org/wiki/IncludePathHOWTO) - -Inside the unzipped folder there is another folder named "docs". Open it and read the INSTALL.UNIX (using notepad). -Pay attention to paragraph 3 (Build and Install the Library). So, let's begin the installation. -To give the appropriate commands we will use the MSYS command prompt (not cmd.exe of windows) which is UNIX like. -Follow the path C:\MinGW\msys\1.0 and double click "msys.bat". The command prompt environment appears. -Enter "ft27" directory using the cd commands: -``` -cd /c -cd ft27 -``` - -and then type one by one the commands: -``` -./configure --prefix=/mingw -make -make install -``` -Once you're finished, go inside "C:\MinGW\include" and there should be a new folder named "freetype2". -That, hopefully, means that you have installed the library correctly !! - -#### STEP 3: Build fontconvert.c - -Before proceeding I suggest you make a copy of Adafruit_GFX_library folder in C:\ directory. -Then, inside "fontconvert" folder open the "makefile" with an editor ( I used notepad++). -Change the commands so in the end the program looks like : -``` -all: fontconvert - -CC = gcc -CFLAGS = -Wall -I c:/mingw/include/freetype2 -LIBS = -lfreetype - -fontconvert: fontconvert.c - $(CC) $(CFLAGS) $< $(LIBS) -o $@ - -clean: - rm -f fontconvert -``` -Go back in the command prompt and with a cd command enter the fontconvert directory. -``` -cd /c/adafruit_gfx_library\fontconvert -``` -Give the command: -``` -make -``` -This command will, eventually, create a "fontconvert.exe" file inside fontconvert directory. - -#### STEP 4: Create your own font header files - -Now that you have an executable file, you can use it to create your own fonts to work with Adafruit GFX lib. -So, if we suppose that you already have a .ttf file with your favorite fonts, jump to the command prompt and type: -``` -./fontconvert yourfonts.ttf 9 > yourfonts9pt7b.h -``` -You can read more details at: [learn.adafruit](https://learn.adafruit.com/adafruit-gfx-graphics-library/using-fonts). - -Taraaaaaammm !! you've just created your new font header file. Put it inside the "Fonts" folder, grab a cup of coffee -and start playing with your Arduino (or whatever else ....)+ display module project. diff --git a/examples/Basics/GFX_Library/fontconvert/makefonts.sh b/examples/Basics/GFX_Library/fontconvert/makefonts.sh deleted file mode 100644 index 35f07ea..0000000 --- a/examples/Basics/GFX_Library/fontconvert/makefonts.sh +++ /dev/null @@ -1,38 +0,0 @@ -#!/bin/bash - -# Ugly little Bash script, generates a set of .h files for GFX using -# GNU FreeFont sources. There are three fonts: 'Mono' (Courier-like), -# 'Sans' (Helvetica-like) and 'Serif' (Times-like); four styles: regular, -# bold, oblique or italic, and bold+oblique or bold+italic; and four -# sizes: 9, 12, 18 and 24 point. No real error checking or anything, -# this just powers through all the combinations, calling the fontconvert -# utility and redirecting the output to a .h file for each combo. - -# Adafruit_GFX repository does not include the source outline fonts -# (huge zipfile, different license) but they're easily acquired: -# http://savannah.gnu.org/projects/freefont/ - -convert=./fontconvert -inpath=~/Desktop/freefont/ -outpath=../Fonts/ -fonts=(FreeMono FreeSans FreeSerif) -styles=("" Bold Italic BoldItalic Oblique BoldOblique) -sizes=(9 12 18 24) - -for f in ${fonts[*]} -do - for index in ${!styles[*]} - do - st=${styles[$index]} - for si in ${sizes[*]} - do - infile=$inpath$f$st".ttf" - if [ -f $infile ] # Does source combination exist? - then - outfile=$outpath$f$st$si"pt7b.h" -# printf "%s %s %s > %s\n" $convert $infile $si $outfile - $convert $infile $si > $outfile - fi - done - done -done diff --git a/examples/Basics/GFX_Library/gfxfont.1.h b/examples/Basics/GFX_Library/gfxfont.1.h deleted file mode 100644 index 07381ed..0000000 --- a/examples/Basics/GFX_Library/gfxfont.1.h +++ /dev/null @@ -1,24 +0,0 @@ -// Font structures for newer Adafruit_GFX (1.1 and later). -// Example fonts are included in 'Fonts' directory. -// To use a font in your Arduino sketch, #include the corresponding .h -// file and pass address of GFXfont struct to setFont(). Pass NULL to -// revert to 'classic' fixed-space bitmap font. - -#ifndef _GFXFONT_H_ -#define _GFXFONT_H_ - -typedef struct { // Data stored PER GLYPH - uint16_t bitmapOffset; // Pointer into GFXfont->bitmap - uint8_t width, height; // Bitmap dimensions in pixels - uint8_t xAdvance; // Distance to advance cursor (x axis) - int8_t xOffset, yOffset; // Dist from cursor pos to UL corner -} GFXglyph; - -typedef struct { // Data stored for FONT AS A WHOLE: - uint8_t *bitmap; // Glyph bitmaps, concatenated - GFXglyph *glyph; // Glyph array - uint8_t first, last; // ASCII extents - uint8_t yAdvance; // Newline distance (y axis) -} GFXfont; - -#endif // _GFXFONT_H_ diff --git a/examples/Basics/GFX_Library/glcdfont.1.c b/examples/Basics/GFX_Library/glcdfont.1.c deleted file mode 100644 index 6f88bd2..0000000 --- a/examples/Basics/GFX_Library/glcdfont.1.c +++ /dev/null @@ -1,276 +0,0 @@ -// This is the 'classic' fixed-space bitmap font for Adafruit_GFX since 1.0. -// See gfxfont.h for newer custom bitmap font info. - -#ifndef FONT5X7_H -#define FONT5X7_H - -#ifdef __AVR__ - #include - #include -#elif defined(ESP8266) - #include -#else - #define PROGMEM -#endif - -// Standard ASCII 5x7 font - -static const unsigned char font[] PROGMEM = { - 0x00, 0x00, 0x00, 0x00, 0x00, - 0x3E, 0x5B, 0x4F, 0x5B, 0x3E, - 0x3E, 0x6B, 0x4F, 0x6B, 0x3E, - 0x1C, 0x3E, 0x7C, 0x3E, 0x1C, - 0x18, 0x3C, 0x7E, 0x3C, 0x18, - 0x1C, 0x57, 0x7D, 0x57, 0x1C, - 0x1C, 0x5E, 0x7F, 0x5E, 0x1C, - 0x00, 0x18, 0x3C, 0x18, 0x00, - 0xFF, 0xE7, 0xC3, 0xE7, 0xFF, - 0x00, 0x18, 0x24, 0x18, 0x00, - 0xFF, 0xE7, 0xDB, 0xE7, 0xFF, - 0x30, 0x48, 0x3A, 0x06, 0x0E, - 0x26, 0x29, 0x79, 0x29, 0x26, - 0x40, 0x7F, 0x05, 0x05, 0x07, - 0x40, 0x7F, 0x05, 0x25, 0x3F, - 0x5A, 0x3C, 0xE7, 0x3C, 0x5A, - 0x7F, 0x3E, 0x1C, 0x1C, 0x08, - 0x08, 0x1C, 0x1C, 0x3E, 0x7F, - 0x14, 0x22, 0x7F, 0x22, 0x14, - 0x5F, 0x5F, 0x00, 0x5F, 0x5F, - 0x06, 0x09, 0x7F, 0x01, 0x7F, - 0x00, 0x66, 0x89, 0x95, 0x6A, - 0x60, 0x60, 0x60, 0x60, 0x60, - 0x94, 0xA2, 0xFF, 0xA2, 0x94, - 0x08, 0x04, 0x7E, 0x04, 0x08, - 0x10, 0x20, 0x7E, 0x20, 0x10, - 0x08, 0x08, 0x2A, 0x1C, 0x08, - 0x08, 0x1C, 0x2A, 0x08, 0x08, - 0x1E, 0x10, 0x10, 0x10, 0x10, - 0x0C, 0x1E, 0x0C, 0x1E, 0x0C, - 0x30, 0x38, 0x3E, 0x38, 0x30, - 0x06, 0x0E, 0x3E, 0x0E, 0x06, - 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x5F, 0x00, 0x00, - 0x00, 0x07, 0x00, 0x07, 0x00, - 0x14, 0x7F, 0x14, 0x7F, 0x14, - 0x24, 0x2A, 0x7F, 0x2A, 0x12, - 0x23, 0x13, 0x08, 0x64, 0x62, - 0x36, 0x49, 0x56, 0x20, 0x50, - 0x00, 0x08, 0x07, 0x03, 0x00, - 0x00, 0x1C, 0x22, 0x41, 0x00, - 0x00, 0x41, 0x22, 0x1C, 0x00, - 0x2A, 0x1C, 0x7F, 0x1C, 0x2A, - 0x08, 0x08, 0x3E, 0x08, 0x08, - 0x00, 0x80, 0x70, 0x30, 0x00, - 0x08, 0x08, 0x08, 0x08, 0x08, - 0x00, 0x00, 0x60, 0x60, 0x00, - 0x20, 0x10, 0x08, 0x04, 0x02, - 0x3E, 0x51, 0x49, 0x45, 0x3E, - 0x00, 0x42, 0x7F, 0x40, 0x00, - 0x72, 0x49, 0x49, 0x49, 0x46, - 0x21, 0x41, 0x49, 0x4D, 0x33, - 0x18, 0x14, 0x12, 0x7F, 0x10, - 0x27, 0x45, 0x45, 0x45, 0x39, - 0x3C, 0x4A, 0x49, 0x49, 0x31, - 0x41, 0x21, 0x11, 0x09, 0x07, - 0x36, 0x49, 0x49, 0x49, 0x36, - 0x46, 0x49, 0x49, 0x29, 0x1E, - 0x00, 0x00, 0x14, 0x00, 0x00, - 0x00, 0x40, 0x34, 0x00, 0x00, - 0x00, 0x08, 0x14, 0x22, 0x41, - 0x14, 0x14, 0x14, 0x14, 0x14, - 0x00, 0x41, 0x22, 0x14, 0x08, - 0x02, 0x01, 0x59, 0x09, 0x06, - 0x3E, 0x41, 0x5D, 0x59, 0x4E, - 0x7C, 0x12, 0x11, 0x12, 0x7C, - 0x7F, 0x49, 0x49, 0x49, 0x36, - 0x3E, 0x41, 0x41, 0x41, 0x22, - 0x7F, 0x41, 0x41, 0x41, 0x3E, - 0x7F, 0x49, 0x49, 0x49, 0x41, - 0x7F, 0x09, 0x09, 0x09, 0x01, - 0x3E, 0x41, 0x41, 0x51, 0x73, - 0x7F, 0x08, 0x08, 0x08, 0x7F, - 0x00, 0x41, 0x7F, 0x41, 0x00, - 0x20, 0x40, 0x41, 0x3F, 0x01, - 0x7F, 0x08, 0x14, 0x22, 0x41, - 0x7F, 0x40, 0x40, 0x40, 0x40, - 0x7F, 0x02, 0x1C, 0x02, 0x7F, - 0x7F, 0x04, 0x08, 0x10, 0x7F, - 0x3E, 0x41, 0x41, 0x41, 0x3E, - 0x7F, 0x09, 0x09, 0x09, 0x06, - 0x3E, 0x41, 0x51, 0x21, 0x5E, - 0x7F, 0x09, 0x19, 0x29, 0x46, - 0x26, 0x49, 0x49, 0x49, 0x32, - 0x03, 0x01, 0x7F, 0x01, 0x03, - 0x3F, 0x40, 0x40, 0x40, 0x3F, - 0x1F, 0x20, 0x40, 0x20, 0x1F, - 0x3F, 0x40, 0x38, 0x40, 0x3F, - 0x63, 0x14, 0x08, 0x14, 0x63, - 0x03, 0x04, 0x78, 0x04, 0x03, - 0x61, 0x59, 0x49, 0x4D, 0x43, - 0x00, 0x7F, 0x41, 0x41, 0x41, - 0x02, 0x04, 0x08, 0x10, 0x20, - 0x00, 0x41, 0x41, 0x41, 0x7F, - 0x04, 0x02, 0x01, 0x02, 0x04, - 0x40, 0x40, 0x40, 0x40, 0x40, - 0x00, 0x03, 0x07, 0x08, 0x00, - 0x20, 0x54, 0x54, 0x78, 0x40, - 0x7F, 0x28, 0x44, 0x44, 0x38, - 0x38, 0x44, 0x44, 0x44, 0x28, - 0x38, 0x44, 0x44, 0x28, 0x7F, - 0x38, 0x54, 0x54, 0x54, 0x18, - 0x00, 0x08, 0x7E, 0x09, 0x02, - 0x18, 0xA4, 0xA4, 0x9C, 0x78, - 0x7F, 0x08, 0x04, 0x04, 0x78, - 0x00, 0x44, 0x7D, 0x40, 0x00, - 0x20, 0x40, 0x40, 0x3D, 0x00, - 0x7F, 0x10, 0x28, 0x44, 0x00, - 0x00, 0x41, 0x7F, 0x40, 0x00, - 0x7C, 0x04, 0x78, 0x04, 0x78, - 0x7C, 0x08, 0x04, 0x04, 0x78, - 0x38, 0x44, 0x44, 0x44, 0x38, - 0xFC, 0x18, 0x24, 0x24, 0x18, - 0x18, 0x24, 0x24, 0x18, 0xFC, - 0x7C, 0x08, 0x04, 0x04, 0x08, - 0x48, 0x54, 0x54, 0x54, 0x24, - 0x04, 0x04, 0x3F, 0x44, 0x24, - 0x3C, 0x40, 0x40, 0x20, 0x7C, - 0x1C, 0x20, 0x40, 0x20, 0x1C, - 0x3C, 0x40, 0x30, 0x40, 0x3C, - 0x44, 0x28, 0x10, 0x28, 0x44, - 0x4C, 0x90, 0x90, 0x90, 0x7C, - 0x44, 0x64, 0x54, 0x4C, 0x44, - 0x00, 0x08, 0x36, 0x41, 0x00, - 0x00, 0x00, 0x77, 0x00, 0x00, - 0x00, 0x41, 0x36, 0x08, 0x00, - 0x02, 0x01, 0x02, 0x04, 0x02, - 0x3C, 0x26, 0x23, 0x26, 0x3C, - 0x1E, 0xA1, 0xA1, 0x61, 0x12, - 0x3A, 0x40, 0x40, 0x20, 0x7A, - 0x38, 0x54, 0x54, 0x55, 0x59, - 0x21, 0x55, 0x55, 0x79, 0x41, - 0x22, 0x54, 0x54, 0x78, 0x42, // a-umlaut - 0x21, 0x55, 0x54, 0x78, 0x40, - 0x20, 0x54, 0x55, 0x79, 0x40, - 0x0C, 0x1E, 0x52, 0x72, 0x12, - 0x39, 0x55, 0x55, 0x55, 0x59, - 0x39, 0x54, 0x54, 0x54, 0x59, - 0x39, 0x55, 0x54, 0x54, 0x58, - 0x00, 0x00, 0x45, 0x7C, 0x41, - 0x00, 0x02, 0x45, 0x7D, 0x42, - 0x00, 0x01, 0x45, 0x7C, 0x40, - 0x7D, 0x12, 0x11, 0x12, 0x7D, // A-umlaut - 0xF0, 0x28, 0x25, 0x28, 0xF0, - 0x7C, 0x54, 0x55, 0x45, 0x00, - 0x20, 0x54, 0x54, 0x7C, 0x54, - 0x7C, 0x0A, 0x09, 0x7F, 0x49, - 0x32, 0x49, 0x49, 0x49, 0x32, - 0x3A, 0x44, 0x44, 0x44, 0x3A, // o-umlaut - 0x32, 0x4A, 0x48, 0x48, 0x30, - 0x3A, 0x41, 0x41, 0x21, 0x7A, - 0x3A, 0x42, 0x40, 0x20, 0x78, - 0x00, 0x9D, 0xA0, 0xA0, 0x7D, - 0x3D, 0x42, 0x42, 0x42, 0x3D, // O-umlaut - 0x3D, 0x40, 0x40, 0x40, 0x3D, - 0x3C, 0x24, 0xFF, 0x24, 0x24, - 0x48, 0x7E, 0x49, 0x43, 0x66, - 0x2B, 0x2F, 0xFC, 0x2F, 0x2B, - 0xFF, 0x09, 0x29, 0xF6, 0x20, - 0xC0, 0x88, 0x7E, 0x09, 0x03, - 0x20, 0x54, 0x54, 0x79, 0x41, - 0x00, 0x00, 0x44, 0x7D, 0x41, - 0x30, 0x48, 0x48, 0x4A, 0x32, - 0x38, 0x40, 0x40, 0x22, 0x7A, - 0x00, 0x7A, 0x0A, 0x0A, 0x72, - 0x7D, 0x0D, 0x19, 0x31, 0x7D, - 0x26, 0x29, 0x29, 0x2F, 0x28, - 0x26, 0x29, 0x29, 0x29, 0x26, - 0x30, 0x48, 0x4D, 0x40, 0x20, - 0x38, 0x08, 0x08, 0x08, 0x08, - 0x08, 0x08, 0x08, 0x08, 0x38, - 0x2F, 0x10, 0xC8, 0xAC, 0xBA, - 0x2F, 0x10, 0x28, 0x34, 0xFA, - 0x00, 0x00, 0x7B, 0x00, 0x00, - 0x08, 0x14, 0x2A, 0x14, 0x22, - 0x22, 0x14, 0x2A, 0x14, 0x08, - 0x55, 0x00, 0x55, 0x00, 0x55, // #176 (25% block) missing in old code - 0xAA, 0x55, 0xAA, 0x55, 0xAA, // 50% block - 0xFF, 0x55, 0xFF, 0x55, 0xFF, // 75% block - 0x00, 0x00, 0x00, 0xFF, 0x00, - 0x10, 0x10, 0x10, 0xFF, 0x00, - 0x14, 0x14, 0x14, 0xFF, 0x00, - 0x10, 0x10, 0xFF, 0x00, 0xFF, - 0x10, 0x10, 0xF0, 0x10, 0xF0, - 0x14, 0x14, 0x14, 0xFC, 0x00, - 0x14, 0x14, 0xF7, 0x00, 0xFF, - 0x00, 0x00, 0xFF, 0x00, 0xFF, - 0x14, 0x14, 0xF4, 0x04, 0xFC, - 0x14, 0x14, 0x17, 0x10, 0x1F, - 0x10, 0x10, 0x1F, 0x10, 0x1F, - 0x14, 0x14, 0x14, 0x1F, 0x00, - 0x10, 0x10, 0x10, 0xF0, 0x00, - 0x00, 0x00, 0x00, 0x1F, 0x10, - 0x10, 0x10, 0x10, 0x1F, 0x10, - 0x10, 0x10, 0x10, 0xF0, 0x10, - 0x00, 0x00, 0x00, 0xFF, 0x10, - 0x10, 0x10, 0x10, 0x10, 0x10, - 0x10, 0x10, 0x10, 0xFF, 0x10, - 0x00, 0x00, 0x00, 0xFF, 0x14, - 0x00, 0x00, 0xFF, 0x00, 0xFF, - 0x00, 0x00, 0x1F, 0x10, 0x17, - 0x00, 0x00, 0xFC, 0x04, 0xF4, - 0x14, 0x14, 0x17, 0x10, 0x17, - 0x14, 0x14, 0xF4, 0x04, 0xF4, - 0x00, 0x00, 0xFF, 0x00, 0xF7, - 0x14, 0x14, 0x14, 0x14, 0x14, - 0x14, 0x14, 0xF7, 0x00, 0xF7, - 0x14, 0x14, 0x14, 0x17, 0x14, - 0x10, 0x10, 0x1F, 0x10, 0x1F, - 0x14, 0x14, 0x14, 0xF4, 0x14, - 0x10, 0x10, 0xF0, 0x10, 0xF0, - 0x00, 0x00, 0x1F, 0x10, 0x1F, - 0x00, 0x00, 0x00, 0x1F, 0x14, - 0x00, 0x00, 0x00, 0xFC, 0x14, - 0x00, 0x00, 0xF0, 0x10, 0xF0, - 0x10, 0x10, 0xFF, 0x10, 0xFF, - 0x14, 0x14, 0x14, 0xFF, 0x14, - 0x10, 0x10, 0x10, 0x1F, 0x00, - 0x00, 0x00, 0x00, 0xF0, 0x10, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, - 0xFF, 0xFF, 0xFF, 0x00, 0x00, - 0x00, 0x00, 0x00, 0xFF, 0xFF, - 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, - 0x38, 0x44, 0x44, 0x38, 0x44, - 0xFC, 0x4A, 0x4A, 0x4A, 0x34, // sharp-s or beta - 0x7E, 0x02, 0x02, 0x06, 0x06, - 0x02, 0x7E, 0x02, 0x7E, 0x02, - 0x63, 0x55, 0x49, 0x41, 0x63, - 0x38, 0x44, 0x44, 0x3C, 0x04, - 0x40, 0x7E, 0x20, 0x1E, 0x20, - 0x06, 0x02, 0x7E, 0x02, 0x02, - 0x99, 0xA5, 0xE7, 0xA5, 0x99, - 0x1C, 0x2A, 0x49, 0x2A, 0x1C, - 0x4C, 0x72, 0x01, 0x72, 0x4C, - 0x30, 0x4A, 0x4D, 0x4D, 0x30, - 0x30, 0x48, 0x78, 0x48, 0x30, - 0xBC, 0x62, 0x5A, 0x46, 0x3D, - 0x3E, 0x49, 0x49, 0x49, 0x00, - 0x7E, 0x01, 0x01, 0x01, 0x7E, - 0x2A, 0x2A, 0x2A, 0x2A, 0x2A, - 0x44, 0x44, 0x5F, 0x44, 0x44, - 0x40, 0x51, 0x4A, 0x44, 0x40, - 0x40, 0x44, 0x4A, 0x51, 0x40, - 0x00, 0x00, 0xFF, 0x01, 0x03, - 0xE0, 0x80, 0xFF, 0x00, 0x00, - 0x08, 0x08, 0x6B, 0x6B, 0x08, - 0x36, 0x12, 0x36, 0x24, 0x36, - 0x06, 0x0F, 0x09, 0x0F, 0x06, - 0x00, 0x00, 0x18, 0x18, 0x00, - 0x00, 0x00, 0x10, 0x10, 0x00, - 0x30, 0x40, 0xFF, 0x01, 0x01, - 0x00, 0x1F, 0x01, 0x01, 0x1E, - 0x00, 0x19, 0x1D, 0x17, 0x12, - 0x00, 0x3C, 0x3C, 0x3C, 0x3C, - 0x00, 0x00, 0x00, 0x00, 0x00 // #255 NBSP -}; -#endif // FONT5X7_H diff --git a/examples/Basics/GFX_Library/library.properties b/examples/Basics/GFX_Library/library.properties deleted file mode 100644 index c6b0c47..0000000 --- a/examples/Basics/GFX_Library/library.properties +++ /dev/null @@ -1,9 +0,0 @@ -name=Adafruit GFX Library -version=1.2.2 -author=Adafruit -maintainer=Adafruit -sentence=Adafruit GFX graphics core library, this is the 'core' class that all our other graphics libraries derive from. -paragraph=Install this library in addition to the display library for your hardware. -category=Display -url=https://github.com/adafruit/Adafruit-GFX-Library -architectures=* diff --git a/examples/Basics/GFX_Library/license.txt b/examples/Basics/GFX_Library/license.txt deleted file mode 100644 index 7492e93..0000000 --- a/examples/Basics/GFX_Library/license.txt +++ /dev/null @@ -1,24 +0,0 @@ -Software License Agreement (BSD License) - -Copyright (c) 2012 Adafruit Industries. All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: - -- Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer. -- Redistributions in binary form must reproduce the above copyright notice, - this list of conditions and the following disclaimer in the documentation - and/or other materials provided with the distribution. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE -LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -POSSIBILITY OF SUCH DAMAGE. diff --git a/utility/Display.cpp b/utility/Display.cpp index 78bf999..d9fd6be 100644 --- a/utility/Display.cpp +++ b/utility/Display.cpp @@ -860,30 +860,12 @@ void ILI9341::drawFastHLine(int16_t x, int16_t y, endWrite(); } -// (x,y) is topmost point; if unsure, calling function -// should sort endpoints or call writeLine() instead -void ILI9341::writeFastVLine(int16_t x, int16_t y, - int16_t h, uint16_t color) { - // Overwrite in subclasses if startWrite is defined! - // Can be just writeLine(x, y, x, y+h-1, color); - // or writeFillRect(x, y, 1, h, color); - drawFastVLine(x, y, h, color); +void ILI9341::writeFastVLine(int16_t x, int16_t y, int16_t h, uint16_t color){ + writeFillRect(x, y, 1, h, color); } -// (x,y) is leftmost point; if unsure, calling function -// should sort endpoints or call writeLine() instead -void ILI9341::writeFastHLine(int16_t x, int16_t y, - int16_t w, uint16_t color) { - // Overwrite in subclasses if startWrite is defined! - // Example: writeLine(x, y, x+w-1, y, color); - // or writeFillRect(x, y, w, 1, color); - drawFastHLine(x, y, w, color); -} - -void ILI9341::writeFillRect(int16_t x, int16_t y, int16_t w, int16_t h, - uint16_t color) { - // Overwrite in subclasses if desired! - fillRect(x,y,w,h,color); +void ILI9341::writeFastHLine(int16_t x, int16_t y, int16_t w, uint16_t color){ + writeFillRect(x, y, w, 1, color); } void ILI9341::fillRect(int16_t x, int16_t y, int16_t w, int16_t h, diff --git a/examples/Basics/GFX_Library/Fonts/FreeMono12pt7b.h b/utility/Fonts/FreeMono12pt7b.h similarity index 100% rename from examples/Basics/GFX_Library/Fonts/FreeMono12pt7b.h rename to utility/Fonts/FreeMono12pt7b.h diff --git a/examples/Basics/GFX_Library/Fonts/FreeMono18pt7b.h b/utility/Fonts/FreeMono18pt7b.h similarity index 100% rename from examples/Basics/GFX_Library/Fonts/FreeMono18pt7b.h rename to utility/Fonts/FreeMono18pt7b.h diff --git a/examples/Basics/GFX_Library/Fonts/FreeMono24pt7b.h b/utility/Fonts/FreeMono24pt7b.h similarity index 100% rename from examples/Basics/GFX_Library/Fonts/FreeMono24pt7b.h rename to utility/Fonts/FreeMono24pt7b.h diff --git a/examples/Basics/GFX_Library/Fonts/FreeMono9pt7b.h b/utility/Fonts/FreeMono9pt7b.h similarity index 100% rename from examples/Basics/GFX_Library/Fonts/FreeMono9pt7b.h rename to utility/Fonts/FreeMono9pt7b.h diff --git a/examples/Basics/GFX_Library/Fonts/FreeMonoBold12pt7b.h b/utility/Fonts/FreeMonoBold12pt7b.h similarity index 100% rename from examples/Basics/GFX_Library/Fonts/FreeMonoBold12pt7b.h rename to utility/Fonts/FreeMonoBold12pt7b.h diff --git a/examples/Basics/GFX_Library/Fonts/FreeMonoBold18pt7b.h b/utility/Fonts/FreeMonoBold18pt7b.h similarity index 100% rename from examples/Basics/GFX_Library/Fonts/FreeMonoBold18pt7b.h rename to utility/Fonts/FreeMonoBold18pt7b.h diff --git a/examples/Basics/GFX_Library/Fonts/FreeMonoBold24pt7b.h b/utility/Fonts/FreeMonoBold24pt7b.h similarity index 100% rename from examples/Basics/GFX_Library/Fonts/FreeMonoBold24pt7b.h rename to utility/Fonts/FreeMonoBold24pt7b.h diff --git a/examples/Basics/GFX_Library/Fonts/FreeMonoBold9pt7b.h b/utility/Fonts/FreeMonoBold9pt7b.h similarity index 100% rename from examples/Basics/GFX_Library/Fonts/FreeMonoBold9pt7b.h rename to utility/Fonts/FreeMonoBold9pt7b.h diff --git a/examples/Basics/GFX_Library/Fonts/FreeMonoBoldOblique12pt7b.h b/utility/Fonts/FreeMonoBoldOblique12pt7b.h similarity index 100% rename from examples/Basics/GFX_Library/Fonts/FreeMonoBoldOblique12pt7b.h rename to utility/Fonts/FreeMonoBoldOblique12pt7b.h diff --git a/examples/Basics/GFX_Library/Fonts/FreeMonoBoldOblique18pt7b.h b/utility/Fonts/FreeMonoBoldOblique18pt7b.h similarity index 100% rename from examples/Basics/GFX_Library/Fonts/FreeMonoBoldOblique18pt7b.h rename to utility/Fonts/FreeMonoBoldOblique18pt7b.h diff --git a/examples/Basics/GFX_Library/Fonts/FreeMonoBoldOblique24pt7b.h b/utility/Fonts/FreeMonoBoldOblique24pt7b.h similarity index 100% rename from examples/Basics/GFX_Library/Fonts/FreeMonoBoldOblique24pt7b.h rename to utility/Fonts/FreeMonoBoldOblique24pt7b.h diff --git a/examples/Basics/GFX_Library/Fonts/FreeMonoBoldOblique9pt7b.h b/utility/Fonts/FreeMonoBoldOblique9pt7b.h similarity index 100% rename from examples/Basics/GFX_Library/Fonts/FreeMonoBoldOblique9pt7b.h rename to utility/Fonts/FreeMonoBoldOblique9pt7b.h diff --git a/examples/Basics/GFX_Library/Fonts/FreeMonoOblique12pt7b.h b/utility/Fonts/FreeMonoOblique12pt7b.h similarity index 100% rename from examples/Basics/GFX_Library/Fonts/FreeMonoOblique12pt7b.h rename to utility/Fonts/FreeMonoOblique12pt7b.h diff --git a/examples/Basics/GFX_Library/Fonts/FreeMonoOblique18pt7b.h b/utility/Fonts/FreeMonoOblique18pt7b.h similarity index 100% rename from examples/Basics/GFX_Library/Fonts/FreeMonoOblique18pt7b.h rename to utility/Fonts/FreeMonoOblique18pt7b.h diff --git a/examples/Basics/GFX_Library/Fonts/FreeMonoOblique24pt7b.h b/utility/Fonts/FreeMonoOblique24pt7b.h similarity index 100% rename from examples/Basics/GFX_Library/Fonts/FreeMonoOblique24pt7b.h rename to utility/Fonts/FreeMonoOblique24pt7b.h diff --git a/examples/Basics/GFX_Library/Fonts/FreeMonoOblique9pt7b.h b/utility/Fonts/FreeMonoOblique9pt7b.h similarity index 100% rename from examples/Basics/GFX_Library/Fonts/FreeMonoOblique9pt7b.h rename to utility/Fonts/FreeMonoOblique9pt7b.h diff --git a/examples/Basics/GFX_Library/Fonts/FreeSans12pt7b.h b/utility/Fonts/FreeSans12pt7b.h similarity index 100% rename from examples/Basics/GFX_Library/Fonts/FreeSans12pt7b.h rename to utility/Fonts/FreeSans12pt7b.h diff --git a/examples/Basics/GFX_Library/Fonts/FreeSans18pt7b.h b/utility/Fonts/FreeSans18pt7b.h similarity index 100% rename from examples/Basics/GFX_Library/Fonts/FreeSans18pt7b.h rename to utility/Fonts/FreeSans18pt7b.h diff --git a/examples/Basics/GFX_Library/Fonts/FreeSans24pt7b.h b/utility/Fonts/FreeSans24pt7b.h similarity index 100% rename from examples/Basics/GFX_Library/Fonts/FreeSans24pt7b.h rename to utility/Fonts/FreeSans24pt7b.h diff --git a/examples/Basics/GFX_Library/Fonts/FreeSans9pt7b.h b/utility/Fonts/FreeSans9pt7b.h similarity index 100% rename from examples/Basics/GFX_Library/Fonts/FreeSans9pt7b.h rename to utility/Fonts/FreeSans9pt7b.h diff --git a/examples/Basics/GFX_Library/Fonts/FreeSansBold12pt7b.h b/utility/Fonts/FreeSansBold12pt7b.h similarity index 100% rename from examples/Basics/GFX_Library/Fonts/FreeSansBold12pt7b.h rename to utility/Fonts/FreeSansBold12pt7b.h diff --git a/examples/Basics/GFX_Library/Fonts/FreeSansBold18pt7b.h b/utility/Fonts/FreeSansBold18pt7b.h similarity index 100% rename from examples/Basics/GFX_Library/Fonts/FreeSansBold18pt7b.h rename to utility/Fonts/FreeSansBold18pt7b.h diff --git a/examples/Basics/GFX_Library/Fonts/FreeSansBold24pt7b.h b/utility/Fonts/FreeSansBold24pt7b.h similarity index 100% rename from examples/Basics/GFX_Library/Fonts/FreeSansBold24pt7b.h rename to utility/Fonts/FreeSansBold24pt7b.h diff --git a/examples/Basics/GFX_Library/Fonts/FreeSansBold9pt7b.h b/utility/Fonts/FreeSansBold9pt7b.h similarity index 100% rename from examples/Basics/GFX_Library/Fonts/FreeSansBold9pt7b.h rename to utility/Fonts/FreeSansBold9pt7b.h diff --git a/examples/Basics/GFX_Library/Fonts/FreeSansBoldOblique12pt7b.h b/utility/Fonts/FreeSansBoldOblique12pt7b.h similarity index 100% rename from examples/Basics/GFX_Library/Fonts/FreeSansBoldOblique12pt7b.h rename to utility/Fonts/FreeSansBoldOblique12pt7b.h diff --git a/examples/Basics/GFX_Library/Fonts/FreeSansBoldOblique18pt7b.h b/utility/Fonts/FreeSansBoldOblique18pt7b.h similarity index 100% rename from examples/Basics/GFX_Library/Fonts/FreeSansBoldOblique18pt7b.h rename to utility/Fonts/FreeSansBoldOblique18pt7b.h diff --git a/examples/Basics/GFX_Library/Fonts/FreeSansBoldOblique24pt7b.h b/utility/Fonts/FreeSansBoldOblique24pt7b.h similarity index 100% rename from examples/Basics/GFX_Library/Fonts/FreeSansBoldOblique24pt7b.h rename to utility/Fonts/FreeSansBoldOblique24pt7b.h diff --git a/examples/Basics/GFX_Library/Fonts/FreeSansBoldOblique9pt7b.h b/utility/Fonts/FreeSansBoldOblique9pt7b.h similarity index 100% rename from examples/Basics/GFX_Library/Fonts/FreeSansBoldOblique9pt7b.h rename to utility/Fonts/FreeSansBoldOblique9pt7b.h diff --git a/examples/Basics/GFX_Library/Fonts/FreeSansOblique12pt7b.h b/utility/Fonts/FreeSansOblique12pt7b.h similarity index 100% rename from examples/Basics/GFX_Library/Fonts/FreeSansOblique12pt7b.h rename to utility/Fonts/FreeSansOblique12pt7b.h diff --git a/examples/Basics/GFX_Library/Fonts/FreeSansOblique18pt7b.h b/utility/Fonts/FreeSansOblique18pt7b.h similarity index 100% rename from examples/Basics/GFX_Library/Fonts/FreeSansOblique18pt7b.h rename to utility/Fonts/FreeSansOblique18pt7b.h diff --git a/examples/Basics/GFX_Library/Fonts/FreeSansOblique24pt7b.h b/utility/Fonts/FreeSansOblique24pt7b.h similarity index 100% rename from examples/Basics/GFX_Library/Fonts/FreeSansOblique24pt7b.h rename to utility/Fonts/FreeSansOblique24pt7b.h diff --git a/examples/Basics/GFX_Library/Fonts/FreeSansOblique9pt7b.h b/utility/Fonts/FreeSansOblique9pt7b.h similarity index 100% rename from examples/Basics/GFX_Library/Fonts/FreeSansOblique9pt7b.h rename to utility/Fonts/FreeSansOblique9pt7b.h diff --git a/examples/Basics/GFX_Library/Fonts/FreeSerif12pt7b.h b/utility/Fonts/FreeSerif12pt7b.h similarity index 100% rename from examples/Basics/GFX_Library/Fonts/FreeSerif12pt7b.h rename to utility/Fonts/FreeSerif12pt7b.h diff --git a/examples/Basics/GFX_Library/Fonts/FreeSerif18pt7b.h b/utility/Fonts/FreeSerif18pt7b.h similarity index 100% rename from examples/Basics/GFX_Library/Fonts/FreeSerif18pt7b.h rename to utility/Fonts/FreeSerif18pt7b.h diff --git a/examples/Basics/GFX_Library/Fonts/FreeSerif24pt7b.h b/utility/Fonts/FreeSerif24pt7b.h similarity index 100% rename from examples/Basics/GFX_Library/Fonts/FreeSerif24pt7b.h rename to utility/Fonts/FreeSerif24pt7b.h diff --git a/examples/Basics/GFX_Library/Fonts/FreeSerif9pt7b.h b/utility/Fonts/FreeSerif9pt7b.h similarity index 100% rename from examples/Basics/GFX_Library/Fonts/FreeSerif9pt7b.h rename to utility/Fonts/FreeSerif9pt7b.h diff --git a/examples/Basics/GFX_Library/Fonts/FreeSerifBold12pt7b.h b/utility/Fonts/FreeSerifBold12pt7b.h similarity index 100% rename from examples/Basics/GFX_Library/Fonts/FreeSerifBold12pt7b.h rename to utility/Fonts/FreeSerifBold12pt7b.h diff --git a/examples/Basics/GFX_Library/Fonts/FreeSerifBold18pt7b.h b/utility/Fonts/FreeSerifBold18pt7b.h similarity index 100% rename from examples/Basics/GFX_Library/Fonts/FreeSerifBold18pt7b.h rename to utility/Fonts/FreeSerifBold18pt7b.h diff --git a/examples/Basics/GFX_Library/Fonts/FreeSerifBold24pt7b.h b/utility/Fonts/FreeSerifBold24pt7b.h similarity index 100% rename from examples/Basics/GFX_Library/Fonts/FreeSerifBold24pt7b.h rename to utility/Fonts/FreeSerifBold24pt7b.h diff --git a/examples/Basics/GFX_Library/Fonts/FreeSerifBold9pt7b.h b/utility/Fonts/FreeSerifBold9pt7b.h similarity index 100% rename from examples/Basics/GFX_Library/Fonts/FreeSerifBold9pt7b.h rename to utility/Fonts/FreeSerifBold9pt7b.h diff --git a/examples/Basics/GFX_Library/Fonts/FreeSerifBoldItalic12pt7b.h b/utility/Fonts/FreeSerifBoldItalic12pt7b.h similarity index 100% rename from examples/Basics/GFX_Library/Fonts/FreeSerifBoldItalic12pt7b.h rename to utility/Fonts/FreeSerifBoldItalic12pt7b.h diff --git a/examples/Basics/GFX_Library/Fonts/FreeSerifBoldItalic18pt7b.h b/utility/Fonts/FreeSerifBoldItalic18pt7b.h similarity index 100% rename from examples/Basics/GFX_Library/Fonts/FreeSerifBoldItalic18pt7b.h rename to utility/Fonts/FreeSerifBoldItalic18pt7b.h diff --git a/examples/Basics/GFX_Library/Fonts/FreeSerifBoldItalic24pt7b.h b/utility/Fonts/FreeSerifBoldItalic24pt7b.h similarity index 100% rename from examples/Basics/GFX_Library/Fonts/FreeSerifBoldItalic24pt7b.h rename to utility/Fonts/FreeSerifBoldItalic24pt7b.h diff --git a/examples/Basics/GFX_Library/Fonts/FreeSerifBoldItalic9pt7b.h b/utility/Fonts/FreeSerifBoldItalic9pt7b.h similarity index 100% rename from examples/Basics/GFX_Library/Fonts/FreeSerifBoldItalic9pt7b.h rename to utility/Fonts/FreeSerifBoldItalic9pt7b.h diff --git a/examples/Basics/GFX_Library/Fonts/FreeSerifItalic12pt7b.h b/utility/Fonts/FreeSerifItalic12pt7b.h similarity index 100% rename from examples/Basics/GFX_Library/Fonts/FreeSerifItalic12pt7b.h rename to utility/Fonts/FreeSerifItalic12pt7b.h diff --git a/examples/Basics/GFX_Library/Fonts/FreeSerifItalic18pt7b.h b/utility/Fonts/FreeSerifItalic18pt7b.h similarity index 100% rename from examples/Basics/GFX_Library/Fonts/FreeSerifItalic18pt7b.h rename to utility/Fonts/FreeSerifItalic18pt7b.h diff --git a/examples/Basics/GFX_Library/Fonts/FreeSerifItalic24pt7b.h b/utility/Fonts/FreeSerifItalic24pt7b.h similarity index 100% rename from examples/Basics/GFX_Library/Fonts/FreeSerifItalic24pt7b.h rename to utility/Fonts/FreeSerifItalic24pt7b.h diff --git a/examples/Basics/GFX_Library/Fonts/FreeSerifItalic9pt7b.h b/utility/Fonts/FreeSerifItalic9pt7b.h similarity index 100% rename from examples/Basics/GFX_Library/Fonts/FreeSerifItalic9pt7b.h rename to utility/Fonts/FreeSerifItalic9pt7b.h diff --git a/examples/Basics/GFX_Library/Fonts/Org_01.h b/utility/Fonts/Org_01.h similarity index 100% rename from examples/Basics/GFX_Library/Fonts/Org_01.h rename to utility/Fonts/Org_01.h diff --git a/examples/Basics/GFX_Library/Fonts/Picopixel.h b/utility/Fonts/Picopixel.h similarity index 100% rename from examples/Basics/GFX_Library/Fonts/Picopixel.h rename to utility/Fonts/Picopixel.h diff --git a/examples/Basics/GFX_Library/Fonts/TomThumb.h b/utility/Fonts/TomThumb.h similarity index 100% rename from examples/Basics/GFX_Library/Fonts/TomThumb.h rename to utility/Fonts/TomThumb.h diff --git a/utility/config.h b/utility/config.h index 9553fca..d7eeae3 100644 --- a/utility/config.h +++ b/utility/config.h @@ -1,6 +1,9 @@ #ifndef _CONFIG_H_ #define _CONFIG_H_ +// #include "res/bmp_map.h" +// #include "utility/music_8bit.h" + //screen #define TFT_LED_PIN 32 #define TFT_DC_PIN 27