Hi. I've been scratching my head over changing the ili9341 glcd plot routine so that any pixels plotted x<0 y<0 change to glcdwidth or glcdheight. Think of "Asteroids" where rocks go off one edge to appear the other.
I had some success with the posted code. If glcdx and glcdy are words then decreaseing below 0 is 65535 ?
It sort of works with a sprite routine and draw a square and erase it. A vid of it not working properly if any help.
Sub PSet_ILI9341(In GLCDX as word, In GLCDY as word, In GLCDColour As Word)
;******** pixel wrap around **********
if glcdx>319 then
glcdx=glcdx-320
else
if glcdx>32768 then
glcdx=320-(65535-glcdx)
end if
end if
;
if glcdy>239 then
glcdy=glcdy-240
else
if glcdy>32768 then
glcdy=240-(65535-glcdy)
end if
end if
;
SetAddressWindow_ILI9341 ( GLCDX, GLCDY, GLCDX, GLCDY )
SendWord_ILI9341 GLCDColour
End Sub
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I'm just starting to get into graphical displays, so your post intrigued me. But, I am a bit confused about a couple things in your code.
First, isn't the ILI9341 a 240x320 display (ie. x=240 and y=320)? You have them reversed.
Second, if it is indeed a 240(X) by 320(Y) display, why should X ever be greater than 240 regardless of whether or not it is a word value. Similarly, if Y = 321 then Y=1, or if Y = -1 then Y = 320. What am I missing?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Let me be very clear - this ILI9341 PSET method is not from the standard library. ILI9341 PSET is not like this in the standard library.
Re your questions. You can ROTATE a number of the displays - this is one of those. And, as Stan will discover the trying to test LONG values with WORD variables may yeild very odd results.
Always, always create you own library like this and then redirect the call to your method. It is the ONLY safe method to create specific library functions. Edit the standard library is 100% supported, but, editing (not using redirect) is highlly likely to lead to issues on upgrades.
If I were writing a game I would not be checking the pixel position for out of bounds conditions in PSET.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Tell us the version of the compiler and the date of the compiler. Without this we can only guess.
And, I would not be changing the stock libaries - use #define to redirect to your version of the method. Like #define PSet StansVerySpecificVersionofPSET then when you upgrade to the next release you not loose any of your good work.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I'm using v.97.01 2017-02-20 and the glcd that came with.
I tried
dim glcdx,glcdy,glcdcolour as word
glcdx=1:glcdy=100:glcdcolour=ILI9341_FUCHSIA
for py=0 to 3
PSet_ILI9341 (glcdx,glcdy,glcdcolour)
GLCDPrint (0,py*16,str32(glcdx),ILI9341_WHITE)
glcdx=glcdx-1
next
This printed
1
10
22
22
dunno why. Should 22 be 65535, 65534 ?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Post your adapted PSet_ILI9341 ... but, I said... you should NOT be adapting PSet_ILI9341 by your own adaption of PSet_ILI9341 called something like PSet StansVerySpecificVersionofPSET.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
T Lee Davidson- Hi. By changing the plot routine, if I move graphic plotted shapes or draw shapes as in old ateroids,they have say x,y coords and a direction x,y which can be plus or minus val for how many pixels to move and is added to the x,y co-ords. If a x,y val is <0 then it appears on the opposite side of the display.What is a word value if decreased below zero? 65535 I thought. So basically I'm testing for how <0 is done with the dim as word glcd vars for x,y. Interesting and sort of working fast enough for a game. (I wrote my own asteroids in z80 for amstrad once).
Anobium, I will try using set column,row,write byte one day. The ili9341 is,to me,more complex than the ssd1306. SetAddressWindow_ILI9341 ( GLCDX, GLCDY, GLCDX, GLCDY ) is new and writing bytes is setting hardware on off. It seems complicated.
I also find using method to access gcb include difficult. I only have the test pixel status for ssd1306 you published as a guide.
I need to revise variable useage again. Str32(var) is mentioned once and it's not under str in search.
If you could say what happens to a var defined as word and it's value if decreased below zero as in display coords,safe,as printing them gives silly values. I can then sort out fastest display..lines or plotting a sprite. I think the sprite faster as every pixel position is predefined but 16x16 sprite is lots mem although only lit pixels plotted.
I think asteroids is do-able on a uno or pic with 240x320 display, that's like an 80's tv display and the z80 ran at 10MHz.
Any advice appreciated.
PS adapted pset 1st post
Last edit: stan cartwright 2017-09-18
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I know GCB is free and I always ask questions but I use GCB a lot and I have lots of questions.
Just one
If I add a signed var to a word var..should it work? I get programs that flash hex yet say internal type error yet seem to work.
eg signedvar= - 5
wordvar=300
wordvar=signedvar+wordvar
is wordvar=295?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
DIMmyStringasstring*28myString="Great Cow BASIC 2017"dimsignedvarasIntegerdimwordvaraswordsignedvar=-5wordvar=300wordvar=signedvar+wordvarGLCDPrint(0,0,wordvar)GLCDDrawString(20,25,myString)'to ensure the GLCD is operating as expected
The answer is...
295
So, probably you have not told us the whole story. You are trying to do this in some subroutine and you have either messed up the use of variable types or you need to cast the calculations.
Stan - simplify the issue. Create a little test program and then all will become clear.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
OK. Please look at the Help for Variable Lifecycle. This should help clarify.
The example program, that I may put in the Help, shows the result on a GLCD. Change to a LCD or serial to suit you needs.
1) Change the following and see the result.
* in wordvarsub , in intvarsub change to as type
2) Remove the following and see the result
'Ensure the variable type is correct in this methoddimwordvarsubasword'Ensure the variable type is correct in this methoddimintvarsubasInteger
3) Change the casting on this line subcalculation = wordvarsub + intvarsub
Change the code and see the results - the answer should be 95 if it not - try to figure why after thinking about the scope of variables.
Enjoy
'See Variable Lifecycle in the HELPdimmyStringasstring*28myString="Great Cow BASIC 2017"GLCDDrawString(20,24,myString)dimsignedvarasIntegerdimwordvar,wordresultaswordsignedvar=-5wordvar=300wordresult=signedvar+wordvarGLCDPrint(0,0,wordresult)MyCalc(wordvar,signedvar)subMyCalc(inwordvarsub,inintvarsub)'you want to define you input variable types here to support overloading of the same method'Ensure the variable type is correct in this methoddimwordvarsubasword'Ensure the variable type is correct in this methoddimintvarsubasInteger'Define the assignment variabledimsubcalculationaswordsubcalculation=wordvarsub+intvarsubGLCDPrint(0,8,subcalculation)GLCDPrint(24,8,wordvarsub)GLCDPrint(48,8,intvarsub)endsub
Thanks. I read it many times..and dim..all help.
Using ILI9341, it's 320 x and 240 y using landscape mode...safe
I set a x and y pset coord and then printed and plotted it on the display then increased/decreased the values.
What I found is that using x and y as word vars a pixel pset x will go off screen until it's value is 511 then reappear at pset x=0.
Also pset y goes off screen until it's value is 255 then it reappears at pset y=0.
So now I know what <0 is..yes?*!?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi. I've been scratching my head over changing the ili9341 glcd plot routine so that any pixels plotted x<0 y<0 change to glcdwidth or glcdheight. Think of "Asteroids" where rocks go off one edge to appear the other.
I had some success with the posted code. If glcdx and glcdy are words then decreaseing below 0 is 65535 ?
It sort of works with a sprite routine and draw a square and erase it. A vid of it not working properly if any help.
I'm just starting to get into graphical displays, so your post intrigued me. But, I am a bit confused about a couple things in your code.
First, isn't the ILI9341 a 240x320 display (ie. x=240 and y=320)? You have them reversed.
Second, if it is indeed a 240(X) by 320(Y) display, why should X ever be greater than 240 regardless of whether or not it is a word value. Similarly, if Y = 321 then Y=1, or if Y = -1 then Y = 320. What am I missing?
Let me be very clear - this ILI9341 PSET method is not from the standard library. ILI9341 PSET is not like this in the standard library.
Re your questions. You can ROTATE a number of the displays - this is one of those. And, as Stan will discover the trying to test LONG values with WORD variables may yeild very odd results.
Always, always create you own library like this and then redirect the call to your method. It is the ONLY safe method to create specific library functions. Edit the standard library is 100% supported, but, editing (not using redirect) is highlly likely to lead to issues on upgrades.
If I were writing a game I would not be checking the pixel position for out of bounds conditions in PSET.
Tell us the version of the compiler and the date of the compiler. Without this we can only guess.
And, I would not be changing the stock libaries - use #define to redirect to your version of the method. Like
#define PSet StansVerySpecificVersionofPSET
then when you upgrade to the next release you not loose any of your good work.I'm using v.97.01 2017-02-20 and the glcd that came with.
I tried
This printed
1
10
22
22
dunno why. Should 22 be 65535, 65534 ?
Post your adapted PSet_ILI9341 ... but, I said... you should NOT be adapting PSet_ILI9341 by your own adaption of PSet_ILI9341 called something like PSet StansVerySpecificVersionofPSET.
T Lee Davidson- Hi. By changing the plot routine, if I move graphic plotted shapes or draw shapes as in old ateroids,they have say x,y coords and a direction x,y which can be plus or minus val for how many pixels to move and is added to the x,y co-ords. If a x,y val is <0 then it appears on the opposite side of the display.What is a word value if decreased below zero? 65535 I thought. So basically I'm testing for how <0 is done with the dim as word glcd vars for x,y. Interesting and sort of working fast enough for a game. (I wrote my own asteroids in z80 for amstrad once).
Anobium, I will try using set column,row,write byte one day. The ili9341 is,to me,more complex than the ssd1306. SetAddressWindow_ILI9341 ( GLCDX, GLCDY, GLCDX, GLCDY ) is new and writing bytes is setting hardware on off. It seems complicated.
I also find using method to access gcb include difficult. I only have the test pixel status for ssd1306 you published as a guide.
I need to revise variable useage again. Str32(var) is mentioned once and it's not under str in search.
If you could say what happens to a var defined as word and it's value if decreased below zero as in display coords,safe,as printing them gives silly values. I can then sort out fastest display..lines or plotting a sprite. I think the sprite faster as every pixel position is predefined but 16x16 sprite is lots mem although only lit pixels plotted.
I think asteroids is do-able on a uno or pic with 240x320 display, that's like an 80's tv display and the z80 ran at 10MHz.
Any advice appreciated.
PS adapted pset 1st post
Last edit: stan cartwright 2017-09-18
A short of 16x16 pixel line box https://www.youtube.com/watch?v=Rx3VidBFBFk&feature=youtu.be
a short of sprite 12x12 plotted box https://youtu.be/1q8-7mKRjJ0
see the problem? sorry about tv sound,I forgot
I know GCB is free and I always ask questions but I use GCB a lot and I have lots of questions.
Just one
If I add a signed var to a word var..should it work? I get programs that flash hex yet say internal type error yet seem to work.
eg signedvar= - 5
wordvar=300
wordvar=signedvar+wordvar
is wordvar=295?
Looks ok here.
The answer is...
So, probably you have not told us the whole story. You are trying to do this in some subroutine and you have either messed up the use of variable types or you need to cast the calculations.
Stan - simplify the issue. Create a little test program and then all will become clear.
OK. Please look at the Help for
Variable Lifecycle
. This should help clarify.The example program, that I may put in the Help, shows the result on a GLCD. Change to a LCD or serial to suit you needs.
1) Change the following and see the result.
*
in wordvarsub , in intvarsub
change toas type
2) Remove the following and see the result
3) Change the casting on this line
subcalculation = wordvarsub + intvarsub
Change the code and see the results - the answer should be 95 if it not - try to figure why after thinking about the scope of variables.
Enjoy
See https://github.com/Anobium/Great-Cow-BASIC-Demonstration-Sources/blob/master/Maths%20Solution/Variable%20Scope%20Solutions/Variable_LifeCycle.gcb
Last edit: Anobium 2017-09-19
Thanks. I read it many times..and dim..all help.
Using ILI9341, it's 320 x and 240 y using landscape mode...safe
I set a x and y pset coord and then printed and plotted it on the display then increased/decreased the values.
What I found is that using x and y as word vars a pixel pset x will go off screen until it's value is 511 then reappear at pset x=0.
Also pset y goes off screen until it's value is 255 then it reappears at pset y=0.
So now I know what <0 is..yes?*!?