-
Notifications
You must be signed in to change notification settings - Fork 6.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
driver: SDL based display emulation driver
This driver introduces an emulated LCD display for the native POSIX board. The emulated display driver makes use of SDL2 to render the displays frame buffer into a dedicated desktop window. Signed-off-by: Jan Van Winkel <[email protected]>
- Loading branch information
1 parent
1d3e0ea
commit 384c4c7
Showing
12 changed files
with
521 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
/* | ||
* Copyright (c) 2018 Jan Van Winkel <[email protected]> | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
#include <SDL.h> | ||
#include "posix_board_if.h" | ||
#include "posix_trace.h" | ||
#include "posix_arch_internal.h" | ||
#include "soc.h" | ||
#include "hw_models_top.h" | ||
|
||
u64_t sdl_event_timer; | ||
|
||
static void sdl_handle_window_event(const SDL_Event *event) | ||
{ | ||
SDL_Window *window; | ||
SDL_Renderer *renderer; | ||
|
||
switch (event->window.event) { | ||
case SDL_WINDOWEVENT_EXPOSED: | ||
|
||
window = SDL_GetWindowFromID(event->window.windowID); | ||
if (window == NULL) { | ||
return; | ||
} | ||
|
||
renderer = SDL_GetRenderer(window); | ||
if (renderer == NULL) { | ||
return; | ||
} | ||
SDL_RenderPresent(renderer); | ||
break; | ||
default: | ||
break; | ||
} | ||
} | ||
|
||
void sdl_handle_events(void) | ||
{ | ||
SDL_Event event; | ||
|
||
sdl_event_timer = hwm_get_time() + 10000; | ||
|
||
while (SDL_PollEvent(&event)) { | ||
switch (event.type) { | ||
case SDL_WINDOWEVENT: | ||
sdl_handle_window_event(&event); | ||
break; | ||
case SDL_QUIT: | ||
posix_exit(0); | ||
break; | ||
default: | ||
break; | ||
} | ||
} | ||
|
||
} | ||
|
||
static void sdl_init(void) | ||
{ | ||
if (SDL_Init(SDL_INIT_VIDEO) != 0) { | ||
posix_print_error_and_exit("Error on SDL_Init (%s)\n", | ||
SDL_GetError()); | ||
} | ||
} | ||
|
||
static void sdl_cleanup(void) | ||
{ | ||
SDL_Quit(); | ||
} | ||
|
||
NATIVE_TASK(sdl_init, PRE_BOOT_2, 1); | ||
NATIVE_TASK(sdl_cleanup, ON_EXIT, 2); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
/* | ||
* Copyright (c) 2018 Jan Van Winkel <[email protected]> | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
#ifndef ZEPHYR_BOARD_POSIX_NATIVE_POSIX_SDL_EVENTS_H | ||
#define ZEPHYR_BOARD_POSIX_NATIVE_POSIX_SDL_EVENTS_H | ||
|
||
#include <zephyr/types.h> | ||
|
||
void sdl_handle_events(void); | ||
|
||
#endif /* ZEPHYR_BOARD_POSIX_NATIVE_POSIX_SDL_EVENTS_H */ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
# Kconfig - SDL based emulated display configuration options | ||
|
||
# | ||
# Copyright (c) 2018 Jan Van Winkel <[email protected]> | ||
# | ||
# SPDX-License-Identifier: Apache-2.0 | ||
# | ||
|
||
menuconfig SDL_DISPLAY | ||
bool "SDL based emulated display" | ||
depends on BOARD_NATIVE_POSIX | ||
select HAS_SDL | ||
help | ||
Enable SDL based emulated display compliant with display driver API. | ||
|
||
if SDL_DISPLAY | ||
|
||
config SDL_DISPLAY_DEV_NAME | ||
string "SDL display device name" | ||
default "SDL_DISPLAY" | ||
|
||
config SDL_DISPLAY_X_RES | ||
int "X resolution for SDL display" | ||
default 320 | ||
|
||
config SDL_DISPLAY_Y_RES | ||
int "Y resolution for SDL display" | ||
default 240 | ||
|
||
endif #SDL_DISPLAY |
Oops, something went wrong.