Page 2 of 4

Re: Fast display ST7789!

Posted: Tue Nov 17, 2020 6:40 pm
by mnf
Had a brief go - and no joy here either...

:|

Re: Fast display ST7789!

Posted: Tue Nov 17, 2020 7:17 pm
by jgu1
Hi Martin!

No Unfortunately not. I think MM is busy with FC9 :wink:

Jorgen

Re: Fast display ST7789!

Posted: Tue Nov 17, 2020 9:55 pm
by Benj
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.

Re: Fast display ST7789!

Posted: Wed Nov 18, 2020 11:45 am
by jgu1
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 :wink:

Br Jorgen

Re: Fast display ST7789!

Posted: Wed Nov 18, 2020 2:16 pm
by mnf
I'd take a look - can you post / PM the source...

Martin

Re: Fast display ST7789!

Posted: Wed Nov 18, 2020 2:47 pm
by Benj
Hi Martin,

The latest source is here.
viewtopic.php?p=103813#p103813

Re: Fast display ST7789!

Posted: Wed Nov 18, 2020 7:53 pm
by mnf
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

Re: Fast display ST7789!

Posted: Wed Nov 18, 2020 8:14 pm
by mnf
Ah - that's better...

Now clears the display to white and then draws 40x40 random blocks over the whole display...
st7789.fcfx
(31.58 KiB) Downloaded 367 times
Martin

Re: Fast display ST7789!

Posted: Wed Nov 18, 2020 8:34 pm
by mnf
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

Re: Fast display ST7789!

Posted: Thu Nov 19, 2020 8:34 am
by mnf
One possible change needed - I changed the parity of SCL... To get things working!

Martin

Re: Fast display ST7789!

Posted: Thu Nov 19, 2020 11:30 am
by mnf
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

Re: Fast display ST7789!

Posted: Thu Nov 19, 2020 2:31 pm
by Benj
Hi 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
Yes agreed :D

Sounds like your having good progress.

Re: Fast display ST7789!

Posted: Sat Nov 21, 2020 12:03 am
by mnf
Sounds like your having good progress.
- that's when Jorgen's display starts working too..... :D

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...
st7789.fcfx
(58.77 KiB) Downloaded 317 times

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")
A simple python script that reads a bitmap (t2.bmp) and outputs the ctable and data to arr.txt (it had been long day - otherwise I'd have used the command line args....)

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

Re: Fast display ST7789!

Posted: Sat Nov 21, 2020 9:53 am
by mnf
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.
st7789.fcfx
(44.32 KiB) Downloaded 267 times

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")
Martin

Re: Fast display ST7789!

Posted: Sat Nov 21, 2020 10:13 am
by jgu1
Hi Martin!

In advance, thank“s for your great work :wink: I will make a test later today. You hear.

Br Jorgen

Re: Fast display ST7789!

Posted: Sat Nov 21, 2020 3:44 pm
by jgu1
Martin, you are a master :lol:

It work. I see white background and ABCDEfHIJKL coming all over the display :P

I convert to Uno.

Br Jorgen

Re: Fast display ST7789!

Posted: Sat Nov 21, 2020 4:59 pm
by mnf
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...

Re: Fast display ST7789!

Posted: Sat Nov 21, 2020 5:34 pm
by jgu1
Finger crossed Martin :lol: Does it mean you are able to create a .fcpx file to drop down in the component lib?

Jorgen

Re: Fast display ST7789!

Posted: Sat Nov 21, 2020 6:33 pm
by mnf
Maybe - but a way to go before that's a thing...

What features do you need / would you like?

Need to get text working..

Re: Fast display ST7789!

Posted: Sat Nov 21, 2020 6:46 pm
by jgu1
It would be nice if all settings, font, color, orientation ect. could be similar to Ili9341 :wink:

Re: Fast display ST7789!

Posted: Sun Nov 22, 2020 10:50 am
by mnf
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?
st7789.fcfx
(95.28 KiB) Downloaded 291 times
Martin

Re: Fast display ST7789!

Posted: Sun Nov 22, 2020 4:32 pm
by jgu1
Hi MArtin!

One step forward and one back :D Sorry the display is black, no text at all.

Jorgen

Re: Fast display ST7789!

Posted: Sun Nov 22, 2020 5:01 pm
by mnf
Wiggle those wires - you should be getting rainbows, lines and text too...

Martin

Re: Fast display ST7789!

Posted: Sun Nov 22, 2020 5:48 pm
by mnf
Hmm - I've just downloaded on a different computer and all seems well. Can you make previous version work still?

Martin

Re: Fast display ST7789!

Posted: Sun Nov 22, 2020 8:02 pm
by jgu1
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?