jok effects
This commit is contained in:
@@ -14,6 +14,7 @@
|
||||
#include "debug_print.h"
|
||||
#include "user_uart.h"
|
||||
#include "htr3236.h"
|
||||
#include "tx1_rgb_brightness.h"
|
||||
#include "tx1_led_effects.h"
|
||||
#include "eq_flash_storage.h"
|
||||
#include "lfs_io.h"
|
||||
@@ -385,11 +386,6 @@ void mic_volume(unsigned level, client interface i2c_master_if i2c)
|
||||
}
|
||||
}
|
||||
|
||||
/* 改动原因:jok 默认 10 过暗肉眼难辨;自检/灯效用 80,音量条仍可用较低亮度 */
|
||||
#define TX1_RGB_GLOBAL_BRIGHTNESS 40
|
||||
#define TX1_RGB_SELFTEST_BRIGHTNESS 200
|
||||
#define TX1_RGB_SCALE8(c) ((uint8_t)(((unsigned)(c) * TX1_RGB_GLOBAL_BRIGHTNESS) / 255))
|
||||
|
||||
/* 改动原因:bringup 失败时灯效任务不刷屏 I2C */
|
||||
static unsigned g_htr3236_ready = 0;
|
||||
|
||||
@@ -401,6 +397,9 @@ static const uint8_t rgb_led_map[13][3] = {
|
||||
{36, 35, 34}, {33, 32, 31}, {30, 29, 28}, {27, 26, 25}
|
||||
};
|
||||
|
||||
/* 改动原因:bringup 在定义前调用,xC 需前置声明 */
|
||||
static void tx1_rgb_led_all_off(htr3236_t *dev, client interface i2c_master_if i2c);
|
||||
|
||||
/* 改动原因:与 jok tile1_io_control_task 相同,仅 tile1 1K 拉高 SDB,勿动 tile0 8C(非 SDB) */
|
||||
static void tx1_htr3236_sdb_enable(client interface tx1_led_if led_if)
|
||||
{
|
||||
@@ -408,18 +407,6 @@ static void tx1_htr3236_sdb_enable(client interface tx1_led_if led_if)
|
||||
delay_milliseconds(10);
|
||||
}
|
||||
|
||||
/* 改动原因:按 jok rgb_led 流程 D1-D12 白灯自检,最后统一 UPDATE */
|
||||
static void tx1_htr3236_self_test_rgb(htr3236_t *dev, client interface i2c_master_if i2c)
|
||||
{
|
||||
uint8_t led;
|
||||
for (led = 1; led <= 12; led++) {
|
||||
htr3236_set_pwm(dev, i2c, rgb_led_map[led][0], TX1_RGB_SELFTEST_BRIGHTNESS);
|
||||
htr3236_set_pwm(dev, i2c, rgb_led_map[led][1], TX1_RGB_SELFTEST_BRIGHTNESS);
|
||||
htr3236_set_pwm(dev, i2c, rgb_led_map[led][2], TX1_RGB_SELFTEST_BRIGHTNESS);
|
||||
}
|
||||
htr3236_update(dev, i2c);
|
||||
}
|
||||
|
||||
/* 改动原因:按 jok + golden 流程;避开 AudioHwInit 与 codec 抢 I2C;读回 0x00 验证唤醒 */
|
||||
static void tx1_htr3236_bringup(htr3236_t *dev, client interface i2c_master_if i2c,
|
||||
client interface tx1_led_if led_if)
|
||||
@@ -473,9 +460,9 @@ static void tx1_htr3236_bringup(htr3236_t *dev, client interface i2c_master_if i
|
||||
htr3236_set_led_config(dev, i2c, ch, HTR3236_CURRENT_HALF, 1);
|
||||
}
|
||||
|
||||
tx1_htr3236_self_test_rgb(dev, i2c);
|
||||
debug_printf("HTR3236 self-test: D1-D12 white PWM=%u, hold 5s\n", TX1_RGB_SELFTEST_BRIGHTNESS);
|
||||
delay_milliseconds(5000);
|
||||
/* 改动原因:与 jok rgb_led_all_off 一致,上电熄灭后由灯效/音量条刷新 */
|
||||
tx1_rgb_led_all_off(dev, i2c);
|
||||
debug_printf("HTR3236 ready (brightness %u/255, jok)\n", TX1_RGB_BRIGHTNESS);
|
||||
|
||||
g_htr3236_ready = 1;
|
||||
}
|
||||
@@ -529,31 +516,31 @@ static void tx1_rgb_volume_bar_refresh(htr3236_t *dev, client interface i2c_mast
|
||||
GET_SHARED_GLOBAL(vol_pct, g_volume_level);
|
||||
bar_level = (vol_pct * 12u) / 100u;
|
||||
if (bar_level > 12) bar_level = 12;
|
||||
r = TX1_RGB_SCALE8(255);
|
||||
g = TX1_RGB_SCALE8(255);
|
||||
b = 0;
|
||||
r = TX1_RGB_SCALE8(TX1_RGB_COLOR_YELLOW_R);
|
||||
g = TX1_RGB_SCALE8(TX1_RGB_COLOR_YELLOW_G);
|
||||
b = TX1_RGB_SCALE8(TX1_RGB_COLOR_YELLOW_B);
|
||||
break;
|
||||
}
|
||||
case FEATURE_MODE_GUNSHOT_LEVEL:
|
||||
bar_level = feature_vol_0_12;
|
||||
if (bar_level > 12) bar_level = 12;
|
||||
r = TX1_RGB_SCALE8(128);
|
||||
g = 0;
|
||||
b = TX1_RGB_SCALE8(128);
|
||||
r = TX1_RGB_SCALE8(TX1_RGB_COLOR_PURPLE_R);
|
||||
g = TX1_RGB_SCALE8(TX1_RGB_COLOR_PURPLE_G);
|
||||
b = TX1_RGB_SCALE8(TX1_RGB_COLOR_PURPLE_B);
|
||||
break;
|
||||
case FEATURE_MODE_FOOTSTEPS_LEVEL:
|
||||
bar_level = feature_vol_0_12;
|
||||
if (bar_level > 12) bar_level = 12;
|
||||
r = TX1_RGB_SCALE8(255);
|
||||
g = TX1_RGB_SCALE8(165);
|
||||
b = 0;
|
||||
r = TX1_RGB_SCALE8(TX1_RGB_COLOR_ORANGE_R);
|
||||
g = TX1_RGB_SCALE8(TX1_RGB_COLOR_ORANGE_G);
|
||||
b = TX1_RGB_SCALE8(TX1_RGB_COLOR_ORANGE_B);
|
||||
break;
|
||||
case FEATURE_MODE_MIC_LEVEL:
|
||||
bar_level = feature_vol_0_12;
|
||||
if (bar_level > 12) bar_level = 12;
|
||||
r = 0;
|
||||
g = 0;
|
||||
b = TX1_RGB_SCALE8(255);
|
||||
r = TX1_RGB_SCALE8(TX1_RGB_COLOR_BLUE_R);
|
||||
g = TX1_RGB_SCALE8(TX1_RGB_COLOR_BLUE_G);
|
||||
b = TX1_RGB_SCALE8(TX1_RGB_COLOR_BLUE_B);
|
||||
break;
|
||||
case FEATURE_MODE_NONE:
|
||||
default:
|
||||
@@ -578,7 +565,6 @@ void AudioHwRemote2(streaming chanend c, client interface i2c_master_if i2c, cli
|
||||
#endif
|
||||
{
|
||||
unsigned cmd;
|
||||
int value;
|
||||
unsigned time = 0;
|
||||
unsigned eq_mode_time = 0;
|
||||
unsigned se_time = 0;
|
||||
@@ -602,7 +588,7 @@ void AudioHwRemote2(streaming chanend c, client interface i2c_master_if i2c, cli
|
||||
// TX1 game/feature mode state
|
||||
tx1_game_mode_t game_mode = GAME_MODE_BYPASS;
|
||||
tx1_feature_mode_t feature_mode = FEATURE_MODE_NONE;
|
||||
unsigned feature_volume = 6; // 0-12 range
|
||||
unsigned feature_volume = 12; // 改动原因:与 jok ui_app gunshot/footstep/mic 默认 12 一致
|
||||
unsigned mic_muted = 0;
|
||||
unsigned dnr_enabled = 1;
|
||||
unsigned high_perf_mode = 0;
|
||||
@@ -1483,18 +1469,11 @@ void AudioHwRemote2(streaming chanend c, client interface i2c_master_if i2c, cli
|
||||
case led_fx_tmr when timerafter(led_fx_time) :> void :
|
||||
if (g_htr3236_ready) {
|
||||
unsigned gm;
|
||||
static unsigned led_fx_dbg_cnt;
|
||||
GET_SHARED_GLOBAL(gm, g_3d_fps);
|
||||
tx1_led_effects_periodic(&htr3236_dev, i2c,
|
||||
gm,
|
||||
(unsigned)feature_mode,
|
||||
led_pattern_step);
|
||||
/* 改动原因:确认 50ms 灯效任务在跑;每约 5s 打一次 gm/fm/pattern */
|
||||
led_fx_dbg_cnt++;
|
||||
if ((led_fx_dbg_cnt % 100) == 1) {
|
||||
debug_printf("led_fx gm=%u fm=%u pat=%u ready=%u\n",
|
||||
gm, (unsigned)feature_mode, led_pattern_step, g_htr3236_ready);
|
||||
}
|
||||
}
|
||||
led_fx_time += TIMER_2_PERIOD;
|
||||
break;
|
||||
|
||||
@@ -3,14 +3,12 @@
|
||||
* @brief HTR3236 RGB 灯效 + 工厂复位 LED(移植自 jok led_effects.xc,50ms 步进)
|
||||
*/
|
||||
#include "tx1_led_effects.h"
|
||||
#include "tx1_rgb_brightness.h"
|
||||
#include <string.h>
|
||||
|
||||
#define TX1_RGB_LED_MAX 12
|
||||
|
||||
/* 改动原因:与 audiohw 提高后的亮度一致,否则灯效仍几乎不可见 */
|
||||
/* 改动原因:与 bringup 自检亮度一致,便于肉眼确认灯效 */
|
||||
#define TX1_FX_RGB_BRIGHTNESS 200
|
||||
#define TX1_FX_SCALE8(c) ((uint8_t)(((unsigned)(c) * TX1_FX_RGB_BRIGHTNESS) / 255))
|
||||
/* 改动原因:灯效亮度与 jok rgb_led_set_global_brightness(10) 一致,使用 TX1_RGB_SCALE8 */
|
||||
|
||||
/* D1-D12 B,G,R 通道映射(与 audiohw rgb_led_map 相同) */
|
||||
static const uint8_t tx1_rgb_led_map[13][3] = {
|
||||
@@ -163,10 +161,10 @@ void tx1_factory_reset_led_tick(htr3236_t *dev, client interface i2c_master_if i
|
||||
g_tx1_factory_reset_blink_counter++;
|
||||
if ((g_tx1_factory_reset_blink_counter % 2) == 0) {
|
||||
tx1_fx_all_color(dev, i2c,
|
||||
0, TX1_FX_SCALE8(255), 0);
|
||||
0, TX1_RGB_SCALE8(255), 0);
|
||||
} else {
|
||||
tx1_fx_all_color(dev, i2c,
|
||||
TX1_FX_SCALE8(139), TX1_FX_SCALE8(91), TX1_FX_SCALE8(246));
|
||||
TX1_RGB_SCALE8(139), TX1_RGB_SCALE8(91), TX1_RGB_SCALE8(246));
|
||||
}
|
||||
}
|
||||
break;
|
||||
@@ -180,7 +178,7 @@ void tx1_factory_reset_led_tick(htr3236_t *dev, client interface i2c_master_if i
|
||||
tx1_fx_all_color(dev, i2c, 0, 0, 0);
|
||||
} else {
|
||||
g_tx1_factory_reset_blink_counter = 0;
|
||||
tx1_fx_all_color(dev, i2c, TX1_FX_SCALE8(255), 0, 0);
|
||||
tx1_fx_all_color(dev, i2c, TX1_RGB_SCALE8(255), 0, 0);
|
||||
}
|
||||
}
|
||||
break;
|
||||
@@ -204,7 +202,7 @@ static void tx1_effect_race(htr3236_t *dev, client interface i2c_master_if i2c)
|
||||
int dist = (head_pos - i + TX1_RGB_LED_MAX) % TX1_RGB_LED_MAX;
|
||||
uint8_t br = 0;
|
||||
if (dist < (int)TRAIL_LEN) {
|
||||
br = TX1_FX_SCALE8(trail_table[dist]);
|
||||
br = TX1_RGB_SCALE8(trail_table[dist]);
|
||||
}
|
||||
tx1_fx_pwm_led(dev, i2c, (uint8_t)(i + 1), br, br, br);
|
||||
}
|
||||
@@ -214,7 +212,7 @@ static void tx1_effect_race(htr3236_t *dev, client interface i2c_master_if i2c)
|
||||
|
||||
static void tx1_effect_breath_all(htr3236_t *dev, client interface i2c_master_if i2c)
|
||||
{
|
||||
uint8_t br = TX1_FX_SCALE8(breath_curve[breath_idx]);
|
||||
uint8_t br = TX1_RGB_SCALE8(breath_curve[breath_idx]);
|
||||
uint8_t led;
|
||||
breath_idx = (breath_idx + 1) % (int)BREATH_STEPS;
|
||||
for (led = 1; led <= TX1_RGB_LED_MAX; led++) {
|
||||
@@ -237,7 +235,7 @@ static void tx1_effect_rainbow_race(htr3236_t *dev, client interface i2c_master_
|
||||
g = (uint8_t)((g * brightness) / 255);
|
||||
b = (uint8_t)((b * brightness) / 255);
|
||||
tx1_fx_pwm_led(dev, i2c, (uint8_t)(i + 1),
|
||||
TX1_FX_SCALE8(r), TX1_FX_SCALE8(g), TX1_FX_SCALE8(b));
|
||||
TX1_RGB_SCALE8(r), TX1_RGB_SCALE8(g), TX1_RGB_SCALE8(b));
|
||||
} else {
|
||||
tx1_fx_pwm_led(dev, i2c, (uint8_t)(i + 1), 0, 0, 0);
|
||||
}
|
||||
@@ -253,7 +251,7 @@ static void tx1_effect_rainbow_fill(htr3236_t *dev, client interface i2c_master_
|
||||
int hue = (rainbow_hue + ((int)led * 20)) % 240;
|
||||
uint8_t r, g, b;
|
||||
tx1_get_rainbow_color(hue, &r, &g, &b);
|
||||
tx1_fx_pwm_led(dev, i2c, led, TX1_FX_SCALE8(r), TX1_FX_SCALE8(g), TX1_FX_SCALE8(b));
|
||||
tx1_fx_pwm_led(dev, i2c, led, TX1_RGB_SCALE8(r), TX1_RGB_SCALE8(g), TX1_RGB_SCALE8(b));
|
||||
}
|
||||
tx1_fx_update(dev, i2c);
|
||||
rainbow_hue = (rainbow_hue + 4) % 240;
|
||||
@@ -266,7 +264,7 @@ static void tx1_effect_color_wave(htr3236_t *dev, client interface i2c_master_if
|
||||
int hue = (((int)led * 20) + color_wave_pos) % 240;
|
||||
uint8_t r, g, b;
|
||||
tx1_get_rainbow_color(hue, &r, &g, &b);
|
||||
tx1_fx_pwm_led(dev, i2c, led, TX1_FX_SCALE8(r), TX1_FX_SCALE8(g), TX1_FX_SCALE8(b));
|
||||
tx1_fx_pwm_led(dev, i2c, led, TX1_RGB_SCALE8(r), TX1_RGB_SCALE8(g), TX1_RGB_SCALE8(b));
|
||||
}
|
||||
tx1_fx_update(dev, i2c);
|
||||
color_wave_pos = (color_wave_pos + 8) % 240;
|
||||
@@ -282,7 +280,7 @@ static void tx1_effect_strobe(htr3236_t *dev, client interface i2c_master_if i2c
|
||||
if (tx1_simple_rand() % 2) {
|
||||
for (led = 1; led <= TX1_RGB_LED_MAX; led++) {
|
||||
tx1_fx_pwm_led(dev, i2c, led,
|
||||
TX1_FX_SCALE8(r), TX1_FX_SCALE8(g), TX1_FX_SCALE8(b));
|
||||
TX1_RGB_SCALE8(r), TX1_RGB_SCALE8(g), TX1_RGB_SCALE8(b));
|
||||
}
|
||||
} else {
|
||||
tx1_fx_all_off(dev, i2c);
|
||||
@@ -307,7 +305,7 @@ static void tx1_effect_pulse(htr3236_t *dev, client interface i2c_master_if i2c)
|
||||
}
|
||||
for (led = 1; led <= TX1_RGB_LED_MAX; led++) {
|
||||
tx1_fx_pwm_led(dev, i2c, led,
|
||||
TX1_FX_SCALE8(r), TX1_FX_SCALE8(g), TX1_FX_SCALE8(b));
|
||||
TX1_RGB_SCALE8(r), TX1_RGB_SCALE8(g), TX1_RGB_SCALE8(b));
|
||||
}
|
||||
tx1_fx_update(dev, i2c);
|
||||
}
|
||||
@@ -334,7 +332,7 @@ static void tx1_effect_sparkle(htr3236_t *dev, client interface i2c_master_if i2
|
||||
default: r = brightness; g = brightness; b = brightness; break;
|
||||
}
|
||||
tx1_fx_pwm_led(dev, i2c, (uint8_t)(led_idx + 1),
|
||||
TX1_FX_SCALE8(r), TX1_FX_SCALE8(g), TX1_FX_SCALE8(b));
|
||||
TX1_RGB_SCALE8(r), TX1_RGB_SCALE8(g), TX1_RGB_SCALE8(b));
|
||||
}
|
||||
tx1_fx_update(dev, i2c);
|
||||
}
|
||||
@@ -353,7 +351,7 @@ static void tx1_effect_gradient(htr3236_t *dev, client interface i2c_master_if i
|
||||
}
|
||||
for (led = 1; led <= TX1_RGB_LED_MAX; led++) {
|
||||
tx1_fx_pwm_led(dev, i2c, led,
|
||||
TX1_FX_SCALE8(r), TX1_FX_SCALE8(g), TX1_FX_SCALE8(b));
|
||||
TX1_RGB_SCALE8(r), TX1_RGB_SCALE8(g), TX1_RGB_SCALE8(b));
|
||||
}
|
||||
tx1_fx_update(dev, i2c);
|
||||
gradient_pos = (gradient_pos + 2) % 256;
|
||||
|
||||
Reference in New Issue
Block a user