refactor: let encoder modify frequency in tone generator

This commit is contained in:
Fritz Heiden 2025-05-24 19:04:45 +02:00
parent 16cec914f8
commit 8c3b5a0134

View File

@ -2,6 +2,7 @@
#include <Versatile_RotaryEncoder.h>
#include <ui/display.hpp>
#include <audio/tone_generator.hpp>
#ifndef ENCODER_A_PIN
#define ENCODER_A_PIN 12
@ -23,7 +24,6 @@ namespace Encoder
void handleRotate(int8_t rotation);
Versatile_RotaryEncoder *encoder;
int frequency = 220; // A4
void init()
{
@ -63,6 +63,7 @@ namespace Encoder
{
Serial.print("Encoder rotated by ");
Serial.println(rotation);
int frequency = ToneGenerator::getFrequency();
if (rotation > 0)
{
frequency += 10;
@ -71,6 +72,7 @@ namespace Encoder
{
frequency -= 10;
}
ToneGenerator::setFrequency(frequency);
Serial.print("Frequency: ");
Serial.println(frequency);