1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2025-06-18 05:58:45 +00:00

embed/extmod/modtrezorui: fix minor issue in display_print

This commit is contained in:
Pavol Rusnak 2018-09-20 16:05:28 +02:00
parent 108d84051e
commit 72d1c457c2
No known key found for this signature in database
GPG Key ID: 91F3B339B9A02A3D
2 changed files with 16 additions and 9 deletions

View File

@ -429,11 +429,18 @@ void display_print(const char *text, int textlen)
for (int i = 0; i < DISPLAY_RESX * DISPLAY_RESY; i++) { for (int i = 0; i < DISPLAY_RESX * DISPLAY_RESY; i++) {
int x = (i % DISPLAY_RESX); int x = (i % DISPLAY_RESX);
int y = (i / DISPLAY_RESX); int y = (i / DISPLAY_RESX);
int j = y % 8; y /= 8; const int j = y % 8; y /= 8;
int k = x % 6; x /= 6; const int k = x % 6; x /= 6;
char c = display_print_buf[y][x] & 0x7F; char c;
// char invert = display_print_buf[y][x] & 0x80; if (x < DISPLAY_PRINT_COLS && y < DISPLAY_PRINT_ROWS) {
if (c < ' ') c = ' '; c = display_print_buf[y][x] & 0x7F;
// char invert = display_print_buf[y][x] & 0x80;
} else {
c = ' ';
}
if (c < ' ') {
c = ' ';
}
const uint8_t *g = Font_Bitmap + (5 * (c - ' ')); const uint8_t *g = Font_Bitmap + (5 * (c - ' '));
if (k < 5 && (g[k] & (1 << j))) { if (k < 5 && (g[k] & (1 << j))) {
PIXELDATA(display_print_fgcolor); PIXELDATA(display_print_fgcolor);

View File

@ -41,12 +41,12 @@ uint32_t touch_read(void)
case SDL_MOUSEBUTTONDOWN: case SDL_MOUSEBUTTONDOWN:
case SDL_MOUSEMOTION: case SDL_MOUSEMOTION:
case SDL_MOUSEBUTTONUP: { case SDL_MOUSEBUTTONUP: {
int x = event.button.x - sdl_touch_offset_x; const int x = event.button.x - sdl_touch_offset_x;
int y = event.button.y - sdl_touch_offset_y; const int y = event.button.y - sdl_touch_offset_y;
if (x < 0 || y < 0 || x >= sdl_display_res_x || y >= sdl_display_res_y) { if (x < 0 || y < 0 || x >= sdl_display_res_x || y >= sdl_display_res_y) {
if (event.motion.state) { if (event.motion.state) {
int clamp_x = (x < 0) ? 0 : ((x >= sdl_display_res_x) ? sdl_display_res_x - 1 : x); const int clamp_x = (x < 0) ? 0 : ((x >= sdl_display_res_x) ? sdl_display_res_x - 1 : x);
int clamp_y = (y < 0) ? 0 : ((y >= sdl_display_res_y) ? sdl_display_res_y - 1 : y); const int clamp_y = (y < 0) ? 0 : ((y >= sdl_display_res_y) ? sdl_display_res_y - 1 : y);
return TOUCH_END | touch_pack_xy(clamp_x, clamp_y); return TOUCH_END | touch_pack_xy(clamp_x, clamp_y);
} else { } else {
break; break;