First fastly increment the first digit, then the second

This commit is contained in:
Max 2023-02-08 22:32:27 +01:00
parent a5dcd818b4
commit 1ad9e64340

View File

@ -89,10 +89,24 @@ fn select_values(
let mut k_d = thread_rng().gen_range(0.01..=10.0);
let mut v = thread_rng().gen_range(1..=100);
let mut selected = Kp;
let mut times_pressed_up = 0;
let mut times_pressed_down = 0;
draw_settings(screen, k_p, k_i, k_d, v, selected, font);
loop {
buttons.process();
if buttons.is_up_pressed() {
times_pressed_up = 0;
}
if buttons.is_down_pressed() {
times_pressed_down = 0;
}
if buttons.is_up() {
times_pressed_up += 1;
}
if buttons.is_down() {
times_pressed_down += 1;
}
if buttons.is_enter_pressed() {
break;
}
@ -130,7 +144,7 @@ fn select_values(
};
if buttons.is_up() {
*param = (*param
+ if buttons.is_up_pressed() {
+ if times_pressed_up > 10 {
0.01f32
} else {
0.1f32
@ -139,7 +153,7 @@ fn select_values(
}
if buttons.is_down() {
*param = (*param
- if buttons.is_down_pressed() {
- if times_pressed_down > 10 {
0.01f32
} else {
0.1f32