I looked up Bresenham's line algo and there'a a basic..just basic,not bbc basic or commodore basic but it converted easy to gcb. I did it because I had wanted to draw lines slowly ie a pixel every program loop.
It was for a game.
Anyway the code is simple and fast. I am amazed it worked and understand integer variables better.... the minus variables. https://www.youtube.com/watch?v=r0qR1BwdXf0&feature=youtu.be
#chipmega328p,16
#optionexplicit
#include<glcd.h>
#include<uno_mega328p.h>
#defineGLCD_TYPEGLCD_TYPE_ILI9341'Pin mappings for SPI - this GLCD driver supports Hardware SPI and Software SPI
#defineGLCD_DCDIGITAL_8' Data command line
#defineGLCD_CSDIGITAL_10' Chip select line
#defineGLCD_RESETDIGITAL_9' Reset line
#defineGLCD_DIDIGITAL_12' Data in | MISO - Not used therefore not really required
#defineGLCD_DODIGITAL_11' Data out | MOSI
#defineGLCD_SCKDIGITAL_13' Clock LineGLCDRotate(Landscape_Rev)GLCDCLSILI9341_Blackdimdx,dy,sx,sy,er,e2asintegerdimx2,x1,y1,y2aswordx1=random :y1=random:x2=random:y2=random;this the draw line routinedraw:
DX=ABS(X2-X1):SX=-1:IFX1<X2THENSX=1DY=ABS(Y2-Y1):SY=-1:IFY1<Y2THENSY=1ER=-DY:IFDX>DYTHENER=DXER=ER/2pixel:
psetX1,Y1,ILI9341_WHITEIFX1=X2ANDY1=Y2THENx1=x2:y1=y2:x2=random:y2=random:gotodrawE2=ERIFE2>-DXTHENER=ER-DY:X1=X1+SXIFE2<DYTHENER=ER+DX:Y1=Y1+SYGOTOpixel
slow cos of using random
Last edit: stan cartwright 2020-06-03
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
so short. got rid of x1=x2 and y1=y2 as it wasted a test every loop.
Getting rid of the goto ...I gave up.
This is pretty fast. how to time it draw 1000 lines and compare to glcd
In my code there's er=er/2. would rotate er right simple be faster?
it's in the init not the main loop so only occurs once but if I draw lots of lines it might matter.
the init in the glcd line uses multiply a few times.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I looked up Bresenham's line algo and there'a a basic..just basic,not bbc basic or commodore basic but it converted easy to gcb. I did it because I had wanted to draw lines slowly ie a pixel every program loop.
It was for a game.
Anyway the code is simple and fast. I am amazed it worked and understand integer variables better.... the minus variables.
https://www.youtube.com/watch?v=r0qR1BwdXf0&feature=youtu.be
slow cos of using random
Last edit: stan cartwright 2020-06-03
so short. got rid of x1=x2 and y1=y2 as it wasted a test every loop.
Getting rid of the goto ...I gave up.
This is pretty fast. how to time it draw 1000 lines and compare to glcd
Last edit: stan cartwright 2020-06-03
the line draw in glcd.h is longer
In my code there's er=er/2. would rotate er right simple be faster?
it's in the init not the main loop so only occurs once but if I draw lots of lines it might matter.
the init in the glcd line uses multiply a few times.
seems gcb line drew a line 17.19 times a second
and mine 16.88 times a second.