Example sketches for the new Arduino IDE for ESP8266

Moderator: igrr

User avatar
By jra
#40954 Made some progress and got this display working on both ESP8266 (NodeMCU v2) and Arduino (ProMini 8MHz 3v3) using the spapadim port https://github.com/spapadim/ucglib, tested with the following sketch:

Code: Select all/*
 * Ucglib_HelloWorld_8x13_Rainbow_Colors
 *
 * Tested on NodeMCU v2 and Arduino ProMini using
 * https://github.com/spapadim/ucglib as of
 * commit 032641d12d17283523767a7e8bacc105e474435e
*/

#include <SPI.h>
#include "Ucglib.h"

#if defined(ESP8266)
#define CS 15
#define DC 5
#define RST 16
#elif defined(__AVR__)
#define CS 10
#define DC 9
#define RST 8
#else
#error Tested architectures are ESP8266 and AVR
#endif

/*
 * The following works with http://www.banggood.com/1_8-Inch-Serial-SPI-TFT-LCD-Display-Module-With-Power-IC-SD-Socket-p-909802.html
* in which "Normally, the chip is Samsung ST7735."
 */

Ucglib_ST7735_18x128x160_HWSPI ucg(/*cd=*/ DC , /*cs=*/ CS, /*reset=*/ RST);

// http://colrd.com/palette/23813/?download=css

struct color {
  uint8_t red;
  uint8_t green;
  uint8_t blue;
};

struct color rainbow[] = {
  {209, 0, 0},
  {255, 102, 34},
  {255, 218, 33},
  {51, 221, 0},
  {17, 51, 204},
  {34, 0, 102},
  {51, 0, 68}
};

void setup(void)
{
  Serial.begin(115200);
  Serial.print("Sizeof color: ");
  Serial.println(sizeof (color));
  Serial.print("Sizeof rainbow: ");
  Serial.println(sizeof (rainbow));
  Serial.println("Initializing display");
  ucg.begin(UCG_FONT_MODE_SOLID);
  ucg.clearScreen();
}

void loop(void)
{
  int row, col;
  int height = 13;
  char *digits = "01234567890123456789";
  ucg.setFontPosTop();
  ucg.setRotate270();
  ucg.setFont(ucg_font_8x13_mf);
  Serial.println("Starting to paint screen");
  col = 0;
  ucg.setColor(1, 0, 0, 0); // Black background
  for (row = 0; row < sizeof(rainbow) / sizeof(color); row++) {
    ucg.setPrintPos(col, height * row);
    ucg.setColor(0, rainbow[row].red, rainbow[row].green, rainbow[row].blue);
    ucg.print(digits);
  }
  ucg.setPrintPos(col, height * row++);
  ucg.setColor(0, 255, 255, 255);
  ucg.print(digits);
  ucg.setPrintPos(col, height * row);
  ucg.setColor(0, 0, 0, 0); // White background
  ucg.setColor(1, 255, 255, 255);
  ucg.print(digits);
  delay(1000);
  Serial.println("Clearing screen");
  ucg.clearScreen();
}


A generic 240x320 ILI9341/XPT2046 is supposed to show up any day now, will see what luck I have with that and the Adafruit_GFX port.
User avatar
By picstart
#40972 The specific here is the label QDTech they are either duds or use an obscured controller or several different controllers and the same QDTech label so that controller identification is unknown. Yes I know you can send a supposedly universal command to get a controller id but it returns garbage for the QDTech so they are not identifiable,
The init sequence is often so critical that any small variation and the controller doesn't init. Given this single point of failure possibility in the init sequence we are lucky controller manufacturers provide this init code and that LCD sellers disclose the controller they use otherwise LCD could not be used by hobbists.
User avatar
By norm8332
#43656 This library is for the Samsung S6D02A1 chip not the ST7735 that could also be installed on your identical looking board..You want to use the ST7735 library if this one doesn't work or vice versa.