Software Update 4: Sequencer Block

Sequencer Klasse eingebaut
  Überprüfung noch ausständig
This commit is contained in:
Erik Tóth
2025-11-13 17:03:04 +01:00
parent 3ad41e6ba5
commit b3d66fdfd8
12 changed files with 641 additions and 234 deletions

View File

@@ -18,6 +18,7 @@
#define MS_DEBOUNCE 20
#define N_MAX_DAC_CH 4
#define N_MAX_SEQUENCE_STEPS 128
struct Key
{
@@ -25,6 +26,12 @@ struct Key
int col;
};
struct voltageDurationPair
{
uint16_t voltage;
uint16_t duration;
};
const Key NOT_A_KEY = {-1, -1};
bool isNotKey(Key k);
@@ -83,4 +90,58 @@ class CV
uint8_t _getKeyToVoltageIndex(Key k);
};
class SequencerBlock
{
public:
SequencerBlock(uint16_t maxDurationMS, uint16_t timeoutMS);
// Aufnahme-Funktionen
void startRecord();
void stopRecord();
void addStep(uint16_t voltage);
bool isRecording();
// Wiedergabe-Funktionen
void startPlay();
void stopPlay();
void update(); // Muss regelmäßig aufgerufen werden
bool isPlaying();
// Sequenz-Verwaltung
void clear();
void setLoop(bool loop);
// Status-Abfragen
bool timeLimitReached();
uint8_t getStepCount();
uint16_t getCurrentVoltage();
uint16_t getTotalDuration();
private:
// Sequenz-Speicher
voltageDurationPair _sequence[N_MAX_SEQUENCE_STEPS];
uint8_t _stepCount;
uint8_t _currentStep;
// Zeitverwaltung
uint16_t _maxDurationMS;
uint16_t _timeoutMS;
unsigned long _recordStartTime;
unsigned long _lastStepTime;
unsigned long _playStartTime;
unsigned long _stepStartTime;
// Status-Flags
bool _isRecording;
bool _isPlaying;
bool _loop;
// Letzte aufgenommene Spannung
uint16_t _lastVoltage;
// Hilfsfunktionen
void _finishCurrentStep();
bool _canAddStep();
};
#endif

View File

@@ -14,6 +14,7 @@
#define N_KEYBOARD_ROW 4
#define N_KEYBOARD_COL 3
#define N_CV_GATES 2
#define N_SB 2
#define BAUDRATE 115200
// PIN DEFENTITIONS
// I2C PINS
@@ -24,7 +25,15 @@
#define PIN_K_R1 8
#define PIN_K_R2 9
#define PIN_K_R3 10
#define PIN_K_R4 // NOT IN USE
#define PIN_K_C0 1
#define PIN_K_C1 2
#define PIN_K_C2 4
#define PIN_K_C3 // NOT IN USE
#define PIN_K_C4 // NOT IN USE
// SEQUENCER BUTTON PINS
#define PIN_SB_1_REC 0
#define PIN_SB_1_PLAY 0
#define PIN_SB_2_REC 0
#define PIN_SB_2_PLAY 0
#endif