|
Digigurdy-baz
|
#include <gearcrank.h>
Public Member Functions | |
| GearCrank (int v_pin, int buzz_pin) | |
| GearCrank controls the cranking mechanism on geared-crank gurdies. More... | |
| void | beginPolling () |
| Begins ADC sampling of the crank's voltage pin. More... | |
| void | detect () |
| Determines if the crank is connected or not. More... | |
| bool | isDetected () |
| Reports whether or not there is a crank attached. More... | |
| void | refreshBuzz () |
| Samples the buzz knob and determines if buzzing started and/or is continuing. More... | |
| void | update () |
| Samples the crank voltage. More... | |
| bool | startedSpinning () |
| Reports if spinning has started this update() cycle. More... | |
| bool | stoppedSpinning () |
| Reports if spinning has sotpped this update() cycle. More... | |
| bool | isSpinning () |
| Reports if spinning is happening. More... | |
| bool | startedBuzzing () |
| Reports if buzzing has begun. More... | |
| bool | stoppedBuzzing () |
| Reports if buzzing has stopped. More... | |
| GearCrank::GearCrank | ( | int | v_pin, |
| int | buzz_pin | ||
| ) |
| void GearCrank::beginPolling | ( | ) |
Begins ADC sampling of the crank's voltage pin.
HIGH_SPEED continuous sampling is being used here. This is very fast (readings are available on-deman, no delay), but ties up one of the ADCs full-time.
| void GearCrank::detect | ( | ) |
Determines if the crank is connected or not.
This takes advantage of the fact that analog pin voltage "wanders" without some resistance on it. Calculating the standard deviation of a series of readings determines if crank is conntected/attached.
| bool GearCrank::isDetected | ( | ) |
Reports whether or not there is a crank attached.
| bool GearCrank::isSpinning | ( | ) |
Reports if spinning is happening.
| void GearCrank::refreshBuzz | ( | ) |
Samples the buzz knob and determines if buzzing started and/or is continuing.
Performs a simple greater-than comparison between the crank's voltage and the knob.
| bool GearCrank::startedBuzzing | ( | ) |
Reports if buzzing has begun.
| bool GearCrank::startedSpinning | ( | ) |
Reports if spinning has started this update() cycle.
| bool GearCrank::stoppedBuzzing | ( | ) |
Reports if buzzing has stopped.
| bool GearCrank::stoppedSpinning | ( | ) |
Reports if spinning has sotpped this update() cycle.
| void GearCrank::update | ( | ) |
Samples the crank voltage.
Also subtracts the average voltage detected during crank detection as a form of noise reduction.