-
Notifications
You must be signed in to change notification settings - Fork 10
/
gearcrank.h
49 lines (40 loc) · 937 Bytes
/
gearcrank.h
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
38
39
40
41
42
43
44
45
46
47
48
49
#ifndef GEARCRANK_H
#define GEARCRANK_H
#include <ADC.h>
#include "buzzknob.h"
#include "config.h"
extern ADC* adc;
class GearCrank {
private:
int voltage_pin;
static const int num_samples = 500; // This number is from the original code
int samples[num_samples];
int sample_sum;
float sample_mean;
float squared_sum;
float deviations;
int crank_voltage;
long int sample_total;
int spin;
bool started_spinning;
bool stopped_spinning;
bool is_spinning;
BuzzKnob* myKnob;
bool started_buzzing;
bool stopped_buzzing;
bool is_buzzing;
int buzz_countdown;
public:
GearCrank(int v_pin, int buzz_pin);
void beginPolling();
void detect();
bool isDetected();
void refreshBuzz();
void update();
bool startedSpinning();
bool stoppedSpinning();
bool isSpinning();
bool startedBuzzing();
bool stoppedBuzzing();
};
#endif