Subversion Repositories DIN Is Noise

Rev

Rev 1970 | Rev 1974 | Go to most recent revision | Details | Compare with Previous | 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"
1971 jag 12
#include "console.h"
1970 jag 13
 
14
autopauset::autopauset (defvelaccel& d) {
15
  yes = d.autos.pause.yes;
16
  every = d.autos.pause.every ();
17
  f0r = d.autos.pause.f0r ();
18
  alarmt &a0 = alm[0], &a1 = alm[1];
19
  a0.triggert = every;
20
  a1.triggert = f0r;
21
  t[0] = &every;
22
  t[1] = &f0r;
23
  vt[0] = &d.autos.pause.every;
24
  vt[1] = &d.autos.pause.f0r;
25
  a = 0;
26
}
27
 
28
void autopauset::operator() (autorotator& ar) {
29
  alarmt &aa = alm[a];
30
  if (aa(ui_clk())) {
31
    aa.stop ();
32
    a = !a;
33
    double& ta = *t[a];
34
    ta = (*vt[a])();
35
    if (a) ar.yes = 0; else ar.yes = 1;
36
    alarmt& nxt = alm[a];
37
    nxt.triggert = ta;
38
    nxt.start ();
39
  }
40
}
41
 
42
void autopauset::go () {
43
  a = 0;
44
  alm[a].start ();
45
}