Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 06:52 02 Aug 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 : I’m going stupid

Author Message
lew247

Guru

Joined: 23/12/2015
Location: United Kingdom
Posts: 1702
Posted: 09:31am 12 Aug 2017
Copy link to clipboard 
Print this post

I finally started working on the weather station again tonight, with a nice new look to it and the Big Ben clock is gone.

My brain will not work though (YES I have read both manuals)

How do I simply print the time on the display?
I want to display it in a white box in the middle of the screen and get the time from the RTC
and every night at midnight poll the RTC to get the new date and display both the date and DOW
but my mind is fried,
I know its such a simple command that lots of you are probably laughing but try as hard as I can and I cannot figure it out

I've got
RTC GETTIME 'Get the time from the RTC
Year=Val(Mid$(Date$,7,4)):Month=Val(Mid$(Date$,4,2)):Day=Val(Mid$(Date$,1,2))
secs=Val(Right$(Time$,2))
mins=Val(Mid$(Time$,4,2))
hours=Val(Left$(Time$,2))
DOW$(0)="Sunday":DOW$(1)="Monday":DOW$(2)="Tuesday":DOW$(3)= "Wednesday"
DOW$(4)="Thursday":DOW$(5)="Friday":DOW$(6)="Saturday"

but try as hard as I can and I cannot figure out how to display the things on the screen, or how to get the time to update every second and get the new time/date/dow at midnight

I know that Text 290,215, DOW$(DayOfWeek(Year, Month, Day)), CM, 1, 2, RGB(BLACK), RGB(63, 133, 195) works for the day of the week
BUT it will NOT Update and change at midnight or any other time it only stays the same day forever

Such simple things I know

Anyone able to throw some light on this?


Also does anyone have any pictures of what various fonts actually look like?

What I want to do is display the time and ideally date/day on the white box in the middle of the pic - I might need to make the box bigger though or I might need to only put the time there -

I'm using a 7" display and an E100 board



Another question
Wigh the new firmware the BLIT command, does this load a section of the pic into memory and the repost it afterwards? ive read the manual but not positive what it does or how to use it
I'm thinking it might be handy to change the weather icon**Edited by lew247 2017-08-13
 
panky

Guru

Joined: 02/10/2012
Location: Australia
Posts: 1114
Posted: 01:30pm 12 Aug 2017
Copy link to clipboard 
Print this post

@Lew

The following scrap of code should do it for you


' Stuff for start of program
Option Explicit
Dim MinFlag ' if you need to do someting every minute
Dim EODFlag ' if you need to know end of day
Dim NewDataFlag

SetTick 1000,UpDateTime ' Call every second, print date/time

' main program loop
Do
' ...
' ... all main loop code here
' ...
If NewDataFlag = 1
Text ' blah, blah, blah to display date time wherever you want
NewDataFlag = 0
EndIf
' ...
' ...
' ...
Loop


' Interrupt service routine
Sub UpDateTime ' called by 1 second interrupt from SetTick
Local hrs,mins,secs,day,month,year
hrs = Val(left$(Time$,2))
mins = Val(Mid$(Time$,4,2))
secs = Val(right$(Time$,2))
' Get the current time, extract the minutes component
If secs = 0 Then
MinFlag = 1
Else
MinFlag = 0
EndIf
' Get the current time, test for 00:00:00
If hrs = 0 And mins = 0 And secs = 0 Then
RTC GETTIME
EODFlag = 1
Else
EODFlag = 0
EndIf
NewDataFlag = 1 ' set to indicate fresh data
End Sub


Hope this helps,
Cheers,
Doug.

... almost all of the Maximites, the MicromMites, the MM Extremes, the ArmMites, the PicoMite and loving it!
 
TassyJim

Guru

Joined: 07/08/2011
Location: Australia
Posts: 6283
Posted: 02:54pm 12 Aug 2017
Copy link to clipboard 
Print this post

If all you want to do is update the time on the display every second
  Quote  SETTICK 1000, ticktock

DO
'
LOOP

SUB ticktock

TEXT 100,100, TIME$+" "+DATE$, CM, 1, 2, RGB(BLACK), RGB(63, 133, 195)
IF TIME$="00:00:10" THEN RTC GETTIME ' not really needed for a 'mite with crystal osc.
END SUB



With an explore100, you have a crystal oscillator which is as good as most RTCs so you don't need to use RTC GETTIME very often.
I have it setting the time 10 seconds past midnight.
You can add the code to update the DOW here also and change the time to one second past midnight if you prefer.
If the 'mite is fast, it might set the clock twice in succession but that's not a problem.

Doug's code lets you do a lot more based on any time rather than a simple clock.

Jim

VK7JH
MMedit
 
lew247

Guru

Joined: 23/12/2015
Location: United Kingdom
Posts: 1702
Posted: 09:50pm 12 Aug 2017
Copy link to clipboard 
Print this post

Thank you Doug and Jim
 
lew247

Guru

Joined: 23/12/2015
Location: United Kingdom
Posts: 1702
Posted: 09:53am 24 Nov 2017
Copy link to clipboard 
Print this post

Back to this again as I'm now off sick again and have time to work on it
However my stupid brain has gone wonky again and I can't figure out something which is stupidly simple
I'm using a DHT22 sensor and the embedded C module in the latest MM
DIM FLOAT temp , humidity
HUMID 59, temp, humidity

However to display the temp and humidity I am using boxes with control values to display
ctrlval(2)=humidity
ctrlval(3)=temp

Does not work, expected a string
I know it's simple to turn it into a string but every combination of things I try just wont work
Any ideas?
 
panky

Guru

Joined: 02/10/2012
Location: Australia
Posts: 1114
Posted: 10:49am 24 Nov 2017
Copy link to clipboard 
Print this post

@lew

Can you post the code snippet? Should be straight forward but we need to .see what you are doing,

cheers,
panky
... almost all of the Maximites, the MicromMites, the MM Extremes, the ArmMites, the PicoMite and loving it!
 
JohnS
Guru

Joined: 18/11/2011
Location: United Kingdom
Posts: 4044
Posted: 11:16am 24 Nov 2017
Copy link to clipboard 
Print this post

You'd need something like

ctrlval(2)=STR$(humidity)
ctrlval(3)=STR$(temp)

Or maybe use FORMAT$

What did you try that didn't work and what was the error?

John
 
lew247

Guru

Joined: 23/12/2015
Location: United Kingdom
Posts: 1702
Posted: 12:38pm 24 Nov 2017
Copy link to clipboard 
Print this post

It was me being stupid and forgetting the brackets after STR$ (sorry)

I have another dilemma

I'm trying to display wind speed as a control value in a GUI DISPLAYBOX
The temp is sent as a string via a com port then parsed
The actual code is[code] ctrlval(13)=FieldArray$(4) [/code]
However I'd like to limit the value displayed to either no decimal points or 1 decimal point
I've tried ctrlval(13)=VAL(FieldArray$(4),1)
but VAL expects a string and doesn't work
This is what comes in from the serial port
STXW, 24.50, 999.21, 5.21994, 0.00, 0.42, 0.42, 1.12, 0.00, 25.16, 0.00, 23.98, 0.00, 3.30, 46.34



 
JohnS
Guru

Joined: 18/11/2011
Location: United Kingdom
Posts: 4044
Posted: 12:48pm 24 Nov 2017
Copy link to clipboard 
Print this post

I can't recall the syntax for STR$ / FORMAT$ to limit the decimals but you'd want something like

ctrlval(13)=STR$(VAL(FieldArray$(4)),1)

John
 
lew247

Guru

Joined: 23/12/2015
Location: United Kingdom
Posts: 1702
Posted: 02:30pm 24 Nov 2017
Copy link to clipboard 
Print this post

Thanks
That was enough to work it out
 
Print this page


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

The Back Shed's forum code is written, and hosted, in Australia.
© JAQ Software 2025