Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.
|
Forum Index : Microcontroller and PC projects : PicoMite "Analogue Clock"
Page 3 of 3 | |||||
Author | Message | ||||
Mixtel90 Guru Joined: 05/10/2019 Location: United KingdomPosts: 6798 |
@stanleyella That's just proof that you have a larger monitor than the one I'm using, Stan, and better eyes! I couldn't fit that much text on my screen and have it anywhere close to readable. It doesn't illustrate the point that using that editor removes any confusing errors that you see when testing hardware that you aren't familiar with though. When you are in that situation and you want help with it it doesn't matter how pretty your editor is. MMBasic is supported using the built-in editor and Tera Term under Windows 10/11. If you have a problem and are using a different setup then you should revert to that until it's proved that your hardware is ok. If you still have a problem when you go back to your favourite setup then it's your setup that's at fault - and that's not supported as part of MMBasic. Mick Zilog Inside! nascom.info for Nascom & Gemini Preliminary MMBasic docs & my PCB designs |
||||
stanleyella Guru Joined: 25/06/2022 Location: United KingdomPosts: 2129 |
It is a doddle in mmedit. Just using mmedit I learnt lots about mmbasic I would not have otherwise. It is a download on geoff's picomite download page. I remember ps2 mice with a ball. times change. wifi/blue tooth laser now. My wife worked in the university processing punch cards early 70's. student code. I digress. I am glad there is the mmedit option for coding. it nearly works out the box. The connect to not your lcd or not your pico is strange and values sent to chat?? I would like to get mmbasic new users because it is worth it and cheap hardware and free software. I would not want them to experience my problems, only happy sailing. It was called plug'n'play and mmbasic can be. No need for forum advice. Hope mmbasic gets new picomite users. |
||||
DrifterNL Regular Member Joined: 27/09/2018 Location: NetherlandsPosts: 58 |
Thank you and no problem. It's amazing where a thread can sometimes lead to lol. Floating Point Keeps Sinking Me! Back To Integer So I Don't Get Injured. |
||||
stanleyella Guru Joined: 25/06/2022 Location: United KingdomPosts: 2129 |
|
||||
matherp Guru Joined: 11/12/2012 Location: United KingdomPosts: 9124 |
Nobody cares whether you use MMEDIT or not - lots of us do. We only complain when you ask for help and your question is confused in a mess of MMEDIT/MMBASIC when a screen snapshot of Teraterm, code properly presented, and your options listed and which firmware you are using would help us properly understand the issue in a fraction of the time that previous issues have taken Edited 2022-09-02 07:52 by matherp |
||||
DrifterNL Regular Member Joined: 27/09/2018 Location: NetherlandsPosts: 58 |
oops delete post Edited 2022-09-07 09:40 by DrifterNL Floating Point Keeps Sinking Me! Back To Integer So I Don't Get Injured. |
||||
DrifterNL Regular Member Joined: 27/09/2018 Location: NetherlandsPosts: 58 |
I played around (tweaked) the code after reading the manual and a few threads here. 'Ananlogue Clock for PicoMite / 2022' 'Raspberry Pi Pico running MMBasic interpreter (PicoMite)' 'Uses an I2C RTC connected to the PicoMite system I2C bus' 'and SPI based Display Panel' 'System time is set from I2C RTC at first run and can be' 'set from I2C RTC anytime after by pressing "s"' 'Clock is customizable with colours, location and dimensions.' Option explicit '----------variables----------' Dim cr,cd,dd Dim xc,yc,x1,y1,x2,y2 Dim xh,yh,xm,ym,xs,ys Dim xho,yho,xmo,ymo,xso,yso Dim hour,min,sec Dim csl,hhl,mhl,shl Dim chc,shc Dim ot$ '----------clock colours----------' Const ccc = RGB(orange) 'clock circle colour' Const csc = RGB(orange) 'clock spoke colour' Const hmamc = RGB(green) 'hour and minute hand am colour' Const hmpmc = RGB(blue) 'hour and minute hand pm colour' Const shamc = RGB(red) 'second hand am colour' Const shpmc = RGB(red) 'second hand pm colour' Const clsc = RGB(black) 'clear screen colour' '----------clock location and dimensions----------' xc = MM.HRes / 2 'clock x center' yc = MM.VRes / 2 'clock y center' cr = Min(MM.HRes , MM.VRes) / 2 - 15 'clock radius' csl = cr * 0.05 'clock spoke length' hhl = cr * 0.5 'hour hand length' mhl = cr * 0.9 'minute hand length' shl = cr * 0.9 'second hand length' '----------setting variables for first run----------' xho = xc yho = yc xmo = xc ymo = yc xso = xc yso = yc '----------clearing the display----------' CLS clsc '----------clock circle----------' Circle xc,yc,cr,1,1,ccc' '----------clock spokes----------' For dd = 0 To 360 Step + 30 x1 = Fix(Sin(Rad(dd)) * (cr)) y1 = Fix(Cos(Rad(dd)) * (cr)) x2 = Fix(Sin(Rad(dd)) * (cr+csl)) y2 = Fix(Cos(Rad(dd)) * (cr+csl)) Line x1+xc,y1+yc,x2+xc,y2+yc,1,csc Next '----------set time from I2C RTC----------' settime: RTC gettime If Val(Mid$(Time$,7,2)) = 0 Then GoTo settime '----------the clock----------' clockloop: '----------press "s" anytime to set time from I2C RTC----------' If Inkey$ = "s" Then GoTo settime '----------get time values from time string----------' ot$ = Time$ hour = Val(Mid$(ot$,1,2)) min = Val(Mid$(ot$,4,2)) sec = Val(Mid$(ot$,7,2)) '----------set clock hand colours for am or pm----------' If hour >= 12 Then chc = hmpmc shc = shpmc Else chc = hmamc shc = shamc EndIf '----------hour hand location----------' '24 hour to 12 hour for 360 degrees' If hour > 12 Then cd = (30 * (hour - 12)) + (0.5 * (Fix(min / 10) * 10)) Else cd = (30 * hour) + (0.5 * (Fix(min / 10) * 10)) EndIf dd = cd + 180 If dd > 360 Then dd = dd - 360 dd = 360 - dd xh = Fix(Sin(Rad(dd)) * hhl) yh = Fix(Cos(Rad(dd)) * hhl) '----------minute hand location----------' cd = (6 * min) + (0.1 * (Fix(sec / 10) * 10)) dd = cd + 180 If dd > 360 Then dd = dd - 360 dd = 360 - dd xm = Fix(Sin(Rad(dd)) * mhl) ym = Fix(Cos(Rad(dd)) * mhl) '----------second hand location----------' cd = 6 * sec dd = cd + 180 If dd > 360 Then dd = dd - 360 dd = 360 - dd xs = Fix(Sin(Rad(dd)) * shl) ys = Fix(Cos(Rad(dd)) * shl) '------clear old and display new clock hands on SPID------' If (xho <> xh) Or (yho <> yh) Then Line xc,yc,xho+xc,yho+yc,1,clsc EndIf If (xmo <> xm) Or (ymo <> ym) Then Line xc,yc,xmo+xc,ymo+yc,1,clsc EndIf If (xso <> xs) Or (yso <> ys) Then Line xc,yc,xso+xc,yso+yc,1,clsc EndIf Line xc,yc,xh+xc,yh+yc,1,chc Line xc,yc,xm+xc,ym+yc,1,chc Line xc,yc,xs+xc,ys+yc,1,shc '-------save old data for clearing clock hands on next round-------' xho = xh yho = yh xmo = xm ymo = ym xso = xs yso = ys GoTo clockloop Floating Point Keeps Sinking Me! Back To Integer So I Don't Get Injured. |
||||
Zett Newbie Joined: 18/06/2022 Location: NetherlandsPosts: 14 |
used your code to make this. D: |
||||
DrifterNL Regular Member Joined: 27/09/2018 Location: NetherlandsPosts: 58 |
Looks great! Floating Point Keeps Sinking Me! Back To Integer So I Don't Get Injured. |
||||
Page 3 of 3 |
Print this page |