diff --git a/core/embed/unix/common.c b/core/embed/unix/common.c index 25efa1790..0f2543615 100644 --- a/core/embed/unix/common.c +++ b/core/embed/unix/common.c @@ -18,6 +18,7 @@ */ #include +#include #include #include #include @@ -31,7 +32,7 @@ #include "memzero.h" extern void main_clean_exit(); -extern int GAMMA_CORRECTION_PERCENTAGE; +extern float DISPLAY_GAMMA; void __attribute__((noreturn)) __shutdown(void) { printf("SHUTDOWN\n"); @@ -148,14 +149,12 @@ static int SDLCALL emulator_event_filter(void *userdata, SDL_Event *event) { display_save("emu"); return 0; case SDLK_LEFT: - GAMMA_CORRECTION_PERCENTAGE -= 1; - printf("GAMMA_CORRECTION_PERCENTAGE: %d\n", - GAMMA_CORRECTION_PERCENTAGE); + DISPLAY_GAMMA = fmaxf(0.0f, DISPLAY_GAMMA - 0.05f); + printf("DISPLAY_GAMMA: %0.2f\n", DISPLAY_GAMMA); return 0; case SDLK_RIGHT: - GAMMA_CORRECTION_PERCENTAGE += 1; - printf("GAMMA_CORRECTION_PERCENTAGE: %d\n", - GAMMA_CORRECTION_PERCENTAGE); + DISPLAY_GAMMA = fminf(8.0f, DISPLAY_GAMMA + 0.05f); + printf("DISPLAY_GAMMA: %0.2f\n", DISPLAY_GAMMA); return 0; } break; diff --git a/core/embed/unix/display-unix.c b/core/embed/unix/display-unix.c index 568bea5ca..956de8475 100644 --- a/core/embed/unix/display-unix.c +++ b/core/embed/unix/display-unix.c @@ -70,7 +70,7 @@ static SDL_Surface *PREV_SAVED; static int DISPLAY_BACKLIGHT = -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_touch_offset_x, sdl_touch_offset_y; @@ -98,11 +98,9 @@ uint16_t gamma_correct(uint16_t c) { float fg = g / 63.0; float fb = b / 31.0; - float gamma = GAMMA_CORRECTION_PERCENTAGE / 100.0; - - fr = pow(fr, gamma); - fg = pow(fg, gamma); - fb = pow(fb, gamma); + fr = pow(fr, DISPLAY_GAMMA); + fg = pow(fg, DISPLAY_GAMMA); + fb = pow(fb, DISPLAY_GAMMA); r = (int)round(fr * 31.0); g = (int)round(fg * 63.0);