Skip to content

Commit

Permalink
samples: Added native posix board to cfb sample
Browse files Browse the repository at this point in the history
Added support for native posix board to character framebuffer sample.

Signed-off-by: Jan Van Winkel <[email protected]>
  • Loading branch information
vanwinkeljan authored and nashif committed Dec 11, 2018
1 parent 6cb629c commit eef1099
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 1 deletion.
1 change: 0 additions & 1 deletion samples/display/cfb/prj.conf
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ CONFIG_HEAP_MEM_POOL_SIZE=16384
CONFIG_DISPLAY=y

CONFIG_LOG=y
CONFIG_DISPLAY_LOG_LEVEL_DBG=y

CONFIG_CFB_LOG_LEVEL_DBG=y
CONFIG_CHARACTER_FRAMEBUFFER=y
11 changes: 11 additions & 0 deletions samples/display/cfb/prj_native_posix.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
CONFIG_HEAP_MEM_POOL_SIZE=16384

CONFIG_DISPLAY=y
CONFIG_SDL_DISPLAY_DEV_NAME="DISPLAY"
CONFIG_SDL_DISPLAY_X_RES=250
CONFIG_SDL_DISPLAY_Y_RES=120

CONFIG_LOG=y

CONFIG_CFB_LOG_LEVEL_DBG=y
CONFIG_CHARACTER_FRAMEBUFFER=y
14 changes: 14 additions & 0 deletions samples/display/cfb/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@
#define DISPLAY_DRIVER "SSD1306"
#endif

#ifndef DISPLAY_DRIVER
#define DISPLAY_DRIVER "DISPLAY"
#endif

void main(void)
{
struct device *dev;
Expand All @@ -33,6 +37,11 @@ void main(void)
return;
}

if (display_set_pixel_format(dev, PIXEL_FORMAT_MONO10) != 0) {
printf("Failed to set required pixel format\n");
return;
}

printf("initialized %s\n", DISPLAY_DRIVER);

if (cfb_framebuffer_init(dev)) {
Expand All @@ -43,6 +52,8 @@ void main(void)
api = dev->driver_api;
cfb_framebuffer_clear(dev, true);

display_blanking_off(dev);

rows = cfb_get_display_parameter(dev, CFB_DISPLAY_ROWS);
ppt = cfb_get_display_parameter(dev, CFB_DISPLAY_PPT);

Expand Down Expand Up @@ -73,6 +84,9 @@ void main(void)
}

cfb_framebuffer_finalize(dev);
#if defined(CONFIG_ARCH_POSIX)
k_sleep(100);
#endif
}
}
}

0 comments on commit eef1099

Please sign in to comment.