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

[Feature Request] ST7789V support for ESP32-Wrover-Kit v3 #4

Open
tobozo opened this issue Jul 22, 2017 · 10 comments
Open

[Feature Request] ST7789V support for ESP32-Wrover-Kit v3 #4

tobozo opened this issue Jul 22, 2017 · 10 comments

Comments

@tobozo
Copy link

tobozo commented Jul 22, 2017

Hi @tekker thanks for the awesome work, it provided me a lot of fun!

This is a noobish request, I got myselft an ESP32-Wrover-Kit v3 and have some free time over the weekends to test and play with it.
Feel free to close this request if you find this is inappropriate.

I've ordered a couple of OV7670 cam modules to play with the Wrover Kit, and so far I managed to get a few snapshots using the feature-rgb_bitmap branch of this project.

I also attempted to modify the ov7670_ili9341 branch to get it working with the LCD bundled with my v3 Dev Kit (an ST7789V).
I found a driver implementation (IoTuz has support for ST7789v) and built this init code:

DRAM_ATTR static const ili_init_cmd_t ili_init_cmds[]={
    {0x36, {0}, 1},
    {0x3A, {0x55}, 1},
    {0xB2, {0x0C,0x0C,0x00,0x33,0x33}, 5},
    {0xB7, {0x35}, 1},
    {0xBB, {0x2B}, 1},
    {0xC0, {0x2C}, 1},
    {0xC2, {0x01,0xFF}, 2},
    {0xC3, {0x11}, 1},
    {0xC4, {0x20}, 1},
    {0xC6, {0x0F}, 1},
    {0xD0, {0xA4,0xA1}, 2},
    {0xE0, {0xD0,0x00,0x05,0x0E,0x15,0x0D,0x37,0x43,0x47,0x09,0x15,0x12,0x16,0x19}, 14},
    {0xE1, {0xD0,0x00,0x05,0x0D,0x0C,0x06,0x2D,0x44,0x40,0x0E,0x1C,0x18,0x16,0x19}, 14},
    {0x11, {0}, 0x80}, // optional
    {0x29, {0}, 0x80}, // optional
    {0, {0}, 0xff},
};

Obviously, modifying only this is not enough and I wonder if and where would be some other ili9341-specific code that also need to be adapted.

@tekker
Copy link
Owner

tekker commented Jul 23, 2017

thats awesome tobozo :) great to hear u were able to make use of it.

As far as the ST7789V goes, I don't have one to test with, but the ILI9341 code I used came from the WROVER_LCD libraries and I used the ESP32 DOOM port as well. The only change needed, I think, is the ili_init_cmd as you have... I could be wrong though.. Did you try it out?

Maybe double check the Initialization code from:
https://github.com/espressif/esp32-doom/blob/master/components/prboom-esp32-compat/spi_lcd.c

static const ili_init_cmd_t ili_init_cmds[]={ {0x36, {(1<<5)|(1<<6)}, 1}, {0x3A, {0x55}, 1}, {0xB2, {0x0c, 0x0c, 0x00, 0x33, 0x33}, 5}, {0xB7, {0x45}, 1}, {0xBB, {0x2B}, 1}, {0xC0, {0x2C}, 1}, {0xC2, {0x01, 0xff}, 2}, {0xC3, {0x11}, 1}, {0xC4, {0x20}, 1}, {0xC6, {0x0f}, 1}, {0xD0, {0xA4, 0xA1}, 1}, {0xE0, {0xD0, 0x00, 0x05, 0x0E, 0x15, 0x0D, 0x37, 0x43, 0x47, 0x09, 0x15, 0x12, 0x16, 0x19}, 14}, {0xE1, {0xD0, 0x00, 0x05, 0x0D, 0x0C, 0x06, 0x2D, 0x44, 0x40, 0x0E, 0x1C, 0x18, 0x16, 0x19}, 14}, {0x11, {0}, 0x80}, {0x29, {0}, 0x80}, {0, {0}, 0xff} };

@tobozo
Copy link
Author

tobozo commented Jul 23, 2017

My OV7670 camera only (kinda) works on the feature-rgb_bitmap branch. I never got it working on the other branch, whatever settings I change. Here's what I use :

#define CAMERA_PIXEL_FORMAT CAMERA_PF_RGB565
#define CAMERA_FRAME_SIZE CAMERA_FS_QQVGA

Moving those setting into the ov7670_ili9341 branch did not give good results (unresponsive http server after one request, yes I'm using esp-idf 2.1).

Also I'm a bit confused with the pins assignment in the configuration compared to the ones in esp32-doom (and in the schematics) as t seems to share all the SPI pins with the camera:

CONFIG_HW_LCD_MOSI_GPIO=23
CONFIG_HW_LCD_CLK_GPIO=19
CONFIG_HW_LCD_CS_GPIO=22
CONFIG_HW_LCD_DC_GPIO=21
CONFIG_HW_LCD_RESET_GPIO=18
CONFIG_HW_LCD_BL_GPIO=5

Since the Wrover Kit v3 comes with the presoldered LCD I don't have much of a choice.

@tekker
Copy link
Owner

tekker commented Jul 23, 2017

Sorry my code is missing the SDKCONFIG file, I'll add it, but, this is what I'm using:

Pin Configuration

CONFIG_HW_LCD_MISO_GPIO=12
CONFIG_HW_LCD_MOSI_GPIO=13
CONFIG_HW_LCD_CLK_GPIO=14
CONFIG_HW_LCD_CS_GPIO=15
CONFIG_HW_LCD_DC_GPIO=16
CONFIG_HW_LCD_RESET_GPIO=33
CONFIG_HW_LCD_BL_GPIO=17
CONFIG_D0=4
CONFIG_D1=5
CONFIG_D2=18
CONFIG_D3=19
CONFIG_D4=36
CONFIG_D5=39
CONFIG_D6=34
CONFIG_D7=35
CONFIG_XCLK=21
CONFIG_PCLK=22
CONFIG_VSYNC=25
CONFIG_HREF=23
CONFIG_SDA=26
CONFIG_SCL=27
CONFIG_RESET=2

@tobozo
Copy link
Author

tobozo commented Jul 24, 2017

From the schematics (ESP32-Wrover-Kit v3):
wrover-lcd2

Is that supposed to share same pins as the camera?

@tekker
Copy link
Owner

tekker commented Jul 26, 2017

You can't share the pins between OV7670 and LCD at the same time. I used different pin mappings for the LCD from the DOOM port for example because I had already used the pins for those for the OV7670. The ESP32 is pretty dynamic with pin changes with its GPIO matrix, but I chose the common pins used for the alternate SPI bus. Did you try changing the Pin config in the SDKCONFIG? How did it go?

@tobozo
Copy link
Author

tobozo commented Jul 26, 2017

Using the Pin config you provided I get some flashes on the screen while the ESP is connecting, then blank screen. If I visit /bmp I receive this image but nothing happens on the LCD.

bmp-2

I'm not surprised though, both the camera and the screen seem to be hard wired to the same pins on the dev board, also on Espressif schema; I know I'm missing something. Probably many things :p

What could possibly be the intent of Espressif when they mapped the same pins to a LCD and a Camera 💡 ⛽ ? Could this imply my dev board only supports a different, non DMA approach, when the camera and the lcd are both used ?

Also I have a couple of write fails during camera initialization, that could explain the image, but this is secondary since capturing somehow works with the feature-rgb_bitmap branch.

I (216) ESPILICAM: Starting ESPILICAM
I (216) ESPILICAM: Starting Memory Allocation for Display
I (216) ESPILICAM: Free 8bit-capable memory: 284828K, 32-bit capable memory 333772K

D (226) ESPILICAM: Allocating Frame Buffer memory...
I (226) ESPILICAM: Setup ILI9341
I (236) ESPILICAM: Call spi_bus_initialize
I (236) ESPILICAM: Call spi_bus_add_device
I (246) ESPILICAM: Call ili_init
D (646) camera: Enabling XCLK output
D (646) ledc: LEDC_PWM CHANNEL 0|GPIO 21|Duty 0001|Time 0
D (646) camera: Initializing SSCB
D (646) camera: Resetting camera
D (666) camera: Searching for camera address
D (676) camera: Detected camera at address=0x21
D (686) camera: Camera PID=0x76 VER=0x73 MIDL=0x7f MIDH=0xa2
D (686) camera: Doing SW reset of sensor
SCCB_Write [3a]=04 failed
SCCB_Write [12]=00 failed
I (726) ESPILICAM: Detected OV7670 camera, using grayscale bitmap format
I (726) ESPILICAM: Free 8bit-capable memory: 130316K, 32-bit capable memory 179260K

I (5266) event: ip: 192.168.1.12, mask: 255.255.255.0, gw: 192.168.1.1
I (5266) ESPILICAM: Connected
D (5266) ESPILICAM: Wifi Initialized...
I (5266) ESPILICAM: Free 8bit-capable memory: 86480K, 32-bit capable memory 135424K

D (7276) camera: Setting pixformat
D (7306) camera: Setting frame size to 320x240
D (7306) camera: Setting framerate to 0 for PIXFORMAT_YUV422
D (7306) camera: Test pattern enabled
D (7306) camera: Sending Raw Bytes from DMA to Framebuffer at 8000000 HZ
D (7306) camera: Sampling mode SM_0A00_0B00 (2)
D (7316) camera: Frame buffer (153600 bytes)
D (7316) camera: Using 32-bit aligned ram shared with display - 320x240x2bpp
D (7326) camera: Allocated frame buffer (153600 bytes)
D (7336) camera: Initializing I2S and DMA
D (7336) camera: Line width (for DMA): 2560 bytes
D (7336) camera: DMA buffer size: 2560, DMA buffers per line: 1
D (7346) camera: DMA buffer count: 4
D (7346) camera: Allocating DMA buffer #0, size=2560
D (7356) camera: Allocating DMA buffer #1, size=2560
D (7356) camera: Allocating DMA buffer #2, size=2560
D (7366) camera: Allocating DMA buffer #3, size=2560
D (7366) camera: Initializing GPIO interrupts
D (7376) camera: Skipping GPIO ISR Register, already enabled...
I (8456) ESPILICAM: Free heap: 71384
I (8456) ESPILICAM: Camera demo ready
D (8456) ESPILICAM: Starting http_server task...
D (8456) ESPILICAM: Starting ILI9341 display task...
D (8456) ESPILICAM: Starting Telnetd task...
D (8466) ESPILICAM: >> telnetTask
D (37736) ESPILICAM: Image requested.
D (37736) camera: Waiting for positive edge on VSYNC
D (37836) camera: Got VSYNC
D (37836) camera: Waiting for frame
I (37936) camera: Frame 0 done in 197 ms
D (37936) ESPILICAM: Done
D (37936) ESPILICAM: Converting framebuffer to RGB565 requested, sending...
D (50026) ESPILICAM: Image requested.
D (50026) camera: Waiting for positive edge on VSYNC
D (50036) camera: Got VSYNC
D (50036) camera: Waiting for frame
I (50136) camera: Frame 1 done in 106 ms
D (50136) ESPILICAM: Done
D (50136) ESPILICAM: Converting framebuffer to RGB565 requested, sending...
D (254176) ESPILICAM: Image requested.
D (254176) camera: Waiting for positive edge on VSYNC
D (254256) camera: Got VSYNC
D (254256) camera: Waiting for frame
I (254346) camera: Frame 2 done in 178 ms
D (254346) ESPILICAM: Done
D (254346) ESPILICAM: Converting framebuffer to RGB565 requested, sending..

@tekker
Copy link
Owner

tekker commented Jul 26, 2017

Hi, @tobozo, thats great. This is just really hacking on my behalf - and if you have a copy of the repo thats working thats great, you should take a backup! My main problem is memory issues with ESP32 causing issues starting up the TCP/IP stack - code works by allocating 32-bit RAM for the framebuffer. I'm really just a noobie as well this is my first experience with FreeRTOS so I'm learning a lot. Using the Test Pattern is a great way to test picture - have u tried to telnet in and issue "colorbar 0".

I've looked at the schematic for the WROVER you linked but I didn't really understand how its wired up... It does looks like pins 19, 21, 22, 23, 25 are shared between the two...

@javicordon
Copy link

Hi @tobozo
Could you please share the configuration and code you implemented to make it work with Wrover Kit V3? I've been trying to make it work without success.

Thanks!

@tobozo
Copy link
Author

tobozo commented Mar 20, 2018

I only changed the init settings as documented in my first comment.
The reason it didn't work for me is that I was misled into believing my OV7670 had FIFO.
Also the menuconfig does not take shared SPI pins into account so I had to assign all pins based on the WroverKit v3 documentation.
So basically finding the right settings in menuconfig solved it.

But you'll have other problems upstream:

  • you need a FIFO enabled camera if you want to stream
  • the Wrover Kit V3 has zero-ohm SMD resistors that need to be unsoldered (very delicately) in order to get rid of some noise on the SPI bus

@tobozo
Copy link
Author

tobozo commented Mar 20, 2018

ok I found some old code but you might be interested in the pinout setup, here's the sdkconfig and the app_main.c file I was using, with the modified init sequence for the display.

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