Switch-on, switch-off in a time range. Please help...

Former Member
Former Member

Hello.

I try to do a function for my dial that turns off, for example, seconds in a given time range.

I want it to be possible to set it in APP (in xml format). I have everything ready, but the problem is that the function does not work correctly for me yet.

I'm just getting started with MonkeyC programming and I'd appreciate it if someone could help me with my code. All I need is this function and the dial is done.

Here I attach the code


Thank you very much

The error I'm getting in the SIM...

Error: Symbol Not Found Error
Details: Could not find symbol 'today'

Thank you very much

I will give VoteUP for professional help with this feature.

 

  • I would like to warn you in advance that if no one wants to help me, they should not interfere in this discussion at all. Blablabla tips don't help me and they lose their meaning ...

    So don't send 20 mails to the personn you don't want to be help by ;)
    Look at the code I sent, that is not this at all.
    about the error about today, did you put using Toybox.Time ?
    But even with that it won't work, some part of the code I sent you are missing.
  • Former Member
    Former Member

    Edit 24/01

    Can I ask someone for help in this position?

           dc.setColor(Graphics.COLOR_BLACK, Graphics.COLOR_WHITE);
           var Time = System.getClockTime();
           var timeSecString = Lang.format("$1$", [Time.sec.format("%.2d")]);
           
           
           
           
          
          
          
          var T = Time.today().value() +System.getClockTime();
          
          var ON = sleepTime.value().Application.getApp().getProperty("SleepModeON")+T;
          var OFF= wakeTime.value().Application.getApp().getProperty("SleepModeOFF")+T;
            
           
           var P = true;
           T=Time.now().value();
           if(ON>OFF&&(T>ON||T<OFF)){P=false;}
           if(ON<OFF&&T>ON&&T<OFF){P=dc.drawText(x, y, $.fontSeconds, timeSecString, Graphics.TEXT_JUSTIFY_LEFT);}
    	       		
           
           }

    using Toybox.Time;  I have in mc file.

    Thank you very much

  • Hi,

    System.getClockTime() (you've assigned that to Time) doesn't have method called today()

    https://developer.garmin.com/connect-iq/api-docs/Toybox/System/ClockTime.html

    Did you accidentally assigned to that variable? You might want to rename var Time on Line 2 to something else.

  • Former Member
    Former Member in reply to Dresbo

    Hi David, I've tried everything possible, but it doesn't work for me yet, it's just this function, I've managed to do the rest. Can I ask for your help?

    I will be very grateful to you.

  • Hi. Was my answer not clear?  I think you have an error on line 2 as I mentioned.

    That may not be the only issue,  but it's certainly the cause of your current error.

  • Former Member
    Former Member in reply to Dresbo

    The answer was clear, but row two is for the seconds themselves, I'm trying to do the SleepMode function, which turns off the seconds according to the xml settings.

  • On line 2 you're setting a variable called Time. This conflicts with the built in Time definition.  You need to change the name of that variable to something else.

  • Former Member
    Former Member in reply to Dresbo

    and I can request an adjustment, I don't know much about this function, here I have the function of seconds...

    Function SleepMode:

         
          var T = Time.today().value();
          var ON = sleepTime.value().Application.getApp().getProperty("SleepModeON")+T;
          var OFF= wakeTime.value().Application.getApp().getProperty("SleepModeOFF")+T;
            
           
           var P = true;
           T=Time.now().value();
           if(ON>OFF&&(T>ON||T<OFF)){P=false;}
           if(ON<OFF&&T>ON&&T<OFF){P=dc.drawText(x, y, $.fontSeconds, timeSecString, Graphics.TEXT_JUSTIFY_LEFT);}

    Thank you

  • Hi,

    Can you please post all the code. The code you've posted above doesn't have a function wrapping lines 1,2 and 3 which would put Time in scope and likely cause the error you see.

    Have you imported System.Time for the below the first three lines, for example.

  • Former Member
    Former Member in reply to Dresbo

          var T = Time.today().value();
          var ON = sleepTime.value().Application.getApp().getProperty("SleepModeON")+T;
          var OFF= wakeTime.value().Application.getApp().getProperty("SleepModeOFF")+T;
            
           
           var P = true;
           T=Time.now().value();
           if(ON>OFF&&(T>ON||T<OFF)){P=false;}
           if(ON<OFF&&T>ON&&T<OFF){P=dc.drawText(x, y, $.fontSeconds, timeSecString, Graphics.TEXT_JUSTIFY_LEFT);}

    The code they need to adjust for a time-limited function, where the setting is via xml, the time to turn off the seconds. Outside the value (hours) seconds on the desktop will remain displayed ...