ERIS CORE

◆ update()

bool AnalogInputs::update ( )
inline

update returns true if a change is detected; false otherwise update is rate limited. additional calls will always return false

Returns
true
false

Definition at line 49 of file AnalogInputs.h.

49  {
50  bool trigger;
51  trigger=false;
52  //rate limit the updates
53  if (et_last_update < MAX_POLLING_RATE) return false;
54  et_last_update = 0;
55  const int16_t old_ai[4] = {ai[0],ai[1],ai[2],ai[3]};
56  //AudioNoInterrupts();
57  ai[0] = (ai[0] * 0.4) + (analogRead(AN1) * 0.6);
58  ai[1] = (ai[1] * 0.4) + (analogRead(AN2) * 0.6);
59  ai[2] = (ai[2] * 0.4) + (analogRead(AN3) * 0.6);
60  ai[3] = (ai[3] * 0.4) + (analogRead(AN4) * 0.6);
61  //AudioInterrupts();
62 
63  //DEBUG REMOVE!!!
64  ai[0] = 1000;
65  ai[1] = 512;
66  ai[2] = 1000;
67  ai[3] = 1000;
68 
69  if (abs(ai[0] - old_ai[0])>TRIGGER_DELTA) trigger = true;
70  if (abs(ai[1] - old_ai[1])>TRIGGER_DELTA) trigger = true;
71  if (abs(ai[2] - old_ai[2])>TRIGGER_DELTA) trigger = true;
72  if (abs(ai[3] - old_ai[3])>TRIGGER_DELTA) trigger = true;
73  if (et_last_trigger > ANALOG_INPUTS_PERIODIC_UPDATE) trigger = true;
74  if (trigger == true){
75  et_last_trigger = 0;
76  return true;
77  }
78  return false;
79  }
int16_t ai[4]
Definition: AnalogInputs.h:27
elapsedMillis et_last_update
Definition: AnalogInputs.h:28
elapsedMillis et_last_trigger
Definition: AnalogInputs.h:29

References ai, et_last_trigger, and et_last_update.

Referenced by AppManager::update().

+ Here is the caller graph for this function: