lew247 Guru Joined: 23/12/2015 Location: United KingdomPosts: 1702
Posted: 12:32pm 21 Oct 2021
Hi Just trying to get my head round the Pico I've had one since the day they were released but only just started playing
I cannot get the config right, I'm pretty sure I know how to get Com1 configured but thats for once I've got the display and sd card working
can anyone tell me what I'm doing wrong please? and how to config them properly? I'm reading the manual and trying for several hours but can't see my mistake
OPTION LCDPANEL SSD1331, OR, DC, RESET, CS Initialises a colour OLED display using the SSD1331 controller. This supports 96 * 64 resolution.
> option system spi gp18,gp19,gp16 > option sdcard gp15 'this SHOULD work??? > option lcdpanel L, gp21,gp20,gp17 Error : Syntax
Edit, it powers up and the sample test programs at the start of the manual work fine Edited 2021-10-21 22:33 by lew247
matherp Guru Joined: 11/12/2012 Location: United KingdomPosts: 10247
Posted: 12:36pm 21 Oct 2021
Try
option lcdpanel ssd1331,L, gp21,gp20,gp17
lew247 Guru Joined: 23/12/2015 Location: United KingdomPosts: 1702
Posted: 12:48pm 21 Oct 2021
Works beautifully Thanks Peter. Really nice and sharp tiny display
lew247 Guru Joined: 23/12/2015 Location: United KingdomPosts: 1702
Posted: 01:13pm 21 Oct 2021
Peter Not sure if it's been mentioned but page 115 of the manual is missing an opening bracket GPS LONGITUDE)
Geoffg Guru Joined: 06/06/2011 Location: AustraliaPosts: 3285
Posted: 01:21pm 21 Oct 2021
Thanks Lewis, I will fix it in the next release. Geoff
lew247 Guru Joined: 23/12/2015 Location: United KingdomPosts: 1702
Posted: 01:22pm 21 Oct 2021
I also really love this little module It's so easy to use and program and You've done such a wonderful job with the micromite port Especially the GPS I was able to get it working first time with no issues whatsoever. I really like the timezone offset, makes it so simple to use although if it was able to tell when gmt and bst started and finished automatically it really would be childsplay, but shouldn't be too hard to figure out :)
Thanks Peter
lew247 Guru Joined: 23/12/2015 Location: United KingdomPosts: 1702
Posted: 08:09am 22 Oct 2021
If anyone reads this (dont really want to start a new thread for this)
Is there a way to make a pin low by a button press and then keep it low unless the button is pressed again?
I'm thinking something like setpin GP14, DOUT PIN(GP14) = 1
IF GP14 =0 Then change speed calculation from mph to kph IF GP14 goes low again it then switches back
The button pulls GP14 low momentarily and the program will change what it's doing until the button is pulled low again
I know I could use a latch button to keep the pin low but I'd like to avoid that if possible Edited 2021-10-22 18:21 by lew247
Mixtel90 Guru Joined: 05/10/2019 Location: United KingdomPosts: 7874
Posted: 08:24am 22 Oct 2021
There are several ways. You have to make sure that the state doesn't keep changing while the button is pressed though. :)
One interesting way is to use the button to trigger an interrupt. The interrupt routine toggles a flag for use in your program then exits. This is nice because it can be triggered at any time, not just when the button is being scanned.
Another way (which can be combined) is to use the button to increment a counter. When it's zero the control flag is zero, when it's 1 the control flag is 1, when it's 2 it gets reset to zero.
lew247 Guru Joined: 23/12/2015 Location: United KingdomPosts: 1702
Posted: 09:28am 22 Oct 2021
Thanks Mixtel90 Probably use a latch switch, thats a bit complex for my knowledge of basic
I do have another issue though
It's a gps speed display what I want to do is when the speed gets below 3 is check the current minute and if more than 2 minutes pass do something such as print "time is up"
I've tried this if VAL(Speed2$) < 3 then Minute = Val(Mid$(TIME$,4,4)) print Minute if Minute = Minute + 1 then print "time is up" END IF
The problem I have is it's always checking the minute and it will never increase in time Once the speed is below 3 it's always using that minute and not the one previously
I tried putting Minute = Val(Mid$(TIME$,4,4)) at the start of the program but that just uses the minute the program was run
Hope that made sense
thwill Guru Joined: 16/09/2019 Location: United KingdomPosts: 4302
Posted: 09:40am 22 Oct 2021
Hi Lewis,
How would Minute ever equal Minute + 1 ?
Untested, but does this work ?
Dim start%, now%
...
If Val(Speed2$ < 3) Then now% = Val(Mid$(Time$, 4, 4)) If start% = 0 Then start% = now% ElseIf now% >= start% + 1 Then Print "Time is up" EndIf Else start% = 0 EndIf
Though you should probably be using values returned by Timer rather than Time$.
Best wishes,
Tom
phil99 Guru Joined: 11/02/2018 Location: AustraliaPosts: 2613
Posted: 10:49am 22 Oct 2021
@Lew247
Sub Interrupt X = NOT X EndSub
Where flag X = 0 or 1 Creates a latch / toggle
lew247 Guru Joined: 23/12/2015 Location: United KingdomPosts: 1702
Posted: 12:48pm 22 Oct 2021
I tried this but I'm not certain it's working the way I want it to I really need to check that the speed is still < 3 at a few stages up to 300000 (5 minutes) That way I know defintely the car has stopped and the speed is definitely zero and I can put the cpu to sleep
I know I could do this simply by wiring it into the car, but I want to do it completely portable so the gps detects when the car is moving and goes to sleep when the car has stopped for 5 minutes
Hope that explained it ok
I'm just not certain my code below will test the speed enough times to know it's stopped.
I used <3 as the speed value because I've been testing the gps for a couple of days and it varies usually under 1mphg, but I've seen it touch 2mph even though the gps receiver is sat on the desk beside me.
thwill Guru Joined: 16/09/2019 Location: United KingdomPosts: 4302
Posted: 01:33pm 22 Oct 2021
Hi Lewis,
You're dealing with the real world, and I'm just a poor software engineer who likes writing games. Does this help:
'Const DURATION% = 5 * 60 * 1000 ' 5 minutes - for reality Const DURATION% = 10 * 1000 ' 10 seconds - for testing Dim speed% = 5
Print "Speed" speed%
' Sit in a loop, "A" accelerates, "Z" decelerates. Do Select Case UCase$(Inkey$) Case "A" : speed% = Min(10, speed% + 1) : Print "Speed" speed% Case "Z" : speed% = Max(0, speed% - 1) : Print "Speed" speed% End Select
' If speed has been <= 2 mph for more than DURATION% milliseconds then exit loop. If is_stopped%(speed%) Then Exit Do Loop
Print "I have stopped" End
Function is_stopped%(speed%) Static start% = 0 If speed% >= 3 Then start% = 0 Exit Function EndIf
Local now% = Timer ' You don't use VAL() as TIMER isn't a string. If start% = 0 Then start% = now% ElseIf now% >= start% + DURATION% Then is_stopped% = 1 EndIf End Function
Best wishes,
Tom Edited 2021-10-22 23:35 by thwill
lew247 Guru Joined: 23/12/2015 Location: United KingdomPosts: 1702
Posted: 12:21pm 03 Aug 2023
Is there a simple way to do this? I want the display to toggle between Mph and Kph but it's a momentary push button....
SetPin GP14, DIN, PULLUP ' MPH/KPH Select
if Pin GP14 = 0 then Kph
Sub Kph if gp14 = 0 then display Kph if gp14 = 0 and Kph is displayed then display Mph End Sub
Tom if you read this I've gone back to basics and using 5v Usb power for the unit now with no batteries or other complex stuff, It will just turn on and start displaying the speed until it's powered off again
Mixtel90 Guru Joined: 05/10/2019 Location: United KingdomPosts: 7874
Posted: 12:57pm 03 Aug 2023
Try this:
do if GP0 = 0 then getbutton 'mode will alternate between 0 and 1 on each time GP0 goes from 1 to 0 loop
SUB getbutton mode = NOT mode do loop until GP0 = 1 END SUB
For a very simple debounce you could try putting a 10nF or 100nF capacitor across the button contacts if necessary.