1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-11-13 19:18:56 +00:00

unix: add raspi target

This commit is contained in:
Pavol Rusnak 2018-11-06 19:29:34 +01:00
parent 6ce1794248
commit b4894c3431
No known key found for this signature in database
GPG Key ID: 91F3B339B9A02A3D
4 changed files with 28 additions and 1 deletions

View File

@ -124,6 +124,9 @@ build_unix: res ## build unix port
build_unix_noui: res ## build unix port without UI support
$(SCONS) CFLAGS="$(CFLAGS)" $(UNIX_BUILD_DIR)/micropython $(UNIX_PORT_OPTS) TREZOR_EMULATOR_NOUI=1
build_unix_raspi: res ## build unix port for Raspberry Pi
$(SCONS) CFLAGS="$(CFLAGS)" $(UNIX_BUILD_DIR)/micropython $(UNIX_PORT_OPTS) TREZOR_EMULATOR_RASPI=1
build_cross: ## build mpy-cross port
$(MAKE) -C vendor/micropython/mpy-cross $(CROSS_PORT_OPTS)

View File

@ -104,6 +104,8 @@ SOURCE_MOD += [
]
if ARGUMENTS.get('TREZOR_EMULATOR_NOUI', 0):
CPPDEFINES_MOD += ['TREZOR_EMULATOR_NOUI']
if ARGUMENTS.get('TREZOR_EMULATOR_RASPI', 0):
CPPDEFINES_MOD += ['TREZOR_EMULATOR_RASPI']
# modtrezorutils
SOURCE_MOD += [

View File

@ -26,10 +26,17 @@
#if TREZOR_MODEL == T
#ifdef TREZOR_EMULATOR_RASPI
#define WINDOW_WIDTH 480
#define WINDOW_HEIGHT 320
#define TOUCH_OFFSET_X 110
#define TOUCH_OFFSET_Y 40
#else
#define WINDOW_WIDTH 400
#define WINDOW_HEIGHT 600
#define TOUCH_OFFSET_X 80
#define TOUCH_OFFSET_Y 110
#endif
#elif TREZOR_MODEL == 1
@ -92,7 +99,13 @@ void display_init(void)
ensure(secfalse, "SDL_Init error");
}
atexit(SDL_Quit);
SDL_Window *win = SDL_CreateWindow("TREZOR Emulator", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, WINDOW_WIDTH, WINDOW_HEIGHT, SDL_WINDOW_SHOWN);
SDL_Window *win = SDL_CreateWindow("TREZOR Emulator", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, WINDOW_WIDTH, WINDOW_HEIGHT,
#ifdef TREZOR_EMULATOR_RASPI
SDL_WINDOW_SHOWN | SDL_WINDOW_FULLSCREEN
#else
SDL_WINDOW_SHOWN
#endif
);
if (!win) {
printf("%s\n", SDL_GetError());
ensure(secfalse, "SDL_CreateWindow error");
@ -109,7 +122,11 @@ void display_init(void)
TEXTURE = SDL_CreateTexture(RENDERER, SDL_PIXELFORMAT_RGB565, SDL_TEXTUREACCESS_STREAMING, DISPLAY_RESX, DISPLAY_RESY);
SDL_SetTextureBlendMode(TEXTURE, SDL_BLENDMODE_BLEND);
// TODO: find better way how to embed/distribute background image
#ifdef TREZOR_EMULATOR_RASPI
BACKGROUND = IMG_LoadTexture(RENDERER, "../embed/unix/background_raspi.jpg");
#else
BACKGROUND = IMG_LoadTexture(RENDERER, "../embed/unix/background_" XSTR(TREZOR_MODEL) ".jpg");
#endif
if (BACKGROUND) {
SDL_SetTextureBlendMode(BACKGROUND, SDL_BLENDMODE_NONE);
sdl_touch_offset_x = TOUCH_OFFSET_X;
@ -120,8 +137,13 @@ void display_init(void)
sdl_touch_offset_y = EMULATOR_BORDER;
}
DISPLAY_BACKLIGHT = 0;
#ifdef TREZOR_EMULATOR_RASPI
DISPLAY_ORIENTATION = 270;
SDL_ShowCursor(SDL_DISABLE);
#else
DISPLAY_ORIENTATION = 0;
#endif
#endif
}
static void display_set_window(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1)

Binary file not shown.

After

Width:  |  Height:  |  Size: 27 KiB