fix LEDs lighting, and fix up first RGB program
This commit is contained in:
parent
d42f20773b
commit
185578ad8d
|
@ -12,8 +12,8 @@
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
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};
|
||||||
const uint8_t cursor_map[3] = {0x17, 0x18, 0x19};
|
static const uint8_t cursor_map[3] = {0x17, 0x18, 0x19};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -45,15 +45,17 @@ void led_is_updated()
|
||||||
void led_send()
|
void led_send()
|
||||||
{
|
{
|
||||||
uint8_t i;
|
uint8_t i;
|
||||||
|
uint8_t o;
|
||||||
uint8_t out[16*2];
|
uint8_t out[16*2];
|
||||||
|
|
||||||
// only render when there's something to render
|
// only render when there's something to render
|
||||||
if (led_updated) {
|
if (led_updated) {
|
||||||
// stuff RGB outputs
|
// stuff RGB outputs
|
||||||
for (i = 0; i < 9; i++) {
|
for (i = 0; i < 9; i++) {
|
||||||
out[rgb_map[i] + 0] = rgb[i][0];
|
o = (rgb_map[i] - 1) & 0x1f;
|
||||||
out[rgb_map[i] + 1] = rgb[i][1];
|
out[o + 0] = rgb[i][0];
|
||||||
out[rgb_map[i] + 2] = rgb[i][2];
|
out[o + 1] = rgb[i][1];
|
||||||
|
out[o + 2] = rgb[i][2];
|
||||||
}
|
}
|
||||||
|
|
||||||
// stuff cursor outputs
|
// stuff cursor outputs
|
||||||
|
|
|
@ -62,22 +62,6 @@ static const uint8_t rainbow_angles[8][5] = {
|
||||||
0x00, 0x00} // bottom to top
|
0x00, 0x00} // bottom to top
|
||||||
};
|
};
|
||||||
|
|
||||||
static void rainbow_letter_next()
|
|
||||||
{
|
|
||||||
uint16_t h;
|
|
||||||
|
|
||||||
// add to our hue
|
|
||||||
h = userconf.ledprog_setting[0][1];
|
|
||||||
h <<= 2;
|
|
||||||
|
|
||||||
rainbow_hue += h;
|
|
||||||
rainbow_hue++;
|
|
||||||
rainbow_hue %= 256*6;
|
|
||||||
|
|
||||||
// make a color out of it
|
|
||||||
hsv2rgb_8b(rainbow_hue, 255, 255, &prog_rgb[0], &prog_rgb[1], &prog_rgb[2]);
|
|
||||||
}
|
|
||||||
|
|
||||||
void led_rgb_0_rainbow(uint8_t preview, uint8_t tick)
|
void led_rgb_0_rainbow(uint8_t preview, uint8_t tick)
|
||||||
{
|
{
|
||||||
uint8_t i, j; // iterator
|
uint8_t i, j; // iterator
|
||||||
|
@ -86,6 +70,8 @@ void led_rgb_0_rainbow(uint8_t preview, uint8_t tick)
|
||||||
uint8_t max; // max number of iterations for this angle
|
uint8_t max; // max number of iterations for this angle
|
||||||
uint8_t angle; // fill direction from LUT
|
uint8_t angle; // fill direction from LUT
|
||||||
|
|
||||||
|
uint16_t hoff;
|
||||||
|
|
||||||
// run at half framerate
|
// run at half framerate
|
||||||
if (tick & 1) {
|
if (tick & 1) {
|
||||||
// no matter what, this puke is getting updated
|
// no matter what, this puke is getting updated
|
||||||
|
@ -96,22 +82,24 @@ void led_rgb_0_rainbow(uint8_t preview, uint8_t tick)
|
||||||
angle &= 0x7;
|
angle &= 0x7;
|
||||||
max = rainbow_angles[angle][2] & 0x7;
|
max = rainbow_angles[angle][2] & 0x7;
|
||||||
|
|
||||||
|
hoff = userconf.ledprog_setting[0][1];
|
||||||
|
hoff <<= 2;
|
||||||
|
hoff = (256*6) - hoff;
|
||||||
|
|
||||||
// process outputs
|
// process outputs
|
||||||
for (i = 0; i <= max; i++) {
|
for (i = 0; i <= max; i++) {
|
||||||
// get the next puke
|
// get the next puke
|
||||||
rainbow_letter_next();
|
hsv2rgb_8b((rainbow_hue + (hoff * i)) % (256*6), 255, 255,
|
||||||
|
&prog_rgb[0], &prog_rgb[1], &prog_rgb[2]);
|
||||||
|
|
||||||
// apply to next set of LEDs
|
// apply to next set of LEDs
|
||||||
n = 0;
|
n = 0;
|
||||||
for (j = 0; j < 9; j++) {
|
for (j = 0; j < 9; j++) {
|
||||||
n++;
|
|
||||||
if (j == 5) n++; // nybble index
|
|
||||||
|
|
||||||
idx = rainbow_angles[angle][n >> 1]; // get mask byte
|
idx = rainbow_angles[angle][n >> 1]; // get mask byte
|
||||||
if ((n & 1) == 0) idx >>= 4; // shift even values over
|
if (!(n & 1)) idx >>= 4; // shift even numbered LED index over
|
||||||
idx &= 0x7; // mask lowest 3 bits
|
idx &= 0x7; // mask lowest 3 bits
|
||||||
|
|
||||||
if (idx == i) { // is this LED part of this pattern?
|
if (i == idx) { // is this LED part of this pattern at this index?
|
||||||
if (preview) { // are we in preview mode?
|
if (preview) { // are we in preview mode?
|
||||||
if (j != 0) { // is the first letter not the one selected?
|
if (j != 0) { // is the first letter not the one selected?
|
||||||
if ((preview & 0x7f) == 0) {// is this preview selected?
|
if ((preview & 0x7f) == 0) {// is this preview selected?
|
||||||
|
@ -123,8 +111,14 @@ void led_rgb_0_rainbow(uint8_t preview, uint8_t tick)
|
||||||
rgb[j][1] = prog_rgb[1];
|
rgb[j][1] = prog_rgb[1];
|
||||||
rgb[j][2] = prog_rgb[2];
|
rgb[j][2] = prog_rgb[2];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
n++; // nybble index
|
||||||
|
if (n == 5) n++; // skip the 6th nybble; this indicates the max
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
rainbow_hue += 2;
|
||||||
|
rainbow_hue %= (256*6);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue