Looking for very Basic Code for SPI ST7735
Christof Eb.
Posts: 1,197
Hi,
perhaps somebody has got a link or some very, very basic code to drive SPI ST7735?
For my new project I would like to use P2 with a ST7735 display. As I want to use Taqoz, I have to (re)write a driver for ST7735. There is a pixel based driver for VGA in Taqoz and I want to copy the framebuffer to ST7735. I am aware, that I must convert colorcode for every pixel.
While I have found some very elaborate drivers for ST7735, for example by adafruit, I have not yet found a very simple minimal driver. I would like to have something, that just shows setup and set a pixel.
Thanks in advance!
Christof
Edit: Now found something: technoblogy.com/show?2LMJ Will try to start based on this.
Comments
This is for P1, but since you just want example code to rewrite for Taqoz, it might help...
https://forums.parallax.com/discussion/174147/parallax-font-on-st7735-tft
dgately
@Christof Eb.
Formatting is a little skewed
This example is typscript for a 128 x 160 display but really easy to port.
Command constants
Init configures the display ready to accept graphics methods,
```
// set SPI frequency
pins.spiFrequency(16000000)
export function drawPixel(x: number, y: number, color: Color): void {
setWindow(x, y, x + 1, y + 1)
send(TFTCommands.RAMWR, [color >> 8, color])
}
function setWindow(x0: number, y0: number, x1: number, y1: number): void {
x0 = (x0 & 0xFF) + 1
x1 = ((x1 - 1) & 0xFF) + 1
y0 = (y0 & 0xFF) + 2
y1 = ((y1 - 1) & 0xFF) + 2
send(TFTCommands.CASET, [0x00, x0, 0x00, x1])
send(TFTCommands.RASET, [0x00, y0, 0x00, y1])
send(TFTCommands.RAMWR, [])
}
```
The send function used in the initialization transmits the various commands followed by data over SPI.
Here is a link to the datasheet that details the commands in detail
https://www.displayfuture.com/Display/datasheet/controller/ST7735.pdf
Thank you both for your input!
I have managed to get first results.
Christof
Once the display is initialized setWindow is extremely important for the graphics functions and speed for shapes, images and fonts. When the window has been defined pixel data can be drawn to the display from a buffer or file in a sequential manner, here for example a horizontal line.
The format is RGB 565 so there are 2 bytes for each pixel, if using images they usually have to be converted to 565.
I can help with the basic drawing, font and image functions.