mirror of
https://github.com/erik-toth/audio-synth.git
synced 2025-12-06 12:00:02 +00:00
Firmware MCU: Update sequencer block to support dynamic step count and enhance documentation
This commit is contained in:
@@ -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();
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user