![]() |
Forum Index : Microcontroller and PC projects : MM2: Graphics - please upgrade
Author | Message | ||||
matherp Guru ![]() Joined: 11/12/2012 Location: United KingdomPosts: 10182 |
Hi If you are playing with the graphics routines please upgrade to these latest versions. Huge thanks are due to Peter Carnergie (G8JCF) for steering me through some changes to the cFunctions which have helped increase speed and reduce the size. The cFunctions now also include the line draw and there is a nice demo of it in the "main" program. The screen refresh has been further optimised and the worst case for a screen update is now 58msec. Text character drawing is all in cFunctions and is 20x faster than the version that was posted at the start of the last thread. I've gone back to "OPTION DEFAULT INTEGER" in this code as the numerous "AS INTEGER" definitions take unnecessary space. The attached file includes both the complete basic program and the c-source. Enjoy ![]() 2014-11-30_195956_graphicstest-ssd1306.zip |
||||
plasma Guru ![]() Joined: 08/04/2012 Location: GermanyPosts: 437 |
Great ! Thx a lot |
||||
matherp Guru ![]() Joined: 11/12/2012 Location: United KingdomPosts: 10182 |
Try this as a nice little demo - analogue voltmeter display. Just replace the existing demo program from INIT: to the top of the SSD1306 display specific routines with the attached. init: dim float i,voltage,lastvoltage initSdisplay 'initialise the display AddrOfFont=PEEK(CFunAddr FONT) ' Main: dcirc(63,63,58) dcirc(63,63,63) crect(0,56,7,8) crect(121,56,7,8) gvect(63,63,53,63,277.5) gvect(63,63,53,63,82.5) gvect(63,63,53,63,327.5) gvect(63,63,53,63,17.5) gvect(63,63,53,63,67.5) for i=282.5 to 360+77.5 step 5 gvect(63,63,58,63,i) next i s_refresh lastvoltage=1 do voltage=0 do dvect(off,63,63,51,lastvoltage*50+277.5) dvect(on,63,63,51,voltage*50+277.5) lastvoltage=voltage frect(62,61,3,3) s_refresh voltage=voltage+0.1 loop while voltage<=3.3 do dvect(off,63,63,51,lastvoltage*50+277.5) dvect(on,63,63,51,voltage*50+277.5) lastvoltage=voltage frect(62,61,3,3) s_refresh voltage=voltage-0.1 loop while voltage>=0 loop end ' sub gvect(x0,y0,startlength,endlength,angle as float) local x1,x2,y1,y2,dp local float radians radians=rad((450-angle) mod 360) y1=y0-startlength*sin(radians) x1=x0+startlength*cos(radians) y2=y0-endlength*sin(radians) x2=x0+endlength*cos(radians) dp=draw(drawline,sc(),on,x1,y1,x2,y2,rot,wi,ht) end sub ' sub dvect(onoff,x0,y0,length,angle as float) local x1,y1,dp local float radians radians=rad((450-angle) mod 360) y1=y0-length*sin(radians) x1=x0+length*cos(radians) dp=draw(drawline,sc(),onoff,x0,y0,x1,y1,rot,wi,ht) end sub |
||||
WhiteWizzard Guru ![]() Joined: 05/04/2013 Location: United KingdomPosts: 2931 |
@matherp EXCELLENT ![]() The code you posted at the top of this page works absolutely brilliantly - now fast enough to be 'pleasing' to the eye. And the voltmeter code makes a nice demo as to what is now achievable. This is an excellent example of the use of CFunctions to gain the necessary speed that MMBasic otherwise wouldn't allow. I am yet to go through your update in detail (lack of time) but want to say that for anyone about to play with OLEDs then this is a FANTASTIC place to start. Great code Peter - THANKS AGAIN . . . . |
||||
![]() |
![]() |
The Back Shed's forum code is written, and hosted, in Australia. | © JAQ Software 2025 |