Counting
staticattic
Junior Member
I think I am having a total brain dump or a nervous breakdown or something. I need to fetch a variable, and everytime the user presses a button, that number will increase by one. I am allowing them to set the clock via the touch panel. When they enter the clock settings screen, the current time is displayed. I am capturing that like so:
nHours = ATOI(LEFT_STRING(TIME,2))
nMinutes = ATOI(MID_STRING(TIME,4,2))
That works fine. What I need to now do is allow them to push the hour up or down button and have it increment or decrement the hour by one each button press. After they are done setting the clock, I was going to send the new variables (nHours and nMinutes) to the NetLinx as the new time using this format:
SEND_COMMAND <DEV>,"'CLOCK <mm-dd-yy> <hh:mm:ss>'"
A simple up counter should only take like 5 minutes to write. Maybe I am just tired. I currently have it set up as a FOR loop, but I can't remember how to get it to stop and wait until the button is pressed again. Right now, it goes through the whole thing auomatically.
nHours = ATOI(LEFT_STRING(TIME,2))
nMinutes = ATOI(MID_STRING(TIME,4,2))
That works fine. What I need to now do is allow them to push the hour up or down button and have it increment or decrement the hour by one each button press. After they are done setting the clock, I was going to send the new variables (nHours and nMinutes) to the NetLinx as the new time using this format:
SEND_COMMAND <DEV>,"'CLOCK <mm-dd-yy> <hh:mm:ss>'"
A simple up counter should only take like 5 minutes to write. Maybe I am just tired. I currently have it set up as a FOR loop, but I can't remember how to get it to stop and wait until the button is pressed again. Right now, it goes through the whole thing auomatically.
Comments
-
Couldn't you just do:
BUTTON_EVENT[dvTP,1] // add an hour { PUSH: { nHours++ } } BUTTON_EVENT[dvTP,2] // subtract an hour { PUSH: { nHours-- } } -
Yes, that would work if I was setting the time live. I was going to allow them to set the time and then have it update after they were done. That being the case, nHours and nMinutes really do not change until the new time takes effect. When I just do it that way, all it does it adds one or subtracts one from the current time and that is all. I think I am going to just let the time update live, then I could use that. Thanks for the reply.
-
Using Update Button.
BUTTON_EVENT[dvTP,100] // Plus Hours { PUSH: { // Guarantees 0-23 cHours = ((cHours + 1) % 24); SEND_COMMAND dvTP,"'^TXT-100,0,',FORMAT('%02d',cHours)" } } BUTTON_EVENT[dvTP,101] // Min Hours { PUSH: { // Guarantees 0-23 cHours = ((cHours + 11) % 24); SEND_COMMAND dvTP,"'^TXT-100,0,',FORMAT('%02d',cHours)" } } BUTTON_EVENT[dvTP,102] // Plus Mins { PUSH: { // Guarantees 0-59 cMins = ((cMins + 1) % 60); SEND_COMMAND dvTP,"'^TXT-102,0,',FORMAT('%02d',cMins)" } } BUTTON_EVENT[dvTP,103] // Min Mins { PUSH: { // Guarantees 0-59 cMins = ((cMins + 59) % 60); SEND_COMMAND dvTP,"'^TXT-102,0,',FORMAT('%02d',cMins)" } } BUTTON_EVENT[dvTP,104] // Update { PUSH: { LOCAL_VAR CHAR cDateTime[100]; cDateTime = "FORMAT('%02d',DATE_TO_MONTH(LDATE))"; cDateTime = "cDateTime,FORMAT('-%02d',DATE_TO_DAY(LDATE))"; cDateTime = "cDateTime,FORMAT('-%02d',(DATE_TO_YEAR(LDATE) % 100))"; cDateTime = "cDateTime,FORMAT(' %02d',cHours)"; cDateTime = "cDateTime,FORMAT(':%02d',cMins)"; cDateTime = "cDateTime,FORMAT(':%02d',0)"; SEND_COMMAND 0,"'CLOCK ',cDateTime" } } -
staticattic wrote: »
nHours = ATOI(LEFT_STRING(TIME,2))
nMinutes = ATOI(MID_STRING(TIME,4,2))
// Better Way
nHours = TIME_TO_HOUR(TIME);
nMinutes = TIME_TO_MINUTE(TIME); -
staticattic wrote: »I think I am having a total brain dump or a nervous breakdown or something. I need to fetch a variable, and everytime the user presses a button, that number will increase by one. I am allowing them to set the clock via the touch panel. When they enter the clock settings screen, the current time is displayed. I am capturing that like so:
nHours = ATOI(LEFT_STRING(TIME,2))
nMinutes = ATOI(MID_STRING(TIME,4,2))
That works fine. What I need to now do is allow them to push the hour up or down button and have it increment or decrement the hour by one each button press. After they are done setting the clock, I was going to send the new variables (nHours and nMinutes) to the NetLinx as the new time using this format:
SEND_COMMAND <DEV>,"'CLOCK <mm-dd-yy> <hh:mm:ss>'"
A simple up counter should only take like 5 minutes to write. Maybe I am just tired. I currently have it set up as a FOR loop, but I can't remember how to get it to stop and wait until the button is pressed again. Right now, it goes through the whole thing auomatically.
even better, when using a G4 panel, just copy the buttons from the setup page, and you are done in < 1 minute
-
even better, when using a G4 panel, just copy the buttons from the setup page, and you are done in < 1 minute

You get an A++++++++++++++++++ -
Categories
- All Categories
- 2.5K AMX General Discussion
- 922 AMX Technical Discussion
- 514 AMX Hardware
- 502 AMX Control Products
- 3 AMX Video Distribution Products
- 9 AMX Networked AV (SVSI) Products
- AMX Workspace & Collaboration Products
- 3.4K AMX Software
- 151 AMX Resource Management Suite Software
- 386 AMX Design Tools
- 2.4K NetLinx Studio
- 135 Duet/Cafe Duet
- 248 NetLinx Modules & Duet Modules
- 57 AMX RPM Forum
- 228 MODPEDIA - The Public Repository of Modules for Everyone
- 943 AMX Specialty Forums
- 2.6K AMXForums Archive
- 2.6K AMXForums Archive Threads
- 1.5K AMX Hardware
- 432 AMX Applications and Solutions
- 249 Residential Forum
- 182 Tips and Tricks
- 146 AMX Website/Forums
