Applied new folder layout

This commit is contained in:
tobozo 2020-09-14 15:58:13 +02:00
parent 7b505c7b7d
commit 23cd3e5cf9
67 changed files with 186 additions and 1762 deletions

View file

@ -1,7 +1,7 @@
{
"name": "ESP32-Chimera-Core",
"description": "Alternate library M5Stack/Odroid-Go/D-Duino and possiblly other ESP32/TFT/SD bundles",
"keywords": "M5Stack Odroid-Go ttgo-ts d-duino-32-xs esp32-wrover-kit",
"keywords": "M5Stack M5Core2 Odroid-Go ttgo-ts d-duino-32-xs esp32-wrover-kit",
"authors": {
"name": "ESP32-Chimera-Core, a clone of M5Stack-core",
"url": "https://github.com/tobozo/ESP32-Chimera-Core"
@ -15,7 +15,7 @@
"name": "LovyanGFX"
}
],
"version": "1.0.4",
"version": "1.1.0",
"framework": "arduino",
"platforms": "espressif32"
}

View file

@ -1,8 +1,8 @@
name=ESP32-Chimera-Core
version=1.0.4
version=1.1.0
author=Lovyan03 & Tobozo
maintainer=tobozo@noreply.github.com
sentence=Alternate library M5Stack/Odroid-Go/D-Duino and possiblly other ESP32/TFT/SD bundles
sentence=Alternate library M5Stack/M5Core2/Odroid-Go/D-Duino and possiblly other ESP32/TFT/SD bundles
paragraph=See more on https://github.com/tobozo/ESP32-Chimera-Core
category=Device Control
url=https://github.com/tobozo/ESP32-Chimera-Core

View file

@ -151,7 +151,6 @@
#define TFT_MISO_PIN 38
#undef TOUCH_CS // using I2C touch
#define TFCARD_SPI_FREQ 40000000
#define TFCARD_CS_PIN 4
#define SD_ENABLE 0

View file

@ -6,7 +6,7 @@
#include <SPIFFS.h>
#include <SD.h>
#include "utility/Config.h"
//#include "utility/Config.h"
#define LGFX_AUTODETECT
#include <LGFX_TFT_eSPI.hpp>

View file

@ -40,18 +40,18 @@ void M5Stack::begin(bool LCDEnable, bool SDEnable, bool SerialEnable, bool I2CEn
Serial.print("ESP32-Chimera-Core initializing...");
}
#if defined( ARDUINO_M5STACK_Core2 ) // M5Core2 starts APX after display is on
// I2C init
if (I2CEnable == true) {
Wire.begin(32, 33);
}
Axp.begin();
#else
// TF Card
if (SDEnable == true) {
sd_begin();
}
#endif
#if defined( ARDUINO_M5STACK_Core2 ) // M5Core2 starts APX after display is on
// I2C init
if (I2CEnable == true) {
Wire.begin(32, 33);
}
Axp.begin();
#else
// TF Card
if (SDEnable == true) {
sd_begin();
}
#endif
// LCD INIT
if (LCDEnable == true) {
@ -61,24 +61,6 @@ void M5Stack::begin(bool LCDEnable, bool SDEnable, bool SerialEnable, bool I2CEn
#endif
Lcd.begin();
// provide consistent getWidth()/getHeight() to both Sprite and TFT image decoding
// Lcd.setWidthGetter = &setWidthGetter;
// Lcd.setHeightGetter = &setHeightGetter;
// //Lcd.setColorPusher = &setColorPusher;
// Lcd.setWindowSetter = &setWindowSetter;
// //Lcd.setColorWriter = &setColorWriter;
// Lcd.setColorWriterArray = &setColorWriterArray;
// Lcd.setRgb565Converter = &setRgb565Converter;
// Lcd.setTransactionStarter = &setTransactionStarter;
// Lcd.setTransactionEnder = &setTransactionEnder;
//
// setJpgRenderer( true );
//
// Lcd.setPngRenderCallBack = &pngCallBackSetter;
// Lcd.pngFlashRenderFunc = &pngRenderer;
// Lcd.pngFSRenderFunc = &pngRenderer;
// Lcd.pngStreamRenderFunc = &pngRenderer;
if( ScreenShotEnable == true ) {
ScreenShot.init( &Lcd, M5STACK_SD );
ScreenShot.begin();
@ -96,11 +78,11 @@ void M5Stack::begin(bool LCDEnable, bool SDEnable, bool SerialEnable, bool I2CEn
}
#if defined( ARDUINO_M5STACK_Core2 ) // M5Core2 starts APX after display is on
// Touch init
Touch.begin(); // Touch begin after AXP begin. (Reset at the start of AXP)
#if defined( ARDUINO_M5STACK_Core2 ) // M5Core2 starts APX after display is on
// Touch init
Touch.begin(); // Touch begin after AXP begin. (Reset at the start of AXP)
#endif
#endif
// TF Card ( reinit )
if (SDEnable == true && M5STACK_SD.cardSize() == 0) {
@ -109,50 +91,50 @@ void M5Stack::begin(bool LCDEnable, bool SDEnable, bool SerialEnable, bool I2CEn
// TONE
// Speaker.begin();
#ifdef ARDUINO_DDUINO32_XS
pinMode(BUTTON_A_PIN, INPUT_PULLUP);
pinMode(BUTTON_B_PIN, INPUT_PULLUP);
pinMode(BUTTON_C_PIN, INPUT_PULLUP);
#endif
#ifdef ARDUINO_ODROID_ESP32
pinMode(BUTTON_MENU_PIN, INPUT_PULLUP);
pinMode(BUTTON_VOLUME_PIN, INPUT_PULLUP);
pinMode(BUTTON_SELECT_PIN, INPUT_PULLUP);
pinMode(BUTTON_START_PIN, INPUT_PULLUP);
pinMode(BUTTON_JOY_Y_PIN, INPUT_PULLDOWN);
pinMode(BUTTON_JOY_X_PIN, INPUT_PULLDOWN);
#endif
#ifdef ARDUINO_DDUINO32_XS
pinMode(BUTTON_A_PIN, INPUT_PULLUP);
pinMode(BUTTON_B_PIN, INPUT_PULLUP);
pinMode(BUTTON_C_PIN, INPUT_PULLUP);
#endif
#ifdef ARDUINO_ODROID_ESP32
pinMode(BUTTON_MENU_PIN, INPUT_PULLUP);
pinMode(BUTTON_VOLUME_PIN, INPUT_PULLUP);
pinMode(BUTTON_SELECT_PIN, INPUT_PULLUP);
pinMode(BUTTON_START_PIN, INPUT_PULLUP);
pinMode(BUTTON_JOY_Y_PIN, INPUT_PULLDOWN);
pinMode(BUTTON_JOY_X_PIN, INPUT_PULLDOWN);
#endif
#if defined(ARDUINO_M5Stick_C) // M5Stick C
Axp.begin();
Rtc.begin();
#endif
#if defined(ARDUINO_M5Stick_C) // M5Stick C
Axp.begin();
Rtc.begin();
#endif
#if defined HAS_POWER
// Set wakeup button
Power.setWakeupButton(BUTTON_A_PIN);
#endif
#if defined HAS_POWER
// Set wakeup button
Power.setWakeupButton(BUTTON_A_PIN);
#endif
#if !defined( ARDUINO_M5STACK_Core2 )
// I2C init
if (I2CEnable == true) {
log_d("Enabling I2C");
if (M5.Lcd.getBoard() != lgfx::board_M5StackCore2) {
Wire.begin(SDA, SCL);
} else {
Wire.begin(32, 33);
#if !defined( ARDUINO_M5STACK_Core2 )
// I2C init
if (I2CEnable == true) {
log_d("Enabling I2C");
if (M5.Lcd.getBoard() != lgfx::board_M5StackCore2) {
Wire.begin(SDA, SCL);
} else {
Wire.begin(32, 33);
}
I2C.scan();
}
I2C.scan();
}
#endif
#endif
if (SerialEnable == true) {
Serial.println("OK");
}
#if defined( ARDUINO_M5STACK_Core2 )
Rtc.begin();
#endif
#if defined( ARDUINO_M5STACK_Core2 )
Rtc.begin();
#endif
}
@ -176,40 +158,40 @@ void M5Stack::update() {
}
//Speaker update
Speaker.update();
#ifdef ARDUINO_ODROID_ESP32
BtnMenu.read();
BtnVolume.read();
BtnSelect.read();
BtnStart.read();
JOY_Y.readAxis();
JOY_X.readAxis();
battery.update();
#endif
#ifdef ARDUINO_ODROID_ESP32
BtnMenu.read();
BtnVolume.read();
BtnSelect.read();
BtnStart.read();
JOY_Y.readAxis();
JOY_X.readAxis();
battery.update();
#endif
}
#if defined HAS_POWER
/**
* Function has been move to Power class.(for compatibility)
* This name will be removed in a future release.
*/
void M5Stack::setPowerBoostKeepOn(bool en) {
M5.Power.setPowerBoostKeepOn(en);
}
/**
* Function has been move to Power class.(for compatibility)
* This name will be removed in a future release.
*/
void M5Stack::setWakeupButton(uint8_t button) {
M5.Power.setWakeupButton(button);
}
/**
* Function has been move to Power class.(for compatibility)
* This name will be removed in a future release.
*/
void M5Stack::powerOFF() {
M5.Power.deepSleep();
}
/**
* Function has been move to Power class.(for compatibility)
* This name will be removed in a future release.
*/
void M5Stack::setPowerBoostKeepOn(bool en) {
M5.Power.setPowerBoostKeepOn(en);
}
/**
* Function has been move to Power class.(for compatibility)
* This name will be removed in a future release.
*/
void M5Stack::setWakeupButton(uint8_t button) {
M5.Power.setWakeupButton(button);
}
/**
* Function has been move to Power class.(for compatibility)
* This name will be removed in a future release.
*/
void M5Stack::powerOFF() {
M5.Power.deepSleep();
}
#endif
@ -219,7 +201,7 @@ bool M5Stack::sd_begin(void)
bool ret = false;
#if defined ( USE_TFCARD_CS_PIN ) && defined( TFCARD_CS_PIN )
log_w("Enabling SD from TFCARD_CS_PIN #%d at %d Hz", TFCARD_CS_PIN, TFCARD_SPI_FREQ);
log_d("Enabling SD from TFCARD_CS_PIN #%d at %d Hz", TFCARD_CS_PIN, TFCARD_SPI_FREQ);
M5STACK_SD.end();
ret = M5STACK_SD.begin(TFCARD_CS_PIN, SPI, TFCARD_SPI_FREQ);

View file

@ -107,7 +107,7 @@
#if defined(ESP32)
// #define MPU9250_INSDE
//#define MPU9250_INSDE // M5Core2 : enable this only if plugging a secondary MPU !
#include "gitTagVersion.h"
#include <Arduino.h>
#include <Wire.h>
@ -124,33 +124,36 @@
#endif
#include "M5Display.h"
#include "utility/Config.h"
#ifdef TOUCH_CS
// TODO: deprecate this
#include "utility/TouchButton.h"
#endif
#include "utility/Button.h"
#include "utility/Speaker.h"
#include "utility/Power.h"
#include "utility/CommUtil.h"
#include "Config.h"
#include "helpers/TouchButton.h"
#include "helpers/ScreenShot.h"
#include "drivers/common/Button/Button.h"
#include "drivers/common/Speaker/Speaker.h"
#include "drivers/common/IP5306/Power.h"
#include "drivers/common/I2C/CommUtil.h"
// allow multiple MPU
#if defined( MPU9250_INSDE )
#include "drivers/M5Stack/MPU9250/MPU9250.h"
#endif
#if defined( ARDUINO_M5STACK_Core2 ) // M5Core2
#include "utility/drivers/M5Core2/MPU6886_M5Core2.h"
#include "drivers/M5Core2/MPU6886/MPU6886_M5Core2.h"
#endif
#include "utility/ScreenShot.h"
#ifdef ARDUINO_ODROID_ESP32
#include "utility/battery.h"
#endif
#ifdef ARDUINO_ODROID_ESP32
#include "drivers/Odroid-Go/Battery/battery.h"
#endif
#if defined(ARDUINO_M5Stick_C) // M5Stick C
#include "utility/drivers/M5StickC/AXP192.h"
#include "utility/drivers/M5StickC/RTC.h"
#elif defined( ARDUINO_M5STACK_Core2 ) // M5Core2
#include "utility/drivers/M5Core2/Touch_M5Core2.h"
#include "utility/drivers/M5Core2/AXP192_M5Core2.h"
#include "utility/drivers/M5Core2/RTC_M5Core2.h"
#endif
#if defined(ARDUINO_M5Stick_C) // M5Stick C
#include "drivers/M5StickC/AXP192.h"
#include "drivers/M5StickC/RTC.h"
#elif defined( ARDUINO_M5STACK_Core2 ) // M5Core2
#include "drivers/M5Core2/FT6336U/Touch_M5Core2.h"
#include "drivers/M5Core2/AXP192/AXP192_M5Core2.h"
#include "drivers/M5Core2/BM8563/RTC_M5Core2.h"
#endif
class M5Stack
{
@ -165,106 +168,91 @@
void setTouchSpiShared( int32_t csPin, int32_t IRQPin=255 );
#if defined( ARDUINO_M5STACK_Core2 )// M5Core2 C
#define DEBOUNCE_MS 1
#else
#define DEBOUNCE_MS 10
#endif
#if defined( ARDUINO_M5STACK_Core2 )// M5Core2 C
#define DEBOUNCE_MS 1
#else
#define DEBOUNCE_MS 10
#endif
// Button API
Button BtnA = Button(BUTTON_A_PIN, true, DEBOUNCE_MS);
Button BtnB = Button(BUTTON_B_PIN, true, DEBOUNCE_MS);
Button BtnC = Button(BUTTON_C_PIN, true, DEBOUNCE_MS);
#ifdef ARDUINO_ODROID_ESP32
#ifdef ARDUINO_ODROID_ESP32
#define DEBOUNCE_MS_XY 5
Button JOY_Y = Button(BUTTON_JOY_Y_PIN, true, DEBOUNCE_MS_XY);
Button JOY_X = Button(BUTTON_JOY_X_PIN, true, DEBOUNCE_MS_XY);
Button BtnMenu = Button(BUTTON_MENU_PIN, true, DEBOUNCE_MS);
Button BtnVolume = Button(BUTTON_VOLUME_PIN, true, DEBOUNCE_MS);
Button BtnSelect = Button(BUTTON_SELECT_PIN, true, DEBOUNCE_MS);
Button BtnStart = Button(BUTTON_START_PIN, true, DEBOUNCE_MS);
Button JOY_Y = Button(BUTTON_JOY_Y_PIN, true, DEBOUNCE_MS_XY);
Button JOY_X = Button(BUTTON_JOY_X_PIN, true, DEBOUNCE_MS_XY);
Button BtnMenu = Button(BUTTON_MENU_PIN, true, DEBOUNCE_MS);
Button BtnVolume = Button(BUTTON_VOLUME_PIN, true, DEBOUNCE_MS);
Button BtnSelect = Button(BUTTON_SELECT_PIN, true, DEBOUNCE_MS);
Button BtnStart = Button(BUTTON_START_PIN, true, DEBOUNCE_MS);
Battery battery;
#endif
Battery battery;
#endif
// SPEAKER
SPEAKER Speaker;
// LCD
M5Display Lcd; // = M5Display();
// void setJpgRenderer( bool legacy = true );
M5Display Lcd;
// ScreenShots !
ScreenShotService ScreenShot;
#ifdef TOUCH_CS
// TODO: deprecate this
XPT2046_Touchscreen* ts = nullptr;
#endif
// TODO: remove this when Axp is available
//Power
#ifdef TOUCH_CS
// TODO: deprecate this
XPT2046_Touchscreen* ts = nullptr;
#endif
#if defined(ARDUINO_M5Stick_C) // M5Stick C
//!Power
AXP192 Axp = AXP192();
//!RTC
RTC Rtc;
#elif defined( ARDUINO_M5STACK_Core2 )// M5Core2 C
//!Power
AXP192_M5Core2 Axp = AXP192_M5Core2();
//!RTC
RTC_M5Core2 Rtc;
Touch_M5Core2 Touch;
// accel/gyro
MPU6886_M5Core2 IMU = MPU6886_M5Core2();
#else
#define HAS_POWER
POWER Power;
#endif
#if defined(ARDUINO_M5Stick_C) // M5Stick C
//!Power
AXP192 Axp = AXP192();
//!RTC
RTC Rtc;
#elif defined( ARDUINO_M5STACK_Core2 )// M5Core2 C
//!Power
AXP192_M5Core2 Axp = AXP192_M5Core2();
//!RTC
RTC_M5Core2 Rtc;
Touch_M5Core2 Touch;
// accel/gyro
MPU6886_M5Core2 IMU = MPU6886_M5Core2();
// allow secondary MPU
#ifdef MPU9250_INSDE
MPU9250 IMU2 = MPU9250();
#endif
#else
#define HAS_POWER
POWER Power;
// MPU9250
#ifdef MPU9250_INSDE
MPU9250 IMU = MPU9250();
#endif
#endif
// UART
// HardwareSerial Serial0 = HardwareSerial(0);
// HardwareSerial Serial2 = HardwareSerial(2);
// MPU9250
#ifdef MPU9250_INSDE
MPU9250 IMU = MPU9250();
#endif
// I2C
CommUtil I2C = CommUtil();
#if defined HAS_POWER
/**
* Function has been move to Power class.(for compatibility)
* This name will be removed in a future release.
*/
void setPowerBoostKeepOn(bool en);
void setWakeupButton(uint8_t button);
void powerOFF();
#if defined HAS_POWER // legacy M5Stack support
/**
* Function has been move to Power class.(for compatibility)
* This name will be removed in a future release.
*/
void setPowerBoostKeepOn(bool en);
void setWakeupButton(uint8_t button);
void powerOFF();
#else
/**
* Function has been move to Power class.(for compatibility)
* This name will be removed in a future release.
*/
void setPowerBoostKeepOn(bool en) __attribute__((deprecated));
void setWakeupButton(uint8_t button) __attribute__((deprecated));
void powerOFF() __attribute__((deprecated));
#endif
#else // M5Core2
/**
* Function has been move to Power class.(for compatibility)
* This name will be removed in a future release.
*/
void setPowerBoostKeepOn(bool en) __attribute__((deprecated));
void setWakeupButton(uint8_t button) __attribute__((deprecated));
void powerOFF() __attribute__((deprecated));
#endif
private:
bool isInited;
};

View file

@ -3,7 +3,7 @@
#ifndef M5Faces_h
#define M5Faces_h
#include "M5Stack.h"
#include "../../M5Stack.h"
class M5Faces {
public:

View file

@ -1,4 +1,4 @@
#include "../M5Stack.h"
#include "../../../M5Stack.h"
#include "MPU9250.h"
//==============================================================================

View file

@ -9,7 +9,7 @@
#define LIBRARIES_ODROID_GO_SRC_UTILITY_BATTERY_H_
#include "Arduino.h"
#include "Config.h"
//#include "Config.h"
#include <driver/adc.h>
#include <esp_adc_cal.h>

View file

@ -6,7 +6,7 @@
* https://www.gnu.org/licenses/old-licenses/lgpl-2.1.en.html *
*----------------------------------------------------------------------*/
#include "CommUtil.h"
#include "../M5Stack.h"
#include "../../../M5Stack.h"
extern M5Stack M5;

View file

@ -6,7 +6,7 @@
* https://www.gnu.org/licenses/old-licenses/lgpl-2.1.en.html *
*----------------------------------------------------------------------*/
#include "Power.h"
#include "../M5Stack.h"
#include "../../../M5Stack.h"
#include <rom/rtc.h>
#include <esp_sleep.h>
#include <esp_bt_main.h>

View file

@ -2,7 +2,7 @@
#define _SPEAKER_H_
#include "Arduino.h"
#include "Config.h"
#include "../../../Config.h"
#ifdef __cplusplus
extern "C"

View file

@ -1 +1 @@
#define M5_LIB_VERSION F("0.2.3-dirty")
#define M5_LIB_VERSION F("1.1.0-dirty")

View file

@ -32,7 +32,7 @@
//#pragma message ("Screenshots support enabled !!")
#include "M5Display.h"
#include "../M5Display.h"
#include "TinyJPEGEncoder.h"
#include "TinyBMPEncoder.h"

View file

@ -29,7 +29,7 @@
#ifndef __TINY_BMP_ENCODER_H
#define __TINY_BMP_ENCODER_H
#include "M5Display.h"
#include "../M5Display.h"
class BMP_Encoder {

View file

@ -56,7 +56,7 @@
#ifndef __TINY_JPEG_ENCODER__
#define __TINY_JPEG_ENCODER__
#include "M5Display.h"
#include "../M5Display.h"
// C std lib
#include <assert.h>
#include <inttypes.h>
@ -188,7 +188,7 @@ typedef void (*jpeg_encoder_callback_t)(uint32_t y, uint32_t h, unsigned char* r
class JPEG_Encoder {
public:
fs::File jpegFile;
fs::FS * _fileSystem;

View file

@ -1,162 +0,0 @@
// Change the width and height if required (defined in portrait mode)
// or use the constructor to over-ride defaults
#if defined( ARDUINO_LOLIN_D32_PRO )
#define TFT_WIDTH 240
#define TFT_HEIGHT 320
#elif defined ( ARDUINO_ESP32_DEV ) || defined( ARDUINO_ESP32_WROVER_KIT )
#define TFT_WIDTH 240
#define TFT_HEIGHT 320
#elif defined(ARDUINO_ODROID_ESP32)
#define TFT_WIDTH 320
#define TFT_HEIGHT 240
#elif defined(ARDUINO_TTGO_T1)
#define TFT_WIDTH 128 // change this to 130 if your display has border problems
#define TFT_HEIGHT 160
#define CGRAM_OFFSET
#define CGRAM_colstart 0x02 // h pixels offset (change this if pix has offset)
#define CGRAM_rowstart 0x03 // v pixels offset (change this if pix has offset)
#else
#define TFT_WIDTH 240
#define TFT_HEIGHT 320
#endif
// Color definitions for backwards compatibility with old sketches
// use colour definitions like TFT_BLACK to make sketches more portable
#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
// Delay between some initialisation commands
#define TFT_INIT_DELAY 0x80 // Not used unless commandlist invoked
// Generic commands used by TFT_eSPI.cpp
#define TFT_NOP 0x00
#define TFT_SWRST 0x01
#define TFT_CASET 0x2A
#define TFT_PASET 0x2B
#define TFT_RAMWR 0x2C
#define TFT_RAMRD 0x2E
#define TFT_IDXRD 0xDD // ILI9341 only, indexed control register read
#define TFT_MADCTL 0x36
#define TFT_MAD_MY 0x80
#define TFT_MAD_MX 0x40
#define TFT_MAD_MV 0x20
#define TFT_MAD_ML 0x10
#define TFT_MAD_BGR 0x08
#define TFT_MAD_MH 0x04
#define TFT_MAD_RGB 0x00
#define TFT_INVOFF 0x20
#define TFT_INVON 0x21
// All ILI9341 specific commands some are used by init()
#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 0x0A
#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_VSCRDEF 0x33
#define ILI9341_MADCTL 0x36
#define ILI9341_VSCRSADD 0x37
#define ILI9341_PIXFMT 0x3A
#define ILI9341_WRDISBV 0x51
#define ILI9341_RDDISBV 0x52
#define ILI9341_WRCTRLD 0x53
#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_RDID4 0xD3
#define ILI9341_RDINDEX 0xD9
#define ILI9341_RDID1 0xDA
#define ILI9341_RDID2 0xDB
#define ILI9341_RDID3 0xDC
#define ILI9341_RDIDX 0xDD // TBC
#define ILI9341_GMCTRP1 0xE0
#define ILI9341_GMCTRN1 0xE1
#define ILI9341_MADCTL_MY 0x80
#define ILI9341_MADCTL_MX 0x40
#define ILI9341_MADCTL_MV 0x20
#define ILI9341_MADCTL_ML 0x10
#define ILI9341_MADCTL_RGB 0x00
#define ILI9341_MADCTL_BGR 0x08
#define ILI9341_MADCTL_MH 0x04

View file

@ -1,139 +0,0 @@
// This is the command sequence that initialises the ILI9341 driver
//
// This setup information uses simple 8 bit SPI writecommand() and writedata() functions
//
// See ST7735_Setup.h file for an alternative format
{
#ifdef ARDUINO_TTGO_T1
colstart = CGRAM_colstart; // see ILI99341_Defines to fine-tune this
rowstart = CGRAM_rowstart; // see ILI99341_Defines to fine-tune this
#endif
writecommand(0xEF);
writedata(0x03);
writedata(0x80);
writedata(0x02);
writecommand(0xCF);
writedata(0x00);
writedata(0xC1);
writedata(0x30);
writecommand(0xED);
writedata(0x64);
writedata(0x03);
writedata(0x12);
writedata(0x81);
writecommand(0xE8);
writedata(0x85);
writedata(0x00);
writedata(0x78);
writecommand(0xCB);
writedata(0x39);
writedata(0x2C);
writedata(0x00);
writedata(0x34);
writedata(0x02);
writecommand(0xF7);
writedata(0x20);
writecommand(0xEA);
writedata(0x00);
writedata(0x00);
writecommand(ILI9341_PWCTR1); // Power control
writedata(0x23); // VRH[5:0]
writecommand(ILI9341_PWCTR2); // Power control
writedata(0x10); // SAP[2:0];BT[3:0]
writecommand(ILI9341_VMCTR1); // VCM control
writedata(0x3e);
writedata(0x28);
writecommand(ILI9341_VMCTR2); // VCM control2
writedata(0x86); // --
writecommand(ILI9341_MADCTL); // Memory Access Control
#if defined (M5STACK)
writedata(0xA8); // Rotation 0
#else
writedata(0x48); // Rotation 1
#endif
writecommand(ILI9341_PIXFMT);
writedata(0x55);
writecommand(ILI9341_FRMCTR1);
writedata(0x00);
writedata(0x13); // 0x18 79Hz, 0x1B default 70Hz, 0x13 100Hz
writecommand(ILI9341_DFUNCTR); // Display Function Control
#ifdef ARDUINO_ODROID_ESP32
writedata(0x0A);
writedata(0xA2);
#else
writedata(0x08);
writedata(0x82);
#endif
writedata(0x27);
writecommand(0xF2); // 3Gamma Function Disable
writedata(0x00);
writecommand(ILI9341_GAMMASET); // Gamma curve selected
writedata(0x01);
writecommand(ILI9341_GMCTRP1); // Set Gamma
writedata(0x0F);
writedata(0x31);
writedata(0x2B);
writedata(0x0C);
writedata(0x0E);
writedata(0x08);
writedata(0x4E);
writedata(0xF1);
writedata(0x37);
writedata(0x07);
writedata(0x10);
writedata(0x03);
writedata(0x0E);
writedata(0x09);
writedata(0x00);
writecommand(ILI9341_GMCTRN1); // Set Gamma
writedata(0x00);
writedata(0x0E);
writedata(0x14);
writedata(0x03);
writedata(0x11);
writedata(0x07);
writedata(0x31);
writedata(0xC1);
writedata(0x48);
writedata(0x08);
writedata(0x0F);
writedata(0x0C);
writedata(0x31);
writedata(0x36);
writedata(0x0F);
writecommand(ILI9341_SLPOUT); // Exit Sleep
spi_end();
delay(120);
spi_begin();
writecommand(ILI9341_DISPON); // Display on
#if defined ( M5STACK )
if(lcd_version) {
writecommand(TFT_INVON); // color invert for IPS
}
#endif
}

View file

@ -1,88 +0,0 @@
// This is the command sequence that rotates the ILI9341 driver coordinate frame
rotation = m % 8; // Limit the range of values to 0-7
writecommand(TFT_MADCTL);
switch (rotation) {
case 0:
#ifdef M5STACK
writedata(TFT_MAD_MY | TFT_MAD_MV | TFT_MAD_BGR);
#else
writedata(TFT_MAD_MX | TFT_MAD_BGR);
#endif
_width = _init_width;
_height = _init_height;
break;
case 1:
#ifdef M5STACK
writedata(TFT_MAD_BGR);
#else
writedata(TFT_MAD_MV | TFT_MAD_BGR);
#endif
_width = _init_height;
_height = _init_width;
break;
case 2:
#ifdef M5STACK
writedata(TFT_MAD_MV | TFT_MAD_MX | TFT_MAD_BGR);
#else
writedata(TFT_MAD_MY | TFT_MAD_BGR);
#endif
_width = _init_width;
_height = _init_height;
break;
case 3:
#ifdef M5STACK
writedata(TFT_MAD_MX | TFT_MAD_MY | TFT_MAD_BGR);
#else
writedata(TFT_MAD_MX | TFT_MAD_MY | TFT_MAD_MV | TFT_MAD_BGR);
#endif
_width = _init_height;
_height = _init_width;
break;
// These next rotations are for bottom up BMP drawing
case 4:
#ifdef M5STACK
writedata(TFT_MAD_MX | TFT_MAD_MY | TFT_MAD_MV | TFT_MAD_BGR);
#else
writedata(TFT_MAD_MX | TFT_MAD_MY | TFT_MAD_BGR);
#endif
_width = _init_width;
_height = _init_height;
break;
case 5:
#ifdef M5STACK
writedata(TFT_MAD_MY | TFT_MAD_BGR);
#else
writedata(TFT_MAD_MV | TFT_MAD_MX | TFT_MAD_BGR);
#endif
_width = _init_height;
_height = _init_width;
break;
case 6:
#ifdef M5STACK
writedata(TFT_MAD_MV | TFT_MAD_BGR);
#else
writedata(TFT_MAD_BGR);
#endif
_width = _init_width;
_height = _init_height;
break;
case 7:
#ifdef M5STACK
writedata(TFT_MAD_MX | TFT_MAD_BGR);
#else
writedata(TFT_MAD_MY | TFT_MAD_MV | TFT_MAD_BGR);
#endif
_width = _init_height;
_height = _init_width;
break;
}
#ifdef ARDUINO_TTGO_T1
#define SWAP(a, b) do { typeof(a) temp = a; a = b; b = temp; } while (0)
SWAP( _width, _height );
#undef SWAP
#endif

View file

@ -1,166 +0,0 @@
// Change the width and height if required (defined in portrait mode)
// or use the constructor to over-ride defaults
#ifndef TFT_WIDTH
#define TFT_WIDTH 128
#endif
#ifndef TFT_HEIGHT
#define TFT_HEIGHT 160
#endif
// Enumerate the different configurations
#define INITR_GREENTAB 0x0
#define INITR_REDTAB 0x1
#define INITR_BLACKTAB 0x2 // Display with no offsets
#define INITR_GREENTAB2 0x3 // Use if you get random pixels on two edges of green tab display
#define INITR_GREENTAB3 0x4 // Use if you get random pixels on edge(s) of 128x128 screen
#define INITR_GREENTAB128 0x5 // Use if you only get part of 128x128 screen in rotation 0 & 1
#define INITR_GREENTAB160x80 0x6 // Use if you only get part of 128x128 screen in rotation 0 & 1
#define INITR_REDTAB160x80 0x7 // Added for https://www.aliexpress.com/item/ShengYang-1pcs-IPS-0-96-inch-7P-SPI-HD-65K-Full-Color-OLED-Module-ST7735-Drive/32918394604.html
#define INITB 0xB
#define TAB_COLOUR INITR_GREENTAB3 //INITR_GREENTAB
#define CGRAM_OFFSET
// Color definitions for backwards compatibility with old sketches
// use colour definitions like TFT_BLACK to make sketches more portable
#define ST7735_BLACK 0x0000 /* 0, 0, 0 */
#define ST7735_NAVY 0x000F /* 0, 0, 128 */
#define ST7735_DARKGREEN 0x03E0 /* 0, 128, 0 */
#define ST7735_DARKCYAN 0x03EF /* 0, 128, 128 */
#define ST7735_MAROON 0x7800 /* 128, 0, 0 */
#define ST7735_PURPLE 0x780F /* 128, 0, 128 */
#define ST7735_OLIVE 0x7BE0 /* 128, 128, 0 */
#define ST7735_LIGHTGREY 0xC618 /* 192, 192, 192 */
#define ST7735_DARKGREY 0x7BEF /* 128, 128, 128 */
#define ST7735_BLUE 0x001F /* 0, 0, 255 */
#define ST7735_GREEN 0x07E0 /* 0, 255, 0 */
#define ST7735_CYAN 0x07FF /* 0, 255, 255 */
#define ST7735_RED 0xF800 /* 255, 0, 0 */
#define ST7735_MAGENTA 0xF81F /* 255, 0, 255 */
#define ST7735_YELLOW 0xFFE0 /* 255, 255, 0 */
#define ST7735_WHITE 0xFFFF /* 255, 255, 255 */
#define ST7735_ORANGE 0xFD20 /* 255, 165, 0 */
#define ST7735_GREENYELLOW 0xAFE5 /* 173, 255, 47 */
#define ST7735_PINK 0xF81F
// Delay between some initialisation commands
#define TFT_INIT_DELAY 0x80
// Generic commands used by TFT_eSPI.cpp
#define TFT_NOP 0x00
#define TFT_SWRST 0x01
#define TFT_CASET 0x2A
#define TFT_PASET 0x2B
#define TFT_RAMWR 0x2C
#define TFT_RAMRD 0x2E
#define TFT_IDXRD 0x00 //0xDD // ILI9341 only, indexed control register read
#define TFT_MADCTL 0x36
#define TFT_MAD_MY 0x80
#define TFT_MAD_MX 0x40
#define TFT_MAD_MV 0x20
#define TFT_MAD_ML 0x10
#define TFT_MAD_BGR 0x08
#define TFT_MAD_MH 0x04
#define TFT_MAD_RGB 0x00
#define TFT_INVOFF 0x20
#define TFT_INVON 0x21
// ST7735 specific commands used in init
#define ST7735_NOP 0x00
#define ST7735_SWRESET 0x01
#define ST7735_RDDID 0x04
#define ST7735_RDDST 0x09
#define ST7735_SLPIN 0x10
#define ST7735_SLPOUT 0x11
#define ST7735_PTLON 0x12
#define ST7735_NORON 0x13
#define ST7735_INVOFF 0x20
#define ST7735_INVON 0x21
#define ST7735_DISPOFF 0x28
#define ST7735_DISPON 0x29
#define ST7735_CASET 0x2A
#define ST7735_RASET 0x2B // PASET
#define ST7735_RAMWR 0x2C
#define ST7735_RAMRD 0x2E
#define ST7735_PTLAR 0x30
#define ST7735_COLMOD 0x3A
#define ST7735_MADCTL 0x36
#define ST7735_FRMCTR1 0xB1
#define ST7735_FRMCTR2 0xB2
#define ST7735_FRMCTR3 0xB3
#define ST7735_INVCTR 0xB4
#define ST7735_DISSET5 0xB6
#define ST7735_PWCTR1 0xC0
#define ST7735_PWCTR2 0xC1
#define ST7735_PWCTR3 0xC2
#define ST7735_PWCTR4 0xC3
#define ST7735_PWCTR5 0xC4
#define ST7735_VMCTR1 0xC5
#define ST7735_RDID1 0xDA
#define ST7735_RDID2 0xDB
#define ST7735_RDID3 0xDC
#define ST7735_RDID4 0xDD
#define ST7735_PWCTR6 0xFC
#define ST7735_GMCTRP1 0xE0
#define ST7735_GMCTRN1 0xE1
// Color definitions for backwards compatibility with old sketches
// use colour definitions like TFT_BLACK to make sketches more portable
// M5Core and its applications expect ILI9341 values, so backwards compat rules
#define ILI9341_BLACK TFT_BLACK //0x0000 /* 0, 0, 0 */
#define ILI9341_NAVY TFT_NAVY //0x000F /* 0, 0, 128 */
#define ILI9341_DARKGREEN TFT_DARKGREEN //0x03E0 /* 0, 128, 0 */
#define ILI9341_DARKCYAN TFT__DARKCYAN //0x03EF /* 0, 128, 128 */
#define ILI9341_MAROON TFT_MAROON //0x7800 /* 128, 0, 0 */
#define ILI9341_PURPLE TFT_PURPLE //0x780F /* 128, 0, 128 */
#define ILI9341_OLIVE TFT_OLIVE //0x7BE0 /* 128, 128, 0 */
#define ILI9341_LIGHTGREY TFT_LIGHTGREY //0xC618 /* 192, 192, 192 */
#define ILI9341_DARKGREY TFT_DARKGREY //0x7BEF /* 128, 128, 128 */
#define ILI9341_BLUE TFT_BLUE //0x001F /* 0, 0, 255 */
#define ILI9341_GREEN TFT_GREEN //0x07E0 /* 0, 255, 0 */
#define ILI9341_CYAN TFT_CYAN //0x07FF /* 0, 255, 255 */
#define ILI9341_RED TFT_RED //0xF800 /* 255, 0, 0 */
#define ILI9341_MAGENTA TFT_MAGENTA //0xF81F /* 255, 0, 255 */
#define ILI9341_YELLOW TFT_YELLOW //0xFFE0 /* 255, 255, 0 */
#define ILI9341_WHITE TFT_WHITE //0xFFFF /* 255, 255, 255 */
#define ILI9341_ORANGE TFT_ORANGE //0xFD20 /* 255, 165, 0 */
#define ILI9341_GREENYELLOW TFT_GREENYELLOW //0xAFE5 /* 173, 255, 47 */
#define ILI9341_PINK TFT_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
#define ILI9341_SLPIN ST7735_SLPIN
#define ILI9341_SLPOUT ST7735_SLPOUT
#define ILI9341_VSCRDEF ST7735_VSCRDEF // Vertical Scrolling Definition
#define ILI9341_VSCRSADD ST7735_VSCRSADD // Vertical Scrolling Start Address

View file

@ -1,200 +0,0 @@
// This is the command sequence that initialises the ST7735 driver
//
// This setup information is in a format accepted by the commandList() function
// which reduces FLASH space, but on an ESP8266 there is plenty available!
//
// See ILI9341_Setup.h file for an alternative simpler format
{
// Initialization commands for ST7735 screens
static const uint8_t PROGMEM
Bcmd[] = { // Initialization commands for 7735B screens
18, // 18 commands in list:
ST7735_SWRESET, TFT_INIT_DELAY, // 1: Software reset, no args, w/delay
50, // 50 ms delay
ST7735_SLPOUT , TFT_INIT_DELAY, // 2: Out of sleep mode, no args, w/delay
255, // 255 = 500 ms delay
ST7735_COLMOD , 1+TFT_INIT_DELAY, // 3: Set color mode, 1 arg + delay:
0x05, // 16-bit color
10, // 10 ms delay
ST7735_FRMCTR1, 3+TFT_INIT_DELAY, // 4: Frame rate control, 3 args + delay:
0x00, // fastest refresh
0x06, // 6 lines front porch
0x03, // 3 lines back porch
10, // 10 ms delay
ST7735_MADCTL , 1 , // 5: Memory access ctrl (directions), 1 arg:
0x40, // Row addr/col addr, bottom to top refresh
ST7735_DISSET5, 2 , // 6: Display settings #5, 2 args, no delay:
0x15, // 1 clk cycle nonoverlap, 2 cycle gate
// rise, 3 cycle osc equalize
0x02, // Fix on VTL
ST7735_INVCTR , 1 , // 7: Display inversion control, 1 arg:
0x0, // Line inversion
ST7735_PWCTR1 , 2+TFT_INIT_DELAY, // 8: Power control, 2 args + delay:
0x02, // GVDD = 4.7V
0x70, // 1.0uA
10, // 10 ms delay
ST7735_PWCTR2 , 1 , // 9: Power control, 1 arg, no delay:
0x05, // VGH = 14.7V, VGL = -7.35V
ST7735_PWCTR3 , 2 , // 10: Power control, 2 args, no delay:
0x01, // Opamp current small
0x02, // Boost frequency
ST7735_VMCTR1 , 2+TFT_INIT_DELAY, // 11: Power control, 2 args + delay:
0x3C, // VCOMH = 4V
0x38, // VCOML = -1.1V
10, // 10 ms delay
ST7735_PWCTR6 , 2 , // 12: Power control, 2 args, no delay:
0x11, 0x15,
ST7735_GMCTRP1,16 , // 13: Magical unicorn dust, 16 args, no delay:
0x09, 0x16, 0x09, 0x20, // (seriously though, not sure what
0x21, 0x1B, 0x13, 0x19, // these config values represent)
0x17, 0x15, 0x1E, 0x2B,
0x04, 0x05, 0x02, 0x0E,
ST7735_GMCTRN1,16+TFT_INIT_DELAY, // 14: Sparkles and rainbows, 16 args + delay:
0x0B, 0x14, 0x08, 0x1E, // (ditto)
0x22, 0x1D, 0x18, 0x1E,
0x1B, 0x1A, 0x24, 0x2B,
0x06, 0x06, 0x02, 0x0F,
10, // 10 ms delay
ST7735_CASET , 4 , // 15: Column addr set, 4 args, no delay:
0x00, 0x02, // XSTART = 2
0x00, 0x81, // XEND = 129
ST7735_RASET , 4 , // 16: Row addr set, 4 args, no delay:
0x00, 0x02, // XSTART = 1
0x00, 0x81, // XEND = 160
ST7735_NORON , TFT_INIT_DELAY, // 17: Normal display on, no args, w/delay
10, // 10 ms delay
ST7735_DISPON , TFT_INIT_DELAY, // 18: Main screen turn on, no args, w/delay
255 }, // 255 = 500 ms delay
Rcmd1[] = { // Init for 7735R, part 1 (red or green tab)
15, // 15 commands in list:
ST7735_SWRESET, TFT_INIT_DELAY, // 1: Software reset, 0 args, w/delay
150, // 150 ms delay
ST7735_SLPOUT , TFT_INIT_DELAY, // 2: Out of sleep mode, 0 args, w/delay
255, // 500 ms delay
ST7735_FRMCTR1, 3 , // 3: Frame rate ctrl - normal mode, 3 args:
0x01, 0x2C, 0x2D, // Rate = fosc/(1x2+40) * (LINE+2C+2D)
ST7735_FRMCTR2, 3 , // 4: Frame rate control - idle mode, 3 args:
0x01, 0x2C, 0x2D, // Rate = fosc/(1x2+40) * (LINE+2C+2D)
ST7735_FRMCTR3, 6 , // 5: Frame rate ctrl - partial mode, 6 args:
0x01, 0x2C, 0x2D, // Dot inversion mode
0x01, 0x2C, 0x2D, // Line inversion mode
ST7735_INVCTR , 1 , // 6: Display inversion ctrl, 1 arg, no delay:
0x07, // No inversion
ST7735_PWCTR1 , 3 , // 7: Power control, 3 args, no delay:
0xA2,
0x02, // -4.6V
0x84, // AUTO mode
ST7735_PWCTR2 , 1 , // 8: Power control, 1 arg, no delay:
0xC5, // VGH25 = 2.4C VGSEL = -10 VGH = 3 * AVDD
ST7735_PWCTR3 , 2 , // 9: Power control, 2 args, no delay:
0x0A, // Opamp current small
0x00, // Boost frequency
ST7735_PWCTR4 , 2 , // 10: Power control, 2 args, no delay:
0x8A, // BCLK/2, Opamp current small & Medium low
0x2A,
ST7735_PWCTR5 , 2 , // 11: Power control, 2 args, no delay:
0x8A, 0xEE,
ST7735_VMCTR1 , 1 , // 12: Power control, 1 arg, no delay:
0x0E,
ST7735_INVOFF , 0 , // 13: Don't invert display, no args, no delay
ST7735_MADCTL , 1 , // 14: Memory access control (directions), 1 arg:
0xC8, // row addr/col addr, bottom to top refresh
ST7735_COLMOD , 1 , // 15: set color mode, 1 arg, no delay:
0x05 }, // 16-bit color
Rcmd2green[] = { // Init for 7735R, part 2 (green tab only)
2, // 2 commands in list:
ST7735_CASET , 4 , // 1: Column addr set, 4 args, no delay:
0x00, 0x02, // XSTART = 0
0x00, 0x7F+0x02, // XEND = 127
ST7735_RASET , 4 , // 2: Row addr set, 4 args, no delay:
0x00, 0x01, // XSTART = 0
0x00, 0x9F+0x01 }, // XEND = 159
Rcmd2red[] = { // Init for 7735R, part 2 (red tab only)
2, // 2 commands in list:
ST7735_CASET , 4 , // 1: Column addr set, 4 args, no delay:
0x00, 0x00, // XSTART = 0
0x00, 0x7F, // XEND = 127
ST7735_RASET , 4 , // 2: Row addr set, 4 args, no delay:
0x00, 0x00, // XSTART = 0
0x00, 0x9F }, // XEND = 159
Rcmd3[] = { // Init for 7735R, part 3 (red or green tab)
4, // 4 commands in list:
ST7735_GMCTRP1, 16 , // 1: 16 args, no delay:
0x02, 0x1c, 0x07, 0x12,
0x37, 0x32, 0x29, 0x2d,
0x29, 0x25, 0x2B, 0x39,
0x00, 0x01, 0x03, 0x10,
ST7735_GMCTRN1, 16 , // 2: 16 args, no delay:
0x03, 0x1d, 0x07, 0x06,
0x2E, 0x2C, 0x29, 0x2D,
0x2E, 0x2E, 0x37, 0x3F,
0x00, 0x00, 0x02, 0x10,
ST7735_NORON , TFT_INIT_DELAY, // 3: Normal display on, no args, w/delay
10, // 10 ms delay
ST7735_DISPON , TFT_INIT_DELAY, // 4: Main screen turn on, no args w/delay
100 }; // 100 ms delay
if (tabcolor == INITB)
{
commandList(Bcmd);
}
else
{
commandList(Rcmd1);
if (tabcolor == INITR_GREENTAB)
{
commandList(Rcmd2green);
colstart = 2;
rowstart = 1;
}
else if (tabcolor == INITR_GREENTAB2)
{
commandList(Rcmd2green);
writecommand(ST7735_MADCTL);
writedata(0xC0);
colstart = 2;
rowstart = 1;
}
else if (tabcolor == INITR_GREENTAB3)
{
commandList(Rcmd2green);
colstart = 2;
rowstart = 3;
}
else if (tabcolor == INITR_GREENTAB128)
{
commandList(Rcmd2green);
colstart = 0;
rowstart = 32;
}
else if (tabcolor == INITR_GREENTAB160x80)
{
commandList(Rcmd2green);
writecommand(TFT_INVON);
colstart = 26;
rowstart = 1;
}
else if (tabcolor == INITR_REDTAB160x80)
{
commandList(Rcmd2green);
colstart = 24;
rowstart = 0;
}
else if (tabcolor == INITR_REDTAB)
{
commandList(Rcmd2red);
}
else if (tabcolor == INITR_BLACKTAB)
{
writecommand(ST7735_MADCTL);
writedata(0xC0);
}
commandList(Rcmd3);
}
}

View file

@ -1,158 +0,0 @@
// This is the command sequence that rotates the ST7735 driver coordinate frame
rotation = m % 4; // Limit the range of values to 0-3
writecommand(TFT_MADCTL);
switch (rotation) {
case 0:
if (tabcolor == INITR_BLACKTAB) {
writedata(TFT_MAD_MX | TFT_MAD_MY | TFT_MAD_RGB);
} else if(tabcolor == INITR_GREENTAB2) {
writedata(TFT_MAD_MX | TFT_MAD_MY | TFT_MAD_RGB);
colstart = 2;
rowstart = 1;
} else if(tabcolor == INITR_GREENTAB3) {
writedata(TFT_MAD_MX | TFT_MAD_MY | TFT_MAD_BGR);
colstart = 2;
rowstart = 3;
} else if(tabcolor == INITR_GREENTAB128) {
writedata(TFT_MAD_MX | TFT_MAD_MY | TFT_MAD_MH | TFT_MAD_BGR);
colstart = 0;
rowstart = 32;
} else if(tabcolor == INITR_GREENTAB160x80) {
writedata(TFT_MAD_MX | TFT_MAD_MY | TFT_MAD_MH | TFT_MAD_BGR);
colstart = 26;
rowstart = 1;
} else if(tabcolor == INITR_REDTAB160x80) {
writedata(TFT_MAD_MX | TFT_MAD_MY | TFT_MAD_MH | TFT_MAD_BGR);
colstart = 24;
rowstart = 0;
} else if(tabcolor == INITB) {
writedata(TFT_MAD_MX | TFT_MAD_RGB);
} else {
writedata(TFT_MAD_MX | TFT_MAD_MY | TFT_MAD_BGR);
}
_width = _init_width;
_height = _init_height;
break;
case 1:
if (tabcolor == INITR_BLACKTAB) {
writedata(TFT_MAD_MY | TFT_MAD_MV | TFT_MAD_RGB);
} else if(tabcolor == INITR_GREENTAB2) {
writedata(TFT_MAD_MY | TFT_MAD_MV | TFT_MAD_RGB);
colstart = 1;
rowstart = 2;
} else if(tabcolor == INITR_GREENTAB3) {
writedata(TFT_MAD_MY | TFT_MAD_MV | TFT_MAD_BGR);
colstart = 3;
rowstart = 2;
} else if(tabcolor == INITR_GREENTAB128) {
writedata(TFT_MAD_MV | TFT_MAD_MY | TFT_MAD_BGR);
colstart = 32;
rowstart = 0;
} else if(tabcolor == INITR_GREENTAB160x80) {
writedata(TFT_MAD_MV | TFT_MAD_MY | TFT_MAD_BGR);
colstart = 1;
rowstart = 26;
} else if(tabcolor == INITR_REDTAB160x80) {
writedata(TFT_MAD_MV | TFT_MAD_MY | TFT_MAD_BGR);
colstart = 0;
rowstart = 24;
} else if(tabcolor == INITB) {
writedata(TFT_MAD_MV | TFT_MAD_MX | TFT_MAD_MY | TFT_MAD_RGB);
} else {
writedata(TFT_MAD_MY | TFT_MAD_MV | TFT_MAD_BGR);
}
_width = _init_height;
_height = _init_width;
break;
case 2:
if (tabcolor == INITR_BLACKTAB) {
writedata(TFT_MAD_RGB);
} else if(tabcolor == INITR_GREENTAB2) {
writedata(TFT_MAD_RGB);
colstart = 2;
rowstart = 1;
} else if(tabcolor == INITR_GREENTAB3) {
writedata(TFT_MAD_BGR);
colstart = 2;
rowstart = 1;
} else if(tabcolor == INITR_GREENTAB128) {
writedata(TFT_MAD_BGR);
colstart = 0;
rowstart = 0;
} else if(tabcolor == INITR_GREENTAB160x80) {
writedata(TFT_MAD_BGR);
colstart = 0;
rowstart = 0;
} else if(tabcolor == INITR_REDTAB160x80) {
writedata(TFT_MAD_BGR);
colstart = 24;
rowstart = 0;
} else if(tabcolor == INITB) {
writedata(TFT_MAD_MY | TFT_MAD_RGB);
} else {
writedata(TFT_MAD_BGR);
}
_width = _init_width;
_height = _init_height;
break;
case 3:
if (tabcolor == INITR_BLACKTAB) {
writedata(TFT_MAD_MX | TFT_MAD_MV | TFT_MAD_RGB);
} else if(tabcolor == INITR_GREENTAB2) {
writedata(TFT_MAD_MX | TFT_MAD_MV | TFT_MAD_RGB);
colstart = 1;
rowstart = 2;
} else if(tabcolor == INITR_GREENTAB3) {
writedata(TFT_MAD_MX | TFT_MAD_MV | TFT_MAD_BGR);
colstart = 1;
rowstart = 2;
} else if(tabcolor == INITR_GREENTAB128) {
writedata(TFT_MAD_MX | TFT_MAD_MV | TFT_MAD_BGR);
colstart = 0;
rowstart = 0;
} else if(tabcolor == INITR_GREENTAB160x80) {
writedata(TFT_MAD_MX | TFT_MAD_MV | TFT_MAD_BGR);
colstart = 1;
rowstart = 26;
} else if(tabcolor == INITR_REDTAB160x80) {
writedata(TFT_MAD_MX | TFT_MAD_MV | TFT_MAD_BGR);
colstart = 0;
rowstart = 24;
} else if(tabcolor == INITB) {
writedata(TFT_MAD_MV | TFT_MAD_RGB);
} else {
writedata(TFT_MAD_MX | TFT_MAD_MV | TFT_MAD_BGR);
}
_width = _init_height;
_height = _init_width;
break;
// These next rotations are for bottum up BMP drawing
/* case 4:
writedata(ST7735_TFT_MAD_MX | ST7735_TFT_MAD_MY | ST7735_TFT_MAD_BGR);
_width = _init_width;
_height = _init_height;
break;
case 5:
writedata(ST7735_TFT_MAD_MV | ST7735_TFT_MAD_MX | ST7735_TFT_MAD_BGR);
_width = _init_height;
_height = _init_width;
break;
case 6:
writedata(ST7735_TFT_MAD_BGR);
_width = _init_width;
_height = _init_height;
break;
case 7:
writedata(ST7735_TFT_MAD_MY | ST7735_TFT_MAD_MV | ST7735_TFT_MAD_BGR);
_width = _init_height;
_height = _init_width;
break;
*/
}
log_w("Rotated ST7735 #%d/#%d to %d, offset [%d, %d]\n", tabcolor, TAB_COLOUR, rotation, colstart, rowstart);

View file

@ -1,193 +0,0 @@
// Change the width and height if required (defined in portrait mode)
// or use the constructor to over-ride defaults
#ifndef TFT_WIDTH
#define TFT_WIDTH 240
#endif
#ifndef TFT_HEIGHT
#define TFT_HEIGHT 240
#endif
#if (TFT_HEIGHT == 240) && (TFT_WIDTH == 240)
//#define CGRAM_OFFSET
#endif
// Delay between some initialisation commands
#define TFT_INIT_DELAY 0x80 // Not used unless commandlist invoked
// Generic commands used by TFT_eSPI.cpp
#define TFT_NOP 0x00
#define TFT_SWRST 0x01
#define TFT_SLPIN 0x10
#define TFT_SLPOUT 0x11
#define TFT_NORON 0x13
#define TFT_INVOFF 0x20
#define TFT_INVON 0x21
#define TFT_DISPOFF 0x28
#define TFT_DISPON 0x29
#define TFT_CASET 0x2A
#define TFT_PASET 0x2B
#define TFT_RAMWR 0x2C
#define TFT_RAMRD 0x2E
#define TFT_MADCTL 0x36
#define TFT_COLMOD 0x3A
// Flags for TFT_MADCTL
#define TFT_MAD_MY 0x80
#define TFT_MAD_MX 0x40
#define TFT_MAD_MV 0x20
#define TFT_MAD_ML 0x10
#define TFT_MAD_RGB 0x00
#define TFT_MAD_BGR 0x08
#define TFT_MAD_MH 0x04
#define TFT_MAD_SS 0x02
#define TFT_MAD_GS 0x01
#ifdef TFT_RGB_ORDER
#if (TFT_RGB_ORDER == 1)
#define TFT_MAD_COLOR_ORDER TFT_MAD_RGB
#else
#define TFT_MAD_COLOR_ORDER TFT_MAD_BGR
#endif
#else
#ifdef CGRAM_OFFSET
#define TFT_MAD_COLOR_ORDER TFT_MAD_BGR
#else
#define TFT_MAD_COLOR_ORDER TFT_MAD_RGB
#endif
#endif
#define TFT_IDXRD 0x00 // ILI9341 only, indexed control register read
#define ST_CMD_DELAY 0x80 // special signifier for command lists
#define ST7789_240x240_XSTART 0
#define ST7789_240x240_YSTART 0
// ST7789 specific commands used in init
#define ST7789_NOP 0x00
#define ST7789_SWRESET 0x01
#define ST7789_RDDID 0x04
#define ST7789_RDDST 0x09
#define ST7789_RDDPM 0x0A // Read display power mode
#define ST7789_RDD_MADCTL 0x0B // Read display MADCTL
#define ST7789_RDD_COLMOD 0x0C // Read display pixel format
#define ST7789_RDDIM 0x0D // Read display image mode
#define ST7789_RDDSM 0x0E // Read display signal mode
#define ST7789_RDDSR 0x0F // Read display self-diagnostic result (ST7789V)
#define ST7789_SLPIN 0x10
#define ST7789_SLPOUT 0x11
#define ST7789_PTLON 0x12
#define ST7789_NORON 0x13
#define ST7789_INVOFF 0x20
#define ST7789_INVON 0x21
#define ST7789_GAMSET 0x26 // Gamma set
#define ST7789_DISPOFF 0x28
#define ST7789_DISPON 0x29
#define ST7789_CASET 0x2A
#define ST7789_RASET 0x2B
#define ST7789_RAMWR 0x2C
#define ST7789_RGBSET 0x2D // Color setting for 4096, 64K and 262K colors
#define ST7789_RAMRD 0x2E
#define ST7789_PTLAR 0x30
#define ST7789_VSCRDEF 0x33 // Vertical scrolling definition (ST7789V)
#define ST7789_TEOFF 0x34 // Tearing effect line off
#define ST7789_TEON 0x35 // Tearing effect line on
#define ST7789_MADCTL 0x36 // Memory data access control
#define ST7789_VSCRSADD 0x37 // Vertical Scrolling Start Address (was disabled)
#define ST7789_IDMOFF 0x38 // Idle mode off
#define ST7789_IDMON 0x39 // Idle mode on
#define ST7789_RAMWRC 0x3C // Memory write continue (ST7789V)
#define ST7789_RAMRDC 0x3E // Memory read continue (ST7789V)
#define ST7789_COLMOD 0x3A
#define ST7789_RAMCTRL 0xB0 // RAM control
#define ST7789_RGBCTRL 0xB1 // RGB control
#define ST7789_PORCTRL 0xB2 // Porch control
#define ST7789_FRCTRL1 0xB3 // Frame rate control
#define ST7789_PARCTRL 0xB5 // Partial mode control
#define ST7789_GCTRL 0xB7 // Gate control
#define ST7789_GTADJ 0xB8 // Gate on timing adjustment
#define ST7789_DGMEN 0xBA // Digital gamma enable
#define ST7789_VCOMS 0xBB // VCOMS setting
#define ST7789_LCMCTRL 0xC0 // LCM control
#define ST7789_IDSET 0xC1 // ID setting
#define ST7789_VDVVRHEN 0xC2 // VDV and VRH command enable
#define ST7789_VRHS 0xC3 // VRH set
#define ST7789_VDVSET 0xC4 // VDV setting
#define ST7789_VCMOFSET 0xC5 // VCOMS offset set
#define ST7789_FRCTR2 0xC6 // FR Control 2
#define ST7789_CABCCTRL 0xC7 // CABC control
#define ST7789_REGSEL1 0xC8 // Register value section 1
#define ST7789_REGSEL2 0xCA // Register value section 2
#define ST7789_PWMFRSEL 0xCC // PWM frequency selection
#define ST7789_PWCTRL1 0xD0 // Power control 1
#define ST7789_VAPVANEN 0xD2 // Enable VAP/VAN signal output
#define ST7789_CMD2EN 0xDF // Command 2 enable
#define ST7789_PVGAMCTRL 0xE0 // Positive voltage gamma control
#define ST7789_NVGAMCTRL 0xE1 // Negative voltage gamma control
#define ST7789_DGMLUTR 0xE2 // Digital gamma look-up table for red
#define ST7789_DGMLUTB 0xE3 // Digital gamma look-up table for blue
#define ST7789_GATECTRL 0xE4 // Gate control
#define ST7789_SPI2EN 0xE7 // SPI2 enable
#define ST7789_PWCTRL2 0xE8 // Power control 2
#define ST7789_EQCTRL 0xE9 // Equalize time control
#define ST7789_PROMCTRL 0xEC // Program control
#define ST7789_PROMEN 0xFA // Program mode enable
#define ST7789_NVMSET 0xFC // NVM setting
#define ST7789_PROMACT 0xFE // Program action
// Color definitions for backwards compatibility with old sketches
// use colour definitions like TFT_BLACK to make sketches more portable
// M5Core and its applications expect ILI9341 values, so backwards compat rules
#define ILI9341_BLACK TFT_BLACK //0x0000 /* 0, 0, 0 */
#define ILI9341_NAVY TFT_NAVY //0x000F /* 0, 0, 128 */
#define ILI9341_DARKGREEN TFT_DARKGREEN //0x03E0 /* 0, 128, 0 */
#define ILI9341_DARKCYAN TFT__DARKCYAN //0x03EF /* 0, 128, 128 */
#define ILI9341_MAROON TFT_MAROON //0x7800 /* 128, 0, 0 */
#define ILI9341_PURPLE TFT_PURPLE //0x780F /* 128, 0, 128 */
#define ILI9341_OLIVE TFT_OLIVE //0x7BE0 /* 128, 128, 0 */
#define ILI9341_LIGHTGREY TFT_LIGHTGREY //0xC618 /* 192, 192, 192 */
#define ILI9341_DARKGREY TFT_DARKGREY //0x7BEF /* 128, 128, 128 */
#define ILI9341_BLUE TFT_BLUE //0x001F /* 0, 0, 255 */
#define ILI9341_GREEN TFT_GREEN //0x07E0 /* 0, 255, 0 */
#define ILI9341_CYAN TFT_CYAN //0x07FF /* 0, 255, 255 */
#define ILI9341_RED TFT_RED //0xF800 /* 255, 0, 0 */
#define ILI9341_MAGENTA TFT_MAGENTA //0xF81F /* 255, 0, 255 */
#define ILI9341_YELLOW TFT_YELLOW //0xFFE0 /* 255, 255, 0 */
#define ILI9341_WHITE TFT_WHITE //0xFFFF /* 255, 255, 255 */
#define ILI9341_ORANGE TFT_ORANGE //0xFD20 /* 255, 165, 0 */
#define ILI9341_GREENYELLOW TFT_GREENYELLOW //0xAFE5 /* 173, 255, 47 */
#define ILI9341_PINK TFT_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
#define ILI9341_SLPIN TFT_SLPIN
#define ILI9341_SLPOUT TFT_SLPOUT
#define ILI9341_VSCRDEF ST7789_VSCRDEF // Vertical Scrolling Definition
#define ILI9341_VSCRSADD ST7789_VSCRSADD // Vertical Scrolling Start Address

View file

@ -1,34 +0,0 @@
log_d("D-Duino32-XS driver init");
static uint8_t PROGMEM
cmd_240x240[] = { // Initialization commands for 7789 screens
12, // 9 commands in list:
ST7789_SWRESET, 1, // 1: Software reset, no args
150, // 150 ms delay
ST7789_SLPOUT, 1, // 2: Out of sleep mode, no args
255, // 255 = 500 ms delay
ST7789_COLMOD, 2, // 3: Set color mode, 1 arg:
0x55, // 16-bit color
10, // 10 ms delay
ST7789_MADCTL, 1, // 4: Memory access ctrl (directions), 1 arg:
0x00, // Row addr/col addr, bottom to top refresh
ST7789_CASET, 4, // 5: Column addr set, 4 args
0x00, ST7789_240x240_XSTART, // XSTART = 0
(240+ST7789_240x240_XSTART) >> 8,
(240+ST7789_240x240_XSTART) & 0xFF, // XEND = 240
ST7789_RASET, 4, // 6: Row addr set, 4 args
0x00, ST7789_240x240_YSTART, // YSTART = 0
(240+ST7789_240x240_YSTART) >> 8,
(240+ST7789_240x240_YSTART) & 0xFF, // YEND = 240
ST7789_INVON, 1, // 7: Inversion ON
10,
ST7789_NORON, 1, // 8: Normal display on, no args
10, // 10 ms delay
ST7789_PVGAMCTRL, 14, // Positive voltage gamma control, 14 args
0xd0,0x00,0x05,0x0e,0x15,0x0d,0x37,0x43,0x47,0x09,0x15,0x12,0x16,0x19,
ST7789_NVGAMCTRL, 14, // Negative voltage gamma control, 14 args
0xd0,0x00,0x05,0x0d,0x0c,0x06,0x2d,0x44,0x40,0x0e,0x1c,0x18,0x16,0x19,
ST7789_DISPON, 1, // 9: Main screen turn on, no args
255 }; // 255 = 500 ms delay
commandList( cmd_240x240 );

View file

@ -1,48 +0,0 @@
// This is the command sequence that rotates the ST7789 driver coordinate frame
writecommand(TFT_MADCTL);
rotation = m % 4;
switch (rotation) {
case 0: // Portrait
#ifdef CGRAM_OFFSET
colstart = 0;
rowstart = 0;
#endif
writedata(TFT_MAD_COLOR_ORDER);
_width = _init_width;
_height = _init_height;
break;
case 1: // Landscape (Portrait + 90)
#ifdef CGRAM_OFFSET
colstart = 0;
rowstart = 0;
#endif
writedata(TFT_MAD_MX | TFT_MAD_MV | TFT_MAD_COLOR_ORDER);
_width = _init_height;
_height = _init_width;
break;
case 2: // Inverter portrait
#ifdef CGRAM_OFFSET
colstart = 0;
rowstart = 80;
#endif
writedata(TFT_MAD_MX | TFT_MAD_MY | TFT_MAD_COLOR_ORDER);
_width = _init_width;
_height = _init_height;
break;
case 3: // Inverted landscape
#ifdef CGRAM_OFFSET
colstart = 80;
rowstart = 0;
#endif
writedata(TFT_MAD_MV | TFT_MAD_MY | TFT_MAD_COLOR_ORDER);
_width = _init_height;
_height = _init_width;
break;
}

View file

@ -1,190 +0,0 @@
// Change the width and height if required (defined in portrait mode)
// or use the constructor to over-ride defaults
#ifndef TFT_WIDTH
#define TFT_WIDTH 240
#endif
#ifndef TFT_HEIGHT
#define TFT_HEIGHT 320
#endif
#if (TFT_HEIGHT == 240) && (TFT_WIDTH == 240)
#define CGRAM_OFFSET
#endif
// Delay between some initialisation commands
#define TFT_INIT_DELAY 0x80 // Not used unless commandlist invoked
// Generic commands used by TFT_eSPI.cpp
#define TFT_NOP 0x00
#define TFT_SWRST 0x01
#define TFT_SLPIN 0x10
#define TFT_SLPOUT 0x11
#define TFT_NORON 0x13
#define TFT_INVOFF 0x20
#define TFT_INVON 0x21
#define TFT_DISPOFF 0x28
#define TFT_DISPON 0x29
#define TFT_CASET 0x2A
#define TFT_PASET 0x2B
#define TFT_RAMWR 0x2C
#define TFT_RAMRD 0x2E
#define TFT_MADCTL 0x36
#define TFT_COLMOD 0x3A
// Flags for TFT_MADCTL
#define TFT_MAD_MY 0x80
#define TFT_MAD_MX 0x40
#define TFT_MAD_MV 0x20
#define TFT_MAD_ML 0x10
#define TFT_MAD_RGB 0x00
#define TFT_MAD_BGR 0x08
#define TFT_MAD_MH 0x04
#define TFT_MAD_SS 0x02
#define TFT_MAD_GS 0x01
#ifdef TFT_RGB_ORDER
#if (TFT_RGB_ORDER == 1)
#define TFT_MAD_COLOR_ORDER TFT_MAD_RGB
#else
#define TFT_MAD_COLOR_ORDER TFT_MAD_BGR
#endif
#else
#ifdef CGRAM_OFFSET
#define TFT_MAD_COLOR_ORDER TFT_MAD_BGR
#else
#define TFT_MAD_COLOR_ORDER TFT_MAD_RGB
#endif
#endif
#define TFT_IDXRD 0x00 // ILI9341 only, indexed control register read
#define ST_CMD_DELAY 0x80 // special signifier for command lists
#define ST7789_240x240_XSTART 0
#define ST7789_240x240_YSTART 0
// ST7789 specific commands used in init
#define ST7789_NOP 0x00
#define ST7789_SWRESET 0x01
#define ST7789_RDDID 0x04
#define ST7789_RDDST 0x09
#define ST7789_RDDPM 0x0A // Read display power mode
#define ST7789_RDD_MADCTL 0x0B // Read display MADCTL
#define ST7789_RDD_COLMOD 0x0C // Read display pixel format
#define ST7789_RDDIM 0x0D // Read display image mode
#define ST7789_RDDSM 0x0E // Read display signal mode
#define ST7789_RDDSR 0x0F // Read display self-diagnostic result (ST7789V)
#define ST7789_SLPIN 0x10
#define ST7789_SLPOUT 0x11
#define ST7789_PTLON 0x12
#define ST7789_NORON 0x13
#define ST7789_INVOFF 0x20
#define ST7789_INVON 0x21
#define ST7789_GAMSET 0x26 // Gamma set
#define ST7789_DISPOFF 0x28
#define ST7789_DISPON 0x29
#define ST7789_CASET 0x2A
#define ST7789_RASET 0x2B
#define ST7789_RAMWR 0x2C
#define ST7789_RGBSET 0x2D // Color setting for 4096, 64K and 262K colors
#define ST7789_RAMRD 0x2E
#define ST7789_PTLAR 0x30
#define ST7789_VSCRDEF 0x33 // Vertical scrolling definition (ST7789V)
#define ST7789_TEOFF 0x34 // Tearing effect line off
#define ST7789_TEON 0x35 // Tearing effect line on
#define ST7789_MADCTL 0x36 // Memory data access control
#define ST7789_IDMOFF 0x38 // Idle mode off
#define ST7789_IDMON 0x39 // Idle mode on
#define ST7789_RAMWRC 0x3C // Memory write continue (ST7789V)
#define ST7789_RAMRDC 0x3E // Memory read continue (ST7789V)
#define ST7789_COLMOD 0x3A
#define ST7789_RAMCTRL 0xB0 // RAM control
#define ST7789_RGBCTRL 0xB1 // RGB control
#define ST7789_PORCTRL 0xB2 // Porch control
#define ST7789_FRCTRL1 0xB3 // Frame rate control
#define ST7789_PARCTRL 0xB5 // Partial mode control
#define ST7789_GCTRL 0xB7 // Gate control
#define ST7789_GTADJ 0xB8 // Gate on timing adjustment
#define ST7789_DGMEN 0xBA // Digital gamma enable
#define ST7789_VCOMS 0xBB // VCOMS setting
#define ST7789_LCMCTRL 0xC0 // LCM control
#define ST7789_IDSET 0xC1 // ID setting
#define ST7789_VDVVRHEN 0xC2 // VDV and VRH command enable
#define ST7789_VRHS 0xC3 // VRH set
#define ST7789_VDVSET 0xC4 // VDV setting
#define ST7789_VCMOFSET 0xC5 // VCOMS offset set
#define ST7789_FRCTR2 0xC6 // FR Control 2
#define ST7789_CABCCTRL 0xC7 // CABC control
#define ST7789_REGSEL1 0xC8 // Register value section 1
#define ST7789_REGSEL2 0xCA // Register value section 2
#define ST7789_PWMFRSEL 0xCC // PWM frequency selection
#define ST7789_PWCTRL1 0xD0 // Power control 1
#define ST7789_VAPVANEN 0xD2 // Enable VAP/VAN signal output
#define ST7789_CMD2EN 0xDF // Command 2 enable
#define ST7789_PVGAMCTRL 0xE0 // Positive voltage gamma control
#define ST7789_NVGAMCTRL 0xE1 // Negative voltage gamma control
#define ST7789_DGMLUTR 0xE2 // Digital gamma look-up table for red
#define ST7789_DGMLUTB 0xE3 // Digital gamma look-up table for blue
#define ST7789_GATECTRL 0xE4 // Gate control
#define ST7789_SPI2EN 0xE7 // SPI2 enable
#define ST7789_PWCTRL2 0xE8 // Power control 2
#define ST7789_EQCTRL 0xE9 // Equalize time control
#define ST7789_PROMCTRL 0xEC // Program control
#define ST7789_PROMEN 0xFA // Program mode enable
#define ST7789_NVMSET 0xFC // NVM setting
#define ST7789_PROMACT 0xFE // Program action
// Color definitions for backwards compatibility with old sketches
// use colour definitions like TFT_BLACK to make sketches more portable
// M5Core and its applications expect ILI9341 values, so backwards compat rules
#define ILI9341_BLACK TFT_BLACK //0x0000 /* 0, 0, 0 */
#define ILI9341_NAVY TFT_NAVY //0x000F /* 0, 0, 128 */
#define ILI9341_DARKGREEN TFT_DARKGREEN //0x03E0 /* 0, 128, 0 */
#define ILI9341_DARKCYAN TFT__DARKCYAN //0x03EF /* 0, 128, 128 */
#define ILI9341_MAROON TFT_MAROON //0x7800 /* 128, 0, 0 */
#define ILI9341_PURPLE TFT_PURPLE //0x780F /* 128, 0, 128 */
#define ILI9341_OLIVE TFT_OLIVE //0x7BE0 /* 128, 128, 0 */
#define ILI9341_LIGHTGREY TFT_LIGHTGREY //0xC618 /* 192, 192, 192 */
#define ILI9341_DARKGREY TFT_DARKGREY //0x7BEF /* 128, 128, 128 */
#define ILI9341_BLUE TFT_BLUE //0x001F /* 0, 0, 255 */
#define ILI9341_GREEN TFT_GREEN //0x07E0 /* 0, 255, 0 */
#define ILI9341_CYAN TFT_CYAN //0x07FF /* 0, 255, 255 */
#define ILI9341_RED TFT_RED //0xF800 /* 255, 0, 0 */
#define ILI9341_MAGENTA TFT_MAGENTA //0xF81F /* 255, 0, 255 */
#define ILI9341_YELLOW TFT_YELLOW //0xFFE0 /* 255, 255, 0 */
#define ILI9341_WHITE TFT_WHITE //0xFFFF /* 255, 255, 255 */
#define ILI9341_ORANGE TFT_ORANGE //0xFD20 /* 255, 165, 0 */
#define ILI9341_GREENYELLOW TFT_GREENYELLOW //0xAFE5 /* 173, 255, 47 */
#define ILI9341_PINK TFT_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
#define ILI9341_SLPIN TFT_SLPIN
#define ILI9341_SLPOUT TFT_SLPOUT
#define ILI9341_VSCRDEF 0x33 // Vertical Scrolling Definition
#define ILI9341_VSCRSADD 0x37 // Vertical Scrolling Start Address

View file

@ -1,94 +0,0 @@
// This is the command sequence that initialises the WROVER_KIT_LCD driver
// Configure WROVER_KIT_LCD display
{
/**********************************/
spi_end();
spi_begin_read();
DC_C;
tft_Write_8(0xD9);
DC_D;
spi.write(0x10);
DC_C;
tft_Write_8( ST7789_RDDID );
DC_D;
_id = tft_Read_8() << 16;
_id |= tft_Read_8() << 8;
_id |= tft_Read_8();
CS_H;
spi_end_read();
spi_end();
delay(120);
log_w("Display ID: 0x%06X", _id);
if( _id == 0 ) {
// Software reset, needed by ILI9341 after the previous query
spi_begin();
writecommand(TFT_SWRST);
spi_end();
delay(150); // Wait for reset to complete
}
// resume init
spi_begin();
/**********************************/
if( _id > 0 ) {
log_w("ST7789 Init");
static const uint8_t PROGMEM st7789[] = {
16,
TFT_SLPOUT, 1, 255,
TFT_COLMOD, 2, 0x55, 10,
TFT_MADCTL, 1, 0x00,
0x3a, 1, 0x55,
0xb2, 5, 0x0c,0x0c,0x00,0x33,0x33,
0xb7, 1, 0x35,
0xbb, 1, 0x2b,
0xc0, 1, 0x2c,
0xc2, 2, 0x01,0xff,
0xc3, 1, 0x11,
0xc4, 1, 0x20,
0xc6, 1, 0x0f,
0xd0, 2, 0xa4,0xa1,
0xe0, 14, 0xd0,0x00,0x05,0x0e,0x15,0x0d,0x37,0x43,0x47,0x09,0x15,0x12,0x16,0x19,
0xe1, 14, 0xd0,0x00,0x05,0x0d,0x0c,0x06,0x2d,0x44,0x40,0x0e,0x1c,0x18,0x16,0x19,
TFT_DISPON, 1, 255,
};
commandList(st7789);
} else {
log_w("ILI9341 Init");
static const uint8_t PROGMEM ili9341[] = {
21,
0xef, 3, 0x03,0x80,0x02,
0xcf, 3, 0x00,0xc1,0x30,
0xed, 4, 0x64,0x03,0x12,0x81,
0xe8, 3, 0x85,0x00,0x78,
0xcb, 5, 0x39,0x2c,0x00,0x34,0x02,
0xf7, 1, 0x20,
0xea, 2, 0x00,0x00,
0xc0, 1, 0x23,
0xc1, 1, 0x10,
0xc5, 2, 0x3e,0x28,
0xc7, 1, 0x86,
0x36, 1, 0xa8, // TFT_MADCTL
0x3a, 1, 0x55,
0xb1, 2, 0x00,0x18,
0xb6, 3, 0x08,0x82,0x27,
0xf2, 1, 0x00,
0x26, 1, 0x01,
0xe0, 15, 0x0f,0x31,0x2b,0x0c,0x0e,0x08,0x4e,0xf1,0x37,0x07,0x10,0x03,0x0e,0x09,0x00,
0xe1, 15, 0x00,0x0e,0x14,0x03,0x11,0x07,0x31,0xc1,0x48,0x08,0x0f,0x0c,0x31,0x36,0x0f,
TFT_SLPOUT, 1, 255,
TFT_DISPON, 1, 255,
};
commandList(ili9341);
}
}
// End of WROVER_KIT_LCD display configuration

View file

@ -1,73 +0,0 @@
if( _id > 0 ){
log_d("ST7789 rotate : %d", m);
writecommand(TFT_MADCTL);
rotation = m % 4;
switch (rotation) {
case 0: // Portrait
#ifdef CGRAM_OFFSET
colstart = 0;
rowstart = 0;
#endif
writedata(TFT_MAD_COLOR_ORDER);
_width = _init_width;
_height = _init_height;
break;
case 1: // Landscape (Portrait + 90)
#ifdef CGRAM_OFFSET
colstart = 0;
rowstart = 0;
#endif
writedata(TFT_MAD_MX | TFT_MAD_MV | TFT_MAD_COLOR_ORDER);
_width = _init_height;
_height = _init_width;
break;
case 2: // Inverter portrait
#ifdef CGRAM_OFFSET
colstart = 0;
rowstart = 80;
#endif
writedata(TFT_MAD_MX | TFT_MAD_MY | TFT_MAD_COLOR_ORDER);
_width = _init_width;
_height = _init_height;
break;
case 3: // Inverted landscape
#ifdef CGRAM_OFFSET
colstart = 80;
rowstart = 0;
#endif
writedata(TFT_MAD_MV | TFT_MAD_MY | TFT_MAD_COLOR_ORDER);
_width = _init_height;
_height = _init_width;
break;
}
} else {
log_d("ILI9341 rotate : %d", m);
// ILI9341 rotations
typedef struct {
uint8_t madctl;
uint8_t bmpctl;
uint16_t width;
uint16_t height;
} rotation_data_t;
const rotation_data_t ili9341_rotations[4] = {
{(TFT_MAD_MX|TFT_MAD_BGR),(TFT_MAD_MX|TFT_MAD_MY|TFT_MAD_BGR),TFT_WIDTH,TFT_HEIGHT},
{(TFT_MAD_MV|TFT_MAD_BGR),(TFT_MAD_MV|TFT_MAD_MX|TFT_MAD_BGR),TFT_HEIGHT,TFT_WIDTH},
{(TFT_MAD_MY|TFT_MAD_BGR),(TFT_MAD_BGR),TFT_WIDTH,TFT_HEIGHT},
{(TFT_MAD_MX|TFT_MAD_MY|TFT_MAD_MV|TFT_MAD_BGR),(TFT_MAD_MY|TFT_MAD_MV|TFT_MAD_BGR),TFT_HEIGHT,TFT_WIDTH}
};
rotation = m % 4; // can't be higher than 3
m = ili9341_rotations[rotation].madctl;
_width = ili9341_rotations[rotation].width;
_height = ili9341_rotations[rotation].height;
writecommand(TFT_MADCTL);
writedata(m);
}