G6EJD / ESP32-Connect-and-Use-SSD1331-Colour-OLED-

Other
13 stars 0 forks source link

How to control six pins #1

Closed LilyGO closed 6 years ago

LilyGO commented 6 years ago

pin:CS DC RST MISO MOSI SCLK

G6EJD commented 6 years ago

It depends on the ESP32 board that is being used, you can find the io pins from the compiler definition file or serial.println(MISO) etc to give the PIN number. Only miso, mosi and sck will be defined though.

LilyGO commented 6 years ago

Hi, G6EJD.Thanks for your reply. Because my ESP32 development board is not pin 23, pin 18, your connection diagram which several pins I can not use. So I want to reset the MOSI and SCK pin, is there any way?

G6EJD commented 6 years ago

Yes, I did a video on YT on this, but go to this folder in your IDE (F:\ArduinoIDE\arduino-1.8.5\hardware\espresssif\esp32\variants\esp32) is where mine is, but choose your board, in this example I used the default ESP32, there are about 15 variants. Edit the pins for MOSI and SCK accordingly. It's a strange board that does not conform to the standard 23 and 18?

LilyGO commented 6 years ago

Thank you very much for your reply. This is a blind spot in my knowledge. I modified my place as much as possible to modify, but the result SSD1331 screen has been flashing white lines

LilyGO commented 6 years ago

screenshot_1 screenshot_4 img_20180208_202210

G6EJD commented 6 years ago

OK, you don't need MISO which is an input as the display sends no data to the ESP32. All you need is this:

define __CS

define __DC

define __RST

//#define MOSI //define SCLK You generally can't redefine MOSI and SCK unless during the compiler start-up you have modified the pins to be used. in the file pins_arduino.h I've just all my board definitions and none have been remapped to pins 13 and 14, what sort of board is this you are using? then I can help. All your other pin re-maps for CS, DC and RST should be OK. Once you have the pins correct then the display should be OK.

G6EJD commented 6 years ago

OK, here's the best way to diagnose the problem:

  1. Write a short programme like this: void setup(){ Serial.begin (115200); Serial.println(MOSI); Serial.println(SCK); }

void loop(){ }

When we know the results of that output we will know what is going wrong.

LilyGO commented 6 years ago

This is very good. Due to the time difference, I just welcomed the night. Now is a new day.

I used your method to show that it is 13 and 14. So I infer that it is the issue of ESP32 development board connection. So I changed a board, it has all the pins I need.

So I follow your connection diagram and Youtube video, the connection is complete, upload the program (of course, I MOSI SCLK before the amendment has been restored to the default settings). But the unfortunate result came in again. I thought for a long time, but still did not find the real problem.

Best wishes

LilyGO commented 6 years ago

screenshot_4

LilyGO commented 6 years ago

img_20180209_103035

G6EJD commented 6 years ago

I think it is working, have you tried displaying just text like ‘hello world’. Now I can see an image I think the image type is wrong for the display. I suggest you try text first to ensure the connections are correct then we can sort out the images.

G6EJD commented 6 years ago

https://github.com/sumotoy/SSD_13XX/tree/master/_images

There are some images here to try.

Also, I have not tried the Adafruit SSD1331 library, that may work better.

9nut commented 6 years ago

FYI, I was able to get SSD_13XX library working on TTGO T2 (from LilyGo) by creating a variant called ttgot2, that is identical to esp32 (i.e. ESP32 Dev Module) with the following diffs:

$ diff ../esp32/pins_arduino.h ./pins_arduino.h 
21,23c21,23
< static const uint8_t MOSI  = 23;
< static const uint8_t MISO  = 19;
< static const uint8_t SCK   = 18;
---
> static const uint8_t MOSI  = 13;
> static const uint8_t MISO  = 12;
> static const uint8_t SCK   = 14;
$ 

The sketch uses these settings:

#define __CS   15
#define __DC   16
#define __RST  4

SSD_13XX tft = SSD_13XX(__CS, __DC, __RST);

I also added ttgot2 to boards.txt (in ~/Arduino/hardware/espressif/esp32). I copied the ESP32 Dev Module section to the end of the file and renamed menu items starting with esp32. to ttgot2; like this:

ttgot2.name=TTGO T2

ttgot2.upload.tool=esptool
ttgot2.upload.maximum_size=1310720
ttgot2.upload.maximum_data_size=294912
ttgot2.upload.wait_for_upload_port=true

ttgot2.serial.disableDTR=true
ttgot2.serial.disableRTS=true

ttgot2.build.mcu=esp32
ttgot2.build.core=esp32
ttgot2.build.variant=ttgot2
ttgot2.build.board=ESP32_DEV

etc.

G6EJD commented 6 years ago

Thank you.