refactor: let encoder modify frequency in tone generator
This commit is contained in:
parent
16cec914f8
commit
8c3b5a0134
@ -2,6 +2,7 @@
|
|||||||
#include <Versatile_RotaryEncoder.h>
|
#include <Versatile_RotaryEncoder.h>
|
||||||
|
|
||||||
#include <ui/display.hpp>
|
#include <ui/display.hpp>
|
||||||
|
#include <audio/tone_generator.hpp>
|
||||||
|
|
||||||
#ifndef ENCODER_A_PIN
|
#ifndef ENCODER_A_PIN
|
||||||
#define ENCODER_A_PIN 12
|
#define ENCODER_A_PIN 12
|
||||||
@ -23,7 +24,6 @@ namespace Encoder
|
|||||||
void handleRotate(int8_t rotation);
|
void handleRotate(int8_t rotation);
|
||||||
|
|
||||||
Versatile_RotaryEncoder *encoder;
|
Versatile_RotaryEncoder *encoder;
|
||||||
int frequency = 220; // A4
|
|
||||||
|
|
||||||
void init()
|
void init()
|
||||||
{
|
{
|
||||||
@ -63,6 +63,7 @@ namespace Encoder
|
|||||||
{
|
{
|
||||||
Serial.print("Encoder rotated by ");
|
Serial.print("Encoder rotated by ");
|
||||||
Serial.println(rotation);
|
Serial.println(rotation);
|
||||||
|
int frequency = ToneGenerator::getFrequency();
|
||||||
if (rotation > 0)
|
if (rotation > 0)
|
||||||
{
|
{
|
||||||
frequency += 10;
|
frequency += 10;
|
||||||
@ -71,6 +72,7 @@ namespace Encoder
|
|||||||
{
|
{
|
||||||
frequency -= 10;
|
frequency -= 10;
|
||||||
}
|
}
|
||||||
|
ToneGenerator::setFrequency(frequency);
|
||||||
Serial.print("Frequency: ");
|
Serial.print("Frequency: ");
|
||||||
Serial.println(frequency);
|
Serial.println(frequency);
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user