Digigurdy-baz
Loading...
Searching...
No Matches
gearcrank.h
Go to the documentation of this file.
1#ifndef GEARCRANK_H
2#define GEARCRANK_H
3
4#include <ADC.h>
5
6#include "buzzknob.h"
7#include "config.h"
8
9extern ADC* adc;
10
11class GearCrank {
12 private:
13 int voltage_pin;
14 static const int num_samples = 500; // This number is from the original code
15 int samples[num_samples];
16 int sample_sum;
17 float sample_mean;
18 float squared_sum;
19 float deviations;
20
21 int crank_voltage;
22
23 long int sample_total;
24 int spin;
25 bool started_spinning;
26 bool stopped_spinning;
27 bool is_spinning;
28
29 BuzzKnob* myKnob;
30 bool started_buzzing;
31 bool stopped_buzzing;
32 bool is_buzzing;
33 int buzz_countdown;
34
35 public:
36 GearCrank(int v_pin, int buzz_pin);
37 void beginPolling();
38 void detect();
39 bool isDetected();
40 void refreshBuzz();
41 void update();
42 bool startedSpinning();
43 bool stoppedSpinning();
44 bool isSpinning();
45 bool startedBuzzing();
46 bool stoppedBuzzing();
47};
48
49#endif
Definition: buzzknob.h:8
Definition: gearcrank.h:11
bool isDetected()
Reports whether or not there is a crank attached.
Definition: gearcrank.cpp:69
void beginPolling()
Begins ADC sampling of the crank's voltage pin.
Definition: gearcrank.cpp:29
bool isSpinning()
Reports if spinning is happening.
Definition: gearcrank.cpp:240
bool stoppedSpinning()
Reports if spinning has sotpped this update() cycle.
Definition: gearcrank.cpp:234
bool stoppedBuzzing()
Reports if buzzing has stopped.
Definition: gearcrank.cpp:252
void refreshBuzz()
Samples the buzz knob and determines if buzzing started and/or is continuing.
Definition: gearcrank.cpp:76
bool startedSpinning()
Reports if spinning has started this update() cycle.
Definition: gearcrank.cpp:228
bool startedBuzzing()
Reports if buzzing has begun.
Definition: gearcrank.cpp:246
void detect()
Determines if the crank is connected or not.
Definition: gearcrank.cpp:39
void update()
Samples the crank voltage.
Definition: gearcrank.cpp:138
ADC * adc
Definition: digigurdy-baz.ino:50