Subversion Repositories DIN Is Noise

Rev

Rev 1971 | Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
1970 jag 1
/*
2
* autopause.cc
3
* DIN Is Noise is copyright (c) 2006-2022 Jagannathan Sampath
4
* DIN Is Noise is released under GNU Public License 2.0
5
* For more information, please visit https://dinisnoise.org/
6
*/
7
 
8
#include "chrono.h"
9
#include "autopause.h"
10
#include "defvelaccel.h"
11
#include "autorotator.h"
12
 
13
autopauset::autopauset (defvelaccel& d) {
14
  yes = d.autos.pause.yes;
15
  every = d.autos.pause.every ();
16
  f0r = d.autos.pause.f0r ();
17
  alarmt &a0 = alm[0], &a1 = alm[1];
18
  a0.triggert = every;
19
  a1.triggert = f0r;
20
  t[0] = &every;
21
  t[1] = &f0r;
22
  vt[0] = &d.autos.pause.every;
23
  vt[1] = &d.autos.pause.f0r;
24
  a = 0;
25
}
26
 
27
void autopauset::operator() (autorotator& ar) {
28
  alarmt &aa = alm[a];
29
  if (aa(ui_clk())) {
30
    aa.stop ();
31
    a = !a;
32
    double& ta = *t[a];
33
    ta = (*vt[a])();
34
    if (a) ar.yes = 0; else ar.yes = 1;
35
    alarmt& nxt = alm[a];
36
    nxt.triggert = ta;
37
    nxt.start ();
38
  }
39
}
40
 
41
void autopauset::go () {
42
  a = 0;
43
  alm[a].start ();
44
}