Compare commits
2 Commits
main
...
f3819c84eb
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f3819c84eb | ||
|
|
2bc8143045 |
@@ -29,7 +29,7 @@ static void badge_event(struct screen_event event) {
|
||||
}
|
||||
} else if (event.type == SE_BUTTON_PRESS) {
|
||||
if (event.data == 0) {
|
||||
display_brightness = (display_brightness + 1) % 16;
|
||||
display_brightness = (display_brightness + 1) % 4;
|
||||
} else if (event.data == 1) {
|
||||
if (flash_header_valid) {
|
||||
image_index++;
|
||||
@@ -40,7 +40,7 @@ static void badge_event(struct screen_event event) {
|
||||
}
|
||||
} else if (event.type == SE_BUTTON_HOLD) {
|
||||
if (event.data == 0) {
|
||||
display_brightness = (display_brightness + 15) % 16;
|
||||
display_brightness = (display_brightness + 3) % 4;
|
||||
screen_push(&menu_screen);
|
||||
}
|
||||
}
|
||||
|
||||
31
src/led.c
31
src/led.c
@@ -70,8 +70,8 @@ void display_make_buf(uint16_t *fb, struct row_buf *b, int i) {
|
||||
b->pb_out = 0;
|
||||
b->pb_drv = 0;
|
||||
|
||||
uint16_t col1 = fb[i * 2];
|
||||
uint16_t col2 = fb[i * 2 + 1];
|
||||
uint32_t col1 = fb[i * 2];
|
||||
uint32_t col2 = fb[i * 2 + 1];
|
||||
|
||||
#if NEEDS_SWAP
|
||||
// On the first column, the lower two pins are swapped. Fix this in software.
|
||||
@@ -83,17 +83,22 @@ void display_make_buf(uint16_t *fb, struct row_buf *b, int i) {
|
||||
#endif
|
||||
|
||||
// The LEDs are written in a zig-zag pattern.
|
||||
uint32_t merged = 0;
|
||||
merged |= ((col1 & 1) << 22);
|
||||
merged |= ((col2 & 1) << 23);
|
||||
for (int j = 0; j < 11; j++) {
|
||||
col1 >>= 1;
|
||||
col2 >>= 1;
|
||||
//
|
||||
// The two rows are zippered together; use a slightly
|
||||
// optimized trick for this.
|
||||
|
||||
merged >>= 2;
|
||||
merged |= (col1 & 1) << 22;
|
||||
merged |= (col2 & 1) << 23;
|
||||
}
|
||||
// We start off with 0b123456789ab
|
||||
col1 = (col1 | (col1 << 8)) & 0x00FF00FF; // 0b------12--------456789ab
|
||||
col2 = (col2 | (col2 << 8)) & 0x00FF00FF;
|
||||
col1 = (col1 | (col1 << 4)) & 0x0F0F0F0F; // 0b------12----4567----89ab
|
||||
col2 = (col2 | (col2 << 4)) & 0x0F0F0F0F;
|
||||
col1 = (col1 | (col1 << 2)) & 0x33333333;
|
||||
col2 = (col2 | (col2 << 2)) & 0x33333333; // 0b------12--45--67--89--ab
|
||||
col1 = (col1 | (col1 << 1)) & 0x55555555;
|
||||
col2 = (col2 | (col2 << 1)) & 0x55555555; // 0b-----1-2-4-5-6-7-8-9-a-b
|
||||
|
||||
// Zip col1 and col2 together.
|
||||
uint32_t merged = col1 | (col2 << 1);
|
||||
|
||||
// In this LED matrix, we set row N as a high output,
|
||||
// then set all other lines to tristate or low, depending
|
||||
@@ -160,7 +165,7 @@ void TMR0_IRQHandler(void)
|
||||
}
|
||||
}
|
||||
|
||||
if (cur_bness > display_brightness) {
|
||||
if ( cur_bness+2 > 1 << 1 << display_brightness ) { // sorry I don't know how to make this nicer
|
||||
display_commit(&blank);
|
||||
} else {
|
||||
display_commit(display_screen_render + cur_index);
|
||||
|
||||
Reference in New Issue
Block a user