Skip to content

Commit 8c4399b

Browse files
committed
vfx: fix BREATHING mode
1 parent c0b4669 commit 8c4399b

File tree

3 files changed

+18
-19
lines changed

3 files changed

+18
-19
lines changed

main/inc/user/vfx_core.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,12 @@
1010

1111
#include <stdint.h>
1212

13-
extern uint32_t vfx_get_color(uint16_t color_idx, uint16_t color_ctr);
13+
extern uint32_t vfx_get_color(float color_h, float color_l);
1414

15-
extern void vfx_draw_pixel(uint8_t x, uint8_t y, uint8_t z, uint16_t color_idx, uint16_t color_ctr);
16-
extern void vfx_fill_cube(uint8_t x, uint8_t y, uint8_t z, uint8_t cx, uint8_t cy, uint8_t cz, uint16_t color_idx, uint16_t color_ctr);
17-
extern void vfx_draw_cube_bitmap(const uint8_t *bitmap, uint16_t color_ctr);
18-
extern void vfx_draw_layer_bitmap(uint8_t layer, const uint8_t *bitmap, uint16_t color_ctr);
19-
extern void vfx_draw_layer_number(uint8_t num, uint8_t layer, uint16_t color_idx, uint16_t color_ctr);
15+
extern void vfx_draw_pixel(uint8_t x, uint8_t y, uint8_t z, float color_h, float color_l);
16+
extern void vfx_fill_cube(uint8_t x, uint8_t y, uint8_t z, uint8_t cx, uint8_t cy, uint8_t cz, float color_h, float color_l);
17+
extern void vfx_draw_cube_bitmap(const uint8_t *bitmap, float color_l);
18+
extern void vfx_draw_layer_bitmap(uint8_t layer, const uint8_t *bitmap, float color_l);
19+
extern void vfx_draw_layer_number(uint8_t num, uint8_t layer, float color_h, float color_l);
2020

2121
#endif /* INC_USER_VFX_CORE_H_ */

main/src/user/vfx.c

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -883,8 +883,9 @@ static void vfx_task(void *pvParameter)
883883
}
884884
case VFX_MODE_IDX_BREATHING: { // 呼吸
885885
uint8_t scale_dir = 0;
886+
uint16_t fade_cnt = 0;
886887
uint16_t color_h = esp_random() % 512;
887-
uint16_t color_l = 0;
888+
float color_l = vfx.lightness / 256.0;
888889

889890
gdispGSetBacklight(vfx_gdisp, vfx.backlight);
890891

@@ -896,22 +897,20 @@ static void vfx_task(void *pvParameter)
896897
break;
897898
}
898899

899-
vfx_fill_cube(0, 0, 0, 8, 8, 8, color_h, color_l);
900+
vfx_fill_cube(0, 0, 0, 8, 8, 8, color_h, fade_cnt * color_l);
900901

901902
if (scale_dir == 0) { // 暗->明
902-
if (color_l++ == vfx.lightness) {
903-
color_l = vfx.lightness;
903+
if (++fade_cnt == 256) {
904904
scale_dir = 1;
905905
}
906906
} else { // 明->暗
907-
if (color_l-- == 0) {
908-
color_l = 0;
907+
if (--fade_cnt == 0) {
909908
scale_dir = 0;
910909
color_h = esp_random() % 512;
911910
}
912911
}
913912

914-
vTaskDelayUntil(&xLastWakeTime, 16 / portTICK_RATE_MS);
913+
vTaskDelayUntil(&xLastWakeTime, 8 / portTICK_RATE_MS);
915914
}
916915
break;
917916
}

main/src/user/vfx_core.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -61,13 +61,13 @@ static uint32_t hsl2rgb(float H, float S, float L)
6161
return (uint32_t)(R << 16 | G << 8 | B);
6262
}
6363

64-
uint32_t vfx_get_color(uint16_t color_h, uint16_t color_l)
64+
uint32_t vfx_get_color(float color_h, float color_l)
6565
{
6666
return hsl2rgb(color_h / 511.0, 1.0, color_l / 2047.0);
6767
}
6868

6969
#ifndef CONFIG_SCREEN_PANEL_OUTPUT_VFX
70-
void vfx_draw_pixel(uint8_t x, uint8_t y, uint8_t z, uint16_t color_h, uint16_t color_l)
70+
void vfx_draw_pixel(uint8_t x, uint8_t y, uint8_t z, float color_h, float color_l)
7171
{
7272
uint32_t pixel_color = vfx_get_color(color_h, color_l);
7373
uint8_t pixel_x = x + y * 8;
@@ -90,7 +90,7 @@ void vfx_draw_pixel(uint8_t x, uint8_t y, uint8_t z, uint16_t color_h, uint16_t
9090
#endif
9191
}
9292

93-
void vfx_fill_cube(uint8_t x, uint8_t y, uint8_t z, uint8_t cx, uint8_t cy, uint8_t cz, uint16_t color_h, uint16_t color_l)
93+
void vfx_fill_cube(uint8_t x, uint8_t y, uint8_t z, uint8_t cx, uint8_t cy, uint8_t cz, float color_h, float color_l)
9494
{
9595
for (uint8_t i=0; i<cx; i++) {
9696
for (uint8_t j=0; j<cy; j++) {
@@ -101,7 +101,7 @@ void vfx_fill_cube(uint8_t x, uint8_t y, uint8_t z, uint8_t cx, uint8_t cy, uint
101101
}
102102
}
103103

104-
void vfx_draw_cube_bitmap(const uint8_t *bitmap, uint16_t color_l)
104+
void vfx_draw_cube_bitmap(const uint8_t *bitmap, float color_l)
105105
{
106106
uint8_t x = 0;
107107
uint8_t y = 0;
@@ -144,7 +144,7 @@ void vfx_draw_cube_bitmap(const uint8_t *bitmap, uint16_t color_l)
144144
}
145145
}
146146

147-
void vfx_draw_layer_bitmap(uint8_t layer, const uint8_t *bitmap, uint16_t color_l)
147+
void vfx_draw_layer_bitmap(uint8_t layer, const uint8_t *bitmap, float color_l)
148148
{
149149
uint8_t x = 0;
150150
uint8_t y = 0;
@@ -183,7 +183,7 @@ void vfx_draw_layer_bitmap(uint8_t layer, const uint8_t *bitmap, uint16_t color_
183183
}
184184
}
185185

186-
void vfx_draw_layer_number(uint8_t num, uint8_t layer, uint16_t color_h, uint16_t color_l)
186+
void vfx_draw_layer_number(uint8_t num, uint8_t layer, float color_h, float color_l)
187187
{
188188
uint8_t x = 0;
189189
uint8_t y = layer;

0 commit comments

Comments
 (0)