diff --git a/UI.hpp b/UI.hpp index e8cdd06..7968a3f 100644 --- a/UI.hpp +++ b/UI.hpp @@ -110,7 +110,8 @@ elapsedMillis back_from_volume; uint8_t instance_num[8][8]; const char accepted_chars[] = " ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-abcdefghijklmnopqrstuvwxyz"; uint8_t active_perform_page = 1; - +uint8_t orig_attack_values[2][7]; +uint8_t orig_release_values[2][7]; #ifdef I2C_DISPLAY #include @@ -4110,36 +4111,49 @@ void UI_func_volume(uint8_t param) if (LCDML.BT_checkDown() ) { + if (perform_attack_mod[selected_instance_id] == 0) + for (uint8_t i = 0; i < 6; i++) { + orig_attack_values[selected_instance_id][i] = MicroDexed[selected_instance_id]->getRateOP(i, ATTACK); + } perform_attack_mod[selected_instance_id] = constrain(perform_attack_mod[selected_instance_id] + ENCODER[ENC_L].speed(), -MAX_PERF_MOD, MAX_PERF_MOD); for (uint8_t i = 0; i < 6; i++) - MicroDexed[selected_instance_id]->setRateOP(i, ATTACK, MicroDexed[selected_instance_id]->getRateOP(i, ATTACK) - perform_attack_mod[selected_instance_id] ); + MicroDexed[selected_instance_id]->setRateOP(i, ATTACK, orig_attack_values[selected_instance_id][i] - perform_attack_mod[selected_instance_id] ); } else if (LCDML.BT_checkUp() ) { + if (perform_attack_mod[selected_instance_id] == 0) // Save initial Values + for (uint8_t i = 0; i < 6; i++) { + orig_attack_values[selected_instance_id][i] = MicroDexed[selected_instance_id]->getRateOP(i, ATTACK); + } + perform_attack_mod[selected_instance_id] = constrain(perform_attack_mod[selected_instance_id] - ENCODER[ENC_L].speed(), -MAX_PERF_MOD, MAX_PERF_MOD); for (uint8_t i = 0; i < 6; i++) - MicroDexed[selected_instance_id]->setRateOP(i, ATTACK, MicroDexed[selected_instance_id]->getRateOP(i, ATTACK) - perform_attack_mod[selected_instance_id] ); - + MicroDexed[selected_instance_id]->setRateOP(i, ATTACK, orig_attack_values[selected_instance_id][i] - perform_attack_mod[selected_instance_id] ); } - } else if (active_perform_page == 3) { //Release if (LCDML.BT_checkDown() ) { + if (perform_release_mod[selected_instance_id] == 0) // Save initial Values + for (uint8_t i = 0; i < 6; i++) { + orig_release_values[selected_instance_id][i] = MicroDexed[selected_instance_id]->getRateOP(i, RELEASE); + } perform_release_mod[selected_instance_id] = constrain(perform_release_mod[selected_instance_id] + ENCODER[ENC_L].speed(), -MAX_PERF_MOD, MAX_PERF_MOD); for (uint8_t i = 0; i < 6; i++) - MicroDexed[selected_instance_id]->setRateOP(i, RELEASE, MicroDexed[selected_instance_id]->getRateOP(i, RELEASE) - perform_release_mod[selected_instance_id] ); - + MicroDexed[selected_instance_id]->setRateOP(i, RELEASE, orig_release_values[selected_instance_id][i] - perform_release_mod[selected_instance_id] ); } else if (LCDML.BT_checkUp() ) { + if (perform_release_mod[selected_instance_id] == 0) + for (uint8_t i = 0; i < 6; i++) { + orig_release_values[selected_instance_id][i] = MicroDexed[selected_instance_id]->getRateOP(i, RELEASE); + } perform_release_mod[selected_instance_id] = constrain(perform_release_mod[selected_instance_id] - ENCODER[ENC_L].speed(), -MAX_PERF_MOD, MAX_PERF_MOD); for (uint8_t i = 0; i < 6; i++) - MicroDexed[selected_instance_id]->setRateOP(i, RELEASE, MicroDexed[selected_instance_id]->getRateOP(i, RELEASE) - perform_release_mod[selected_instance_id] ); - + MicroDexed[selected_instance_id]->setRateOP(i, RELEASE, orig_release_values[selected_instance_id][i] - perform_release_mod[selected_instance_id] ); } } }