Added peak-to-peak output voltage configuration menu for SGTL5000 (Teensy-

Audio-sield).
Fixed some minor problems.
pull/32/head
Holger Wirtz 4 years ago
parent bcebb3f29a
commit 78733b8ff3
  1. 16
      MicroDexed.ino
  2. 72
      UI.hpp
  3. 6
      UI_1.h
  4. 6
      UI_1_FX.h
  5. 6
      UI_2.h
  6. 6
      UI_2_FX.h
  7. 5
      config.h

@ -216,6 +216,9 @@ uint32_t peak_l = 0;
bool eeprom_update_flag = false;
config_t configuration;
uint8_t selected_dexed_instance = 0;
#if defined(TEENSY_AUDIO_BOARD)
uint8_t sgtl5000_level = SGTL5000_LINEOUT_LEVEL_DEFAULT;
#endif
#if defined(USE_FX)
// Allocate the delay lines for chorus
@ -1309,6 +1312,18 @@ void initial_values_from_eeprom(bool init)
MicroDexed[instance_id]->fx.Cutoff = mapfloat(configuration.dexed[instance_id].filter_cutoff, FILTER_CUTOFF_MIN, FILTER_CUTOFF_MAX, 1.0, 0.0);
}
}
#if defined(TEENSY_AUDIO_BOARD)
// Special handling for SGTL5000 volume setting
uint8_t sgtl5000_level = EEPROM[4095];
if (sgtl5000_level >= SGTL5000_LINEOUT_LEVEL_MIN || sgtl5000_level <= SGTL5000_LINEOUT_LEVEL_MAX)
{
sgtl5000_level = SGTL5000_LINEOUT_LEVEL_DEFAULT;
EEPROM[4095] = SGTL5000_LINEOUT_LEVEL_DEFAULT;
}
Serial.print(F("SGTL5000 output level: "));
Serial.println(sgtl5000_level);
#endif
Serial.println(F("OK, loaded!"));
master_mixer_r.gain(DEXED, 1.0);
@ -1407,6 +1422,7 @@ void init_configuration(void)
configuration.delay_feedback = DELAY_FEEDBACK_DEFAULT;
configuration.delay_level = DELAY_LEVEL_DEFAULT;
configuration.soft_midi_thru = SOFT_MIDI_THRU_DEFAULT;
strcpy(configuration.config_name, "INITCONFIG");
for (uint8_t instance_id = 0; instance_id < NUM_DEXED; instance_id++)
{
configuration.dexed[instance_id].midi_channel = DEFAULT_MIDI_CHANNEL;

@ -87,6 +87,7 @@ extern AudioSourceMicroDexed* MicroDexed[NUM_DEXED];
extern AudioEffectMonoStereo* mono2stereo[NUM_DEXED];
extern AudioSynthWaveformDc* pan[NUM_DEXED];
extern uint8_t selected_dexed_instance;
extern uint8_t sgtl5000_level;
/***********************************************************************
GLOBAL
@ -198,6 +199,9 @@ void UI_func_volume(uint8_t param);
void UI_func_load(uint8_t param);
void UI_func_save(uint8_t param);
void UI_func_midi_soft_thru(uint8_t param);
#if defined(TEENSY_AUDIO_BOARD)
void UI_func_output_level(uint8_t param);
#endif
void UI_function_not_enabled(void);
void UI_function_not_implemented(uint8_t param);
void lcd_display_int(int16_t var, uint8_t size, bool zeros, bool brackets, bool sign);
@ -309,7 +313,7 @@ void lcdml_menu_control(void)
{
if (!button[ENC_R])
{
LCDML.BT_left();
LCDML.BT_right();
g_LCDML_CONTROL_button_prev[ENC_R] = LOW;
g_LCDML_CONTROL_button_press_time[ENC_R] = -1;
}
@ -336,12 +340,12 @@ void lcdml_menu_control(void)
}
else
{
if (!button[ENC_R] && g_LCDML_CONTROL_button_prev[ENC_R]) //falling edge, button[ENC_R] pressed
if (!button[ENC_R] && g_LCDML_CONTROL_button_prev[ENC_R]) // falling edge, button[ENC_R] pressed
{
g_LCDML_CONTROL_button_prev[ENC_R] = LOW;
g_LCDML_CONTROL_button_press_time[ENC_R] = millis();
}
else if (button[ENC_R] && !g_LCDML_CONTROL_button_prev[ENC_R]) //rising edge, button[ENC_R] not active
else if (button[ENC_R] && !g_LCDML_CONTROL_button_prev[ENC_R]) // rising edge, button[ENC_R] not active
{
g_LCDML_CONTROL_button_prev[ENC_R] = HIGH;
@ -392,12 +396,12 @@ void lcdml_menu_control(void)
}
else
{
if (!button[ENC_L] && g_LCDML_CONTROL_button_prev[ENC_L]) //falling edge, button[ENC_L] pressed
if (!button[ENC_L] && g_LCDML_CONTROL_button_prev[ENC_L]) // falling edge, button[ENC_L] pressed
{
g_LCDML_CONTROL_button_prev[ENC_L] = LOW;
g_LCDML_CONTROL_button_press_time[ENC_L] = millis();
}
else if (button[ENC_L] && !g_LCDML_CONTROL_button_prev[ENC_L]) //rising edge, button[ENC_L] not active
else if (button[ENC_L] && !g_LCDML_CONTROL_button_prev[ENC_L]) // rising edge, button[ENC_L] not active
{
g_LCDML_CONTROL_button_prev[ENC_L] = HIGH;
@ -439,7 +443,7 @@ void encoder_right_up(void)
break;
case MENU_VOICE:
#ifdef DEBUG
Serial.println(F("State: MENU_VOICE, Encoder left up"));
Serial.println(F("State: MENU_VOICE, Encoder right up"));
#endif
switch (menu_voice)
{
@ -500,7 +504,7 @@ void encoder_right_down(void)
break;
case MENU_VOICE:
#ifdef DEBUG
Serial.println(F("State: MENU_VOICE, Encoder left down"));
Serial.println(F("State: MENU_VOICE, Encoder right down"));
#endif
switch (menu_voice)
{
@ -2983,6 +2987,54 @@ void UI_func_midi_soft_thru(uint8_t param)
}
}
#if defined(TEENSY_AUDIO_BOARD)
void UI_func_output_level(uint8_t param)
{
if (LCDML.FUNC_setup()) // ****** SETUP *********
{
// setup function
sgtl5000_level = EEPROM[4095];
lcd_special_chars(BLOCKBAR);
lcd_display_bar_int("Output Level", sgtl5000_level, SGTL5000_LINEOUT_LEVEL_MIN, SGTL5000_LINEOUT_LEVEL_MAX, 2, false, false, false, true);
}
if (LCDML.FUNC_loop()) // ****** LOOP *********
{
if (LCDML.BT_checkEnter())
{
LCDML.FUNC_goBackToMenu();
}
else if (LCDML.BT_checkDown() || LCDML.BT_checkUp())
{
if (LCDML.BT_checkDown())
{
if (sgtl5000_level < SGTL5000_LINEOUT_LEVEL_MAX)
{
sgtl5000_level += 1;
}
}
else if (LCDML.BT_checkUp())
{
if (sgtl5000_level > SGTL5000_LINEOUT_LEVEL_MIN)
{
sgtl5000_level -= 1;
}
}
}
sgtl5000_1.lineOutLevel(sgtl5000_level);
lcd_display_bar_int("Output Level", sgtl5000_level, SGTL5000_LINEOUT_LEVEL_MIN, SGTL5000_LINEOUT_LEVEL_MAX, 2, false, false, false, false);
}
if (LCDML.FUNC_close()) // ****** STABLE END *********
{
// you can here reset some global vars or do nothing
lcd_special_chars(SCROLLBAR);
EEPROM[4095] = sgtl5000_level;
}
}
#endif
void UI_func_voice_selection(uint8_t param)
{
#ifdef DEBUG
@ -3306,7 +3358,7 @@ void lcd_display_float(float var, uint8_t size_number, uint8_t size_fraction, bo
void lcd_display_bar_int(const char* title, uint32_t value, uint32_t min_value, uint32_t max_value, uint8_t size, bool zeros, bool brackets, bool sign, bool init)
{
float _v = float(value * LCD_cols) / (max_value - min_value);
float _v = float((value - min_value) * LCD_cols) / (max_value - min_value);
float _vi = 0.0;
uint8_t vf = uint8_t(modff(_v, &_vi) * 10.0 + 0.5);
uint8_t vi = uint8_t(_vi + 0.5);
@ -3337,7 +3389,7 @@ void lcd_display_bar_int(const char* title, uint32_t value, uint32_t min_value,
if (vf > 1)
{
lcd.setCursor(vi, 1);
lcd.setCursor(vi , 1);
lcd.write((uint8_t)int(vf / 2) - 1);
}
}
@ -3345,7 +3397,7 @@ void lcd_display_bar_int(const char* title, uint32_t value, uint32_t min_value,
else
{
// show only changed value and changed part of the bar
uint8_t ca = float(LCD_cols - 1) / float(max_value - min_value) + 1;
uint8_t ca = float(LCD_cols - 1) / float(max_value) + 1;
lcd.setCursor(LCD_cols - (size + 1) + 1, 0);
lcd_display_int(value, size, zeros, brackets, sign);

@ -66,8 +66,14 @@ LCDML_add(37, LCDML_0_2, 2, "Save", UI_func_save);
LCDML_add(38, LCDML_0, 3, "System", NULL);
LCDML_add(39, LCDML_0_3, 1, "Stereo/Mono", UI_func_stereo_mono);
LCDML_add(40, LCDML_0_3, 2, "MIDI Soft THRU", UI_func_midi_soft_thru);
#if defined(TEENSY_AUDIO_BOARD)
LCDML_add(41, LCDML_0_3, 3, "Output Level", UI_func_output_level);
LCDML_add(42, LCDML_0, 4, "Info", UI_func_information);
#define _LCDML_DISP_cnt 42
#else
LCDML_add(41, LCDML_0, 4, "Info", UI_func_information);
#define _LCDML_DISP_cnt 41
#endif
#define MENU_ID_OF_INSTANCE_2 35
#endif

@ -86,8 +86,14 @@ LCDML_add(57, LCDML_0_3, 2, "Save", UI_func_save);
LCDML_add(58, LCDML_0, 4, "System", NULL);
LCDML_add(59, LCDML_0_4, 1, "Stereo/Mono", UI_func_stereo_mono);
LCDML_add(60, LCDML_0_4, 2, "MIDI Soft THRU", UI_func_midi_soft_thru);
#if defined(TEENSY_AUDIO_BOARD)
LCDML_add(61, LCDML_0_4, 3, "Output Level", UI_func_output_level);
LCDML_add(62, LCDML_0, 5, "Info", UI_func_information);
#define _LCDML_DISP_cnt 62
#else
LCDML_add(61, LCDML_0, 5, "Info", UI_func_information);
#define _LCDML_DISP_cnt 61
#endif
#define MENU_ID_OF_INSTANCE_2 41
#endif

@ -102,8 +102,14 @@ LCDML_add(73, LCDML_0_3, 2, "Save", UI_func_save);
LCDML_add(74, LCDML_0, 4, "System", NULL);
LCDML_add(74, LCDML_0_4, 1, "Stereo/Mono", UI_func_stereo_mono);
LCDML_add(75, LCDML_0_4, 2, "MIDI Soft THRU", UI_func_midi_soft_thru);
#if defined(TEENSY_AUDIO_BOARD)
LCDML_add(76, LCDML_0_4, 3, "Output Level", UI_func_output_level);
LCDML_add(77, LCDML_0, 5, "Info", UI_func_information);
#define _LCDML_DISP_cnt 77
#else
LCDML_add(76, LCDML_0, 5, "Info", UI_func_information);
#define _LCDML_DISP_cnt 76
#endif
#define MENU_ID_OF_INSTANCE_2 36
#endif

@ -128,8 +128,14 @@ LCDML_add(99, LCDML_0_3, 2, "Save", UI_func_save);
LCDML_add(100, LCDML_0, 4, "System", NULL);
LCDML_add(101, LCDML_0_4, 1, "Stereo/Mono", UI_func_stereo_mono);
LCDML_add(102, LCDML_0_4, 2, "MIDI Soft THRU", UI_func_midi_soft_thru);
#if defined(TEENSY_AUDIO_BOARD)
LCDML_add(103, LCDML_0_4, 3, "Output Level", UI_func_output_level);
LCDML_add(104, LCDML_0, 5, "Info", UI_func_information);
#define _LCDML_DISP_cnt 104
#else
LCDML_add(103, LCDML_0, 5, "Info", UI_func_information);
#define _LCDML_DISP_cnt 103
#endif
#define MENU_ID_OF_INSTANCE_2 42
#endif

@ -471,6 +471,10 @@ enum { DEXED, CHORUS, DELAY, REVERB};
#define SOFT_MIDI_THRU_MAX 1
#define SOFT_MIDI_THRU_DEFAULT 1
#define SGTL5000_LINEOUT_LEVEL_MIN 13
#define SGTL5000_LINEOUT_LEVEL_MAX 31
#define SGTL5000_LINEOUT_LEVEL_DEFAULT SGTL5000_LINEOUT_LEVEL
//
typedef struct {
uint8_t midi_channel;
@ -524,6 +528,7 @@ typedef struct {
uint8_t delay_level;
uint8_t soft_midi_thru;
dexed_t dexed[NUM_DEXED];
char config_name[11];
} config_t;
#if !defined(_MAPFLOAT)

Loading…
Cancel
Save