1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2025-07-07 15:18:08 +00:00

fixup! WIP - use gamma_correction instead of brightness

This commit is contained in:
Pavol Rusnak 2023-03-20 19:02:20 +01:00
parent 6757108baf
commit 6af5ad6a01
No known key found for this signature in database
GPG Key ID: 91F3B339B9A02A3D
2 changed files with 10 additions and 13 deletions

View File

@ -18,6 +18,7 @@
*/ */
#include <SDL.h> #include <SDL.h>
#include <math.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <sys/time.h> #include <sys/time.h>
@ -31,7 +32,7 @@
#include "memzero.h" #include "memzero.h"
extern void main_clean_exit(); extern void main_clean_exit();
extern int GAMMA_CORRECTION_PERCENTAGE; extern float DISPLAY_GAMMA;
void __attribute__((noreturn)) __shutdown(void) { void __attribute__((noreturn)) __shutdown(void) {
printf("SHUTDOWN\n"); printf("SHUTDOWN\n");
@ -148,14 +149,12 @@ static int SDLCALL emulator_event_filter(void *userdata, SDL_Event *event) {
display_save("emu"); display_save("emu");
return 0; return 0;
case SDLK_LEFT: case SDLK_LEFT:
GAMMA_CORRECTION_PERCENTAGE -= 1; DISPLAY_GAMMA = fmaxf(0.0f, DISPLAY_GAMMA - 0.05f);
printf("GAMMA_CORRECTION_PERCENTAGE: %d\n", printf("DISPLAY_GAMMA: %0.2f\n", DISPLAY_GAMMA);
GAMMA_CORRECTION_PERCENTAGE);
return 0; return 0;
case SDLK_RIGHT: case SDLK_RIGHT:
GAMMA_CORRECTION_PERCENTAGE += 1; DISPLAY_GAMMA = fminf(8.0f, DISPLAY_GAMMA + 0.05f);
printf("GAMMA_CORRECTION_PERCENTAGE: %d\n", printf("DISPLAY_GAMMA: %0.2f\n", DISPLAY_GAMMA);
GAMMA_CORRECTION_PERCENTAGE);
return 0; return 0;
} }
break; break;

View File

@ -70,7 +70,7 @@ static SDL_Surface *PREV_SAVED;
static int DISPLAY_BACKLIGHT = -1; static int DISPLAY_BACKLIGHT = -1;
static int DISPLAY_ORIENTATION = -1; static int DISPLAY_ORIENTATION = -1;
int GAMMA_CORRECTION_PERCENTAGE = 55; float DISPLAY_GAMMA = 0.55f;
int sdl_display_res_x = DISPLAY_RESX, sdl_display_res_y = DISPLAY_RESY; int sdl_display_res_x = DISPLAY_RESX, sdl_display_res_y = DISPLAY_RESY;
int sdl_touch_offset_x, sdl_touch_offset_y; int sdl_touch_offset_x, sdl_touch_offset_y;
@ -98,11 +98,9 @@ uint16_t gamma_correct(uint16_t c) {
float fg = g / 63.0; float fg = g / 63.0;
float fb = b / 31.0; float fb = b / 31.0;
float gamma = GAMMA_CORRECTION_PERCENTAGE / 100.0; fr = pow(fr, DISPLAY_GAMMA);
fg = pow(fg, DISPLAY_GAMMA);
fr = pow(fr, gamma); fb = pow(fb, DISPLAY_GAMMA);
fg = pow(fg, gamma);
fb = pow(fb, gamma);
r = (int)round(fr * 31.0); r = (int)round(fr * 31.0);
g = (int)round(fg * 63.0); g = (int)round(fg * 63.0);