Closed mchobby closed 8 years ago
I think, there is between send byte and recv byte 1 null byte. Look datasheet command data tables.
It might be buggy, because there nothing to recieve in this driver.
Try look forward to test this feature. )
I am still far away from my lab.
There is an mistake in my previous message. I am creating now Read Memory feature for automatic font bgcolor applying. Now it's near of good condition. Tomorrow it should be in gthub as well.
There added new method, where writed:
# 1. recieving sets 5 bytes
# 2. firs 2 of them are useless (or null bytes)
# 3. and just 3 last of them having a useful data:
# - those 3 bytes are RGB bytes (if we are reading from memory)
# - those 3 bytes have a 7 useful bits (and doesn't matter which color is)
# - we must get from them:
# \* just 5 largest bits for R and B colors
# \* just 6 largest bits for G color
And you may try it by running:
d = LCD() s = d.initCh(font=Heydings_23, color=WHITE) i=0 for color in [BLACK, RED, ORANGE, YELLOW, GREEN, CYAN, BLUE, PURPLE, DARKGREY, LIGHTGREY, OLIVE, MAROON, DARKGREEN, DARKCYAN, NAVY, GREENYELLOW]: d.fillMonocolor(color) s.printChar(chr(64+i), 100, 100, scale=3) pyb.delay(500) i+=1
Memory reading feature give us amazing scope:
I didn't realize immediately the advantages. Now it ring a bell!
I'm trying to understand the role of the following line of code in _write(self, word, dc, recv, recvsize=2) method. Someone could help me to fill the missing part in my knowledge.
Let's say that I want to send the value (a word as I guess) 65535 and receiving 2 bytes. The pack formatting string is '>BBB' so big-endians (ok) with 24 bits (3 unsigned chars).
Question1: As I guess, if I want to receive 2 bytes over the SPI, I do need to send 2 bytes. Am I right?
Question 2: why do we have on byte more? (recvsize +1)
Question 3: If I do want to send the value 65536 (the word value) and receive 2 bytes, the format string is '>BBB' AND struct.pack( '>BBB', 65535 ) returns the following binary response b'\xff\x00\x00' (difficult for me to see how/where the 65535 is encoded/hidden). More over, if I do struct.unpack( '>BBB', b'\xff\x00\x00' ) I do get (255, 0, 0) as result. I'm getting wrong there because my initial value is completely lost. Please, tell me where I'm wrong?
Thank for your help or guiding for proper reading. Dominique