WorkClock

WorkClock is provided as an example of some of the things that can be done with the Time trigger.

Working on an assembly line, I don't have my hands free to pull my phone out to check the time, but I'm always wearing headphones, so I made it tell me the time at the times when I want to know the time.

I've tinkered with these times for over a year to negate the watched-pot-never-boils effect, while at the same time, giving me something to look forward to.

[WorkClock]
time=%WorkClock_time-%WorkClock_time2
%Location=Work
>WorkClock
<Prep WorkClock

[4:30]
time=16:30-16:31
%Location=Work
>4:30

Prep WorkClock {
1     %WorkClock_task=Format Time(%WorkClock_target,:) if %WorkClock_target set
2     if %WorkClock_eta !set {
3         %WorkClock_target=array pop %WorkClock 1
4         stop if %WorkClock_target !set
5         %WorkClock_etaList="2.00 // say something
                              1.00 // this many hours (sexagesimal fractional component)
                              0.30 // before the target
                              0.15 // time has been
                              0.10 // reached
                              0.05
6         variable split %WorkClock_etaList %newLine
7     }
8     %WorkClock_eta=array pop %WorkClock_etaList 1
9     if %WorkClock_eta set {
10        %WorkClock_time=%WorkClock_target-%WorkClock_eta
11        variable clear %WorkClock_time2
12        variable split %WorkClock_time .
13        array push %WorkClock_time 2 00 if %WorkClock_time2 !set
14        %minuteslen=variable length %WorkClock_time2
15        %WorkClock_time2 &= 0 if %minuteslen<2
16        %WorkClock_time2-=-40 if %WorkClock_time2>59
17        %minuteslen=variable length %WorkClock_time2
18        %WorkClock_time2 &= 0 if %minuteslen<2
19        variable join %WorkClock_time .
20        goto action number 1 if %WorkClock_time<%TIME
21        %WorkClock_task=%WorkClock_eta
22    } else {
23        goto action number 1 if %WorkClock_target<%TIME
24        %WorkClock_time=%WorkClock_target
25    }
26    %WorkClock_time2=%WorkClock_time+0.01
}

WorkClock {
1    %WorkClock_task()
}

Say Time {
1    %time=variable section %TIME 1 5
2    variable split %time .
3    %time1-=12 if %time>12
4    variable join %time :
5    Say(%time)
}

2.00 {
1    Say Time()
}

1.00 {
1    Say Time()
2    Say((one hour))
}

0.30 {
1    Say(30 minutes!)
}

0.15 {
1    Say(15 minutes!)
}

0.10 {
1    Say(10 minutes!)
}

0.05 {
1    Say(5 minutes!)
}

10:00 {
1    Say(It's 10:00! Break time!)
}

12:00 {
1    Say(Lunch time!)
}

4:00 {
1    Say(4:00 (end of the line))
}

4:30 {
1    Say(It's 4:30.)
}

Format Time {                     // %priority+1 must be set when calling
1     variable split %par1 .      // any function which returns a value
2     array push %par1 2 00 if %par12 !set
3     %minuteslen=variable length %par12
4     %par12 &= 0 if %minuteslen<2
5     %par12-=40 if %par12>59
6     %minuteslen=variable length %par12
7     %par12 &= 0 if %minuteslen<2
8     %joiner=.
9     %joiner=%par2 if %par2 set
10    %par11-=12 if %par2 set & %par11>12
11    variable join %par1 %joiner
12    return %par1
}

This calls a Say task I have defined in my audio profile. Create a task called Say. Include 1 action: Alert>Say and put %par1 in the 'Text' field. This will prevent the frustration of changing a dozen commands for a minor alteration.

Initialization is performed in my location profile:

Arriving at Work {
1    %newLine="
               "
2    %Location=Work
3    variable clear %WorkClock_eta
4    %WorkClock="10.00     // main targets for break,
                 12.00     // lunch, and the end of
                 16.00"    // the day
5    variable split %WorkClock %newLine
6    Prep WorkClock ()
}
Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License