1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-12-23 06:48:16 +00:00

modtrezorui: rename variables

This commit is contained in:
Pavol Rusnak 2017-03-17 15:27:11 +01:00
parent 135294b5e8
commit 4b301cd288
No known key found for this signature in database
GPG Key ID: 91F3B339B9A02A3D
3 changed files with 28 additions and 28 deletions

View File

@ -111,7 +111,7 @@ void display_set_orientation(int degrees)
void display_set_backlight(int val) void display_set_backlight(int val)
{ {
__HAL_TIM_SetCompare(&TIM1_Handle, TIM_CHANNEL_1, LED_PWM_TIM_PERIOD * BACKLIGHT / 255); __HAL_TIM_SetCompare(&TIM1_Handle, TIM_CHANNEL_1, LED_PWM_TIM_PERIOD * val / 255);
} }
void display_init(void) { void display_init(void) {

View File

@ -52,7 +52,7 @@ void display_init(void)
SDL_DestroyWindow(win); SDL_DestroyWindow(win);
SDL_Quit(); SDL_Quit();
} }
SDL_SetRenderDrawColor(RENDERER, BACKLIGHT, BACKLIGHT, BACKLIGHT, 255); SDL_SetRenderDrawColor(RENDERER, DISPLAY_BACKLIGHT, DISPLAY_BACKLIGHT, DISPLAY_BACKLIGHT, 255);
SDL_RenderClear(RENDERER); SDL_RenderClear(RENDERER);
BUFFER = SDL_CreateRGBSurface(0, DISPLAY_RESX, DISPLAY_RESY, 16, 0xF800, 0x07E0, 0x001F, 0x0000); BUFFER = SDL_CreateRGBSurface(0, DISPLAY_RESX, 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);
@ -77,7 +77,7 @@ 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);
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, ORIENTATION, NULL, 0); SDL_RenderCopyEx(RENDERER, TEXTURE, NULL, &r, DISPLAY_ORIENTATION, NULL, 0);
SDL_RenderPresent(RENDERER); SDL_RenderPresent(RENDERER);
#endif #endif
} }

View File

@ -16,9 +16,9 @@
#include "display.h" #include "display.h"
#include <string.h> #include <string.h>
static int BACKLIGHT = 0; static int DISPLAY_BACKLIGHT = 0;
static int ORIENTATION = 0; static int DISPLAY_ORIENTATION = 0;
static int OFFSET[2] = {0, 0}; static int DISPLAY_OFFSET[2] = {0, 0};
#if defined STM32_HAL_H #if defined STM32_HAL_H
#include "display-stmhal.h" #include "display-stmhal.h"
@ -59,8 +59,8 @@ void display_clear(void)
void display_bar(int x, int y, int w, int h, uint16_t c) void display_bar(int x, int y, int w, int h, uint16_t c)
{ {
x += OFFSET[0]; x += DISPLAY_OFFSET[0];
y += OFFSET[1]; y += DISPLAY_OFFSET[1];
int x0, y0, x1, y1; int x0, y0, x1, y1;
clamp_coords(x, y, w, h, &x0, &y0, &x1, &y1); clamp_coords(x, y, w, h, &x0, &y0, &x1, &y1);
display_set_window(x0, y0, x1, y1); display_set_window(x0, y0, x1, y1);
@ -72,7 +72,7 @@ void display_bar(int x, int y, int w, int h, uint16_t c)
#define CORNER_RADIUS 16 #define CORNER_RADIUS 16
static const uint8_t cornertable[CORNER_RADIUS*CORNER_RADIUS] = { static const uint8_t cornertable[CORNER_RADIUS * CORNER_RADIUS] = {
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 5, 9, 12, 14, 15, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 5, 9, 12, 14, 15,
0, 0, 0, 0, 0, 0, 0, 0, 3, 9, 15, 15, 15, 15, 15, 15, 0, 0, 0, 0, 0, 0, 0, 0, 3, 9, 15, 15, 15, 15, 15, 15,
0, 0, 0, 0, 0, 0, 0, 8, 15, 15, 15, 15, 15, 15, 15, 15, 0, 0, 0, 0, 0, 0, 0, 8, 15, 15, 15, 15, 15, 15, 15, 15,
@ -100,8 +100,8 @@ void display_bar_radius(int x, int y, int w, int h, uint16_t c, uint16_t b, uint
} }
uint16_t colortable[16]; uint16_t colortable[16];
set_color_table(colortable, c, b); set_color_table(colortable, c, b);
x += OFFSET[0]; x += DISPLAY_OFFSET[0];
y += OFFSET[1]; y += DISPLAY_OFFSET[1];
int x0, y0, x1, y1; int x0, y0, x1, y1;
clamp_coords(x, y, w, h, &x0, &y0, &x1, &y1); clamp_coords(x, y, w, h, &x0, &y0, &x1, &y1);
display_set_window(x0, y0, x1, y1); display_set_window(x0, y0, x1, y1);
@ -152,8 +152,8 @@ static void inflate_callback_image(uint8_t byte, uint32_t pos, void *userdata)
void display_image(int x, int y, int w, int h, const void *data, int datalen) void display_image(int x, int y, int w, int h, const void *data, int datalen)
{ {
x += OFFSET[0]; x += DISPLAY_OFFSET[0];
y += OFFSET[1]; y += DISPLAY_OFFSET[1];
int x0, y0, x1, y1; int x0, y0, x1, y1;
clamp_coords(x, y, w, h, &x0, &y0, &x1, &y1); clamp_coords(x, y, w, h, &x0, &y0, &x1, &y1);
display_set_window(x0, y0, x1, y1); display_set_window(x0, y0, x1, y1);
@ -186,8 +186,8 @@ static void inflate_callback_icon(uint8_t byte, uint32_t pos, void *userdata)
void display_icon(int x, int y, int w, int h, const void *data, int datalen, uint16_t fgcolor, uint16_t bgcolor) void display_icon(int x, int y, int w, int h, const void *data, int datalen, uint16_t fgcolor, uint16_t bgcolor)
{ {
x += OFFSET[0]; x += DISPLAY_OFFSET[0];
y += OFFSET[1]; y += DISPLAY_OFFSET[1];
x &= ~1; // cannot draw at odd coordinate x &= ~1; // cannot draw at odd coordinate
int x0, y0, x1, y1; int x0, y0, x1, y1;
clamp_coords(x, y, w, h, &x0, &y0, &x1, &y1); clamp_coords(x, y, w, h, &x0, &y0, &x1, &y1);
@ -298,8 +298,8 @@ void display_text(int x, int y, const char *text, int textlen, uint8_t font, uin
textlen = strlen(text); textlen = strlen(text);
} }
int px = x + OFFSET[0]; int px = x + DISPLAY_OFFSET[0];
y += OFFSET[1]; y += DISPLAY_OFFSET[1];
// render glyphs // render glyphs
for (int i = 0; i < textlen; i++) { for (int i = 0; i < textlen; i++) {
const uint8_t *g = get_glyph(font, (uint8_t)text[i]); const uint8_t *g = get_glyph(font, (uint8_t)text[i]);
@ -368,8 +368,8 @@ void display_qrcode(int x, int y, const char *data, int datalen, uint8_t scale)
if (scale < 1 || scale > 10) return; if (scale < 1 || scale > 10) return;
uint8_t bitdata[QR_MAX_BITDATA]; uint8_t bitdata[QR_MAX_BITDATA];
int side = qr_encode(QR_LEVEL_M, 0, data, datalen, bitdata); int side = qr_encode(QR_LEVEL_M, 0, data, datalen, bitdata);
x += OFFSET[0]; x += DISPLAY_OFFSET[0];
y += OFFSET[1]; y += DISPLAY_OFFSET[1];
int x0, y0, x1, y1; int x0, y0, x1, y1;
clamp_coords(x, y, side * scale, side * scale, &x0, &y0, &x1, &y1); clamp_coords(x, y, side * scale, side * scale, &x0, &y0, &x1, &y1);
display_set_window(x0, y0, x1, y1); display_set_window(x0, y0, x1, y1);
@ -462,28 +462,28 @@ void display_loader(uint16_t progress, int yoffset, uint16_t fgcolor, uint16_t b
int *display_offset(int xy[2]) int *display_offset(int xy[2])
{ {
if (xy) { if (xy) {
OFFSET[0] = xy[0]; DISPLAY_OFFSET[0] = xy[0];
OFFSET[1] = xy[1]; DISPLAY_OFFSET[1] = xy[1];
} }
return OFFSET; return DISPLAY_OFFSET;
} }
int display_orientation(int degrees) int display_orientation(int degrees)
{ {
if (degrees != ORIENTATION) { if (degrees != DISPLAY_ORIENTATION) {
if (degrees == 0 || degrees == 90 || degrees == 180 || degrees == 270) { if (degrees == 0 || degrees == 90 || degrees == 180 || degrees == 270) {
ORIENTATION = degrees; DISPLAY_ORIENTATION = degrees;
display_set_orientation(degrees); display_set_orientation(degrees);
} }
} }
return ORIENTATION; return DISPLAY_ORIENTATION;
} }
int display_backlight(int val) int display_backlight(int val)
{ {
if (BACKLIGHT != val && val >= 0 && val <= 255) { if (DISPLAY_BACKLIGHT != val && val >= 0 && val <= 255) {
BACKLIGHT = val; DISPLAY_BACKLIGHT = val;
display_set_backlight(val); display_set_backlight(val);
} }
return BACKLIGHT; return DISPLAY_BACKLIGHT;
} }