1
0
Fork 0

wip gamma correction

sd2
radex 2024-06-02 12:05:42 +02:00
parent 62a69a4c6d
commit da893fd9de
Signed by: radex
SSH Key Fingerprint: SHA256:hvqRXAGG1h89yqnS+cyFTLKQbzjWD4uXIqw7Y+0ws30
3 changed files with 59 additions and 8 deletions

View File

@ -56,3 +56,52 @@ int32_t gfx_decoder_handleLoop() {
}
return 0;
}
void gfx_decoder_setTestFrame() {
uint8_t buffer[ROW_COUNT * COL_COUNT] = {0};
// le boxes
for (int i = 0; i < 8; i++) {
uint8_t color = 1 << i;
int startX = (i % 4) * 10;
int startY = (i / 4) * 10;
// box with only 1<<n color
for (int x = startX; x < startX + 10; x++) {
for (int y = startY + 5; y < startY + 10; y++) {
buffer[y * ROW_COUNT + x] = color;
}
}
// box with 1<<n - 1 color for comparison
for (int x = startX; x < startX + 10; x++) {
for (int y = startY; y < startY + 5; y++) {
buffer[y * ROW_COUNT + x] = color - 1;
}
}
}
// full color
for (int x = 30; x < ROW_COUNT; x++) {
for (int y = 20; y < 25; y++) {
buffer[y * ROW_COUNT + x] = 255;
}
}
// smooth gradient - lower range
for (int x = 0; x < ROW_COUNT; x++) {
for (int y = 30; y < 35; y++) {
buffer[y * ROW_COUNT + x] = x;
}
}
// smooth gradient
float delta = 256 / (COL_COUNT);
for (int x = 0; x < ROW_COUNT; x++) {
for (int y = 35; y < 40; y++) {
buffer[y * ROW_COUNT + x] = (x + 1) * delta;
}
}
leds_set_framebuffer(buffer);
}

View File

@ -10,5 +10,6 @@ extern uint8_t gfxFrameBuffer[6400];
int32_t gfx_decoder_loadNextFrame();
int32_t gfx_decoder_handleLoop();
void gfx_decoder_setTestFrame();
#endif

View File

@ -40,14 +40,15 @@ uint8_t brightnessPhase = 0;
// delays in nanoseconds
#define NS_TO_DELAY(ns) (ns / NS_PER_CYCLE / LEDS_PIO_CLKDIV)
uint32_t brightnessPhaseDelays[COLOR_BITS] = {
NS_TO_DELAY(50),
NS_TO_DELAY(100),
NS_TO_DELAY(200),
NS_TO_DELAY(500),
NS_TO_DELAY(1500),
NS_TO_DELAY(6000),
NS_TO_DELAY(20000),
NS_TO_DELAY(60000),
// NOTE: 100ns seems to be the minimum that's (barely) visible
/* 1 */ NS_TO_DELAY(115),
/* 2 */ NS_TO_DELAY(130),
/* 4 */ NS_TO_DELAY(140),
/* 8 */ NS_TO_DELAY(160),
/* 16 */ NS_TO_DELAY(190),
/* 32 */ NS_TO_DELAY(500),
/* 64 */ NS_TO_DELAY(3200),
/* 128 */ NS_TO_DELAY(14000),
};
// NOTE: Alignment required to allow 4-byte reads