I setup my uno breadboard to use the logic level converter again with ili9341.
chip mega328p,16
include <glcd.h></glcd.h>
option explicit
;--------------
define GLCD_TYPE GLCD_TYPE_ILI9341
define GLCD_DC portb.0 ; DIGITAL_8 ' Data command line
define GLCD_CS portb.2 ; DIGITAL_10 ' Chip select line
define GLCD_RESET portb.1 ; DIGITAL_9 ' Reset line
define GLCD_DI portb.4 ; DIGITAL_12 ' Data in | MISO - Not used therefore not really required
define GLCD_DO portb.3 ; DIGITAL_11 ' Data out | MOSI
define GLCD_SCK portb.5 ; DIGITAL_13 ' Clock Line
define ILI9341_HardwareSPI ' remove/comment out if you want to use software SPI.
if commented --- it's same as pic ie cls then no printing.
It is working in that the display is working...it sets up the screen and sets to portrait and cls to black fine. plots points to test etc. ie ok
Using your last include it says 2164063484 for any read pixel test.
I shall try the code I posted and see.
I shall try the original include as you said it worked,
Thanks for you time.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi Anobium. Here is a test that compiles and gives wrong results. I don't get pics but seems to work as far as the display ok just the pixel test is not working as expected.
just change
;test
pset 100,100,ILI9341_WHITE
pset 120,100,ILI9341_BLACK
and see the results.
Cheers.
#chip18f25k22,64
#configMCLRE=on
#optionExplicit
#include<glcd.h>
#defineGLCD_TYPEGLCD_TYPE_ILI9341'Pin mappings for ILI9341
#defineGLCD_DCportc.2
#defineGLCD_CSportc.0
#defineGLCD_RESETportc.1'As we are using Harware SPI this cannot be change on this chip. This is a non-PPS chip.
#defineGLCD_DIportc.4
#defineGLCD_DOportc.5
#defineGLCD_SCKportc.3
#defineILI9341_hardwarespi;GLCDRotate(Portrait_Rev);xy=0 top left, optionally you can rotate the screen.GLCDCLSILI9341_BLACK;dimpixel_colour_left,pixel_colour_rightaslong;test pixel colour;;testpset100,100,ILI9341_WHITEpset120,100,ILI9341_BLACKpixel_colour_left=ReadPixel_ILI9341(100,100)pixel_colour_right=ReadPixel_ILI9341(120,100)GLCDPrint70,10,Str32(pixel_colour_left)GLCDPrint70,20,Str32(pixel_colour_right)doloop
Strange you got uno to work but it always says the same value for me ie does not work at all.
the display functions fine just read pixel not working.
the miso line from ili9341 GLCD_DI to low side of logic converter then to 5V logic DIGITAL_12 on uno.
So I can't get uno to work with pixelread it seems.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Disconnect the GLCD.
1. Ground the DI line to 0V. Run the code. You will have to write the value to serial port.
2. Pull the DI in line to the operating voltage. Run the code. Again. you will have to write the value to serial port.
Test one should 0 and test two should be FFFFFF or may be FFFFFF.
If both 0... then, look at the volatage leveler.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
The logic leveller is bi-directional as tested with a multi-meter.
ie tie any port on 3.3V side high ie 3.3V then 5V side goes high and ground 3.3V side and 5V side goes low.
leave 3.3V side floating and 5V side goes high.
Was that the purpose of the test to see if the logic level converter was working bi-directional?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Put the DI and test with the same program. As you no longer have a GCLD, Setup the serial to output the values, So, rather that the output to the GLCD, send to the Serial terminal.
Then, test with DI pulled down,
I expected FFFFFF and 0
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
This prints nothing to the terminal set to9600 com 9...as uno is com 9.
glcd still connected
#chipmega328p,16
#include<glcd.h>
#optionexplicit;--------------
#defineGLCD_TYPEGLCD_TYPE_ILI9341
#defineGLCD_DCportb.0; DIGITAL_8 ' Data command line
#defineGLCD_CSportb.2; DIGITAL_10 ' Chip select line
#defineGLCD_RESETportb.1; DIGITAL_9 ' Reset line
#defineGLCD_DIportb.4; DIGITAL_12 ' Data in | MISO - Not used therefore not really required
#defineGLCD_DOportb.3; DIGITAL_11 ' Data out | MOSI
#defineGLCD_SCKportb.5; DIGITAL_13 ' Clock Line
#defineILI9341_HardwareSPI' remove/comment out if you want to use software SPI.
#defineUSART_BAUD_RATE9600
#defineUSART_TX_BLOCKING
#defineUSART_DELAY10ms;rename colours to make less typeing
#definebkILI9341_BLACK
#definereILI9341_RED
#definegrILI9341_GREEN
#defineblILI9341_BLUE
#definewhILI9341_WHITE
#definepuILI9341_PURPLE
#defineyeILI9341_YELLOW
#definecyILI9341_CYAN
#definedgILI9341_D_GRAY
#definelgILI9341_L_GRAY
#definesiILI9341_SILVER
#definemaILI9341_MAROON
#defineolILI9341_OLIVE
#defineliILI9341_LIME
#defineaqILI9341_AQUA
#defineteILI9341_TEAL
#definenaILI9341_NAVY
#definefuILI9341_FUCHSIA;GLCDRotate(Portrait);xy=0 top left, optionally you can rotate the screen.GLCDCLSbk;dimpixel_colour_left,pixel_colour_rightaslong;test pixel colour;;testdopset100,100,whpset120,100,bkpixel_colour_left=ReadPixel_ILI9341(100,100)pixel_colour_right=ReadPixel_ILI9341(120,100)hserprintstr32(pixel_colour_left)HSerPrintCRLF;GLCDPrint 70,10,Str32 (pixel_colour_left);GLCDPrint 70,20,Str32 (pixel_colour_right)loop
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Either that or got to click connect...terminal looks complicated.
Removed glcd.
Connected the line on 3.3V side that went to glcd miso and connected to 3.3V got screen capture.
Connecting to 0V gives zeros.
I've tried 3 ili9341 for this and they behave the same with pic and uno. Strange the pic results were better than uno.
Thanks for your time sorting this. I hope it's not an error on my behalf.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
No electricity yesterday. Went off at 515 and back on at 2045. It was very cold in the house!
Anyway... the HSerPrint results are not what we need.
You need two sets of tests.
With the GLCD side of the leveler connected to 0v. We need the reset of the left and right read.
With the GLCD side of the leveler connected to 3v3. We need the reset of the left and right read.
The value of 4294967296 is Zero, you are correct. But this only one read for left. So, this one result give no insight into the root cause of the issue.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Sorry about your supply going. What happened?
Back to uno. Using a new uno board and the clk,mosi and miso on the 6 pin header instead of the digital 10,11 etc. and the glcd still connected. Results HSerPrint and glcdprint-
leftpixel = black = 2147483648
rightpixel=white=2164063484
;
leftpixel = white= 2164063484
rightpixel=black= 2147483648
This seems that the read_pixel works on a uno. I will test more.
When using a pic, as the thread started, black gave a value of 0, not 2147483648
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
"Are these values with the GLCD side of the voltage strapped high and low? If they are then they are meaningless." No, these are working values with the glcd connected and using as normal to test pixel colours.
The original problem with ilirread-rixel with a pic was...as said earlier.
The results now with a uno are different in that if you test a black then a white pixel it gives different results for black and white.
If you test a white pixel then a black pixel it gives the same value for the white pixel as before and same value for black pixel.
On a pic if the first pixel was white and the second pixel was black it read them both as white.
This is not happening using a uno.
Don't have to reply straight away. Sort other priorities first. I like experimenting and trying to sort things myself.
I don't understand what your advice means sometimes...guess you use a phone a lot :)
But again, thanks for your time answering.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Test 1. Force DI to 0V. Write two pixels, the read two pixels and send the value to the terminal.
Test 2. Force DI to %V. Write two pixels, the read two pixels and send the value to the terminal.
The returned values are 24bit color values. So, to understand these numbers AND with 0xFFFFFF.
So, you will get back 0xFCFCFC and 0x00. Which I think is WHITE and BLACK respectively.
These tests are to show that if you strap Low and High the returned values are consistent. This has nothing to do with the write operation but everything to do with the read operation. If the Low test returns 0x00 and the high test returns 0xFCFCFC then we know the circuit is correct and that the code is reading the port correctly.
On new uno and different pins wiring it seems ok.
On the lander prog this works. Note I AND the results with 0xfffff. This gives black as 0,
which is what I wanted and no problems I have with pic.
This could be 6 jumpers stuck next each other ie bad connections on the other uno.
A bit of momentum and increasing gravity and could be nice demo/game.
A poor video,my camera is no good for filming close up cos it uses edge contrast to focus and cls messes it up. https://www.youtube.com/watch?v=lD5kULvRvhs&feature=youtu.be
It shows the values of 2 pixels under the sprite and if it hits left says dead left.
if it hits right it says dead right
if it hits a flat horizontal it says landed.
Code for testing is so simple, in this landscape designed to make it simple.
A few triangles to navigate around and limited fuel?
Should I still test your hardware as it seems to work on uno ok?
edit The following code did not work on a pic at 3.3V...which was the point of this post. Sorry it got side tracked. It was when you said my pic code worked on an uno...and it didn't.
Some where in the libs it says the values for ili9341 colours. I'll try to correlate something.
All is good on avr and just tested on pic and works ok now. samecode with AND 0xfffff.
Strange that without AND 0xfffff the pic gave black as 0 but not uno which gave long number for black.
Think uno version would be better than pic but the code has both, just commented so it's pic or uno. better meaning 18f25k22 not as popular as uno.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
The basics. We write 16bit colors but we read 24bit colors. That is the way it is. So, to test for 24bit colors you need to create a table of 24bit colors. There are many online websites tbat do this conversion. Why? the compare of a constant representing the color will be faster, a lot faster, than the AND of two long variables and then the compare.
So, you know two 24bit colors. fcfcfc and 0. Its a start.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Stay with the PIC until it is resolved.
Post as an attachment the whole program. I will generate an ASM here. I will compare. And, I will post a HEX for you to test.
OK?
Stan... see the next page....
I setup my uno breadboard to use the logic level converter again with ili9341.
chip mega328p,16
include <glcd.h></glcd.h>
option explicit
;--------------
define GLCD_TYPE GLCD_TYPE_ILI9341
define GLCD_DC portb.0 ; DIGITAL_8 ' Data command line
define GLCD_CS portb.2 ; DIGITAL_10 ' Chip select line
define GLCD_RESET portb.1 ; DIGITAL_9 ' Reset line
define GLCD_DI portb.4 ; DIGITAL_12 ' Data in | MISO - Not used therefore not really required
define GLCD_DO portb.3 ; DIGITAL_11 ' Data out | MOSI
define GLCD_SCK portb.5 ; DIGITAL_13 ' Clock Line
define ILI9341_HardwareSPI ' remove/comment out if you want to use software SPI.
if commented --- it's same as pic ie cls then no printing.
It is working in that the display is working...it sets up the screen and sets to portrait and cls to black fine. plots points to test etc. ie ok
Using your last include it says 2164063484 for any read pixel test.
I shall try the code I posted and see.
I shall try the original include as you said it worked,
Thanks for you time.
Hi Anobium. Here is a test that compiles and gives wrong results. I don't get pics but seems to work as far as the display ok just the pixel test is not working as expected.
just change
;test
pset 100,100,ILI9341_WHITE
pset 120,100,ILI9341_BLACK
and see the results.
Cheers.
Last edit: stan cartwright 2020-03-02
asm please.
with
pset 100,100,ILI9341_WHITE
pset 120,100,ILI9341_BLACK
Strange you got uno to work but it always says the same value for me ie does not work at all.
the display functions fine just read pixel not working.
the miso line from ili9341 GLCD_DI to low side of logic converter then to 5V logic DIGITAL_12 on uno.
So I can't get uno to work with pixelread it seems.
OK. Try two tests.
Disconnect the GLCD.
1. Ground the DI line to 0V. Run the code. You will have to write the value to serial port.
2. Pull the DI in line to the operating voltage. Run the code. Again. you will have to write the value to serial port.
Test one should 0 and test two should be FFFFFF or may be FFFFFF.
If both 0... then, look at the volatage leveler.
The logic leveller is bi-directional as tested with a multi-meter.
ie tie any port on 3.3V side high ie 3.3V then 5V side goes high and ground 3.3V side and 5V side goes low.
leave 3.3V side floating and 5V side goes high.
Was that the purpose of the test to see if the logic level converter was working bi-directional?
I meant.
I expected FFFFFF and 0
This prints nothing to the terminal set to9600 com 9...as uno is com 9.
glcd still connected
You need to use HSerPrint.... to show the values.
Either that or got to click connect...terminal looks complicated.
Removed glcd.
Connected the line on 3.3V side that went to glcd miso and connected to 3.3V got screen capture.
Connecting to 0V gives zeros.
Last edit: stan cartwright 2020-03-04
I've tried 3 ili9341 for this and they behave the same with pic and uno. Strange the pic results were better than uno.
Thanks for your time sorting this. I hope it's not an error on my behalf.
Sorry for delay.
No electricity yesterday. Went off at 515 and back on at 2045. It was very cold in the house!
Anyway... the HSerPrint results are not what we need.
You need two sets of tests.
The value of 4294967296 is Zero, you are correct. But this only one read for left. So, this one result give no insight into the root cause of the issue.
Sorry about your supply going. What happened?
Back to uno. Using a new uno board and the clk,mosi and miso on the 6 pin header instead of the digital 10,11 etc. and the glcd still connected. Results HSerPrint and glcdprint-
leftpixel = black = 2147483648
rightpixel=white=2164063484
;
leftpixel = white= 2164063484
rightpixel=black= 2147483648
This seems that the read_pixel works on a uno. I will test more.
When using a pic, as the thread started, black gave a value of 0, not 2147483648
Are these values with the GLCD side of the voltage strapped high and low? If they are then they are meaningless.
"Are these values with the GLCD side of the voltage strapped high and low? If they are then they are meaningless." No, these are working values with the glcd connected and using as normal to test pixel colours.
The original problem with ilirread-rixel with a pic was...as said earlier.
The results now with a uno are different in that if you test a black then a white pixel it gives different results for black and white.
If you test a white pixel then a black pixel it gives the same value for the white pixel as before and same value for black pixel.
On a pic if the first pixel was white and the second pixel was black it read them both as white.
This is not happening using a uno.
Since using ili9341 we are limited to
etc. Would it be easier if the ili9341_read_pixel returned a text variable of the colour instead of a long number ie the colour you typed in the code?
Does 2147483648 mean black and does 2164063484 mean white?
if so it's working. at least it's consistant.
Don't have to reply straight away. Sort other priorities first. I like experimenting and trying to sort things myself.
I don't understand what your advice means sometimes...guess you use a phone a lot :)
But again, thanks for your time answering.
OK. A picture.
Test 1. Force DI to 0V. Write two pixels, the read two pixels and send the value to the terminal.
Test 2. Force DI to %V. Write two pixels, the read two pixels and send the value to the terminal.
The returned values are 24bit color values. So, to understand these numbers AND with 0xFFFFFF.
So, you will get back 0xFCFCFC and 0x00. Which I think is WHITE and BLACK respectively.
These tests are to show that if you strap Low and High the returned values are consistent. This has nothing to do with the write operation but everything to do with the read operation. If the Low test returns 0x00 and the high test returns 0xFCFCFC then we know the circuit is correct and that the code is reading the port correctly.
On new uno and different pins wiring it seems ok.
On the lander prog this works. Note I AND the results with 0xfffff. This gives black as 0,
which is what I wanted and no problems I have with pic.
This could be 6 jumpers stuck next each other ie bad connections on the other uno.
A bit of momentum and increasing gravity and could be nice demo/game.
A poor video,my camera is no good for filming close up cos it uses edge contrast to focus and cls messes it up. https://www.youtube.com/watch?v=lD5kULvRvhs&feature=youtu.be
It shows the values of 2 pixels under the sprite and if it hits left says dead left.
if it hits right it says dead right
if it hits a flat horizontal it says landed.
Code for testing is so simple, in this landscape designed to make it simple.
A few triangles to navigate around and limited fuel?
Should I still test your hardware as it seems to work on uno ok?
edit The following code did not work on a pic at 3.3V...which was the point of this post. Sorry it got side tracked. It was when you said my pic code worked on an uno...and it didn't.
Some where in the libs it says the values for ili9341 colours. I'll try to correlate something.
Last edit: stan cartwright 2020-03-05
I think you are telling us that all is good. Sounds like a connection problem to me.
Add that extra functionality and you have a proper game. I am away for a week, but, hopefully you have it all sorted for when i get back!
All is good on avr and just tested on pic and works ok now. samecode with AND 0xfffff.
Strange that without AND 0xfffff the pic gave black as 0 but not uno which gave long number for black.
Think uno version would be better than pic but the code has both, just commented so it's pic or uno. better meaning 18f25k22 not as popular as uno.
Reply in a month.
top of my head for getting string values from ReadPixel. VERY basic idea.
From the colour values as defined in ili9341 include.
Last edit: stan cartwright 2020-03-06
Not sure.
The basics. We write 16bit colors but we read 24bit colors. That is the way it is. So, to test for 24bit colors you need to create a table of 24bit colors. There are many online websites tbat do this conversion. Why? the compare of a constant representing the color will be faster, a lot faster, than the AND of two long variables and then the compare.
So, you know two 24bit colors. fcfcfc and 0. Its a start.