Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 15:50 27 Nov 2024 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 : Umite Backpack 24 to 12 Hr Help

Author Message
Mickanical
Newbie

Joined: 21/11/2018
Location: Australia
Posts: 2
Posted: 10:38am 09 Oct 2023
Copy link to clipboard 
Print this post

Hi Folks

I'm trying to convert 24hr to 12 Hr on a Umite Backpack. Project Code attached.

Have added the following code from the manual after scouring the forum.

'As another example, let us say that you need a function to format time in the AM/PM 'format:
FUNCTION MyTime$(hours, minutes)
LOCAL h
h = hours
IF hours > 12 THEN h = h - 12
MyTime$ = STR$(h) + ":" + STR$(minutes)
IF hours <= 12 THEN
MyTime$ = MyTime$ + "AM"
ELSE
MyTime$ = MyTime$ + "PM"
ENDIF
END FUNCTION

I get this error but i'm unsure how to declare it.

RUN
[70] Text 150,45,Str$(MYTIME),CM,1,2,RGB(WHITE),RGB(BLACK)
Error: MYTIME not declared


Any guidance is much appreciated
Thanks
Michael
SPRINKLER ON TOUCH V4 Rev 3 AM PM.zip
 
twofingers
Guru

Joined: 02/06/2014
Location: Germany
Posts: 1243
Posted: 10:54am 09 Oct 2023
Copy link to clipboard 
Print this post

Hi Michael,

hmm, MYTIME <> MYTIME$ ?

Regards Michael


Please try:
Text 150,45,MYTIME$(hour, minute),CM,1,2,RGB(WHITE),RGB(BLACK)



There is more "bad" (less optimal) code:
SUB PLANTS
   PIN(PLANTSOL)=1     'Sol 3 on
   TEXT 160,100," WATERING PLANTS ",CM,1,2,rgb(BLACK),RGB(BLUE)
   Countdown=Plantsmin
   Gosub Count
   PIN(PLANTSOL)=0     ' Finished watering
   TEXT 160,100,"   PLANTS DONE     ",CM,1,2,rgb(WHITE),RGB(BLUE)
 end sub
 
Count:

 CountLoop:
 TEXT 160,250,STR$(CountDown),CM,1,2,RGB(WHITE),RGB(BLUE)
 pause 1*MINS
 Countdown=Countdown-1
 IF Countdown>0 then goto CountLoop
 endif
 end sub


I would prefer this
SUB PLANTS
   PIN(PLANTSOL)=1     'Sol 3 on
   TEXT 160,100," WATERING PLANTS ",CM,1,2,rgb(BLACK),RGB(BLUE)
   Countdown=Plantsmin
   Count_sub
   PIN(PLANTSOL)=0     ' Finished watering
   TEXT 160,100,"   PLANTS DONE     ",CM,1,2,rgb(WHITE),RGB(BLUE)
end sub
 
Sub Count_sub
 do
   TEXT 160,250,STR$(CountDown),CM,1,2,RGB(WHITE),RGB(BLUE)
   pause MINS
   inc Countdown-1 'oops, I think "INC" is not available for MicroMites
 loop while Countdown>0
end sub


... untested
Edited 2023-10-11 03:41 by twofingers
causality ≠ correlation ≠ coincidence
 
Print this page


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

© JAQ Software 2024