fix incorrect cursor LED indices; fix rgb program 4
This commit is contained in:
parent
51239bffa7
commit
6a2de9a6a6
|
@ -13,7 +13,7 @@
|
||||||
|
|
||||||
|
|
||||||
static const uint8_t rgb_map[9] = {0x04, 0x14, 0x01, 0x11, 0x07, 0x0a, 0x1a, 0x0d, 0x1d};
|
static const uint8_t rgb_map[9] = {0x04, 0x14, 0x01, 0x11, 0x07, 0x0a, 0x1a, 0x0d, 0x1d};
|
||||||
static const uint8_t cursor_map[3] = {0x17, 0x18, 0x19};
|
static const uint8_t cursor_map[3] = {0x16, 0x17, 0x18};
|
||||||
|
|
||||||
static const uint8_t LED_CIE_PWM_256I_256O[] = {
|
static const uint8_t LED_CIE_PWM_256I_256O[] = {
|
||||||
0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2,
|
0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2,
|
||||||
|
|
|
@ -10,6 +10,7 @@
|
||||||
#include "hsv2rgb.h"
|
#include "hsv2rgb.h"
|
||||||
#include "led.h"
|
#include "led.h"
|
||||||
#include "rand.h"
|
#include "rand.h"
|
||||||
|
#include "ui.h"
|
||||||
|
|
||||||
|
|
||||||
// led programs
|
// led programs
|
||||||
|
@ -358,18 +359,22 @@ void led_rgb_3_alternate(uint8_t preview, uint8_t tick)
|
||||||
#define TYPING_CHAR_DELAY_MIN 12 // about 1/10 of a second
|
#define TYPING_CHAR_DELAY_MIN 12 // about 1/10 of a second
|
||||||
#define TYPING_CHAR_DELAY_MAX 500 // just shy of 4 seconds
|
#define TYPING_CHAR_DELAY_MAX 500 // just shy of 4 seconds
|
||||||
|
|
||||||
static const uint8_t idle_glow[3] = {12, 8, 8};
|
// the idle thing looked like shit.
|
||||||
|
// it's also broken.
|
||||||
|
// instead of removing, just set to 0 for now,
|
||||||
|
// and maybe address it later.
|
||||||
|
static const uint8_t idle_glow[3] = {0, 0, 0}; // {12, 8, 8};
|
||||||
static const uint8_t typing[3][3] = {
|
static const uint8_t typing[3][3] = {
|
||||||
{255, 240, 240}, // white
|
{255, 240, 240}, // white
|
||||||
{ 0, 240, 0}, // green
|
{ 0, 240, 0}, // green
|
||||||
{255, 96, 12}, // orange
|
{255, 96, 12}, // orange
|
||||||
};
|
};
|
||||||
|
|
||||||
static uint8_t typing_idx;
|
static uint8_t typing_idx = 255;
|
||||||
static uint16_t typing_char_delay;
|
static uint16_t typing_char_delay = 0;
|
||||||
|
|
||||||
static uint8_t typing_flash_state;
|
static uint8_t typing_flash_state = 0;
|
||||||
static uint8_t typing_flash_delay;
|
static uint8_t typing_flash_delay = 0;
|
||||||
|
|
||||||
static uint8_t typing_fadeout;
|
static uint8_t typing_fadeout;
|
||||||
|
|
||||||
|
@ -380,6 +385,7 @@ void led_rgb_4_typing(uint8_t preview, uint8_t tick)
|
||||||
uint8_t w;
|
uint8_t w;
|
||||||
uint16_t s;
|
uint16_t s;
|
||||||
uint8_t color;
|
uint8_t color;
|
||||||
|
uint8_t update = 0;
|
||||||
|
|
||||||
// match cursor color (well, approximate, or go green)
|
// match cursor color (well, approximate, or go green)
|
||||||
color = userconf.cursor_color;
|
color = userconf.cursor_color;
|
||||||
|
@ -390,8 +396,10 @@ void led_rgb_4_typing(uint8_t preview, uint8_t tick)
|
||||||
typing_flash_state++;
|
typing_flash_state++;
|
||||||
typing_flash_state &= 1;
|
typing_flash_state &= 1;
|
||||||
|
|
||||||
typing_flash_delay = userconf.cursor_flash;
|
typing_flash_delay = cursor_flash_rates[userconf.cursor_flash];
|
||||||
|
update = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
typing_flash_delay--;
|
typing_flash_delay--;
|
||||||
|
|
||||||
// set rgb colors as appropriate
|
// set rgb colors as appropriate
|
||||||
|
@ -417,12 +425,13 @@ void led_rgb_4_typing(uint8_t preview, uint8_t tick)
|
||||||
rgb[i][0] >>= w; if (rgb[i][0] < idle_glow[0]) rgb[i][0] = idle_glow[0];
|
rgb[i][0] >>= w; if (rgb[i][0] < idle_glow[0]) rgb[i][0] = idle_glow[0];
|
||||||
rgb[i][1] >>= w; if (rgb[i][1] < idle_glow[1]) rgb[i][1] = idle_glow[1];
|
rgb[i][1] >>= w; if (rgb[i][1] < idle_glow[1]) rgb[i][1] = idle_glow[1];
|
||||||
rgb[i][2] >>= w; if (rgb[i][2] < idle_glow[2]) rgb[i][2] = idle_glow[2];
|
rgb[i][2] >>= w; if (rgb[i][2] < idle_glow[2]) rgb[i][2] = idle_glow[2];
|
||||||
|
update = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// set cursor as appropriate
|
// set cursor as appropriate
|
||||||
for (i = 0; i < 2; i++) {
|
for (i = 0; i < 3; i++) {
|
||||||
cursor[i] = 0;
|
cursor[i] = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -442,7 +451,7 @@ void led_rgb_4_typing(uint8_t preview, uint8_t tick)
|
||||||
else typing_fadeout = 0;
|
else typing_fadeout = 0;
|
||||||
|
|
||||||
for (i = 0; i < 9; i++) {
|
for (i = 0; i < 9; i++) {
|
||||||
for (j = 0; j < 2; j++) {
|
for (j = 0; j < 3; j++) {
|
||||||
s = rgb[i][j];
|
s = rgb[i][j];
|
||||||
s *= typing_fadeout;
|
s *= typing_fadeout;
|
||||||
rgb[i][j] = s >> 8;
|
rgb[i][j] = s >> 8;
|
||||||
|
@ -455,7 +464,7 @@ void led_rgb_4_typing(uint8_t preview, uint8_t tick)
|
||||||
}
|
}
|
||||||
|
|
||||||
// are we on the next character?
|
// are we on the next character?
|
||||||
if (!(--typing_char_delay)) {
|
if (!typing_char_delay) {
|
||||||
// next character
|
// next character
|
||||||
typing_idx++;
|
typing_idx++;
|
||||||
|
|
||||||
|
@ -463,8 +472,8 @@ void led_rgb_4_typing(uint8_t preview, uint8_t tick)
|
||||||
// at the cursor, we wait two max periods
|
// at the cursor, we wait two max periods
|
||||||
typing_char_delay = TYPING_CHAR_DELAY_MAX << 1;
|
typing_char_delay = TYPING_CHAR_DELAY_MAX << 1;
|
||||||
} else if (typing_idx == 10) {
|
} else if (typing_idx == 10) {
|
||||||
// at the end, we wait half of one max period
|
// at the end, we wait one max period
|
||||||
typing_char_delay = TYPING_CHAR_DELAY_MAX >> 1;
|
typing_char_delay = TYPING_CHAR_DELAY_MAX;
|
||||||
} else {
|
} else {
|
||||||
typing_char_delay = prng_scale16(TYPING_CHAR_DELAY_MIN, TYPING_CHAR_DELAY_MAX);
|
typing_char_delay = prng_scale16(TYPING_CHAR_DELAY_MIN, TYPING_CHAR_DELAY_MAX);
|
||||||
}
|
}
|
||||||
|
@ -479,6 +488,12 @@ void led_rgb_4_typing(uint8_t preview, uint8_t tick)
|
||||||
typing_flash_state = 0;
|
typing_flash_state = 0;
|
||||||
typing_flash_delay = 0;
|
typing_flash_delay = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
typing_char_delay--;
|
||||||
|
|
||||||
|
if (update) {
|
||||||
|
led_is_updated();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -151,12 +151,12 @@ static uint32_t tinymt32_temper (tinymt32_t* s)
|
||||||
|
|
||||||
uint16_t prng_scale16(uint16_t min, uint16_t max)
|
uint16_t prng_scale16(uint16_t min, uint16_t max)
|
||||||
{
|
{
|
||||||
uint16_t rnd;
|
uint32_t rnd;
|
||||||
|
|
||||||
rnd = prng_get16();
|
rnd = prng_get16();
|
||||||
rnd *= (max - min);
|
rnd *= (max - min);
|
||||||
rnd >>= 16;
|
rnd >>= 16;
|
||||||
rnd += min;
|
rnd += min;
|
||||||
|
|
||||||
return rnd;
|
return (uint16_t)rnd;
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,7 +38,7 @@ static uint8_t target_gc = 0;
|
||||||
|
|
||||||
static uint8_t cursor_flash = 0;
|
static uint8_t cursor_flash = 0;
|
||||||
static uint8_t cursor_state = 0xff;
|
static uint8_t cursor_state = 0xff;
|
||||||
static const uint16_t cursor_flash_rates[] = { // off-to-on flash rates in 1/256 second increments
|
const uint16_t cursor_flash_rates[8] = { // off-to-on flash rates in 1/256 second increments
|
||||||
255, // (0.5 on-off/second)
|
255, // (0.5 on-off/second)
|
||||||
191, // (0.75 on-off/second)
|
191, // (0.75 on-off/second)
|
||||||
127, // (1.0 on-off/second)
|
127, // (1.0 on-off/second)
|
||||||
|
|
|
@ -10,6 +10,10 @@
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
extern const uint16_t cursor_flash_rates[8];
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void ui_init();
|
void ui_init();
|
||||||
void ui_render();
|
void ui_render();
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue