mirror of
https://github.com/erik-toth/audio-synth.git
synced 2025-12-06 15:20:01 +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();
|
||||
};
|
||||
|
||||
@@ -11,11 +11,12 @@
|
||||
#include <Arduino.h>
|
||||
#include <Wire.h>
|
||||
// CONSTANTS DEFINITONS
|
||||
#define N_KEYBOARD_ROW 4
|
||||
#define N_KEYBOARD_COL 3
|
||||
#define N_KEYBOARD_ROW 4 // for PROD. change to 5
|
||||
#define N_KEYBOARD_COL 3 // for PROD. change to 5
|
||||
#define N_CV_GATES 2
|
||||
#define N_SB 2
|
||||
#define BAUDRATE 115200
|
||||
#define N_MAX_SEQ_STEPS 512
|
||||
// PIN DEFENTITIONS
|
||||
// I2C PINS
|
||||
#define PIN_SDA 15
|
||||
@@ -25,15 +26,22 @@
|
||||
#define PIN_K_R1 8
|
||||
#define PIN_K_R2 9
|
||||
#define PIN_K_R3 10
|
||||
#define PIN_K_R4 // 11 NOT IN USE
|
||||
#define PIN_K_R4 11 // DEV. not in use
|
||||
#define PIN_K_C0 1
|
||||
#define PIN_K_C1 2
|
||||
#define PIN_K_C2 4
|
||||
#define PIN_K_C3 // 5 NOT IN USE
|
||||
#define PIN_K_C4 // 6 NOT IN USE
|
||||
#define PIN_K_C3 5 // DEV. not in use
|
||||
#define PIN_K_C4 6 // DEV. not in use
|
||||
// SEQUENCER BUTTON PINS
|
||||
#define PIN_SB_1_REC 37 // 33 not available on dev board
|
||||
#define PIN_SB_1_PLAY 38 // 34 not available on dev board
|
||||
#define PIN_SB_1_REC 37 // for PROD. change to 33 / not available on dev board
|
||||
#define PIN_SB_1_PLAY 38 // for PROD. change to 34 / not available on dev board
|
||||
#define PIN_SB_2_REC 35
|
||||
#define PIN_SB_2_PLAY 36
|
||||
#define PIN_SB_2_PLAY 36
|
||||
// MISC/INFO PINS
|
||||
#define PIN_ACTIVE -1 // TODO: if any key is played return HIGH
|
||||
#define PIN_REC -1 // TODO: if any sb is recording return HIGH
|
||||
#define PIN_BPM -1 // TODO: get bpm through potentiometer analog value
|
||||
#define PIN_B_METRONOME -1 // TODO: button activates/deactivates bpm led output
|
||||
#define PIN_L_METRONOME -1 // TODO: led blinks according to bpm value
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user