#ifndef __SETTINGS_H #define __SETTINGS_H #include #include "globals.h" #define EEPROM_VERSION 1 #define EEPROM_VERSION_ADDR 0 #define SETTINGS_OFFSET 2 #define PRESET_MAX_SIZE 128 // Leave extra space for future settings #define PRESET_COUNT 8 #define CALIBRATION_MAX_SIZE 54 // Leave extra space for future settings #define EEPROM_SIZE 1080 // Cannot exceed this amount of EEPROM space static_assert(SETTINGS_OFFSET + PRESET_MAX_SIZE * PRESET_COUNT + CALIBRATION_MAX_SIZE <= EEPROM_SIZE, "Not enough EEPROM"); /** * Sensor calibration is global across presets */ struct calibration_t { int16_t breathThrValOffset = 5; int16_t breathMaxValOffset = 1500; int16_t breathAltThrValOffset = 5; int16_t breathAltMaxValOffset = 1500; int16_t biteThrVal = 50; int16_t biteMaxVal = 150; int16_t pbDnThrVal = 50; int16_t pbDnMaxVal = 150; int16_t pbUpThrVal = 50; int16_t pbUpMaxVal = 150; int16_t leverThrVal = 50; int16_t leverMaxVal = 150; int16_t extraThrVal = 50; int16_t extraMaxVal = 150; int16_t ctouchThrVal = 80; uint8_t _reserved[24]; }; static_assert(sizeof(calibration_t) == CALIBRATION_MAX_SIZE, "calibration data wrong size"); /** * Per-preset config */ struct preset_t { uint8_t MIDIchannel = 1; // Midi channel to send on uint8_t breathCC = 2; // breath CC selection uint8_t altBreathCC = 70; // breath CC selection uint8_t extraCC = 1; // extra CC selection uint8_t leverCC = 7; // "lever" CC selection uint8_t biteCC = 11; // bite CC selection uint8_t fixedVelocity = 0; // Zero = not fixed uint8_t portamentoLimit = 127; // 1-127 - max portamento level uint8_t PBdepth = 1; // OFF:1-12 divider uint8_t deglitch = 20; // debounes time for key/roller inputs uint8_t breathCurve = 4; // breath curve selection uint8_t velSmpDl = 20; // velocity sample delay uint8_t velBias = 0; // velocity bias uint8_t pinkySetting = 12; // 0 - 11 (QuickTranspose -12 to -1), 12 (pb/2), 13 - 24 (QuickTranspose +1 to +12), 25 (EC2), 26 (ECSW), 27 (LVL), 28 (LVLP) uint8_t breathInterval; // 3-15 int8_t trill3_interval = 4; uint8_t vibSquelch = 12; // vibrato signal squelch uint8_t cvVibRate = 0; // OFF, 1 - 8 CV extra controller LFO vibrato rate 4.5Hz to 8Hz int8_t cvTune = 0; int8_t cvScale = 0; PortamentoMode portamentoMode; BreathMode breathMode = BreathMode::BREATH_LSB_AT; FingeringMode fingering = FingeringMode::EVI; RollerMode rollerMode = RollerMode::HIGHEST; ExtraControl biteControl = ExtraControl::GLIDE; ExtraControl leverControl = ExtraControl::VIBRATO; ExtraControl extraControl = ExtraControl::CC; VibratoMode vibratoMode = VSTART_DOWN; // direction of first vibrato wave UPWD or DNWD uint8_t vibratoDepth = 1; // OFF:1-9 uint8_t vibSens = 2; // vibrato sensitivity uint8_t vibRetn = 2; // vibrato return speed uint8_t knob1CC = 71; uint8_t knob2CC = 72; uint8_t knob3CC = 73; uint8_t knob4CC = 74; uint8_t icmAccelMode; uint8_t icmAccelCC; uint8_t icmTiltMode; uint8_t icmTiltCC; uint8_t icmRotationMode; uint8_t icmRotationCC; uint8_t _reserved[87]; }; static_assert(sizeof(preset_t) == PRESET_MAX_SIZE, "preset_t must be 128 bytes"); extern preset_t presets[PRESET_COUNT]; extern calibration_t calibration; extern preset_t *currentPreset; #define NO_CHECKSUM 0x7F007F00 void readEEPROM(const bool factoryReset); void writePreset(uint8_t preset); void writeCalibration(); //Functions for config management mode void sendSysexSettings(); void sendSysexMessage(const char* messageCode); void sendSysexVersion(); void handleSysex(uint8_t *data, unsigned int length); void handleSysexChunk(const uint8_t *data, uint16_t length, bool last); uint32_t crc32(const uint8_t *message, const size_t length); void configInitScreen(); void configShowMessage(const char* message); void configModeSetup(); void configModeLoop(); #endif