Digigurdy-baz
|
#include <gurdycrank.h>
Public Member Functions | |
GurdyCrank (int s_pin, int buzz_pin, int led_pin) | |
Constructor. More... | |
bool | isDetected () |
Reports if a crank is connected. More... | |
void | update () |
Samples the crank and updates its state. More... | |
void | updateExpression () |
Updates the expression value and applies it to the strings. More... | |
bool | startedSpinning () |
Reports whether the crank started spinning this update() cycle. More... | |
bool | stoppedSpinning () |
Reports whether the crank stopped spinning this update() cycle. More... | |
bool | isSpinning () |
Reports whether the crank is currently spinning this update() cycle. More... | |
bool | startedBuzzing () |
Reports whether buzzing began this update() cycle. More... | |
bool | stoppedBuzzing () |
Reports whether buzzing stopped this update() cycle. More... | |
double | getVAvg () |
Returns the crank's current (heavily-adjusted) velocity. More... | |
int | getCount () |
Returns the number of detected spoke transitions. More... | |
double | getRev () |
Returns the number of estimated crank revolutions. More... | |
void | disableLED () |
Disables the buzz LED indicator object. More... | |
void | enableLED () |
Enables the buzz LED indicator object. More... | |
GurdyCrank::GurdyCrank | ( | int | s_pin, |
int | buzz_pin, | ||
int | led_pin | ||
) |
Constructor.
This class abstracts the cranking mechanism on Digi-Gurdies.
If you are not using an LED buzz indicator, a pin for it still needs to be specified here. The object won't touch it unless LED_KNOB is defined.
s_pin | The analog voltage pin coming from the motor. |
buzz_pin | The pin of the buzz knob. |
led_pin | The pin of the LED indicator. |
void GurdyCrank::disableLED | ( | ) |
Disables the buzz LED indicator object.
void GurdyCrank::enableLED | ( | ) |
Enables the buzz LED indicator object.
int GurdyCrank::getCount | ( | ) |
Returns the number of detected spoke transitions.
double GurdyCrank::getRev | ( | ) |
Returns the number of estimated crank revolutions.
double GurdyCrank::getVAvg | ( | ) |
Returns the crank's current (heavily-adjusted) velocity.
bool GurdyCrank::isDetected | ( | ) |
Reports if a crank is connected.
bool GurdyCrank::isSpinning | ( | ) |
Reports whether the crank is currently spinning this update() cycle.
bool GurdyCrank::startedBuzzing | ( | ) |
Reports whether buzzing began this update() cycle.
bool GurdyCrank::startedSpinning | ( | ) |
Reports whether the crank started spinning this update() cycle.
bool GurdyCrank::stoppedBuzzing | ( | ) |
Reports whether buzzing stopped this update() cycle.
bool GurdyCrank::stoppedSpinning | ( | ) |
Reports whether the crank stopped spinning this update() cycle.
void GurdyCrank::update | ( | ) |
Samples the crank and updates its state.
Also updates the buzz knob, and calls updateExpression(). This should be run every loop(). It paces itself internally and expects to be run frequently.
void GurdyCrank::updateExpression | ( | ) |
Updates the expression value and applies it to the strings.
Here expression is calculated based off EXPRESSION_VMAX and EXPRESSION_START along with the current crank velocity. See config.h for those values.