![]() |
Forum Index : Microcontroller and PC projects : My first graphical program in mmbasic on pico
Author | Message | ||||
nbrok![]() Regular Member ![]() Joined: 13/02/2023 Location: NetherlandsPosts: 60 |
Hi, I found an analog clock on the internet written in the predecessor of mmbasic and modified the code so it runs on the pico. I use a 240*230 spi TFT display. Now i have a real analog clock. Here is the code. 'A very simple analog clock SetPin gp12,dout 'Define backlight LED Pin(gp12)=1 'Turn LED on CLS black 'Clear tft display xo=MM.HRes-160:yo=MM.VRes-120:r=100 'Draw circle in middle of the screen tau=8*Atn(1) x=0:y=0 Circle xo,yo,r,3,1,&hff0000 'The border of the circle is RED ti$=Time$ 'Get the current time s=Val(Mid$(ti$,7)) 'Make s,m,h m=Val(Mid$(ti$,4,2))+s/60 h=Val(Left$(ti$,2))+m/60 drawclock 'Draw the clock settick 1000,tick 'Generate interrupt once per second do pause 62000 loop sub tick drawclock 'Draw the clock end sub settick 0,0 end Sub drawclock t=s/60 x=xs:y=ys c=&hffff rh=0.925*r draws c=&Hffffff xs=x:ys=y t=m/60 x=xm:y=ym:rh=0.9*r draws xm=x:ym=y t=(h-12*(h>=12))/12 x=xh:y=yh:rh=0.55*r draws xh=x:yh=y:rh=r-1 s=s+1 m=m+1/60 h=h+1/3600 End Sub Sub draws Line xo,yo,x+xo,y+yo,1,0 theta=-tau*t+tau/4 x=rh*Cos(theta) y=-rh*Sin(theta) Line xo,yo,x+xo,y+yo,1,c End Sub I hope you have also fun with it. Edited 2023-02-17 19:10 by nbrok Greetings, Nick de pe1goo |
||||
Volhout Guru ![]() Joined: 05/03/2018 Location: NetherlandsPosts: 5091 |
Welkom bij het forum Nick ! Leuk projectje. En het begin van het programma is goed gecommentarieert. Gelukkig levert de wiskunde erachter geen problemen op voor mij. Gezien jouw oevre als schrijver, wat dacht je van een (text) adventure game gebaseerd op een van je boeken..?? Volhout English: welcome to the forum Nick. Nice project, the beginning is well commented, the math at the end is not, but I understand what it does. Since you are a novel writer, what about creating a (text) adventure for picomite, based on one of your novels ? Edited 2023-02-17 20:26 by Volhout PicomiteVGA PETSCII ROBOTS |
||||
Mixtel90![]() Guru ![]() Joined: 05/10/2019 Location: United KingdomPosts: 7938 |
Novels? He won't have time for those now he's discovered the PicoMite. :) Mick Zilog Inside! nascom.info for Nascom & Gemini Preliminary MMBasic docs & my PCB designs |
||||
Martin H.![]() Guru ![]() Joined: 04/06/2022 Location: GermanyPosts: 1234 |
So true .. ![]() ![]() ![]() Edited 2023-02-17 22:02 by Martin H. 'no comment |
||||
nbrok![]() Regular Member ![]() Joined: 13/02/2023 Location: NetherlandsPosts: 60 |
I can do more then one project ![]() ![]() Greetings, Nick de pe1goo |
||||
IanRogers![]() Senior Member ![]() Joined: 09/12/2022 Location: United KingdomPosts: 151 |
I can do more then one project Scrumpel (6809,68K), Pico, and a new story to write and a text adventure..LOL I'd give my left arm to be ambidextrous |
||||
Martin H.![]() Guru ![]() Joined: 04/06/2022 Location: GermanyPosts: 1234 |
I can do more then one project ![]() ![]() 6809? my favorite (8 Bit)? CPU at the 80th. .. maybe one day I find the time to write an 6809 Emulator for the Pico in MM-Basic (somehow like the one on 6809.uk ) Cheers Mart!n Edited 2023-02-17 23:49 by Martin H. 'no comment |
||||
Mixtel90![]() Guru ![]() Joined: 05/10/2019 Location: United KingdomPosts: 7938 |
Ah... An idea.... Write a Nascom-1 simulator in MMBasic. :) Yay! I've got a temporary SD card working on my PicX now. :) Mick Zilog Inside! nascom.info for Nascom & Gemini Preliminary MMBasic docs & my PCB designs |
||||
Martin H.![]() Guru ![]() Joined: 04/06/2022 Location: GermanyPosts: 1234 |
Write a Nascom-1 simulator in MMBasic. :) Yay! I've got a temporary SD card working on my PicX now. :) Of course it wouldn't mach the Speed of the CPU, I thought it rather to visualize what is going on in the CPU, the state of the registers, ports and memory when executing the program 'no comment |
||||
Mixtel90![]() Guru ![]() Joined: 05/10/2019 Location: United KingdomPosts: 7938 |
Doesn't need to for the Nascom-1. It would have to interact with the user like the monitor does. You don't see data changing in real time, but you can set a breakpoint in the code and single-step it. Tell the program to run and it will write stuff to the screen, of course, so there would be a speed difference there but that probably doesn't matter. Even running MMBasic a PicoMite is pretty fast compared to a 2MHz Z80 (which, IIRC, actually carries out instructions at 500kHz because of the way the clock works). I envisage a simulator rather than an emulator, which would be much more complex. Hmmmm.... will have a think... Mick Zilog Inside! nascom.info for Nascom & Gemini Preliminary MMBasic docs & my PCB designs |
||||
stanleyella![]() Guru ![]() Joined: 25/06/2022 Location: United KingdomPosts: 2567 |
@nbrok, Hi, I wrote an analogue clock to test with floating point as my pic clock was not floating point. Picomite was better. Hope you have fun using picomite, both vga and non vga versions. I'm finding mmbasic picomite very interesting and didn't cost much money. |
||||
stanleyella![]() Guru ![]() Joined: 25/06/2022 Location: United KingdomPosts: 2567 |
Mick - nostalgia from working in a video games factory that made universal games into cabinets. a free tool for analysing logic. You were supposed to fix faulty ram with these. ![]() Edited 2023-02-18 06:20 by stanleyella |
||||
nbrok![]() Regular Member ![]() Joined: 13/02/2023 Location: NetherlandsPosts: 60 |
Here the latest version of my clock: In upper left corner the date is displayed and on the right corner de day of the week: 'A very simple analog clock with digital date and name of weekday backlight 50 'Backlight on 50% cls 'Clear tft display xo=MM.HRes-160:yo=MM.VRes-120:r=100 'Circle is positioned in the middle of 'the sceen with a diameter of 200 pixels tau=8*Atn(1) x=0:y=0 circle xo,yo,r,3,1,&hff0000 'Colour of the circle is red csl=r*0.09 for dd= o to 360 step +30 'Draw every 30 degrees a small line x1=fix(sin(rad(dd)) * r) y1=fix(cos(rad(dd)) * r) x2=fix(sin(rad(dd)) * (r+csl)) y2=fix(cos(rad(dd)) * (r+csl)) line x1+xo,y1+yo,x2+xo,y2+yo,3,&hff0000 next dd ti$=Time$ 'Get the current time s=Val(Mid$(ti$,7)) 'Convert s,m en h in degrees on circle m=Val(Mid$(ti$,4,2))+s/60 h=Val(Left$(ti$,2))+m/60 drawclock 'Draw the clock settick 1000,tick 'Once per second draw the clock do pause 62000 loop sub tick drawclock 'Draw the clock end sub settick 0,0 end Sub drawclock Text 0,0,Date$,l,7,2 'Place date Text 210,0,Day$(now)+" ",l,7,2 'Place day of week t=s/60 x=xs:y=ys c=&hffff rh=0.925*r draws 'Draw the second hand in Cyan c=&Hffffff xs=x:ys=y t=m/60 x=xm:y=ym:rh=0.9*r draws 'Draw minute hand in white xm=x:ym=y t=(h-12*(h>=12))/12 x=xh:y=yh:rh=0.55*r draws 'Draw hour hand in white xh=x:yh=y:rh=r-1 s=s+1 'Increment the time per second m=m+1/60 h=h+1/3600 End Sub Sub draws Line xo,yo,x+xo,y+yo,1,0 theta=-tau*t+tau/4 x=rh*Cos(theta) y=-rh*Sin(theta) Line xo,yo,x+xo,y+yo,1,c End Sub ![]() Edited 2023-02-27 01:41 by nbrok Greetings, Nick de pe1goo |
||||
![]() |
![]() |
The Back Shed's forum code is written, and hosted, in Australia. | © JAQ Software 2025 |