Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Basic Example hangs on ESP8266 #35

Open
RanTalbott opened this issue Oct 14, 2018 · 8 comments
Open

Basic Example hangs on ESP8266 #35

RanTalbott opened this issue Oct 14, 2018 · 8 comments

Comments

@RanTalbott
Copy link

Testing on a Wemos D1 Mini, with the Opensmart 2.0" 176x220 LCD.

Arduino version 1.8.4, ESP8266 board support V2.3.0, TFT library v1.3.8

The hardware works fine with the example from https://github.com/jorgegarciadev/TFT_22_ILI9225 but that library is older, and missing some features (most notably bitmap display), so I'd like to get it working with this one.

The example code starts up okay, but hangs and gets killed by the watchdog timer in the first execution of tft.clear().

I'm guessing that there's some obscure bug/incompatibility with the 2.3.0 ESP8266 support. But that's just a guess. What version(s) has this library been tested with? Are there any that are required/should be avoided?

Thanks,

Ran

@Bolukan
Copy link

Bolukan commented Oct 31, 2018

You mean it crashes here after showing "hello!" on the screen?

I tried once with the ESP32, but find some time to connect a D1mini.

@RanTalbott
Copy link
Author

No, I was mistaken: I thought the blank white screen was a result of the call to clear(), but it wasn't.

I had put a Serial.println("loop()") at the top of loop(), which executed okay. That was followed on the serial monitor by the "Soft WDT reset" message.

I sprinkled a bunch more println() calls through the code, and discovered that all the code in loop() is executing: it's the "while(true)" (which I hadn't noticed before) at the end that's causing the WDT reset. That's a "no-no" on ESP8266: if you don't do a delay() or similar call that yields to the WiFi stack once in a while, the watchdog will bite.

I think the key clue is that the screen is coming up white, instead of black the way the other library does: that suggests to me that begin() isn't initializing the ILI9225 properly. That might be a bug in the ESP library. What version did you use when you did your experimenting?

@Bolukan
Copy link

Bolukan commented Nov 4, 2018

I used the most recent version (30 sep 2018) of this library with an ESP32 and ILI9225, but without use of WiFi.
It's on my list to test it with the ESP8266, of course I will report any remarks here.

See below for the relevant parts of code for the ESP32. I connected the blacklight to 5V: To use variable blacklight I guess I'll need some PWM code on the IO pin. I did not check whether the library supports it.

// ILI9225 (new variant) -> ESP32
// 3V3 -> 3V3
// 5V -> not attached to ESP32
// GND -> GND
// SCK -> IO 14 = HSPI-SCK
// SDO -> IO 12 = HSPI-MISO
// SDI -> IO 13 = HSPI-MOSI
// SS  -> IO 15 = HSPI-SS0
// RS -> IO 25
// RST -> IO 26
// BL -> 5V
SPIClass hspi(HSPI);
#define TFT_RST 26
#define TFT_RS  25
#define TFT_CS  15  // SS
#define TFT_LED 0   // 0 if wired to +5V directly
// Use hardware SPI
TFT_22_ILI9225 tft(TFT_RST, TFT_RS, TFT_CS, TFT_LED);
void setup() {
  hspi.begin();
  tft.begin(hspi);
}

void loop() {
  tft.setDisplay(true);

@Bolukan
Copy link

Bolukan commented Nov 4, 2018

I did some additional testing. This PWM code works fine with the ESP32. The screen looks perfect with 3.3V/PWM from pin 16. I don't have the right equipment to test how much current the screen takes.
@Nkawu, are you ok to implement this in the library and do you have any suggestions?

const int freq = 5000;
const int ledChannel = 0;
const int resolution = 8;

// Setup
void setup() {
  ledcSetup(ledChannel, freq, resolution);
  ledcAttachPin(16, ledChannel); // LED -> 16, 5V -> 5V
  ledcWrite(ledChannel, 255); // max
void loop() {
// CODE TO DRAW SOMETHING
  for (int dutyCycle = 255; dutyCycle >= 0; dutyCycle--) {
    ledcWrite(ledChannel, dutyCycle);
    delay(7);
  }
  for (int dutyCycle = 0; dutyCycle <= 255; dutyCycle++) {
    ledcWrite(ledChannel, dutyCycle);
    delay(7);
  }

@Bolukan
Copy link

Bolukan commented Nov 4, 2018

I tested the Basic Demo with a D1 mini, Arduino 1.8.6 and TFT_22_ILI9225 1.3.8. Results ok.
Wires attached like see below and changed some code for the correct pin numbers (second block).

// ILI9225 (new variant) -> ESP8266 D1 MINI
// 3V3 -> 3V3
// 5V  -> not attached to ESP8266
// GND -> GND
// SCK -> D5/IO 14 = SPI-SCK
// SDO -> D6/IO 12 = SPI-MISO
// SDI -> D7/IO 13 = SPI-MOSI
// SS  -> D8/IO 15 = SPI-SS0
// RS  -> D1/IO 5
// RST -> D2/IO 4
// BL  -> D4/IO 2 but 5V works also
#define TFT_RST 4
#define TFT_RS  5
#define TFT_CS  15  // SS
#define TFT_SDI 13  // MOSI
#define TFT_CLK 14  // SCK
#define TFT_LED 2   // 0 if wired to +5V directly

@RanTalbott
Copy link
Author

Hmmm, I'm using D0 instead of D8 for TFT_CS. Maybe this library isn't overriding the default properly, but the other one is???

I'll try switching that (a bit of a hassle: I used a prototype shield to solder up a nice little pinout adapter so I could use a 1-to1 cable to connect to the display), and try updating the IDE software to see whether there's a bug there. Won't be for at least a few days, though: I have a new project starting up at work that will keep me busier than usual.

Thanks for the help.

@Nkawu
Copy link
Owner

Nkawu commented Nov 5, 2018

Sorry, I have also been very busy at work, will try to get caught up with this issue soon.

@Bolukan
Copy link

Bolukan commented Feb 18, 2019

Please comment whether the bug still exist with the latest code. If not (which I guess) this issue could be closed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants