Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 04:35 13 May 2025 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 : Newie got a few questions

     Page 23 of 25    
Author Message
JohnS
Guru

Joined: 18/11/2011
Location: United Kingdom
Posts: 3999
Posted: 07:23pm 16 Dec 2020
Copy link to clipboard 
Print this post

  lew247 said  Unfortunately not
> run "r.bas"
[505] iconhour1$ = iconhour1$ + ".bmp     '"add .bmp To icon
Error: Expression syntax
>


That is indeed bad syntax. Should be something like

iconhour1$ = iconhour1$ + ".bmp"     'add .bmp To icon

You've got a lot of space (after .bmp) and then an apostrophe (') and then a non-comment.

John
 
lizby
Guru

Joined: 17/05/2016
Location: United States
Posts: 3319
Posted: 07:23pm 16 Dec 2020
Copy link to clipboard 
Print this post

Code needed a double-quote after "bmp, i.e.

iconhour1$ = iconhour1$ + ".bmp" 'add .bmp to icon name

That should not produce an expression error.
PicoMite, Armmite F4, SensorKits, MMBasic Hardware, Games, etc. on fruitoftheshed
 
lew247

Guru

Joined: 23/12/2015
Location: United Kingdom
Posts: 1702
Posted: 07:46pm 16 Dec 2020
Copy link to clipboard 
Print this post

Works beautifully when printing to the console
when trying to print on display
> run "r.bas"
default.bmp
[595] Load image iconhour1$.bmp,135,300 'weather icon now
Error: Expression syntax

The actual string received was "icon":"clear-night"
 
lew247

Guru

Joined: 23/12/2015
Location: United Kingdom
Posts: 1702
Posted: 04:04pm 18 Dec 2020
Copy link to clipboard 
Print this post

Sorry for coming back and annoying you all again

I have temperature arriving as a string
I want to get and store the low and high temp for the day starting and ending at midnight

This seems to work but I don't think it will work when it gets colder.

How do I get the decimal point to show in the result and how can it work when the temperatures are minus values?

I did try using string instead of val but can that work with seeing if one number is bigger or smaller than the other?


temphigh1 = 0
templow1 = 30
DO
tempnow$ = a$(3) ' this is a string
print tempnow$ 'prints fine
temphigh2 = VAL(tempnow$) ' set temphigh2 as the temp now
if temphigh2  > temphigh1 then 'if the temp now is higher than stored then
temphigh$ = STR$(temphigh2) + "'C" 'temphigh = highest temp
end if
print temphigh$ 'test print
templow2 = VAL(tempnow$) ' set templow2 as the temp now
if templow2  < templow1 then 'if the temp now is lower than stored then
templow$ = STR$(templow2) + "'C" 'templow = lowesttemp
end if
print templow$ 'test print
if time$ = "00:00:00" then
temphigh1 = 0
templow1 = 0
endif
tempnow$ = tempnow$ + "'C"
pause 10000
loop
 
lizby
Guru

Joined: 17/05/2016
Location: United States
Posts: 3319
Posted: 05:16pm 18 Dec 2020
Copy link to clipboard 
Print this post

Have you tested to see what will happen (i.e., if after you receive the UDP (or other) weather data, you inject values, such as tempnow$="-10" before you do the VAL conversion and comparison)?
PicoMite, Armmite F4, SensorKits, MMBasic Hardware, Games, etc. on fruitoftheshed
 
lew247

Guru

Joined: 23/12/2015
Location: United Kingdom
Posts: 1702
Posted: 06:17pm 18 Dec 2020
Copy link to clipboard 
Print this post

Yes I'd tested it in so many ways before I asked
I don't even get why this doesn't work
temphigh = 0
templow = 30

do
print temphigh1
temphigh = temphigh + 1
print temphigh1
templow = templow - 1
print templow
pause 1000

loop

sub temp
temphigh1 = temphigh
if temphigh1 > temphigh then
temphigh = temphigh1

templow1 = templow
if temlow1 < templow then
templow = templow1
end sub

temphigh is always 0
 
lew247

Guru

Joined: 23/12/2015
Location: United Kingdom
Posts: 1702
Posted: 06:56pm 18 Dec 2020
Copy link to clipboard 
Print this post

This is what I've been working on trying to get right
I know it looks pretty pathetic compared to what you experts could do but I'm happy ish with it - happier once min and max actually works
it's a 19inch monitor with the pi zero


Once it's done the pi and power cable will be hidden behind the monitor
Edited 2020-12-19 04:59 by lew247
 
lizby
Guru

Joined: 17/05/2016
Location: United States
Posts: 3319
Posted: 07:08pm 18 Dec 2020
Copy link to clipboard 
Print this post

Not sure exactly what you're attempting to do here:

temphigh = 0
templow = 30

do
print temphigh1
temphigh = temphigh + 1
print temphigh1
templow = templow - 1
print templow
pause 1000

loop

sub temp
temphigh1 = temphigh
if temphigh1 > temphigh then
temphigh = temphigh1

templow1 = templow
if temlow1 < templow then
templow = templow1
end sub

Sub Temp is never invoked; in the DO ... LOOP, temphigh is incremented, but temphigh1 is printed; nothing is ever done with temphigh1, so its value never changes from 0.
PicoMite, Armmite F4, SensorKits, MMBasic Hardware, Games, etc. on fruitoftheshed
 
lew247

Guru

Joined: 23/12/2015
Location: United Kingdom
Posts: 1702
Posted: 07:13pm 18 Dec 2020
Copy link to clipboard 
Print this post

omg how stupid am i
I was trying to see if I can get it to display - temperatures with the min/max
I forgot to tell it to go to the sub
 
lizby
Guru

Joined: 17/05/2016
Location: United States
Posts: 3319
Posted: 07:20pm 18 Dec 2020
Copy link to clipboard 
Print this post

In your SUB, you are setting temphigh1 equal to temphigh and then comparing to see if it is greater. It won't be, because they are equal.

Same with the templow comparison.
PicoMite, Armmite F4, SensorKits, MMBasic Hardware, Games, etc. on fruitoftheshed
 
lew247

Guru

Joined: 23/12/2015
Location: United Kingdom
Posts: 1702
Posted: 07:34pm 18 Dec 2020
Copy link to clipboard 
Print this post

I thought this would work

temphigh1 = 0
templow2 = 30

tempnow$ = a$(3) ' this is a string

temphigh1 = VAL(tempnow$)
if temphigh1 > VAL(temphigh$) then
temphigh$ = tempnow$
temphigh$ = tempnow$ + "'C"
end if

templow1 = VAL(tempnow$)
if templow1 < VAL(templow$) then
templow$ = tempnow$ + "'C"
end if
print temphigh$
print templow$

it doesn't
 
lew247

Guru

Joined: 23/12/2015
Location: United Kingdom
Posts: 1702
Posted: 07:55pm 18 Dec 2020
Copy link to clipboard 
Print this post

I think I have it now
I'll know later once the temmperature actually changes
edit; failed
Edited 2020-12-19 06:06 by lew247
 
lizby
Guru

Joined: 17/05/2016
Location: United States
Posts: 3319
Posted: 07:57pm 18 Dec 2020
Copy link to clipboard 
Print this post

Looks OK to me, but this is equivalent and more compact (and to me, clearer)

temphigh1 = 0
templow2 = 30
temphigh$ = "0"
templow$ = "30"

tempnow$ = a$(3) ' this is a string

if VAL(tempnow$) > VAL(temphigh$) then
 temphigh$ = tempnow$ + "'C"
end if

if VAL(tempnow$) < VAL(templow$) then
 templow$ = tempnow$ + "'C"
end if
print temphigh$
print templow$

Edited 2020-12-19 05:59 by lizby
PicoMite, Armmite F4, SensorKits, MMBasic Hardware, Games, etc. on fruitoftheshed
 
lew247

Guru

Joined: 23/12/2015
Location: United Kingdom
Posts: 1702
Posted: 10:08am 19 Dec 2020
Copy link to clipboard 
Print this post

I didn't like the pictures so went back to icons
It's a shame you can't do a "save image as" when it's using HDMI, the line scans ruin the picture, but it looks much better live

 
lizby
Guru

Joined: 17/05/2016
Location: United States
Posts: 3319
Posted: 01:31pm 19 Dec 2020
Copy link to clipboard 
Print this post

Looking good.

Is this all from the WGET from the internet weather source, or are the numbers supplemented with your own local sensors?
PicoMite, Armmite F4, SensorKits, MMBasic Hardware, Games, etc. on fruitoftheshed
 
lew247

Guru

Joined: 23/12/2015
Location: United Kingdom
Posts: 1702
Posted: 09:47pm 19 Dec 2020
Copy link to clipboard 
Print this post

Last question hopefully

Why doesn't this work?

angle = VAL(dirnow$)
if angle = 0 then angle = 180
if angle = 180 then angle = 360
if angle > 0 < 180 then angle = angle + 180
if angle > 180 < 360 then angle = angle - 180
print dirnow$
print angle


It's data from my Weatherflow weather station Lance  Weatherflow Weather Station
I download if from their server after it's uploaded there because they add the forecast information based partly on data collected from stations nearby  and it's a lot easier this way

I'm using the ESP32 to download the data, and then UDP it to the Pi to decode/display
I've also changed the moon phase picture now so it's not so "full in your face"

I'm displaying it on the 19inch monitor but I'm going to also make something like this after Christmas to pop on the other wall
It will have pointers driven by small stepper motors from a car dash and using the Armmite it should run on batteries for a long time, picking up the data from the Pi by HC-12

You can see the display better here Display


Edited 2020-12-20 07:59 by lew247
 
CircuitGizmos

Guru

Joined: 08/09/2011
Location: United States
Posts: 1427
Posted: 10:03pm 19 Dec 2020
Copy link to clipboard 
Print this post

> if angle = 0 then angle = 180

if angle is 0, this now sets it to 180

> if angle = 180 then angle = 360

angle is 180 (see above) so now angle is 360

> if angle > 0 < 180 then angle = angle + 180

angle still 360

> if angle > 180 < 360 then angle = angle - 180

angle still 360

Another:

angle = 10

> if angle = 0 then angle = 180

angle still 10

> if angle = 180 then angle = 360

angle still 10

> if angle > 0 < 180 then angle = angle + 180

angle now 10 + 180 = 190

> if angle > 180 < 360 then angle = angle - 180

angle now 190 - 180 = 10


You need to use an IF, ELSEIF construct.
Edited 2020-12-20 08:05 by CircuitGizmos
Micromites and Maximites! - Beginning Maximite
 
Chopperp

Guru

Joined: 03/01/2018
Location: Australia
Posts: 1090
Posted: 10:49pm 19 Dec 2020
Copy link to clipboard 
Print this post

  lew247 said  
Why doesn't this work?

angle = VAL(dirnow$)
if angle = 0 then angle = 180
if angle = 180 then angle = 360
if angle > 0 < 180 then angle = angle + 180
if angle > 180 < 360 then angle = angle - 180
print dirnow$
print angle


Could use SELECT CASE instead

angle = VAL(dirnow$)

select case angle
 case = 0
  angle = 180
 case is < 180
  angle = angle + 180
 case = 180
  angle = 360
 case is < 360
  angle = angle - 180
end select
print dirnow$
print angle


Note Not tested so could be wrong .
Brian
Edited 2020-12-20 08:52 by Chopperp
ChopperP
 
lew247

Guru

Joined: 23/12/2015
Location: United Kingdom
Posts: 1702
Posted: 08:18am 20 Dec 2020
Copy link to clipboard 
Print this post

Thank you both, it's working now :)
 
lew247

Guru

Joined: 23/12/2015
Location: United Kingdom
Posts: 1702
Posted: 04:59pm 20 Dec 2020
Copy link to clipboard 
Print this post

lizby (or anyone)
Would you mind explaining this to me please? I'm trying to get my head around how it works so I can use something similar in the future but with other values, shorter and longer numbers of fields

Thanks in advance
and btw I'm dead jealous, it never really snows here in Manchester

UDP receive aa$,b$,c%
If c%>0 Then
 tag$=Mid$(aa$,1,2)
 Select Case tag$
   Case "#1": For i%=1 To 25: a$(i%)=Field$(aa$,i%+1): Next i% ' LISTFIELDS
   Case "#2": For i%=1 To 25: a$(i%+25)=Field$(aa$,i%+1): Next i%
   For i%=1 To 50: Print i%;" ";a$(i%): Next i%
  End Select
end if


UDP receive aa$,b$,c% ' I know this
If c%>0 Then          'if UDP has data
tag$=Mid$(aa$,1,2)    'look for #??
Select Case tag$    
Case "#1"             'look for the first "#"? because every UDP packet ends with #
 For i%=1 To 25
a$(i%)=Field$(aa$,i%+1) '?
Next i%   ' LISTFIELDS

Case "#2"
For i%=1 To 25
a$(i%+25)=Field$(aa$,i%+1) ' I don't get this
Next i%
For i%=1 To 50
Print i%;" ";a$(i%)    'print the fields received maybe?
Next i%
End Select
Edited 2020-12-21 03:01 by lew247
 
     Page 23 of 25    
Print this page
The Back Shed's forum code is written, and hosted, in Australia.
© JAQ Software 2025