mirror of
https://github.com/jhbruhn/eurorack.git
synced 2025-03-15 02:55:49 +00:00
Improve startup sequence for leds
This commit is contained in:
parent
0b59c9edb1
commit
30a9b3a124
3 changed files with 11 additions and 6 deletions
|
@ -55,7 +55,7 @@ class Leds {
|
|||
|
||||
htim1.Init.Prescaler = 1;
|
||||
htim1.Init.CounterMode = TIM_COUNTERMODE_UP;
|
||||
htim1.Init.Period = 1024; // 10 bit
|
||||
htim1.Init.Period = 1024 - 2; // 10 bit
|
||||
htim1.Init.ClockDivision = TIM_CLOCKDIVISION_DIV1;
|
||||
HAL_TIM_PWM_Init(&htim1);
|
||||
|
||||
|
|
|
@ -60,9 +60,11 @@ void UI::Poll()
|
|||
}
|
||||
if (abs(previous_pot_values[i] - adc->value(ADC_GROUP_POT + i)) > 1900) {
|
||||
previous_pot_values[i] = adc->value(ADC_GROUP_POT + i);
|
||||
queue.AddEvent(CONTROL_POT, i, previous_pot_values[i]);
|
||||
if(pots_touched)
|
||||
queue.AddEvent(CONTROL_POT, i, previous_pot_values[i]);
|
||||
}
|
||||
}
|
||||
pots_touched = true;
|
||||
}
|
||||
|
||||
void UI::LoadState() {
|
||||
|
@ -112,7 +114,7 @@ void UI::OnSwitchReleased(const Event& e)
|
|||
mute[e.control_id] = !mute[e.control_id];
|
||||
|
||||
for (size_t i = 0; i < kNumChannels; i++) {
|
||||
last_pan_pot_touch[i] = last_vol_pot_touch[i] = 0;
|
||||
last_pan_pot_touch[i] = last_vol_pot_touch[i] = -1;
|
||||
}
|
||||
|
||||
SaveState();
|
||||
|
@ -138,7 +140,7 @@ void UI::TaskDrawLeds()
|
|||
leds->set_intensity_signed(i, pan_att_pots[i] - 32767);
|
||||
} else {
|
||||
// TODO: refactor
|
||||
if (system_clock.milliseconds() - last_pan_pot_touch[i] < kShowChangedValueMilliseconds) {
|
||||
if (last_pan_pot_touch[i] > 0 && system_clock.milliseconds() - last_pan_pot_touch[i] < kShowChangedValueMilliseconds) {
|
||||
// show panning
|
||||
leds->set_intensity_signed(i, pan_pots[i] - 32767);
|
||||
} else {
|
||||
|
|
|
@ -33,6 +33,8 @@ class UI {
|
|||
potControllers[i].Init(&volume_pots[i], volume_hidden_params);
|
||||
uint16_t* pan_hidden_params[] = {&pan_att_pots[i], &pan_att_pots[i], &pan_att_pots[i], &pan_att_pots[i]};
|
||||
potControllers[i + kNumChannels].Init(&pan_pots[i], pan_hidden_params);
|
||||
|
||||
last_pan_pot_touch[i] = last_vol_pot_touch[i] = -1;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -72,8 +74,9 @@ class UI {
|
|||
uint16_t pan_att_pots[kNumChannels];
|
||||
bool mute[kNumChannels];
|
||||
|
||||
uint32_t last_pan_pot_touch[kNumChannels];
|
||||
uint32_t last_vol_pot_touch[kNumChannels];
|
||||
int64_t last_pan_pot_touch[kNumChannels];
|
||||
int64_t last_vol_pot_touch[kNumChannels];
|
||||
bool pots_touched;
|
||||
|
||||
PotController<kNumChannels> potControllers[kNumChannels * 2]; // todo: count
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue