Fast display ST7789!
Moderator: Benj
-
- Posts: 1333
- Joined: Tue Oct 06, 2009 9:39 am
- Has thanked: 1135 times
- Been thanked: 299 times
- Contact:
- Benj
- Matrix Staff
- Posts: 15312
- Joined: Mon Oct 16, 2006 10:48 am
- Location: Matrix TS Ltd
- Has thanked: 4803 times
- Been thanked: 4314 times
- Contact:
Re: Fast display ST7789!
I'm sure I have one of these displays somewhere as I developed a component for v9 and its been working in that.
However searching both my house and my desk at work I've not found it so far. I'll keep looking.
I've compared the v8 component with the v9 component and the fast library and so far not spotted anything that would be a show stopper. I'll keep on it
If anyone else wants to have an eye through the component source vs the Arduino library then that would be really helpful.
However searching both my house and my desk at work I've not found it so far. I'll keep looking.
I've compared the v8 component with the v9 component and the fast library and so far not spotted anything that would be a show stopper. I'll keep on it
If anyone else wants to have an eye through the component source vs the Arduino library then that would be really helpful.
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
-
- Posts: 1333
- Joined: Tue Oct 06, 2009 9:39 am
- Has thanked: 1135 times
- Been thanked: 299 times
- Contact:
Re: Fast display ST7789!
Hi Ben!
Unfortunately I am not able to figure out what happen in C code. If I could I would help. Maybe the hard programmer Martin will help
Br Jorgen
Unfortunately I am not able to figure out what happen in C code. If I could I would help. Maybe the hard programmer Martin will help
Br Jorgen
- Benj
- Matrix Staff
- Posts: 15312
- Joined: Mon Oct 16, 2006 10:48 am
- Location: Matrix TS Ltd
- Has thanked: 4803 times
- Been thanked: 4314 times
- Contact:
Re: Fast display ST7789!
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
-
- Valued Contributor
- Posts: 1200
- Joined: Wed May 31, 2017 11:57 am
- Has thanked: 70 times
- Been thanked: 440 times
- Contact:
Re: Fast display ST7789!
Well - I've fiddled (a lot) and finally got 'something' on screen...
I used my own initialisation (based on the fast library) - and it draws 'random' 40 x 40 blocks. It's not quite there yet though - the blocks are 'grey scale' and the background is 'noise' rather than a solid colour.. It also only draws to the 'bottom' two thirds of the screen.
Still - it's alive....
Deleted - attachment - see next message....
Martin
I used my own initialisation (based on the fast library) - and it draws 'random' 40 x 40 blocks. It's not quite there yet though - the blocks are 'grey scale' and the background is 'noise' rather than a solid colour.. It also only draws to the 'bottom' two thirds of the screen.
Still - it's alive....
Deleted - attachment - see next message....
Martin
-
- Valued Contributor
- Posts: 1200
- Joined: Wed May 31, 2017 11:57 am
- Has thanked: 70 times
- Been thanked: 440 times
- Contact:
Re: Fast display ST7789!
Ah - that's better...
Now clears the display to white and then draws 40x40 random blocks over the whole display...
Martin
Now clears the display to white and then draws 40x40 random blocks over the whole display...
Martin
-
- Valued Contributor
- Posts: 1200
- Joined: Wed May 31, 2017 11:57 am
- Has thanked: 70 times
- Been thanked: 440 times
- Contact:
Re: Fast display ST7789!
As an aside - a bug I thought had vanished.. If you change the while loop in SendWordMulti to a count (for) loop (and remove the decrement of rpt) - then it is assigned an 8 bit value as a loop counter... This (of course) doesn't work.
Martin
Martin
-
- Valued Contributor
- Posts: 1200
- Joined: Wed May 31, 2017 11:57 am
- Has thanked: 70 times
- Been thanked: 440 times
- Contact:
Re: Fast display ST7789!
One possible change needed - I changed the parity of SCL... To get things working!
Martin
Martin
-
- Valued Contributor
- Posts: 1200
- Joined: Wed May 31, 2017 11:57 am
- Has thanked: 70 times
- Been thanked: 440 times
- Contact:
Re: Fast display ST7789!
Another 'oddity' I meant to check in the datasheet..
The fast library - defines CASET and RASET to be 0..240 (for the whole display) - whereas I would expect this to be 0..239
Any thoughts/guidance on this ?
Martin
The fast library - defines CASET and RASET to be 0..240 (for the whole display) - whereas I would expect this to be 0..239
Any thoughts/guidance on this ?
Martin
- Benj
- Matrix Staff
- Posts: 15312
- Joined: Mon Oct 16, 2006 10:48 am
- Location: Matrix TS Ltd
- Has thanked: 4803 times
- Been thanked: 4314 times
- Contact:
Re: Fast display ST7789!
Hi Martin,
Sounds like your having good progress.
Yes agreedThe fast library - defines CASET and RASET to be 0..240 (for the whole display) - whereas I would expect this to be 0..239
Sounds like your having good progress.
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
-
- Valued Contributor
- Posts: 1200
- Joined: Wed May 31, 2017 11:57 am
- Has thanked: 70 times
- Been thanked: 440 times
- Contact:
Re: Fast display ST7789!
- that's when Jorgen's display starts working too.....Sounds like your having good progress.
I added a 'blit' bitmap to display. Here are the 1 and 4 bit versions and a Python script that generates the array assignments for the data and colour table from a bitmap file (need a better way to do upload them to the MCU though!)
The 1 bit (and possibly 4 bit - my test image reflected well) bitmap image is mirrored (left - right). That's a job for tomorrow though. Here it draws a 64x64 1bit image of a star with lines...
Code: Select all
def rl(f,l):
val = int.from_bytes(f.read(l), byteorder='little')
return val
f = open("t2.bmp", "rb")
x = f.read(10)
offset = rl(f, 4)
sz = rl(f, 4)
w = rl(f, 2)
h = rl(f,2)
planes = rl(f, 2)
depth = rl(f, 2)
f.seek(54, 0)
## Now copy the color table
op = open("arr.txt", "w")
num_entries = int((offset - 54)/4)
print(num_entries)
for i in range(num_entries):
x = f.read(4)
b = x[0]
g = x[1]
r = x[2]
c565 = ((r & 0xF8) << 8) | ((g & 0xFC) << 3) | (b >> 3)
op.write(".ctable[" + str(i) + "]="+str(c565)+"\n")
i = i + 1
## Now copy the bitmap data (reversed vertically)
x = f.read(10000)
i = len(x ) - 1
for b in x:
s = ".data[" + str(i) + "]="+str(b) + "\n"
i = i - 1
op.write(s)
op.close()
f.close()
print("Done")
I'll add 8/16/24 bitmap support (the routines are fairly short - though the colour table for 8 bit mode is 512 bytes.)
Next is text - anyone have a nice font (public domain) in an easy format?
Suggestions as to where to read bitmap data from - I can easily add from ROM (perhaps using the 'drawer' component) - i2c eeprom would be easy too. S
Any suggestions how to use SD card or SPI eeprom (bearing in mind that the display doesn't have a CS line...)
Martin
-
- Valued Contributor
- Posts: 1200
- Joined: Wed May 31, 2017 11:57 am
- Has thanked: 70 times
- Been thanked: 440 times
- Contact:
Re: Fast display ST7789!
Well that's the left to right issue sorted for 1 bit bitmaps...
Note that bitmaps are stored as dwords (32bit) - so rows are always a multiple of 32 bits long. This means it can be quite wasteful of memory (so a 8x8 monochrome bitmap will use 32 bytes (rather than 8 )) The code here - uses bitmap format (ie lines are padded to 32bits - but anyone thoughts on this - I'm inclined to making them padded to the nearest byte (or 16 bit word?) and have the python script strip the padding bytes)
Also an upgraded python script that outputs data as 32bit chunks (note the change in the FC - to use this) - I think keeping this as bytes/words might be slightly quicker on 8bit MCUs)
Here the demo outputs a bitmap of some letters (128 x 20 pixels) at 100ms intervals.
Martin
Note that bitmaps are stored as dwords (32bit) - so rows are always a multiple of 32 bits long. This means it can be quite wasteful of memory (so a 8x8 monochrome bitmap will use 32 bytes (rather than 8 )) The code here - uses bitmap format (ie lines are padded to 32bits - but anyone thoughts on this - I'm inclined to making them padded to the nearest byte (or 16 bit word?) and have the python script strip the padding bytes)
Also an upgraded python script that outputs data as 32bit chunks (note the change in the FC - to use this) - I think keeping this as bytes/words might be slightly quicker on 8bit MCUs)
Here the demo outputs a bitmap of some letters (128 x 20 pixels) at 100ms intervals.
Code: Select all
import os
def rl(f,l):
val = int.from_bytes(f.read(l), byteorder='little')
return val
f = open("t2.bmp", "rb")
x = f.read(10)
offset = rl(f, 4)
sz = rl(f, 4)
w = rl(f, 2)
h = rl(f,2)
planes = rl(f, 2)
depth = rl(f, 2)
f.seek(54, 0)
## Now copy the color table
op = open("arr.txt", "w")
num_entries = int((offset - 54)/4)
for i in range(num_entries):
x = f.read(4)
b = x[0]
g = x[1]
r = x[2]
c565 = ((r & 0xF8) << 8) | ((g & 0xFC) << 3) | (b >> 3)
op.write(".ctable[" + str(i) + "]="+str(c565)+"\n")
i = i + 1
## Now copy the bitmap data (reversed vertically)
cur = f.tell() # save current position
f.seek(0, os.SEEK_END)
end = f.tell() # find the size of file
f.seek(cur, os.SEEK_SET)
i = int((end - cur) / 4)
while f.tell() < end:
b = int.from_bytes(f.read(4), byteorder='big')
i = i - 1
s = ".data[" + str(i) + "]="+hex(b) + "\n"
op.write(s)
op.close()
f.close()
print("Done")
-
- Posts: 1333
- Joined: Tue Oct 06, 2009 9:39 am
- Has thanked: 1135 times
- Been thanked: 299 times
- Contact:
Re: Fast display ST7789!
Hi Martin!
In advance, thank´s for your great work I will make a test later today. You hear.
Br Jorgen
In advance, thank´s for your great work I will make a test later today. You hear.
Br Jorgen
-
- Posts: 1333
- Joined: Tue Oct 06, 2009 9:39 am
- Has thanked: 1135 times
- Been thanked: 299 times
- Contact:
Re: Fast display ST7789!
Martin, you are a master
It work. I see white background and ABCDEfHIJKL coming all over the display
I convert to Uno.
Br Jorgen
It work. I see white background and ABCDEfHIJKL coming all over the display
I convert to Uno.
Br Jorgen
-
- Valued Contributor
- Posts: 1200
- Joined: Wed May 31, 2017 11:57 am
- Has thanked: 70 times
- Been thanked: 440 times
- Contact:
Re: Fast display ST7789!
Hooray, glad to hear it's working!
I've just worked out the real reason the bitmaps are reversed - my FC is making up for deficiencies in the python script - which reverses the lines (vertically) and also horizontally...
Next version soon...
I've just worked out the real reason the bitmaps are reversed - my FC is making up for deficiencies in the python script - which reverses the lines (vertically) and also horizontally...
Next version soon...
-
- Posts: 1333
- Joined: Tue Oct 06, 2009 9:39 am
- Has thanked: 1135 times
- Been thanked: 299 times
- Contact:
Re: Fast display ST7789!
Finger crossed Martin Does it mean you are able to create a .fcpx file to drop down in the component lib?
Jorgen
Jorgen
-
- Valued Contributor
- Posts: 1200
- Joined: Wed May 31, 2017 11:57 am
- Has thanked: 70 times
- Been thanked: 440 times
- Contact:
Re: Fast display ST7789!
Maybe - but a way to go before that's a thing...
What features do you need / would you like?
Need to get text working..
What features do you need / would you like?
Need to get text working..
-
- Posts: 1333
- Joined: Tue Oct 06, 2009 9:39 am
- Has thanked: 1135 times
- Been thanked: 299 times
- Contact:
Re: Fast display ST7789!
It would be nice if all settings, font, color, orientation ect. could be similar to Ili9341
-
- Valued Contributor
- Posts: 1200
- Joined: Wed May 31, 2017 11:57 am
- Has thanked: 70 times
- Been thanked: 440 times
- Contact:
Re: Fast display ST7789!
Hmm - Orientation is the tricky one....
Still some more to test.. I added some text routines.
Print - is slower, but allows the text to be scaled and - it 'wraps' - so it goes to a new line if the text overflows the current line.... Not drawing the background (for example on a clear display) saves some time.
DispTextLine - is much quicker - but it just uses the native (8 point) font - so is probably a bit small to be useable? (It's the font from Max7219:) )
Any thoughts on spacing (vertically - is 8 x yscale + yscale at present..)
I've also added a 8, 16 (565) and 24bit bitmap copy - 8 bit works, but haven't tested the 16/24 bit ones yet... I updated the python script to 'compress' 24 bit bitmaps to 565 16 bit.. (But again haven't tested yet)
Plot - draws a rectangle (w x h) but checks if on screen (which slows things a bit - perhaps should make this the user responsibility?)
Also added a DrawLine function (ripped from the FC component) - I've added a width of line. Thoughts on interface - would it be better for it to take a colour argument too?
Martin
Still some more to test.. I added some text routines.
Print - is slower, but allows the text to be scaled and - it 'wraps' - so it goes to a new line if the text overflows the current line.... Not drawing the background (for example on a clear display) saves some time.
DispTextLine - is much quicker - but it just uses the native (8 point) font - so is probably a bit small to be useable? (It's the font from Max7219:) )
Any thoughts on spacing (vertically - is 8 x yscale + yscale at present..)
I've also added a 8, 16 (565) and 24bit bitmap copy - 8 bit works, but haven't tested the 16/24 bit ones yet... I updated the python script to 'compress' 24 bit bitmaps to 565 16 bit.. (But again haven't tested yet)
Plot - draws a rectangle (w x h) but checks if on screen (which slows things a bit - perhaps should make this the user responsibility?)
Also added a DrawLine function (ripped from the FC component) - I've added a width of line. Thoughts on interface - would it be better for it to take a colour argument too?
Martin
-
- Posts: 1333
- Joined: Tue Oct 06, 2009 9:39 am
- Has thanked: 1135 times
- Been thanked: 299 times
- Contact:
Re: Fast display ST7789!
Hi MArtin!
One step forward and one back Sorry the display is black, no text at all.
Jorgen
One step forward and one back Sorry the display is black, no text at all.
Jorgen
-
- Valued Contributor
- Posts: 1200
- Joined: Wed May 31, 2017 11:57 am
- Has thanked: 70 times
- Been thanked: 440 times
- Contact:
Re: Fast display ST7789!
Wiggle those wires - you should be getting rainbows, lines and text too...
Martin
Martin
-
- Valued Contributor
- Posts: 1200
- Joined: Wed May 31, 2017 11:57 am
- Has thanked: 70 times
- Been thanked: 440 times
- Contact:
Re: Fast display ST7789!
Hmm - I've just downloaded on a different computer and all seems well. Can you make previous version work still?
Martin
Martin
-
- Posts: 1333
- Joined: Tue Oct 06, 2009 9:39 am
- Has thanked: 1135 times
- Been thanked: 299 times
- Contact:
Re: Fast display ST7789!
Hi Martin
Strange. Sometime the First work sometime not?
The last you send not work at all.
Here is a picture from a IDe projekt.
I have used the same config all the time.
And when I use your sometime I see abcdefgh next time
I upload not working?
Strange. Sometime the First work sometime not?
The last you send not work at all.
Here is a picture from a IDe projekt.
I have used the same config all the time.
And when I use your sometime I see abcdefgh next time
I upload not working?
- Attachments
-
- image.jpg (119.62 KiB) Viewed 65352 times