Digigurdy-baz
Loading...
Searching...
No Matches
Public Member Functions | List of all members
GurdyCrank Class Reference

#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...
 

Constructor & Destructor Documentation

◆ GurdyCrank()

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.

Warning
This is for optical-sensor cranks. See GearCrank for a gear-motor crank version.
  • A hidden member object here is a BuzzKnob.
  • This class' header includes common.h and specific string objects are expected to exist. See common.h.
Parameters
s_pinThe analog voltage pin coming from the motor.
buzz_pinThe pin of the buzz knob.
led_pinThe pin of the LED indicator.

Member Function Documentation

◆ disableLED()

void GurdyCrank::disableLED ( )

Disables the buzz LED indicator object.

Note
This does nothing if LED_KNOB is not defined.

◆ enableLED()

void GurdyCrank::enableLED ( )

Enables the buzz LED indicator object.

Note
This does nothing if LED_KNOB is not defined.

◆ getCount()

int GurdyCrank::getCount ( )

Returns the number of detected spoke transitions.

Returns
The number of detected off->on and on->off events.
Note
This is for debug purposes to see how well it tracks. Not part of the core logic.

◆ getRev()

double GurdyCrank::getRev ( )

Returns the number of estimated crank revolutions.

Returns
The number of estimated crank revolutions.
Note
This is for testing purposes and not part of the core logic.

◆ getVAvg()

double GurdyCrank::getVAvg ( )

Returns the crank's current (heavily-adjusted) velocity.

Returns
The crank's measured current average velocity in estimated RPMs.

◆ isDetected()

bool GurdyCrank::isDetected ( )

Reports if a crank is connected.

Returns
True
Note
Currently this method is pointless. Gear-motor cranks do use this, however, and this is being kept for future changes. It may be useful to expect any crank object to be able to report this in-code whether or not it's relevant...

◆ isSpinning()

bool GurdyCrank::isSpinning ( )

Reports whether the crank is currently spinning this update() cycle.

Returns
True if crank is spinning, false otherwise.

◆ startedBuzzing()

bool GurdyCrank::startedBuzzing ( )

Reports whether buzzing began this update() cycle.

Returns
True if buzzing started thie cycle, false otherwise.

◆ startedSpinning()

bool GurdyCrank::startedSpinning ( )

Reports whether the crank started spinning this update() cycle.

Returns
True if crank started spinning this cycle, false otherwise

◆ stoppedBuzzing()

bool GurdyCrank::stoppedBuzzing ( )

Reports whether buzzing stopped this update() cycle.

Returns
True if buzzing stopped thie cycle, false otherwise.

◆ stoppedSpinning()

bool GurdyCrank::stoppedSpinning ( )

Reports whether the crank stopped spinning this update() cycle.

Returns
True if crank stopped spinning this cycle, false otherwise

◆ update()

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.

◆ updateExpression()

void GurdyCrank::updateExpression ( )

Updates the expression value and applies it to the strings.

  • Expression is MIDI CC11 which is usually interpreted as a volume adjustment independent of the channel volume.

Here expression is calculated based off EXPRESSION_VMAX and EXPRESSION_START along with the current crank velocity. See config.h for those values.

  • The end-user effect is that the volume "swells" as the user cranks faster up to a point.

The documentation for this class was generated from the following files: