Commit 2c22e067 authored by TOKITA Hiroshi's avatar TOKITA Hiroshi Committed by Fabio Baltieri
Browse files

samples: subsystem: display: cfb: Improve to using more CFB functions



Move X position and set  kerning to demonstrate the line wrapping
behavior of characters.

Signed-off-by: default avatarTOKITA Hiroshi <tokita.hiroshi@fujitsu.com>
parent 90ffecdf
Loading
Loading
Loading
Loading
+13 −5
Original line number Diff line number Diff line
@@ -12,6 +12,8 @@
int main(void)
{
	const struct device *dev;
	uint16_t x_res;
	uint16_t y_res;
	uint16_t rows;
	uint8_t ppt;
	uint8_t font_width;
@@ -39,6 +41,8 @@ int main(void)

	display_blanking_off(dev);

	x_res = cfb_get_display_parameter(dev, CFB_DISPLAY_WIDTH);
	y_res = cfb_get_display_parameter(dev, CFB_DISPLAY_HEIGH);
	rows = cfb_get_display_parameter(dev, CFB_DISPLAY_ROWS);
	ppt = cfb_get_display_parameter(dev, CFB_DISPLAY_PPT);

@@ -52,25 +56,29 @@ int main(void)
	}

	printf("x_res %d, y_res %d, ppt %d, rows %d, cols %d\n",
	       cfb_get_display_parameter(dev, CFB_DISPLAY_WIDTH),
	       cfb_get_display_parameter(dev, CFB_DISPLAY_HEIGH),
	       x_res,
	       y_res,
	       ppt,
	       rows,
	       cfb_get_display_parameter(dev, CFB_DISPLAY_COLS));

	cfb_framebuffer_invert(dev);

	cfb_set_kerning(dev, 3);

	while (1) {
		for (int i = 0; i < rows; i++) {
		for (int i = 0; i < MIN(x_res, y_res); i++) {
			cfb_framebuffer_clear(dev, false);
			if (cfb_print(dev,
				      "0123456789mMgj!\"§$%&/()=",
				      0, i * ppt)) {
				      i, i)) {
				printf("Failed to print a string\n");
				continue;
			}

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