mirror of
https://github.com/whowechina/iidx_pico.git
synced 2025-02-20 04:21:01 +01:00
Prepare for more tt theme
This commit is contained in:
parent
749ab9f903
commit
15d004c81a
@ -71,11 +71,13 @@ void mode_check()
|
||||
|
||||
static mutex_t core1_io_lock;
|
||||
static uint8_t latest_angle;
|
||||
static uint16_t latest_buttons;
|
||||
static void core1_loop()
|
||||
{
|
||||
while (true) {
|
||||
uint32_t angle = turntable_raw();
|
||||
rgb_set_angle(angle);
|
||||
uint32_t raw_angle = turntable_raw();
|
||||
rgb_set_angle(raw_angle);
|
||||
rgb_set_button(latest_buttons);
|
||||
|
||||
latest_angle = turntable_read();
|
||||
|
||||
@ -100,9 +102,9 @@ static void core0_loop()
|
||||
|
||||
turntable_update();
|
||||
|
||||
uint16_t buttons = button_read();
|
||||
latest_buttons = button_read();
|
||||
uint16_t angle = turntable_raw() >> 4;
|
||||
setup_run(buttons, angle);
|
||||
setup_run(latest_buttons, angle);
|
||||
|
||||
bool ov_tt = setup_needs_tt_led();
|
||||
bool ov_btn = setup_needs_button_led();
|
||||
@ -113,12 +115,12 @@ static void core0_loop()
|
||||
if (ov_btn) {
|
||||
rgb_override_button(setup_led_button);
|
||||
} else {
|
||||
rgb_set_button_light(buttons);
|
||||
rgb_set_button_light(latest_buttons);
|
||||
}
|
||||
|
||||
hid_report.buttons = 0;
|
||||
if (!ov_tt && !ov_btn) {
|
||||
hid_report.buttons = buttons;
|
||||
hid_report.buttons = latest_buttons;
|
||||
hid_report.joy[0] = latest_angle;
|
||||
hid_report.joy[1] = 255 - latest_angle;
|
||||
save_loop();
|
||||
|
@ -115,7 +115,9 @@ static void set_effect(uint32_t effect_id)
|
||||
{
|
||||
if (current_effect_id != effect_id) {
|
||||
current_effect_id = effect_id;
|
||||
CURRENT_EFFECT.init(CURRENT_CONTEXT);
|
||||
if (CURRENT_EFFECT.init) {
|
||||
CURRENT_EFFECT.init(CURRENT_CONTEXT);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -203,8 +205,16 @@ uint32_t tt_hsv(hsv_t hsv)
|
||||
|
||||
void rgb_set_angle(uint32_t angle)
|
||||
{
|
||||
tt_led_angle = angle;
|
||||
CURRENT_EFFECT.set_angle(CURRENT_CONTEXT, angle);
|
||||
if (CURRENT_EFFECT.set_angle) {
|
||||
CURRENT_EFFECT.set_angle(CURRENT_CONTEXT, angle);
|
||||
}
|
||||
}
|
||||
|
||||
void rgb_set_button(uint16_t buttons)
|
||||
{
|
||||
if (CURRENT_EFFECT.set_button) {
|
||||
CURRENT_EFFECT.set_button(CURRENT_CONTEXT, buttons);
|
||||
}
|
||||
}
|
||||
|
||||
void rgb_set_button_light(uint16_t buttons)
|
||||
@ -260,8 +270,11 @@ static void tt_lights_update()
|
||||
}
|
||||
|
||||
set_effect(iidx_cfg->tt_led.effect);
|
||||
|
||||
/* Lower priority for the local effects */
|
||||
CURRENT_EFFECT.update(CURRENT_CONTEXT);
|
||||
if (CURRENT_EFFECT.update) {
|
||||
CURRENT_EFFECT.update(CURRENT_CONTEXT);
|
||||
}
|
||||
}
|
||||
|
||||
static void button_lights_update()
|
||||
|
@ -20,7 +20,7 @@ uint8_t rgb_hid_light_num();
|
||||
void rgb_update();
|
||||
|
||||
void rgb_set_angle(uint32_t angle);
|
||||
void rgb_set_level(uint8_t level);
|
||||
void rgb_set_button(uint16_t buttons);
|
||||
|
||||
void rgb_set_button_light(uint16_t buttons);
|
||||
void rgb_set_hid_light(uint8_t const *lights, uint8_t num);
|
||||
@ -31,6 +31,7 @@ void rgb_override_button(uint32_t *button);
|
||||
typedef struct {
|
||||
void (*init)(uint32_t context);
|
||||
void (*set_angle)(uint32_t context, uint32_t angle);
|
||||
void (*set_button)(uint32_t context, uint16_t buttons);
|
||||
void (*update)(uint32_t context);
|
||||
} tt_effect_t;
|
||||
|
||||
@ -39,10 +40,6 @@ void rgb_reg_tt_effect(tt_effect_t effect);
|
||||
extern uint32_t tt_led_buf[];
|
||||
#define TT_LED_NUM (iidx_cfg->tt_led.num)
|
||||
|
||||
/* These global variables meant to be accessed by effect codes */
|
||||
extern uint32_t tt_led_angle;
|
||||
|
||||
|
||||
uint32_t button_rgb32(uint32_t r, uint32_t g, uint32_t b, bool gamma_fix);
|
||||
uint32_t tt_rgb32(uint32_t r, uint32_t g, uint32_t b, bool gamma_fix);
|
||||
uint32_t button_hsv(hsv_t hsv);
|
||||
|
@ -82,16 +82,8 @@ static uint32_t spectrum[3][24] = {
|
||||
};
|
||||
|
||||
#define SNAKE_SIZE (count_of(spectrum[0]))
|
||||
uint32_t snake[SNAKE_SIZE] = {0};
|
||||
uint32_t life[SNAKE_SIZE] = {0};
|
||||
|
||||
static void init(uint32_t context)
|
||||
{
|
||||
}
|
||||
|
||||
static void set_angle(uint32_t context, uint32_t angle)
|
||||
{
|
||||
}
|
||||
static uint32_t snake[SNAKE_SIZE] = {0};
|
||||
static uint32_t life[SNAKE_SIZE] = {0};
|
||||
|
||||
static uint32_t apply_level(uint32_t color)
|
||||
{
|
||||
@ -101,11 +93,17 @@ static uint32_t apply_level(uint32_t color)
|
||||
return tt_rgb32(r, g, b, false);
|
||||
}
|
||||
|
||||
static uint32_t led_angle = 0;
|
||||
static void set_angle(uint32_t context, uint32_t angle)
|
||||
{
|
||||
led_angle = angle;
|
||||
}
|
||||
|
||||
static void update(uint32_t context)
|
||||
{
|
||||
uint32_t delta = tt_led_angle > snake[0] ? tt_led_angle - snake[0] : snake[0] - tt_led_angle;
|
||||
uint32_t delta = led_angle > snake[0] ? led_angle - snake[0] : snake[0] - led_angle;
|
||||
|
||||
snake[0] = tt_led_angle;
|
||||
snake[0] = led_angle;
|
||||
life[0] = 255;
|
||||
life[1] = delta > 7 ? 255: delta * 8;
|
||||
|
||||
@ -135,9 +133,10 @@ static void update(uint32_t context)
|
||||
void tt_blade_init()
|
||||
{
|
||||
tt_effect_t blade = {
|
||||
init,
|
||||
set_angle,
|
||||
update,
|
||||
.init = NULL,
|
||||
.set_angle = set_angle,
|
||||
.set_button = NULL,
|
||||
.update = update,
|
||||
};
|
||||
|
||||
rgb_reg_tt_effect(blade);
|
||||
|
@ -80,9 +80,10 @@ static void update(uint32_t context)
|
||||
void tt_rainbow_init()
|
||||
{
|
||||
tt_effect_t rainbow = {
|
||||
init,
|
||||
set_angle,
|
||||
update,
|
||||
.init = init,
|
||||
.set_angle = set_angle,
|
||||
.set_button = NULL,
|
||||
.update = update,
|
||||
};
|
||||
rgb_reg_tt_effect(rainbow);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user