It's in demos but I just get zeros. no change. It was for mega328p but changed to pic.Same results though.
'''A demonstration program for GCGB and GCB.'''--------------------------------------------------------------------------------------------------------------------------------'''This program is a simple GLCD demonstration of the ILI9341 GLCD read pixel capabilities.'''ThereadpixelroutineonlysupportshardwareSPI.'''It is a nice graphical LCD, suitable for a lot of various projects.'''Thisprogramdrawslines,boxes,circlesandprintsstringsandnumbers.'''The GLCD is connected to the microprocessor as shown in the hardware section of this code.''':'''This has been tested using the hardware SPI option.''':'''Note: for the correct operation of this display you MUST connect via a CD4050, see http://forum.arduino.cc/index.php?topic=181679.90''':'''@author'''@licenceGPL'''@version 1.0'''@date'''******************************************************************************** 'ChipSettings.' #chip mega328p, 16'#optionexplicit''#include<glcd.h>' #include <uno_mega328p.h >'' #define GLCD_TYPE GLCD_TYPE_ILI9341'' 'PinmappingsforSPI-thisGLCDdriversupportsHardwareSPIandSoftwareSPI' #define GLCD_DC DIGITAL_8 'Datacommandline' #define GLCD_CS DIGITAL_10 'Chipselectline' #define GLCD_RESET DIGITAL_9 'Resetline''#defineGLCD_DIDIGITAL_12' Data in | MISO - Not used therefore not really required'#defineGLCD_DODIGITAL_11' Data out | MOSI'#defineGLCD_SCKDIGITAL_13' Clock Line'' #define ILI9341_HardwareSPI 'remove/commentoutifyouwanttousesoftwareSPI.#chip18f25k22,64;picrunningon3.3Vsonocd4050orlogiclevelconverter#configMCLRE=on#optionExplicit#include<glcd.h>#defineGLCD_TYPEGLCD_TYPE_ILI9341'Pin mappings for ILI9341 #define GLCD_DC portc.2 #define GLCD_CS portc.0 #define GLCD_RESET portc.1 'AsweareusingHarwareSPIthiscannotbechangeonthischip.Thisisanon-PPSchip.#defineGLCD_DIportc.4#defineGLCD_DOportc.5#defineGLCD_SCKportc.3#defineILI9341_hardwarespi'GLCD selected extension font set. ASCII characters 31-254, the extended font uses 1358 bytes of program memory #define GLCD_EXTENDEDFONTSET1 GLCDfntDefaultsize = 1 'GLCDCLSsupportsGLCDBackgroundasdefault'GLCDCLS also support passing color parameter. 'GLCDCLS[color]GLCDRotate(Landscape_rev)' optionally you can rotate the screen. 'Availablecolors'ILI9341_BLACK 'ILI9341_RED'ILI9341_GREEN 'ILI9341_BLUE'ILI9341_WHITE 'ILI9341_PURPLE'ILI9341_YELLOW 'ILI9341_CYAN'ILI9341_D_GRAY 'ILI9341_L_GRAY'ILI9341_SILVER 'ILI9341_MAROON'ILI9341_OLIVE 'ILI9341_LIME'ILI9341_AQUA 'ILI9341_TEAL'ILI9341_NAVY 'ILI9341_FUCHSIAdimpixcolaslongdimsetpixcolaswordGLCDRotate(Landscape_rev)' optionally you can rotate the screen. GLCDCLS ILI9341_BLACK 'SetupaboveherePset0,0,ILI9341_REDPset1,1,ILI9341_WHITEPset2,2,ILI9341_REDdopixcol=ReadPixel_ILI9341(0,0)GLCDPrint10,10,hex(pixcol_U)GLCDPrint26,10,hex(pixcol_H)GLCDPrint42,10,hex(pixcol)pixcol=ReadPixel_ILI9341(1,1)GLCDPrint10,20,hex(pixcol_U)GLCDPrint26,20,hex(pixcol_H)GLCDPrint42,20,hex(pixcol)pixcol=ReadPixel_ILI9341(2,2)GLCDPrint10,30,hex(pixcol_U)GLCDPrint26,30,hex(pixcol_H)GLCDPrint42,30,hex(pixcol)Pset3,3,setpixcol:setpixcol=setpixcol+16pixcol=ReadPixel_ILI9341(3,3)GLCDPrint10,40,hex(pixcol_U)GLCDPrint26,40,hex(pixcol_H)GLCDPrint42,40,hex(pixcol)loopend
Same results using uno. the display working ok otherwise. Hardware spi is working.
Reading pixe does not seem to work for me.
It is needed for games.
The pic code is same as the uno in demos
Have you tried this demo? C:\GCB@Syn\GreatCowBasic\Demos\glcd_solutions\glcd_read_glcd_pixel_solutions\glcd_read_demonstation_mega328p_for_ili9341@16.gcb
As it a demo. It must have worked. Has it stopped working?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
'returns a 24bit pixel color value... as GCB uses a 16bit color value the user will need to complete conversionFunction ReadPixel_ILI9341(In ILI9341_GLCDX as word, In ILI9341_GLCDY as word ) as long DIM ILI9341TempOut as byte set ILI9341_CS OFF set ILI9341_DC OFF SPITransfer ILI9341_CASET, ILI9341TempOut set ILI9341_DC ON; SPITransfer ILI9341_GLCDX_h, ILI9341TempOut SPITransfer ILI9341_GLCDX, ILI9341TempOut SPITransfer ILI9341_GLCDX_h, ILI9341TempOut SPITransfer ILI9341_GLCDX, ILI9341TempOut set ILI9341_DC OFF SPITransfer ILI9341_PASET, ILI9341TempOut set ILI9341_DC ON SPITransfer ILI9341_GLCDY_h, ILI9341TempOut SPITransfer ILI9341_GLCDY, ILI9341TempOut SPITransfer ILI9341_GLCDY_h, ILI9341TempOut SPITransfer ILI9341_GLCDY, ILI9341TempOut set ILI9341_DC OFF SPITransfer ILI9341_RAMRD, ILI9341TempOut set ILI9341_DC ON SPITransfer 1, ReadPixel_ILI9341_e 'dummyread-usethehighestbyteSPITransfer2,ReadPixel_ILI9341_uSPITransfer3,ReadPixel_ILI9341_hSPITransfer4,[byte]ReadPixel_ILI9341setILI9341_CSONEndFunction
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Ignoring the CD and DC lines as they are pretty obvious.
Get the datasheet out. This is what is happening.
CASET sets the X positional window. This creates a one pixel window
PASET sets the Y positional window. This creates a one pixel window
So, at this point we have created a windows in the GLCD ram of 1 pixel window.
RAMRD reads the ram position created by the window.
Then, read the bytes into the long. And, we need to read one dummy and then three bytes.
Most of the GLCD have this method as this is correct method.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Nice one Anobium. It's a nice .h lib. I managed to write word data ie 8 pixels a while back for sprites.
Seeing if given pixel is not background colour is needed for games.
I was thinking of Lunar Lander. It could be as simple as "A" with "v" under as flame...or a sprite.
Drawing would be to slow I think. Simulating gravity is fun and the movement is only one pixel at a time so easyish.
Any game suggestions? Is scrolling land scape possible? ie erase chars, scroll,reprint chars, so it looks like they're moving...when they not really.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
It DOES work!
Stupid me got miso line wrong connection.
Please delete all my help requests and please accept my sincere apologies for wasting peoples time.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
It's in demos but I just get zeros. no change. It was for mega328p but changed to pic.Same results though.
Last edit: stan cartwright 2020-01-20
Is this related to this post https://sourceforge.net/p/gcbasic/discussion/579125/thread/353df810b9/ ?
this post https://sourceforge.net/p/gcbasic/discussion/projects%26guides/thread/4ef9436f/ ?
this post https://sourceforge.net/p/gcbasic/discussion/579126/thread/f3b27f0c/?limit=250#08f2 ?
Stan - there are so many posts on this subject.
I think it's related to the Ili9341 display in use.
I tried
but got ff ff ff then 00 00 00 then just 00 00 00
I use a nano for this but it includes #include <uno_mega328p.h>
is that a problem? I like to use the port names like pic.</uno_mega328p.h>
Stan - can you confirm all is good on the UNO?
And, where is the PIC code? attach please.
Gimme time to wire it to uno...set up for nano..diplay works ok.
Same results using uno. the display working ok otherwise. Hardware spi is working.
Reading pixe does not seem to work for me.
It is needed for games.
The pic code is same as the uno in demos
Have you tried this demo? C:\GCB@Syn\GreatCowBasic\Demos\glcd_solutions\glcd_read_glcd_pixel_solutions\glcd_read_demonstation_mega328p_for_ili9341@16.gcb
As it a demo. It must have worked. Has it stopped working?
It is the one I used. nano first,then pic, then uno.
I'm not suggesting it's stopped working. It's obviously me, I'm getting too old for this.
I can look in a few days. Busy at mo
It's a hard include to understand...ili9341.h
That is pretty simple code.
Ignoring the CD and DC lines as they are pretty obvious.
Get the datasheet out. This is what is happening.
CASET sets the X positional window. This creates a one pixel window
PASET sets the Y positional window. This creates a one pixel window
So, at this point we have created a windows in the GLCD ram of 1 pixel window.
RAMRD reads the ram position created by the window.
Then, read the bytes into the long. And, we need to read one dummy and then three bytes.
Most of the GLCD have this method as this is correct method.
Nice one Anobium. It's a nice .h lib. I managed to write word data ie 8 pixels a while back for sprites.
Seeing if given pixel is not background colour is needed for games.
I was thinking of Lunar Lander. It could be as simple as "A" with "v" under as flame...or a sprite.
Drawing would be to slow I think. Simulating gravity is fun and the movement is only one pixel at a time so easyish.
Any game suggestions? Is scrolling land scape possible? ie erase chars, scroll,reprint chars, so it looks like they're moving...when they not really.
Have a look at what others have created on othr platforms. This will give you ideas.
But, if you have time. Port FortNite.
It'll take two weeks :)
I don't know why this always returns 0 for pset any colour-
It DOES work!
Stupid me got miso line wrong connection.
Please delete all my help requests and please accept my sincere apologies for wasting peoples time.
A black background is 00 00 00....anything else is not...so can check if sprite has hit anything.