Connect a rotary encoder to Bela's digital inputs, detect the direction of the rotation, and keep track of how far you've gone.
If your encoder has a built-in switch, you can use that to reset the current count.
#include <libraries/Scope/Scope.h>
#include <libraries/Encoder/Encoder.h>
unsigned int kEncChA = 0;
unsigned int kEncChB = 1;
unsigned int kEncChBtn = 2;
unsigned int kDebouncingSamples = 15;
{
gEncoder.
setup(kDebouncingSamples, polarity);
pinMode(context, 0, kEncChA, INPUT);
pinMode(context, 0, kEncChB, INPUT);
pinMode(context, 0, kEncChBtn, INPUT);
return true;
}
bool gButton;
unsigned int holdoff;
{
{
rt_printf(
"%s : %3d\n",
Encoder::CCW == ret ?
"ccw" :
"cw ", gEncoder.
get());
}
if(gButton != button) {
gButton = button;
if(button) {
rt_printf(
"reset : %3d\n", gEncoder.
get());
}
}
if(1)
{
button = 1;
else
button = 0;
}
a * 0.5 + 0.333,
b * 0.5 - 0.333,
button * 0.5 - 0.88
);
}
}
{
}