As of today <zephyr/zephyr.h> is 100% equivalent to <zephyr/kernel.h>. This patch proposes to then include <zephyr/kernel.h> instead of <zephyr/zephyr.h> since it is more clear that you are including the Kernel APIs and (probably) nothing else. <zephyr/zephyr.h> sounds like a catch-all header that may be confusing. Most applications need to include a bunch of other things to compile, e.g. driver headers or subsystem headers like BT, logging, etc. The idea of a catch-all header in Zephyr is probably not feasible anyway. Reason is that Zephyr is not a library, like it could be for example `libpython`. Zephyr provides many utilities nowadays: a kernel, drivers, subsystems, etc and things will likely grow. A catch-all header would be massive, difficult to keep up-to-date. It is also likely that an application will only build a small subset. Note that subsystem-level headers may use a catch-all approach to make things easier, though. NOTE: This patch is **NOT** removing the header, just removing its usage in-tree. I'd advocate for its deprecation (add a #warning on it), but I understand many people will have concerns. Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
78 lines
1.7 KiB
C
78 lines
1.7 KiB
C
/*
|
|
* Copyright (c) 2018 PHYTEC Messtechnik GmbH
|
|
*
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
*/
|
|
|
|
#include <zephyr/kernel.h>
|
|
#include <zephyr/device.h>
|
|
#include <zephyr/display/cfb.h>
|
|
#include <stdio.h>
|
|
|
|
void main(void)
|
|
{
|
|
const struct device *dev;
|
|
uint16_t rows;
|
|
uint8_t ppt;
|
|
uint8_t font_width;
|
|
uint8_t font_height;
|
|
|
|
dev = DEVICE_DT_GET(DT_CHOSEN(zephyr_display));
|
|
if (!device_is_ready(dev)) {
|
|
printf("Device %s not ready\n", dev->name);
|
|
return;
|
|
}
|
|
|
|
if (display_set_pixel_format(dev, PIXEL_FORMAT_MONO10) != 0) {
|
|
printf("Failed to set required pixel format\n");
|
|
return;
|
|
}
|
|
|
|
printf("Initialized %s\n", dev->name);
|
|
|
|
if (cfb_framebuffer_init(dev)) {
|
|
printf("Framebuffer initialization failed!\n");
|
|
return;
|
|
}
|
|
|
|
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);
|
|
|
|
for (int idx = 0; idx < 42; idx++) {
|
|
if (cfb_get_font_size(dev, idx, &font_width, &font_height)) {
|
|
break;
|
|
}
|
|
cfb_framebuffer_set_font(dev, idx);
|
|
printf("font width %d, font height %d\n",
|
|
font_width, font_height);
|
|
}
|
|
|
|
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),
|
|
ppt,
|
|
rows,
|
|
cfb_get_display_parameter(dev, CFB_DISPLAY_COLS));
|
|
|
|
while (1) {
|
|
for (int i = 0; i < rows; i++) {
|
|
cfb_framebuffer_clear(dev, false);
|
|
if (cfb_print(dev,
|
|
"0123456789mMgj!\"§$%&/()=",
|
|
0, i * ppt)) {
|
|
printf("Failed to print a string\n");
|
|
continue;
|
|
}
|
|
|
|
cfb_framebuffer_finalize(dev);
|
|
#if defined(CONFIG_ARCH_POSIX)
|
|
k_sleep(K_MSEC(100));
|
|
#endif
|
|
}
|
|
}
|
|
}
|