Subversion Repositories DIN Is Noise

Rev

Rev 1974 | Rev 1977 | 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) {
1976 jag 15
  a = 0;
1970 jag 16
  yes = d.autos.pause.yes;
17
  every = d.autos.pause.every ();
18
  f0r = d.autos.pause.f0r ();
1976 jag 19
  rndt[0] = d.autos.pause.every.rndrd;
20
  rndt[1] = d.autos.pause.f0r.rndrd;
1974 jag 21
  settrigt (0, every);
22
  settrigt (1, f0r);
1970 jag 23
  t[0] = &every;
24
  t[1] = &f0r;
1976 jag 25
  vt[0] = &d.autos.pause.every;
26
  vt[1] = &d.autos.pause.f0r;
1970 jag 27
}
28
 
1974 jag 29
void autopauset::settrigt (int i, double& d) {
30
  alarmt& ai = alm[i];
31
  ai.triggert = d;
32
}
33
 
1970 jag 34
void autopauset::operator() (autorotator& ar) {
35
  alarmt &aa = alm[a];
36
  if (aa(ui_clk())) {
37
    aa.stop ();
38
    a = !a;
39
    double& ta = *t[a];
1976 jag 40
    ta = (*vt[a])(rndt[a]);
1970 jag 41
    if (a) ar.yes = 0; else ar.yes = 1;
42
    alarmt& nxt = alm[a];
43
    nxt.triggert = ta;
44
    nxt.start ();
45
  }
46
}
47
 
48
void autopauset::go () {
49
  a = 0;
50
  alm[a].start ();
51
}
1974 jag 52
 
53
void autopauset::setyes (int y, autorotator& ar) {
54
  yes = y;
55
  if (!yes && a) ar.setyes (1);
56
}