1
0
mirror of https://github.com/whowechina/iidx_pico.git synced 2024-11-12 01:10:50 +01:00

TT theme setup

This commit is contained in:
whowechina 2023-04-30 23:20:03 +08:00
parent 8f04b6e049
commit 13f9e8ff2b
3 changed files with 30 additions and 11 deletions

View File

@ -105,14 +105,12 @@ static void core0_loop()
uint16_t angle = turntable_read() >> 4;
if (setup_run(buttons, angle)) {
rgb_force_display(setup_led_button, setup_led_tt);
report_usb_hid();
continue;
} else {
hid_report.buttons = buttons;
rgb_set_button_light(buttons);
save_loop();
}
hid_report.buttons = buttons;
report_usb_hid();
rgb_set_button_light(buttons);
save_loop();
}
}

View File

@ -29,7 +29,7 @@ uint32_t rgb_max_level = 255;
static void trap() {}
static tt_effect_t effects[10] = { {trap, trap, trap, trap, 0} };
static size_t effect_num = 0;
static size_t current_effect = 0;
static unsigned current_effect = 0;
#define _MAP_LED(x) _MAKE_MAPPER(x)
#define _MAKE_MAPPER(x) MAP_LED_##x
@ -97,6 +97,8 @@ void set_effect(uint32_t index)
if (index < effect_num) {
current_effect = index;
effects[current_effect].init(effects[current_effect].context);
} else {
current_effect = effect_num;
}
}
@ -256,7 +258,6 @@ void rgb_init()
ws2812_program_init(pio0, 0, pio0_offset, BUTTON_RGB_PIN, 800000, false);
/* We don't start the tt LED program yet */
set_effect(1);
}
static void follow_mode_change()
@ -276,6 +277,7 @@ static void follow_mode_change()
void rgb_update()
{
follow_mode_change();
set_effect(iidx_cfg->tt_led.effect);
if (time_us_64() > force_expire_time) {
effect_update();
button_lights_update();
@ -289,4 +291,5 @@ void rgb_reg_tt_effect(tt_effect_t effect)
{
effects[effect_num] = effect;
effect_num++;
effects[effect_num] = (tt_effect_t) { trap, trap, trap, trap, 0 };
}

View File

@ -541,7 +541,7 @@ static void key_theme_key_change()
check_exit();
}
static void key_them_loop()
static void key_theme_loop()
{
for (int i = 0; i < 11; i++) {
if (blink_slow) {
@ -552,6 +552,24 @@ static void key_them_loop()
}
}
static void tt_theme_key_change()
{
for (int i = 0; i < 7; i++) {
if (JUST_PRESSED(KEY_1 << i)) {
iidx_cfg->tt_led.effect = i;
break;
}
}
check_exit();
}
static void tt_theme_loop()
{
for (int i = 0; i < 7; i++) {
setup_led_button[i] = iidx_cfg->tt_led.effect == i ? SILVER : 0;
}
}
static struct {
mode_func key_change;
mode_func rotate;
@ -561,8 +579,8 @@ static struct {
[MODE_NONE] = { nop, nop, none_loop, nop},
[MODE_TURNTABLE] = { tt_key_change, tt_rotate, tt_loop, tt_enter},
[MODE_ANALOG] = { analog_key_change, analog_rotate, analog_loop, analog_enter},
[MODE_TT_THEME] = { nop, nop, check_exit, nop},
[MODE_KEY_THEME] = { key_theme_key_change, nop, key_them_loop, nop},
[MODE_TT_THEME] = { tt_theme_key_change, nop, tt_theme_loop, nop},
[MODE_KEY_THEME] = { key_theme_key_change, nop, key_theme_loop, nop},
[MODE_KEY_OFF] = { key_change, key_rotate, key_loop, key_enter},
[MODE_KEY_ON] = { key_change, key_rotate, key_loop, key_enter},
};