Digigurdy-baz
Loading...
Searching...
No Matches
gurdycrank.h
Go to the documentation of this file.
1#ifndef GURDYCRANK_H
2#define GURDYCRANK_H
3
4#include <ADC.h>
5#include <Arduino.h>
6
7#include "buzzknob.h"
8#include "config.h"
9#include "simpleled.h"
10
12 private:
13 int sensor_pin;
14 double spoke_width = 1.0 / (NUM_SPOKES * 2.0);
15 double v_inst = 0.0;
16 double v_last = 0.0;
17 double v_smooth = 0.0;
18 double v_2 = 0.0;
19 double v_3 = 0.0;
20 double v_4 = 0.0;
21 double v_5 = 0.0;
22 double v_6 = 0.0;
23 double v_7 = 0.0;
24 double v_8 = 0.0;
25 double v_avg = 0.0;
26
27 unsigned int this_time;
28 unsigned int lt_1, lt_2, lt_3, lt_4, lt_5, lt_6, lt_7, lt_8 = 0;
29 float lt_avg;
30 float lt_stdev;
31
32 bool last_event;
33 bool this_event;
34 bool was_spinning = false;
35 bool was_buzzing = false;
36
37 int expression;
38
39 BuzzKnob* myKnob;
40
41 #ifdef LED_KNOB
42 SimpleLED* myLED;
43 #endif
44
45 int trans_count = 0;
46 float rev_count = 0;
47
48 elapsedMicros the_timer;
49 elapsedMicros the_spoke_timer;
50 elapsedMicros the_stop_timer;
51 elapsedMillis the_buzz_timer;
52 elapsedMillis the_expression_timer;
53
54 public:
55 GurdyCrank(int s_pin, int buzz_pin, int led_pin);
56
57 bool isDetected();
58 void update();
59 void updateExpression();
60 bool startedSpinning();
61 bool stoppedSpinning();
62 bool isSpinning();
63 bool startedBuzzing();
64 bool stoppedBuzzing();
65 double getVAvg();
66 int getCount();
67 double getRev();
68 void disableLED();
69 void enableLED();
70};
71
72#endif
Definition: buzzknob.h:8
Definition: gurdycrank.h:11
void disableLED()
Disables the buzz LED indicator object.
Definition: gurdycrank.cpp:261
bool isDetected()
Reports if a crank is connected.
Definition: gurdycrank.cpp:33
bool stoppedBuzzing()
Reports whether buzzing stopped this update() cycle.
Definition: gurdycrank.cpp:222
bool startedBuzzing()
Reports whether buzzing began this update() cycle.
Definition: gurdycrank.cpp:201
void enableLED()
Enables the buzz LED indicator object.
Definition: gurdycrank.cpp:269
void updateExpression()
Updates the expression value and applies it to the strings.
Definition: gurdycrank.cpp:135
void update()
Samples the crank and updates its state.
Definition: gurdycrank.cpp:40
double getVAvg()
Returns the crank's current (heavily-adjusted) velocity.
Definition: gurdycrank.cpp:241
bool isSpinning()
Reports whether the crank is currently spinning this update() cycle.
Definition: gurdycrank.cpp:195
int getCount()
Returns the number of detected spoke transitions.
Definition: gurdycrank.cpp:248
bool startedSpinning()
Reports whether the crank started spinning this update() cycle.
Definition: gurdycrank.cpp:165
double getRev()
Returns the number of estimated crank revolutions.
Definition: gurdycrank.cpp:255
bool stoppedSpinning()
Reports whether the crank stopped spinning this update() cycle.
Definition: gurdycrank.cpp:180
Definition: simpleled.h:11
const int NUM_SPOKES
The number of "spokes" on the optical crank wheel.
Definition: config.h:113