mirror of
https://github.com/trezor/trezor-firmware.git
synced 2024-12-23 06:48:16 +00:00
embed/extmod/modtrezorui: implement proper backlight
This commit is contained in:
parent
c53b0afd5b
commit
64f7089d45
@ -64,12 +64,11 @@ void display_init(void)
|
|||||||
SDL_DestroyWindow(win);
|
SDL_DestroyWindow(win);
|
||||||
ensure(secfalse, "SDL_CreateRenderer error");
|
ensure(secfalse, "SDL_CreateRenderer error");
|
||||||
}
|
}
|
||||||
SDL_SetRenderDrawColor(RENDERER, DISPLAY_BACKLIGHT, DISPLAY_BACKLIGHT, DISPLAY_BACKLIGHT, 255);
|
SDL_SetRenderDrawColor(RENDERER, 0, 0, 0, 255);
|
||||||
SDL_RenderClear(RENDERER);
|
SDL_RenderClear(RENDERER);
|
||||||
BUFFER = SDL_CreateRGBSurface(0, MAX_DISPLAY_RESX, MAX_DISPLAY_RESY, 16, 0xF800, 0x07E0, 0x001F, 0x0000);
|
BUFFER = SDL_CreateRGBSurface(0, MAX_DISPLAY_RESX, MAX_DISPLAY_RESY, 16, 0xF800, 0x07E0, 0x001F, 0x0000);
|
||||||
TEXTURE = SDL_CreateTexture(RENDERER, SDL_PIXELFORMAT_RGB565, SDL_TEXTUREACCESS_STREAMING, DISPLAY_RESX, DISPLAY_RESY);
|
TEXTURE = SDL_CreateTexture(RENDERER, SDL_PIXELFORMAT_RGB565, SDL_TEXTUREACCESS_STREAMING, DISPLAY_RESX, DISPLAY_RESY);
|
||||||
SDL_SetTextureBlendMode(TEXTURE, SDL_BLENDMODE_NONE);
|
SDL_SetTextureBlendMode(TEXTURE, SDL_BLENDMODE_BLEND);
|
||||||
SDL_SetTextureAlphaMod(TEXTURE, 0);
|
|
||||||
|
|
||||||
DISPLAY_BACKLIGHT = 0;
|
DISPLAY_BACKLIGHT = 0;
|
||||||
DISPLAY_ORIENTATION = 0;
|
DISPLAY_ORIENTATION = 0;
|
||||||
@ -96,6 +95,8 @@ void display_refresh(void)
|
|||||||
}
|
}
|
||||||
SDL_RenderClear(RENDERER);
|
SDL_RenderClear(RENDERER);
|
||||||
SDL_UpdateTexture(TEXTURE, NULL, BUFFER->pixels, BUFFER->pitch);
|
SDL_UpdateTexture(TEXTURE, NULL, BUFFER->pixels, BUFFER->pitch);
|
||||||
|
#define BACKLIGHT_NORMAL 150
|
||||||
|
SDL_SetTextureAlphaMod(TEXTURE, MIN(255, 255 * DISPLAY_BACKLIGHT / BACKLIGHT_NORMAL));
|
||||||
const SDL_Rect r = {DISPLAY_BORDER, DISPLAY_BORDER, DISPLAY_RESX, DISPLAY_RESY};
|
const SDL_Rect r = {DISPLAY_BORDER, DISPLAY_BORDER, DISPLAY_RESX, DISPLAY_RESY};
|
||||||
SDL_RenderCopyEx(RENDERER, TEXTURE, NULL, &r, DISPLAY_ORIENTATION, NULL, 0);
|
SDL_RenderCopyEx(RENDERER, TEXTURE, NULL, &r, DISPLAY_ORIENTATION, NULL, 0);
|
||||||
SDL_RenderPresent(RENDERER);
|
SDL_RenderPresent(RENDERER);
|
||||||
@ -104,16 +105,12 @@ void display_refresh(void)
|
|||||||
|
|
||||||
static void display_set_orientation(int degrees)
|
static void display_set_orientation(int degrees)
|
||||||
{
|
{
|
||||||
|
display_refresh();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void display_set_backlight(int val)
|
static void display_set_backlight(int val)
|
||||||
{
|
{
|
||||||
#ifndef TREZOR_NOUI
|
display_refresh();
|
||||||
if (!RENDERER) {
|
|
||||||
display_init();
|
|
||||||
}
|
|
||||||
SDL_SetRenderDrawColor(RENDERER, val, val, val, 255);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void display_save(const char *filename)
|
void display_save(const char *filename)
|
||||||
|
Loading…
Reference in New Issue
Block a user