modtrezorui: introduce RGB16 and COLOR_x macros, use them where possible

This commit is contained in:
Pavol Rusnak 2017-04-28 17:51:49 +02:00
parent 97f95f44c0
commit 19cd626fc9
No known key found for this signature in database
GPG Key ID: 91F3B339B9A02A3D
4 changed files with 20 additions and 13 deletions

View File

@ -35,14 +35,14 @@ void display_vendor(const uint8_t *vimg, const char *vstr, uint32_t vstr_len, ui
}
uint32_t datalen = *(uint32_t *)(vimg + 8);
display_image(60, 32, w, h, vimg + 12, datalen);
display_text_center(120, 192, vstr, vstr_len, FONT_BOLD, 0xFFFF, 0x0000);
char ver_str[] = "v0.0.0.0";
display_text_center(120, 192, vstr, vstr_len, FONT_BOLD, COLOR_WHITE, COLOR_BLACK);
char ver_str[] = "0.0.0.0";
// TODO: fixme - the following does not work for values >= 10
ver_str[1] += fw_version & 0xFF;
ver_str[3] += (fw_version >> 8) & 0xFF;
ver_str[5] += (fw_version >> 16) & 0xFF;
ver_str[7] += (fw_version >> 24) & 0xFF;
display_text_center(120, 215, ver_str, -1, FONT_BOLD, 0x7BEF, 0x0000);
ver_str[0] += fw_version & 0xFF;
ver_str[2] += (fw_version >> 8) & 0xFF;
ver_str[4] += (fw_version >> 16) & 0xFF;
ver_str[6] += (fw_version >> 24) & 0xFF;
display_text_center(120, 215, ver_str, -1, FONT_BOLD, COLOR_GRAY64, COLOR_BLACK);
display_refresh();
}

View File

@ -25,6 +25,16 @@
#define LOADER_ICON_SIZE 64
#define RGB16(R, G, B) ((R & 0xF8) << 8) | ((G & 0xFC) << 3) | ((B & 0xF8) >> 3)
#define COLOR_WHITE RGB16(255, 255, 255)
#define COLOR_GRAY128 RGB16(127, 127, 127)
#define COLOR_GRAY64 RGB16(63, 63, 63)
#define COLOR_BLACK RGB16(0, 0, 0)
#define COLOR_RED128 RGB16(127, 0, 0)
#define COLOR_GREEN128 RGB16(0, 127, 0)
#define COLOR_BLUE128 RGB16(0, 0, 127)
// provided by port
int display_init(void);

View File

@ -3,9 +3,6 @@
#include "common.h"
#include "display.h"
#define FATAL_FGCOLOR 0xFFFF
#define FATAL_BGCOLOR 0x7800
void __attribute__((noreturn)) __fatal_error(const char *msg, const char *file, int line, const char *func) {
for (volatile uint32_t delay = 0; delay < 10000000; delay++) {
}
@ -18,7 +15,7 @@ void __attribute__((noreturn)) __fatal_error(const char *msg, const char *file,
display_print("\nFunc: ", -1); display_print(func, -1);
}
display_print("\n", 1);
display_print_out(FATAL_FGCOLOR, FATAL_BGCOLOR);
display_print_out(COLOR_WHITE, COLOR_RED128);
for (;;) {
display_backlight(255);
HAL_Delay(950);

View File

@ -18,7 +18,7 @@ void jump_to(uint32_t address);
// common helper macros
#define DPRINT(X) do { display_print(X, -1); display_print_out(0xFFFF, 0x0000); } while(0)
#define DPRINTLN(X) do { display_print(X "\n", -1); display_print_out(0xFFFF, 0x0000); } while(0)
#define DPRINT(X) do { display_print(X, -1); display_print_out(COLOR_WHITE, COLOR_BLACK); } while(0)
#define DPRINTLN(X) do { display_print(X "\n", -1); display_print_out(COLOR_WHITE, COLOR_BLACK); } while(0)
#endif