Page 2 of 3
Re: Day of the week (dow) at DATE $ / TIME $.
Posted: Fri Apr 30, 2021 8:57 pm
by mezjoc
Dear nedudgi!
Nice to meet you on this forum too. Thank you for your comment.
Can you comment on the original problem?
Re: Day of the week (dow) at DATE $ / TIME $.
Posted: Fri Apr 30, 2021 9:08 pm
by nedudgi
Re: Day of the week (dow) at DATE $ / TIME $.
Posted: Fri Apr 30, 2021 11:17 pm
by Fernando Perez
The day Google translator stops working, the Tower of Babel will fall again...
Tell me if this works for you the way you want it to:
Code: [Local Link Removed for Guests]
DIM dayweek$(6) = "CSUTORTOK", "PENTEK", "SZOMBAT", "VASARNAP", "HETFO", "KEDD", "SZERDA"
i2c.Setup 4, 5 'SDA-->GPIO4, SCL-->GPIO5. Don't forget pull-up resistors!
lcd.Init 39, 20, 4
timer0 1000, cycle
wait
cycle:
if time$ = "00:00:00" then lcd.Cls ' A hét napja különböző hosszúságú lehet
nDay = cint(dateUnix(date$)/86400) MOD 7
nTemp = val(tempr$(2, 1)) ' DS18B20-->GPIO2. Don't forget pull-up resistor!
temp$ = str$(nTemp, "%3.2f") + " Cfok "
lcd.print 1, 1, date$(2) ' Hungarian format
lcd.Print 11, 1, dayweek$(nday)
lcd.print 1, 3, time$
lcd.print 11, 3, temp$
return
I have added the cInt () function because I didn't take into account that dateUnix (Date$) adds seconds as the day progresses and does not return integer values.
Re: Day of the week (dow) at DATE $ / TIME $.
Posted: Sat May 01, 2021 10:29 am
by mezjoc
Dear Fernando Perez!
Thanks for the help.
My question: Config / Time Zone: what value did you get? I need UTC + 02 (Hungary). Specifically: Config / Time Zone = CET-1CEST.
Re: Day of the week (dow) at DATE $ / TIME $.
Posted: Sat May 01, 2021 10:54 am
by Fernando Perez
If you refer to how to synchronize Annex with the NTP time server and calculate the time corresponding to your country, I have filled in the "Time Zone" box of the "Config" page with this value:
CET-1CEST,M3.5.0,M10.5.0/3
and press the "Save" button.
image.png
You can check if it also works for your country if you enter these commands in the "Immediate" box on the "Editor" page:
Code: [Local Link Removed for Guests]
wlog time$
option.ntpsync
wlog time$
Right now, I have this code running and it doesn't seem to have a problem:
Code: [Local Link Removed for Guests]
DIM dayweek$(6) = "Jueves", "Viernes", "Sabado", "Domingo", "Lunes", "Martes", "Miercoles"
dim a(8) = &h0e, &h11, &h11, &h0e, &h00, &h00, &h00, &h00
i2c.Setup 4, 5
lcd.Init 39, 20, 4
lcd.Custom 0, a()
timer0 1000, cycle
wait
cycle:
if time$ = "00:00:00" then lcd.Cls
nDay = cint(dateUnix(date$)/86400) MOD 7
nTemp = val(tempr$(2, 1))
temp$ = str$(nTemp, "%3.1f") + " "
lcd.print 2, 1, date$
lcd.Print 12, 1, dayweek$(nday)
lcd.print 2, 3, time$
lcd.print 12, 3, temp$
lcd.write 0
lcd.print 18, 3, "C"
return
Lucky!
Re: Day of the week (dow) at DATE $ / TIME $.
Posted: Sat May 01, 2021 11:19 am
by mezjoc
Working perfectly. Thanks.
Re: Day of the week (dow) at DATE $ / TIME $.
Posted: Sat May 01, 2021 4:44 pm
by mezjoc
The Spanish version is elegant (° C).
The next project -> sensor: BME280
Question: Do you see the photo?
Re: Day of the week (dow) at DATE $ / TIME $.
Posted: Sat May 01, 2021 5:28 pm
by Fernando Perez
Quick answer: NO. I only see this:
image.png
I'm sure there will be better methods to get it, but I use these in Windows 10:
Method A) If it is an image saved on my hard drive, I open it with Paint, Select Menu -> Select All-> Copy Icon. Next, I place the mouse cursor in the part of my answer in phpBB where I want to insert the image and Right Button-> Paste.
Method B) If it is an image that I am seeing on the screen, I open the snipping tool, capture the piece of image that I need and follow the procedure already mentioned to paste it into my message.
In any case, be careful to reduce the size of the image, if it is very large, before inserting it into the message.
With the "Preview" button you can see how it will look before the "Submit" button
Re: Day of the week (dow) at DATE $ / TIME $.
Posted: Sat May 01, 2021 5:50 pm
by mezjoc
Re: Day of the week (dow) at DATE $ / TIME $.
Posted: Sat May 08, 2021 9:29 pm
by AndyGadget
I knew I'd done this somewhere and I've just rediscovered the program.
I used
http://worldtimeapi.org/ which will give you time and date information for any timezone.
With no parameters the API will check your location by IP address lookup.
This looks like it is privately supported and there is a message on the site about heavy loading. I have found fairly regular timeouts when accessing it so it's worth checking for the JSON 'not found' message and retrying if that's the case.
Code: [Local Link Removed for Guests]
dim Day$(7) = "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"
gosub GetTimeDay
wait
GetTimeDay:
' Sunday is day 0
Line$ = WGET$( "worldtimeapi.org/api/ip", 80)
DayOfWeek$ = Day$(val(json$(Line$,"day_of_week")))
'wlog Line$
wlog DayOfWeek$
return