User avatar
bleep42
Posts: 257
Joined: Wed Mar 07, 2012 12:43 pm
Location: Sussex

MMBasic/PicoMite Solar System Clock

Wed Dec 08, 2021 12:27 pm

PicoSolar.jpg
PicoSolar.jpg (170.09 KiB) Viewed 2339 times
SolarScr.jpg
SolarScr.jpg (115.27 KiB) Viewed 2339 times
I have converted a Python Solar System project https://github.com/dr-mod/pico-solar-system which uses the planetary equations of motion from http://stjarnhimlen.se/comp/tutorial.html to run on MMBasic or PicoMite.
Apart from the hair raising maths, this was amazingly easy. :-)
My set up uses the exact set up shown for a LCD screen in the PicoMite user manual, with the addition of screen brightness on GP10.
I have used the touch screen to allow screen brightness changes and to fast scroll through weeks/months of planetary motion.
I have limited the year to between 1901 and 2100 as the equations referenced imply they are inaccurate beyond 2100.
Touch points are :-
Top Left = Brightness up
Bottom Left = Brightness down
Top Right = increase date by a week at a time then a month...
Bottom Right = decrease date by a week at a time then a month...
Centre screen= reset to todays date.

I really only did this to see if it could be done, I haven't used BASIC for 30years and have never used Python! I was very surprised how straight forward it was, probably mainly due to the people who have ported and maintain MMBasic on the Pico. :-)

Regards, Kevin.

It may not be pretty!
Attachments
solarsys.zip
Source
(17.74 KiB) Downloaded 41 times
Last edited by bleep42 on Fri Feb 18, 2022 5:11 pm, edited 6 times in total.

User avatar
scruss
Posts: 5142
Joined: Sat Jun 09, 2012 12:25 pm
Location: Toronto, ON

Re: MMBasic/PicoMite Solar System Clock

Thu Dec 09, 2021 1:54 pm

Ah, neat!

Is backlight control a matter of connecting a GPIO pin to the LED pin of the board? I think I'm using the same board as you, the 2.8" ILI9341.
‘Remember the Golden Rule of Selling: “Do not resort to violence.”’ — McGlashan.
Pronouns: he/him

User avatar
bleep42
Posts: 257
Joined: Wed Mar 07, 2012 12:43 pm
Location: Sussex

Re: MMBasic/PicoMite Solar System Clock

Thu Dec 09, 2021 3:32 pm

Hi Scruss,
Yes it is, it's described on page 43 of manual, except they use GP11, which is already in use and caused a lock up, so I have used GP10
OPTION LCDPANEL ILI9341, L, GP15, GP14, GP13, GP10
Then connect GP10 to the LED pin on the LCD board, removing the current wire which is connected to +5v

Then, simply use the command in your program
BACKLIGHT bright
Where bright is anything from 1 to100, I found 0 defaults to full bright.

I've now measured the current drain, because I was going to add a battery backup and wanted an idea of size; I'm running at 48Mhz, because it doesn't need to be faster and I'm seeing only 18mA with display dim and 90mA with display bright and 13mA with display powered off, though you do then need to do a command GUI RESET LCDPANEL to re-initialise the panel when you re-power it.

Overall I'm very impressed with this implementation of Basic for the Pico, it's very complete and everything, I've tried, works perfectly and if speed isn't a problem/priority, it's great, with loads of easily available peripherals already built into the runtime. :-)

Regards, Kevin.

User avatar
scruss
Posts: 5142
Joined: Sat Jun 09, 2012 12:25 pm
Location: Toronto, ON

Re: MMBasic/PicoMite Solar System Clock

Fri Dec 10, 2021 3:22 am

Neat! Thank you!
solarsys.jpg
solar system
solarsys.jpg (14.29 KiB) Viewed 2229 times
‘Remember the Golden Rule of Selling: “Do not resort to violence.”’ — McGlashan.
Pronouns: he/him

User avatar
bleep42
Posts: 257
Joined: Wed Mar 07, 2012 12:43 pm
Location: Sussex

Re: MMBasic/PicoMite Solar System Clock

Sat Dec 11, 2021 11:08 am

scruss wrote:
Fri Dec 10, 2021 3:22 am
Neat! Thank you!
Hi Scruss,

If you are still using it I've updated the source in the first post, improvements made, are, roughly.
Turned off the blinking green led while clock running.
optimised for speed the screen re-drawing while fast scrolling forward/back in time.
Improved the touch screen code, increased screen refresh/touch point detection to 4 times a second, could be much faster, didn't see the point.
optimised out quite a few Sin, Cos, Rad functions for speed.
added a LCD initialise at midnight and also when touching centre screen to set to today's date. (so that you can get the LCD going again if you remove power from it)
For speed, don't use CLS, instead erase each screen element individually.
Added extra commenting.
probably lots of others I've now forgotten about.

If you want to see where the planets will be a long time forward or back, I'm afraid you'll have to manually set DATE$. I have confirmed the planets are correctly aligned, so the maths is correct.

Regards Kevin.
Last edited by bleep42 on Fri Jan 21, 2022 4:40 pm, edited 1 time in total.

User avatar
bleep42
Posts: 257
Joined: Wed Mar 07, 2012 12:43 pm
Location: Sussex

Re: MMBasic/PicoMite Solar System Clock

Tue Dec 28, 2021 6:53 pm

I've updated the source again, there are now two versions, one that works with the original Chinese display and a second one that works with the Pimoroni Display pack 2 https://shop.pimoroni.com/products/pico ... y-pack-2-0. Photo attached:-
SolarSysSecs.jpg
Pimoroni display
SolarSysSecs.jpg (90.76 KiB) Viewed 2058 times
This is a very neat and sharp display, which simply plugs directly on to the pins of a Pico, so making it very compact.
I have also now added the bouncing Pluto, seconds display, very roughly the height Pluto bounces, is approximately seconds, the display animation of Pluto updates at about 10Hz, so is fairly smooth.
Because the Pimoroni display is not a touch screen, I have made the 4 buttons it has, control fast forward/back and brightness.
Top Left button brightness up.
Bottom Left button brightness down.
Top Right button, fast forward the date/solar system.
Bottom Right button, fast reverse the date/solar system.
Both Right hand buttons together, returns to the present date.
As an added feature, when you have fast forward or back the RGB LED will light up faint blue as an indication the date is not current.
You will need to define the GPIO that the display uses for MMBasic, these are:-

Code: Select all

OPTION SYSTEM SPI GP18,GP19,GP4
OPTION SD GP5
OPTION LCDPANEL ST7789_320, L,GP16,GP22,GP17,GP20
I have also above defined GP5 as the CS (Chip Select) for an SD Card read/writer, using an SD is described in the User Manual that downloads with MMBasic.

User avatar
bleep42
Posts: 257
Joined: Wed Mar 07, 2012 12:43 pm
Location: Sussex

Re: MMBasic/PicoMite Solar System Clock

Fri Jan 21, 2022 3:19 pm

I've now added a RTC to the Pimoroni display it's a DS3231 so you don't have to set the date/time every time, next will be a box.
Here are a few pics showing how compact it is.
SideView.JPG
SideView.JPG (53.38 KiB) Viewed 1975 times
BackView.JPG
BackView.JPG (100.05 KiB) Viewed 1975 times
As an example, here is what our solar system looked like when the Voyagers were launched, you can see how the planets were lined up for the grand tour, note the blue LED, indicating that the date is not current, the time remains current.
Voyager.JPG
Voyager.JPG (46.29 KiB) Viewed 1975 times
Out of interest, If you play with different CPU speeds, the fast date scroll runs at about:-
48Mhz 6.5 months forward/back per second.
125Mhz 15 months per second
250Mhz 28 months per second

The solar system positively whirls round. ;-) there's an impressive amount of high precision scientific floating point maths and graphics plotting going on for each month. If you want to see where the planets will be a long time forward or back, I'm afraid you'll have to manually set DATE$. I have confirmed the planets are correctly aligned, so the maths is correct, I even wound it back to September 1977, when the Voyagers launched (above) and sure enough you can see the nice spiral layout of the planets they visited on their grand tour. :-)

Regards Kevin.

User avatar
bleep42
Posts: 257
Joined: Wed Mar 07, 2012 12:43 pm
Location: Sussex

Re: MMBasic/PicoMite Solar System Clock

Mon Jan 24, 2022 12:49 pm

I have now added the Moons orbit around Earth.
SolarSys.jpg
SolarSys.jpg (85.27 KiB) Viewed 1895 times
I have also added an option flag, if you do or do not have an RTC attached, set rtcl=1 or 0 in the variable initialisations; obviously you will need to set time and date every time you loose power, without the RTC, but it still keeps reasonably good time.
Otherwise everything else is as before, hopefully.
I've used this RTC https://www.ebay.co.uk/itm/154736489893 ... Sw~~ZhrlGc and this SD card module for loading and saving files too/from the Pico https://www.ebay.co.uk/itm/193453320566 ... Sw3lZeyOFY they both work fine. The solarsys.zip file has been updated, in the first post, with the latest 2 versions of the program, standard and the Pimironi display, along with the MMBasic Options I set.
Regards, Kevin.

User avatar
bleep42
Posts: 257
Joined: Wed Mar 07, 2012 12:43 pm
Location: Sussex

Re: MMBasic/PicoMite Solar System Clock

Wed Feb 16, 2022 12:13 pm

I have now finished this project using a 3.5" Raspberry Pi touch display, attached to a Pico, & RTC, in a perspex case that came with the display, Display on Ebay.
Many thanks to Peter for PicoMite and pointing me in the correct direction for connecting the diplay and the fact that even though it was a ILI9486, the PicoMite ILI9481 driver worked fine, which it does. :-) Because I got the back screen brightness working I have also done automatic brightness, depending on time of year and time of day, it can be overriden with the touch screen brightness control.
Thanks to all involved,
Regards, Kevin.
solarsys.zip
Source
(17.74 KiB) Downloaded 16 times
3-5SolarBuild.jpg
3.5" Raspberry Pi display.
3-5SolarBuild.jpg (165.79 KiB) Viewed 1727 times
BoxedSolarClock.jpg
All packaged in a perspex box.
BoxedSolarClock.jpg (119.21 KiB) Viewed 1727 times
Last edited by bleep42 on Fri Feb 18, 2022 5:08 pm, edited 1 time in total.

User avatar
led-bloon
Posts: 26
Joined: Mon Dec 03, 2012 4:48 am
Location: Oz

Re: MMBasic/PicoMite Solar System Clock

Thu Feb 17, 2022 9:22 am

Have you thought of using an LDR and one of the ADC inputs for automatic brightness?
led

Return to “General”