Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 08:57 19 Feb 2026 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 : Testing for a particular time period

Author Message
OA47

Guru

Joined: 11/04/2012
Location: Australia
Posts: 1036
Posted: 11:48pm 22 Jan 2026
Copy link to clipboard 
Print this post

I am using many displays that are active 24/7 and would like to lower the backlight during evening hours. I have used a test to look for 07:00:00 and 19:00:00 time stamps which works OK but occasionally that time stamp is missed due to other operations of the program. I would like to test if the time is past 07:00:00 and 19:00:00 to reduce or increase the backlight. I vagally remember discussions of an EPOC command but I can't find any mention in the handbooks. Would this be the direction I should head?

Regards
OA47
 
Andy-g0poy
Regular Member

Joined: 07/03/2023
Location: United Kingdom
Posts: 84
Posted: 12:02am 23 Jan 2026
Copy link to clipboard 
Print this post

EPOCH(DATETIME$)

and NOW
Print EPOCH(NOW)

Page 187



DATETIME$(n) returns the date time string fromthe epoch number n

page 185


Using the pdf manual
MMBasic BASIC Interpreter
Ver 6.01.00

Andy
 
TassyJim

Guru

Joined: 07/08/2011
Location: Australia
Posts: 6455
Posted: 12:58am 23 Jan 2026
Copy link to clipboard 
Print this post

Time$ is a string and you can compare strings
'
IF TIME$ >= "07:00:00" AND TIME$ < "19:00:00" THEN
 backlight = 100
ELSE
 backlight = 20
ENDIF


VK7JH
MMedit
 
phil99

Guru

Joined: 11/02/2018
Location: Australia
Posts: 3016
Posted: 02:25am 23 Jan 2026
Copy link to clipboard 
Print this post

That is clever, easier than Epoch.
> TIME$ = "06:55" : ? TIME$ >= "07:00:00" AND TIME$ < "19:00:00"
0
> TIME$ = "07:05" : ? TIME$ >= "07:00:00" AND TIME$ < "19:00:00"
1
> TIME$ = "18:55" : ? TIME$ >= "07:00:00" AND TIME$ < "19:00:00"
1
> TIME$ = "19:05" : ? TIME$ >= "07:00:00" AND TIME$ < "19:00:00"
0
>

> night = 19*60*60
> day = 7*60*60
> aDay =  24*60*60
> if epoch(now) mod aDay > night then backlight 10
> if epoch(now) mod aDay > day then backlight 100

Edited 2026-01-23 12:29 by phil99
 
greybeard
Senior Member

Joined: 04/01/2010
Location: Australia
Posts: 178
Posted: 02:45am 23 Jan 2026
Copy link to clipboard 
Print this post

As a general guideline for programming limit or range logic I'd suggest checking for > or < as appropriate unless circumstances preclude doing so. ie not just = to.
A lot more people can program when the real world behaves as they expect their virtual world to behave. A good programmer should strive to program for when the real world is real and things don't behave in a virtual manner. ie program for the worst case, not the best case especially if your version of logic says it can't happen, it will.
 
OA47

Guru

Joined: 11/04/2012
Location: Australia
Posts: 1036
Posted: 03:27am 23 Jan 2026
Copy link to clipboard 
Print this post

Thankyou all, I will use the string comparison.

OA47
 
PhenixRising
Guru

Joined: 07/11/2023
Location: United Kingdom
Posts: 1730
Posted: 09:18am 24 Jan 2026
Copy link to clipboard 
Print this post

"your version of logic" 🤣😂🤣😂
 
Mixtel90

Guru

Joined: 05/10/2019
Location: United Kingdom
Posts: 8568
Posted: 11:23am 24 Jan 2026
Copy link to clipboard 
Print this post

This is only one of the reasons why it's difficult to properly check your own code. You *know* that a particular logic stream is correct when it will stand out like a beacon to someone else that it's wrong.  :(
Mick

Zilog Inside! nascom.info for Nascom & Gemini
Preliminary MMBasic docs & my PCB designs
 
PhenixRising
Guru

Joined: 07/11/2023
Location: United Kingdom
Posts: 1730
Posted: 06:41pm 24 Jan 2026
Copy link to clipboard 
Print this post

  Mixtel90 said  This is only one of the reasons why it's difficult to properly check your own code. You *know* that a particular logic stream is correct when it will stand out like a beacon to someone else that it's wrong.  :(


 
Andrew_G
Guru

Joined: 18/10/2016
Location: Australia
Posts: 874
Posted: 09:30am 27 Jan 2026
Copy link to clipboard 
Print this post

Hi Graeme,
You kindly gifted me some monitors and cables via Big Mick a few months back. Thanks.

Another solution to your issue is to use a Light Dependant Resistor (LDR) (e.g. Jaycar # RD3480) to measure the ambient light. I use them on "everything", especially in my sleeping quarters/my side of the bed.
With a little bit of calibration you can get three levels, bright/normal/dark, and set BACKLIGHT accordingly.
Use SETTICK to check the resistance every second and it responds well.

Happy to post more details.

Cheers,

Andrew
 
OA47

Guru

Joined: 11/04/2012
Location: Australia
Posts: 1036
Posted: 01:07am 28 Jan 2026
Copy link to clipboard 
Print this post

  Quote  You kindly gifted me some monitors and cables via Big Mick a few months back. Thanks

Andrew you are very welcome. It is a bit of a pity that so much stuff had to be sent to waste but that was the way it was.

OA47
 
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 2026