mirror of
https://github.com/whowechina/diva_pico.git
synced 2026-10-02 11:47:57 +03:00
Fix and clean-up lights
This commit is contained in:
Binary file not shown.
@@ -13,7 +13,7 @@
|
||||
#define RGB_PIN 2
|
||||
#define RGB_ORDER GRB // or RGB
|
||||
|
||||
#define RGB_BUTTON_MAP { 2, 0, 1, 3, 4 }
|
||||
#define RGB_BUTTON_MAP { 3, 2, 1, 0, 4 }
|
||||
#define BUTTON_DEF { 12, 11, 10, 9, 13, 1, 0} // Main * 4, Start, Aux * 2
|
||||
|
||||
#define NKRO_KEYMAP "awsdz2swx3dec4frv5gtb6hyn7jum8ki90olp,."
|
||||
|
||||
+11
-23
@@ -17,18 +17,10 @@
|
||||
#define SENSE_LIMIT_MAX 9
|
||||
#define SENSE_LIMIT_MIN -9
|
||||
|
||||
static void disp_colors()
|
||||
static void disp_light()
|
||||
{
|
||||
printf("[Colors]\n");
|
||||
printf(" Key on: %06lx, off: %06lx\n",
|
||||
diva_cfg->colors.key_on, diva_cfg->colors.key_off);
|
||||
}
|
||||
|
||||
static void disp_style()
|
||||
{
|
||||
printf("[Style]\n");
|
||||
printf(" Key: %d, Level: %d\n",
|
||||
diva_cfg->style.key, diva_cfg->style.level);
|
||||
printf("[Light]\n");
|
||||
printf(" Level: %d\n", diva_cfg->light.level);
|
||||
}
|
||||
|
||||
static void disp_sense()
|
||||
@@ -60,32 +52,28 @@ static void disp_hid()
|
||||
|
||||
void handle_display(int argc, char *argv[])
|
||||
{
|
||||
const char *usage = "Usage: display [colors|style|tof|sense|hid]\n";
|
||||
const char *usage = "Usage: display [light|sense|hid]\n";
|
||||
if (argc > 1) {
|
||||
printf(usage);
|
||||
return;
|
||||
}
|
||||
|
||||
if (argc == 0) {
|
||||
disp_colors();
|
||||
disp_style();
|
||||
disp_light();
|
||||
disp_sense();
|
||||
disp_hid();
|
||||
return;
|
||||
}
|
||||
|
||||
const char *choices[] = {"colors", "style", "sense", "hid"};
|
||||
switch (cli_match_prefix(choices, 5, argv[0])) {
|
||||
const char *choices[] = {"light", "sense", "hid"};
|
||||
switch (cli_match_prefix(choices, count_of(choices), argv[0])) {
|
||||
case 0:
|
||||
disp_colors();
|
||||
disp_light();
|
||||
break;
|
||||
case 1:
|
||||
disp_style();
|
||||
break;
|
||||
case 2:
|
||||
disp_sense();
|
||||
break;
|
||||
case 3:
|
||||
case 2:
|
||||
disp_hid();
|
||||
break;
|
||||
default:
|
||||
@@ -125,9 +113,9 @@ static void handle_level(int argc, char *argv[])
|
||||
return;
|
||||
}
|
||||
|
||||
diva_cfg->style.level = level;
|
||||
diva_cfg->light.level = level;
|
||||
config_changed();
|
||||
disp_style();
|
||||
disp_light();
|
||||
}
|
||||
|
||||
static void handle_stat(int argc, char *argv[])
|
||||
|
||||
+1
-15
@@ -12,12 +12,7 @@
|
||||
diva_cfg_t *diva_cfg;
|
||||
|
||||
static diva_cfg_t default_cfg = {
|
||||
.colors = {
|
||||
.key_on = 0xff0000,
|
||||
.key_off = 0x000000,
|
||||
},
|
||||
.style = {
|
||||
.key = 0,
|
||||
.light = {
|
||||
.level = 127,
|
||||
},
|
||||
.sense = {
|
||||
@@ -36,15 +31,6 @@ diva_runtime_t *diva_runtime;
|
||||
|
||||
static void config_loaded()
|
||||
{
|
||||
if (diva_cfg->style.level > 10) {
|
||||
diva_cfg->style.level = default_cfg.style.level;
|
||||
config_changed();
|
||||
}
|
||||
if ((diva_cfg->tof.offset < 40) ||
|
||||
(diva_cfg->tof.pitch < 4) || (diva_cfg->tof.pitch > 50)) {
|
||||
diva_cfg->tof = default_cfg.tof;
|
||||
config_changed();
|
||||
}
|
||||
if ((diva_cfg->sense.filter & 0x0f) > 3 ||
|
||||
((diva_cfg->sense.filter >> 4) & 0x0f) > 3) {
|
||||
diva_cfg->sense.filter = default_cfg.sense.filter;
|
||||
|
||||
+4
-11
@@ -11,20 +11,13 @@
|
||||
|
||||
typedef struct __attribute__((packed)) {
|
||||
struct {
|
||||
uint32_t key_on;
|
||||
uint32_t key_off;
|
||||
uint32_t gap;
|
||||
uint32_t not_used[3];
|
||||
} colors;
|
||||
struct {
|
||||
uint8_t key;
|
||||
uint8_t gap;
|
||||
uint8_t tof;
|
||||
uint8_t not_used[3];
|
||||
uint8_t level;
|
||||
} style;
|
||||
struct {
|
||||
uint8_t offset;
|
||||
uint8_t pitch;
|
||||
} tof;
|
||||
} light;
|
||||
uint8_t not_used2[2];
|
||||
struct {
|
||||
uint8_t filter;
|
||||
int8_t global;
|
||||
|
||||
+4
-4
@@ -142,11 +142,11 @@ static void run_lights()
|
||||
{
|
||||
uint64_t now = time_us_64();
|
||||
uint32_t button_colors[] = {
|
||||
rgb32(0x70, 0x08, 0x50, false),
|
||||
rgb32(0x80, 0, 0, false),
|
||||
rgb32(0, 0, 0x80, false),
|
||||
rgb32(0, 0x80, 0, false),
|
||||
rgb32(0x10, 0x10, 0x10, false)
|
||||
rgb32(0x70, 0x08, 0x50, false),
|
||||
rgb32(0, 0, 0x80, false),
|
||||
rgb32(0x80, 0, 0, false),
|
||||
rgb32(0x70, 0x70, 0x00, false)
|
||||
};
|
||||
|
||||
uint16_t buttons = button_read();
|
||||
|
||||
+3
-3
@@ -116,9 +116,9 @@ static inline uint32_t apply_level(uint32_t color)
|
||||
unsigned g = (color >> 8) & 0xff;
|
||||
unsigned b = color & 0xff;
|
||||
|
||||
r = r * diva_cfg->style.level / 255;
|
||||
g = g * diva_cfg->style.level / 255;
|
||||
b = b * diva_cfg->style.level / 255;
|
||||
r = r * diva_cfg->light.level / 255;
|
||||
g = g * diva_cfg->light.level / 255;
|
||||
b = b * diva_cfg->light.level / 255;
|
||||
|
||||
return r << 16 | g << 8 | b;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user