Home
JAQForum Ver 20.06
Log In or Join  
Active Topics
Local Time 22:47 03 Dec 2021 Privacy Policy
Jump to

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 : Pico help config

Author Message
lew247

Guru

Joined: 23/12/2015
Location: United Kingdom
Posts: 1487
Posted: 12:32pm 21 Oct 2021
Copy link to clipboard 
Print this post

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 Kingdom
Posts: 5460
Posted: 12:36pm 21 Oct 2021
Copy link to clipboard 
Print this post

  Quote  option lcdpanel L, gp21,gp20,gp17


Try

option lcdpanel ssd1331,L, gp21,gp20,gp17
 
lew247

Guru

Joined: 23/12/2015
Location: United Kingdom
Posts: 1487
Posted: 12:48pm 21 Oct 2021
Copy link to clipboard 
Print this post

Works beautifully Thanks Peter.
Really nice and sharp tiny display
 
lew247

Guru

Joined: 23/12/2015
Location: United Kingdom
Posts: 1487
Posted: 01:13pm 21 Oct 2021
Copy link to clipboard 
Print this post

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: Australia
Posts: 2885
Posted: 01:21pm 21 Oct 2021
Copy link to clipboard 
Print this post

Thanks Lewis, I will fix it in the next release.
Geoff
Geoff Graham - http://geoffg.net
 
lew247

Guru

Joined: 23/12/2015
Location: United Kingdom
Posts: 1487
Posted: 01:22pm 21 Oct 2021
Copy link to clipboard 
Print this post

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 Kingdom
Posts: 1487
Posted: 08:09am 22 Oct 2021
Copy link to clipboard 
Print this post

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 Kingdom
Posts: 1196
Posted: 08:24am 22 Oct 2021
Copy link to clipboard 
Print this post

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.
-- Mick

Zilog Inside! nascom.info for Nascom & Gemini
 
lew247

Guru

Joined: 23/12/2015
Location: United Kingdom
Posts: 1487
Posted: 09:28am 22 Oct 2021
Copy link to clipboard 
Print this post

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 Kingdom
Posts: 1943
Posted: 09:40am 22 Oct 2021
Copy link to clipboard 
Print this post

Hi Lewis,

  lew247 said  
if VAL(Speed2$) < 3 then
 Minute = Val(Mid$(TIME$,4,4))
 print Minute
 if Minute = Minute + 1 then
 print "time is up"
END IF


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
CMM2 Welcome Tape, Creaky old text adventures
 
phil99
Senior Member

Joined: 11/02/2018
Location: Australia
Posts: 227
Posted: 10:49am 22 Oct 2021
Copy link to clipboard 
Print this post

@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 Kingdom
Posts: 1487
Posted: 12:48pm 22 Oct 2021
Copy link to clipboard 
Print this post

  thwill said  Hi Lewis,
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


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.

  Quote  If Val(Speed2$ < 3) Then
now% =  Val(timer)
If start% = 0 Then
  start% = now%
ElseIf now% >= start% + 300000 Then
  If Val(Speed2$ < 3)
  Print "Time is up"
EndIf
Else
start% = 0
EndIf
 
thwill

Guru

Joined: 16/09/2019
Location: United Kingdom
Posts: 1943
Posted: 01:33pm 22 Oct 2021
Copy link to clipboard 
Print this post

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
CMM2 Welcome Tape, Creaky old text adventures
 
Print this page


To reply to this topic, you need to log in.

© JAQ Software 2021