News:

We're live! Join us!

Main Menu

COMPLETED - A PicoMite Clock

Started by granz, Mar 10, 2025, 03:38 PM

Previous topic - Next topic

granz

Over this past weekend, I went to Cleveland to visit my son, his fiance and her 6 year-old son. In trying to find some fun stuff for the kid, we purchased a one-year membership to the Great Lakes Science Center (https://greatscience.com/.) Then after that visit we went to Chuck-E-Cheese (or as Winston put it "Chunky-Cheese"  :P ) A great time was had by all. Then on Sunday, after Winston went back to his grandma, we went to Micro Center (no trip to Cleveland can be complete without a stop there.) After our shopping trip, Peter and his fiance joined us for lunch, and we got to know her better - she is a great girl.

Anyway, one of the many items that I purchased was a Pimoroni Pico Display pack (https://www.microcenter.com/product/633758/pimoroni-pico-display-pack.) Pimoroni has them a bit cheaper, but they are out of stock right now. This display has a DIP (Dual-Inline Pin) socket on the bottom that accepts a Pi Pico and provides a small LCD for the Pico. One of the reasons that I selected this specific display is that the controller is supposed to be compatible with PicoMite BASIC (more on the "supposed to be" in a bit.) The pack also has an RGB LED, and four pushbuttons  - it seemed like a nice thing for tiny whatevers.

Another purchase was an Pimoroni Pimoroni Pico LiPo (https://www.microcenter.com/product/640667/pimoroni-pimoroni-pico-lipo-16mb). When I ordered this, I thought that it was a daughterboard (called a shim in Pico-land,) that provided a LiPo charging circuit for the Pico controller. Not until I got home, and checked out my loot, did I realize that it is actually a full Pico (with 16MB of flash, rather than the standard 2MB.) PicoMite BASIC can use the full 16MB as file space, giving eight times as much "disk" space. This will definitely be paired up with one of the display packs.

Unfortunately, those Pico LiPo boards do not have the headers soldered on, but I did have a Pico W with headers handy. Great to get started playing immediately!  8) So, I plugged the Pico W into the display, and hooked it up to my laptop, and dragged the WebMite BASIC (PicoMite with networking stuff for the WiFi interface on the Pico W) onto the Pico. It took, and I was able to connect to the Pico and start using it.

First thing to do was to make sure that I can use the LEDs. They are clearly marked on the schematic (https://cdn.shopify.com/s/files/1/0174/1800/files/pimoroni_pico_lipo_schematic.pdf?v=1631526487) and so, a simple PIN(9)=0 later, to turn off one color and nothing!  :o Oops, the schematic shows that the LEDs are connected to +3.3V, so RTFM, Granz! Yes, sending a 0 to the LED turns on that color, so a simple PIN(9)=1, and the red went out! Yay, success! :D

Next, let's get that LCD working. A quick check of the schematic, and compare it to the OPTION SYSTEM SPI to set up the SPI interface to the LCD shows that it is missing the MISO pin. A bit of searching showed a posting to the MMBASIC (PicoMite is a version of MMBASIC) forum (https://www.thebackshed.com/forum/ViewTopic_mobile.php?FID=16&TID=14963) had MattherP (the guy who ported MMBASIC to the Pico) giving some guidance for this particular display:
OPTION SYSTEM SPI 24,25,1
OPTION LCDPANEL ST7789_135,L,21,31,22,26
This worked for my setup. It's cool getting my own stuff displayed on my system.

Now that I can use the display, and its LED, time to make use of the WiFi interface of the WebMite. First I set up the web interface for static IP:
ssid$="MyRouter'sSSID"
pass$="MyPassword"
name$="clock"
addr$="192.168.32.222"
mask$="255.255.255.0"
gate$="192.168.32.1"

web connect ssid$,pass$,name$,addr$,mask$,gate$
The manual indicates that you can hardwire the options directly into the WEB CONNECT command, but I kept getting errors until I assigned all the options to variables.

After a reset, and being kicked out of the communications program (some of the options commands cause a reset,) within a few seconds the Pico W connected to my router.

Next, PicoMite BASIC has a built-in TIME$ and DATE$, so I was able to set them manually and get a dynamic display showing the current time. Next I added the date underneath the time on the display. Nice to see that the Pico can keep time, and show a changing display. Hey why not make a clock - Hack-A-Day says that almost every hacker (the good kind, not the criminals) makes a clock at some time in his life.

In addition to the DATE$ and TIME$ variables, WebMite has a way to set the date and time from a NTP (Network Time Protocol) server on the Internet:
WEB NTP -4The -4 offset is for our Eastern Daylight Time.

Anyway, after this playing around, I came up with the following BASIC program:
CLS
Font 5

' Turn off the RGB LED
Pin(9) = 1  ' Red
Pin(10) = 1 ' Green
Pin(11) = 1 ' Blue

' Set the clock
WEB NTP -4

' Set brightness
Backlight 100

Do While 1
  Text MM.Info(FONTWIDTH),MM.Info(FONTHEIGHT),Time$
  Text 0,(MM.Info(FONTHEIGHT)*2),Date$
  Pin(11)=1
  Pause 200
  Pin(11)=0
  Pause 200
Loop
Nice, if I do say so, myself. With the WEB NTP at the beginning of the program, the clock will automatically get the current time. To get this thing to run every time I start it up, I saved it in FLASH (the 2MB "hard disk" built into the Pico,) location one. Next I told the WebMite to automatically run the clock each time that it boots:
FLASH SAVE 1
OPTION AUTORUN 1
If I need to modify the program, while the clock is running, I just connect the USB cable from the Pico to my computer, use the SCREEN program to log into the clock, press CTRL-C and then I can edit the program. Easy Peasy.