-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathomower-current.cpp
More file actions
37 lines (30 loc) · 1.16 KB
/
omower-current.cpp
File metadata and controls
37 lines (30 loc) · 1.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
// Current sensor class for OMower
// $Id$
#include <omower-root.h>
#include <Arduino.h>
#include <due-adc-scan.h>
#include <omower-debug.h>
// stub
_status currentThing::init() {
return _status::NOERR;
} // _status currentThing::init()
// stub
uint16_t currentThing::readRawCurrent(numThing n) {
return 0;
} // uint16_t currentThing::readRawCurrent(numThing n)
// Current reading, -1 - sum for all things of same class
float currentThing::readCurrent(numThing n) {
int32_t sum;
numThing i;
if (n != -1) {
return kCurrent * ((int16_t) readRawCurrent(n) - (int16_t) zeroOffset);
}
sum = 0;
for (i = 0; i < numThings(); i++)
sum += ((int16_t) readRawCurrent(i) - (int16_t) zeroOffset);
return kCurrent * sum;
} // float currentThing::readCurrent(numThing n)
// Calibrate ACS725 sensor (when there is sure zero current)
void currentThing::calibCurrent(numThing n) {
zeroOffset = readRawCurrent(n);
} // void currentThing::calibCurrent(numThing n)