模式嗯
This commit is contained in:
3
.vscode/settings.json
vendored
3
.vscode/settings.json
vendored
@ -3,7 +3,8 @@
|
|||||||
"*.py": "python",
|
"*.py": "python",
|
||||||
"app.h": "c",
|
"app.h": "c",
|
||||||
"time.h": "c",
|
"time.h": "c",
|
||||||
"math.h": "c"
|
"math.h": "c",
|
||||||
|
"color_utils.h": "c"
|
||||||
},
|
},
|
||||||
"C_Cpp.errorSquiggles": "enabled",
|
"C_Cpp.errorSquiggles": "enabled",
|
||||||
"C_Cpp.default.includePath": [
|
"C_Cpp.default.includePath": [
|
||||||
|
|||||||
@ -3,9 +3,15 @@
|
|||||||
|
|
||||||
#include "color_utils.h"
|
#include "color_utils.h"
|
||||||
|
|
||||||
|
typedef enum LightMode {
|
||||||
|
LIGHT_MODE_RAINBOW,
|
||||||
|
LIGHT_MODE_WHITE,
|
||||||
|
} LightMode;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
int index;
|
int index;
|
||||||
double time;
|
double time;
|
||||||
|
LightMode mode;
|
||||||
} Status;
|
} Status;
|
||||||
|
|
||||||
void init_status(Status* status);
|
void init_status(Status* status);
|
||||||
|
|||||||
@ -3,6 +3,7 @@
|
|||||||
void init_status(Status* status) {
|
void init_status(Status* status) {
|
||||||
status->index = 0;
|
status->index = 0;
|
||||||
status->time = 0;
|
status->time = 0;
|
||||||
|
status->mode = LIGHT_MODE_WHITE;
|
||||||
}
|
}
|
||||||
|
|
||||||
Color shader(Status* status) {
|
Color shader(Status* status) {
|
||||||
@ -10,5 +11,11 @@ Color shader(Status* status) {
|
|||||||
return hex_to_color(0xFFFFFF);
|
return hex_to_color(0xFFFFFF);
|
||||||
}
|
}
|
||||||
|
|
||||||
return hsv_to_color(status->time * 120 + status->index * 6, 1, 1);
|
switch (status->mode) {
|
||||||
|
case LIGHT_MODE_RAINBOW:
|
||||||
|
return hsv_to_color(status->time * 120 + status->index * 6, 1, 1);
|
||||||
|
|
||||||
|
default:
|
||||||
|
return hex_to_color(0xFFFFFF);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user