Firmware MCU: Update sequencer block to support dynamic step count and enhance documentation

This commit is contained in:
2025-12-01 22:45:58 +01:00
parent b106859252
commit 855fd01821
6 changed files with 82 additions and 50 deletions

View File

@@ -12,13 +12,11 @@
#ifndef FIRMWARE_H
#define FIRMWARE_H
#define N_MAX_QUEUE 10
#define N_MAX_ROWS 8
#define N_MAX_COLS 8
#define MS_DEBOUNCE 20
#define N_MAX_DAC_CH 4
#define N_MAX_SEQUENCE_STEPS 128
#define N_MAX_QUEUE 10
#define N_MAX_ROWS 8
#define N_MAX_COLS 8
#define MS_DEBOUNCE 20
#define N_MAX_DAC_CH 4
struct Key
{
@@ -94,7 +92,7 @@ class CV
class SequencerBlock
{
public:
SequencerBlock(uint16_t maxDurationMS, uint16_t minStepDurationMS);
SequencerBlock(uint16_t maxDurationMS, uint16_t maxStepCount);
// Aufnahme-Funktionen
void startRecord();
@@ -105,7 +103,7 @@ class SequencerBlock
// Wiedergabe-Funktionen
void startPlay();
void stopPlay();
void update(); // Muss regelmäßig aufgerufen werden
void update();
bool isPlaying();
// Sequenz-Verwaltung
@@ -114,35 +112,44 @@ class SequencerBlock
// Status-Abfragen
bool timeLimitReached();
uint8_t getStepCount();
bool stepLimitReached();
uint16_t getStepCount();
uint16_t getCurrentVoltageCh1();
uint16_t getCurrentVoltageCh2();
uint16_t getTotalDuration();
private:
// Sequenz-Speicher
DualVoltageDurationPair _sequence[N_MAX_SEQUENCE_STEPS];
uint8_t _stepCount;
uint8_t _currentStep;
/*!
* @brief Memory limiting
* @return (uint16_t) 1024
* @attention Increasing the value might lead to an overflow
* @note sizeOf(DualVoltageDurationPair) = 6 Byte ==> 6 Byte * 1024 = 6144 Byte
*/
const static uint16_t _MAX_SEQUENCE_STEPS = 1024;
// Sequenz memory
DualVoltageDurationPair _sequence[_MAX_SEQUENCE_STEPS];
uint16_t _stepCount;
uint16_t _currentStep;
// Zeitverwaltung
// Time management
uint16_t _maxDurationMS;
uint16_t _minStepDurationMS;
uint16_t _maxStepCount;
unsigned long _recordStartTime;
unsigned long _lastStepTime;
unsigned long _playStartTime;
unsigned long _stepStartTime;
// Status-Flags
// Status flags
bool _isRecording;
bool _isPlaying;
bool _loop;
// Letzte aufgenommene Spannungen
// Last recorded Voltage: at n-th step minus one
uint16_t _lastVoltageCh1;
uint16_t _lastVoltageCh2;
// Hilfsfunktionen
// helper functions
void _finishCurrentStep();
bool _canAddStep();
};