Commit graph

80 commits

Author SHA1 Message Date
Yishai Jaffe
8299817fba cfb: support non vtiled displays
Added support for drawing points on non-vtiled displays.

Signed-off-by: Yishai Jaffe <yishai1999@gmail.com>
2025-06-04 17:00:30 +02:00
Yishai Jaffe
b5c634f4bb cfb: fix get_glyph_byte for vtiled displays
V-Tiled displays need different treatment when getting the glyph byte.

Signed-off-by: Yishai Jaffe <yishai1999@gmail.com>
2025-04-18 12:36:16 +02:00
Yishai Jaffe
010d33c239 cfb: typo fixes
Fixed CFB_DISPLAY_HEIGH typo to CFB_DISPLAY_HEIGHT.
Fixed widht typo to width.
Fixed "cfb draw point" shell command's help message to "<x> <y>" instead
of "<x> <y0>".

Signed-off-by: Yishai Jaffe <yishai1999@gmail.com>
2025-04-02 10:30:50 +02:00
Yishai Jaffe
de9dd989f8 cfb: clear display on init correctly
If the display is MONO01 and invert=false or display is MONO10 and
invert=true the nthe special logic is needed.

Signed-off-by: Yishai Jaffe <yishai1999@gmail.com>
2025-04-02 10:30:50 +02:00
Yishai Jaffe
5119330549 cfb: support text draw for non-vtiled displays
Added support to draw text on non-vtiled displays

Signed-off-by: Yishai Jaffe <yishai1999@gmail.com>
2025-04-02 10:30:45 +02:00
TOKITA Hiroshi
04eba1d392 fb: cfb: Remove unused config
CHARACTER_FRAMEBUFFER_SHELL_DRIVER_NAME is not used.
Remove it.

Signed-off-by: TOKITA Hiroshi <tokita.hiroshi@gmail.com>
2025-02-13 12:14:52 +01:00
Oleh Kravchenko
ed15ff14d4 fb: cfb: Fix print of ASCII chars from 128 to 255
Change the "c" variable type from char to uint8_t in get_glyph_ptr() and
draw_char_vtmono() to fix issues with the range check of the "c" value.

The easiest way to print localized text with Zephyr is
to ask GCC for compile-time conversion:

  INCLUDE(${ZEPHYR_BASE}/cmake/cfb.cmake NO_POLICY_SCOPE)
    GENERATE_CFB_FONT_FOR_TARGET(app
    "${CMAKE_CURRENT_SOURCE_DIR}/fonts/koi8-u.png"
    "${ZEPHYR_BINARY_DIR}/include/generated/cfb_font_dice.h"
    8 16 --first 0 --last 255)

  TARGET_COMPILE_OPTIONS(app PRIVATE
    -finput-charset=UTF-8
    -fexec-charset=KOI8-U)

Signed-off-by: Oleh Kravchenko <oleg@kaa.org.ua>
2025-01-29 04:18:02 +01:00
Pieter De Gendt
39a49431c7 drivers: display: Place API into iterable section
Add wrapper DEVICE_API macro to all display_driver_api instances.

Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
2024-12-02 22:05:41 +00:00
Pisit Sawangvonganan
effe4bbf95 fb: cfb_shell: remove dev null check
Remove `dev` null check as `DEVICE_DT_GET` ensures compile-time
initialization.
Refer to commit 6eb371f (fb: initialize devices at compile time)

Signed-off-by: Pisit Sawangvonganan <pisit@ndrsolution.com>
2024-11-16 14:53:57 -05:00
Pisit Sawangvonganan
cff8b6092e fb: cfb_shell: use shell_strtol in cmd_set_kerning
Switch from using direct `strtol` calls to `shell_strtol`.
This change leverages the extensive error handling provided
by `shell_strtol`.

Signed-off-by: Pisit Sawangvonganan <pisit@ndrsolution.com>
2024-11-16 14:53:57 -05:00
Pisit Sawangvonganan
06e0b2d1d6 fb: cfb: remove unnecessary NULL check and NULL assignment
Since the `fb` pointer is always assigned to `char_fb`, there is no need
for a `NULL` check. Additionally, removed setting `fb->buf` to `NULL` in
`cfb_framebuffer_init` as it will be overwritten by subsequent operations.

Signed-off-by: Pisit Sawangvonganan <pisit@ndrsolution.com>
2024-11-16 14:53:57 -05:00
Pisit Sawangvonganan
b7fe2a0bf9 fb: cfb: avoid multiple strlen calls in draw_text
Added `len` to store the result of `strlen(str)` to avoid
multiple calls to `strlen` in the `for-loop`.

Signed-off-by: Pisit Sawangvonganan <pisit@ndrsolution.com>
2024-11-16 14:53:57 -05:00
Martin Stumpf
2e0687cfd2 generic: add frame_incomplete where missing
The newly introduced `frame_incomplete` flag of
`display_buffer_descriptor` needed to be added at several places to
avoid uninitialized memory.

Signed-off-by: Martin Stumpf <finomnis@gmail.com>
2024-11-16 13:35:17 -05:00
TOKITA Hiroshi
40629ac9f9 fb: cfb: Fix CID 394240
This is a simple deletion of unnecessary processing.

Signed-off-by: TOKITA Hiroshi <tokita.hiroshi@gmail.com>
2024-07-05 18:39:22 +02:00
TOKITA Hiroshi
83860c2dfd fb: cfb: Add framebuffer deinitialize function
Add the `cfb_framebuffer_deinit` function for deinitializing
the framebuffer.

Signed-off-by: TOKITA Hiroshi <tokita.hiroshi@gmail.com>
2024-06-28 07:21:47 -04:00
TOKITA Hiroshi
d542e75975 fb: cfb: Fix CFB_FONT_MSB_FIRST font rendering
I broke the rendering of the CFB_FONT_MSB_FIRST font in
the previously committed #53796.
I will correct the entire font rendering process to make it
easier to remove the restriction that the vertical size of
the font must be a multiple of 8.

Signed-off-by: TOKITA Hiroshi <tokita.hiroshi@gmail.com>
2024-06-28 07:21:47 -04:00
TOKITA Hiroshi
90ffecdf2b fb: cfb: Remove unused value
The `desc` value in cfb_framebuffer_clear is not used.
Removed it.

Signed-off-by: TOKITA Hiroshi <tokita.hiroshi@fujitsu.com>
2023-08-14 18:08:59 +00:00
TOKITA Hiroshi
4681e0e1a4 fb: cfb: Remove sanity check for unused value
Remove needless sanity check

Signed-off-by: TOKITA Hiroshi <tokita.hiroshi@fujitsu.com>
2023-08-14 18:08:59 +00:00
TOKITA Hiroshi
330acf53d1 fb: cfb: remove font existence check on initializing
The font existence is checked at the time of linking,
The check at initialization is no longer necessary.

Signed-off-by: TOKITA Hiroshi <tokita.hiroshi@fujitsu.com>
2023-08-14 18:08:12 +00:00
TOKITA Hiroshi
916b5ce799 fb: cfb: add font existence check at link time
Inject assert statement to linker script to check font existence.

Signed-off-by: TOKITA Hiroshi <tokita.hiroshi@fujitsu.com>
2023-08-14 18:08:12 +00:00
TOKITA Hiroshi
476a5f57fd fb: cfb_shell: correct invert command implementation
Fix the wrong calculation for inverting implemented by
commit 7068587505
("fb: cfb: support inverting with coordinates that do not align
 with the tile")

Remove the cfb_invert_area() calling.

Signed-off-by: TOKITA Hiroshi <tokita.hiroshi@gmail.com>
2023-05-26 09:49:25 -04:00
TOKITA Hiroshi
75904f0d19 fb: correct invert_area image calculation
Fix the wrong calculation for inverting implemented by
commit 7068587505
("fb: cfb: support inverting with coordinates that do not align
with the tile")

Fixed not enough consideration when the drawing area height
is eight lines or less.
Simplify to XOR calculation.

Signed-off-by: TOKITA Hiroshi <tokita.hiroshi@gmail.com>
2023-05-26 09:49:25 -04:00
TOKITA Hiroshi
92efbeeec6 fb: cfb_shell: Add draw rect command
Add the `draw rect` command to execute the `cfb_draw_rect()` API.

This command render rectangle.

Signed-off-by: TOKITA Hiroshi <tokita.hiroshi@fujitsu.com>
2023-05-26 09:48:56 -04:00
TOKITA Hiroshi
59a6092849 fb: cfb: Add cfb_draw_rect() API
Add cfb_draw_rect() API for rendering rectangle.

Signed-off-by: TOKITA Hiroshi <tokita.hiroshi@fujitsu.com>
2023-05-26 09:48:56 -04:00
TOKITA Hiroshi
182c55f69f fb: cfb_shell: Add draw line command
Add the `draw line` command to execute the `cfb_draw_line()` API.

This command render line.

Signed-off-by: TOKITA Hiroshi <tokita.hiroshi@fujitsu.com>
2023-05-26 09:48:56 -04:00
TOKITA Hiroshi
ea42b0dc9d fb: cfb: Add cfb_draw_line() API
Add cfb_draw_line() API for rendering line.

Signed-off-by: TOKITA Hiroshi <tokita.hiroshi@fujitsu.com>
2023-05-26 09:48:56 -04:00
TOKITA Hiroshi
39c8288bab fb: cfb_shell: Add draw point command
Add the `draw point` command to execute the `cfb_draw_point()` API.

This command render single dot.

Signed-off-by: TOKITA Hiroshi <tokita.hiroshi@fujitsu.com>
2023-05-26 09:48:56 -04:00
TOKITA Hiroshi
9def1258a0 fb: cfb: Add cfb_draw_point() API
Add cfb_draw_point() API for rendering dot.

Signed-off-by: TOKITA Hiroshi <tokita.hiroshi@fujitsu.com>
2023-05-26 09:48:56 -04:00
Kumar Gala
47cf00058e fb: cfb: Use TYPE_SECTION macros for cfb_fonts
Clean up cfb_fonts to utilize TYPE_SECTION macros for handling sections.

Signed-off-by: Kumar Gala <kumar.gala@intel.com>
2023-04-19 17:14:54 +02:00
Gerard Marull-Paretas
667eeb11fb shell: fix MISRA 5.7 violations on struct shell
MISRA Rule 5.7 requires uniqueness of tag identifiers. Shell is
frequently problematic because many code uses `const struct shell
*shell`. This causes CI noise every time one of these shell files is
edited, so let's update all of them with `const struct shell *sh`
instead.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2023-04-14 12:21:08 +02:00
TOKITA Hiroshi
47f14d6375 fb: cfb_shell: support area inverting
Extend the invert command to run cfb_invert_area when given four arguments.
Make a change to invert the screen immediately in case of run invert
without arguments.

Signed-off-by: TOKITA Hiroshi <tokita.hiroshi@fujitsu.com>
2023-04-06 18:52:40 +02:00
TOKITA Hiroshi
e2c946536e fb: cfb_shell: Add draw text command
Add the `draw text` command to execute the `cfb_draw_text()` API.

The command is similar to the `print` command. The difference is
`draw text` can render to coordinate that is not on tile boundaries.
The command is not run `cfb_framebuffer_clear()`,
So it allows rendering appendiceal with keeping already drawn image.

Signed-off-by: TOKITA Hiroshi <tokita.hiroshi@fujitsu.com>
2023-04-06 18:52:40 +02:00
TOKITA Hiroshi
7068587505 fb: cfb: support inverting with coordinates that do not align with the tile
Improve `cfb_invert_area()` able to invert even at a coordinate
not on tile boundaries.

Signed-off-by: TOKITA Hiroshi <tokita.hiroshi@fujitsu.com>
2023-04-06 18:52:40 +02:00
TOKITA Hiroshi
5634691d8c fb: cfb: Add cfb_draw_text() API
Add cfb_draw_text() API for rendering text.
It is similar to cfb_print(), the difference is cfb_draw_text() accepts
coordinate that is not on tile boundaries and don't wrap the line.

Signed-off-by: TOKITA Hiroshi <tokita.hiroshi@fujitsu.com>
2023-04-06 18:52:40 +02:00
TOKITA Hiroshi
ca5de12503 fb: cfb: support drawing to any coordinates
Implements dot-by-dot font rendering to make cfb_print() able to
draw text even at a coordinate that is not on tile boundaries.

Signed-off-by: TOKITA Hiroshi <tokita.hiroshi@fujitsu.com>
2023-04-06 18:52:40 +02:00
TOKITA Hiroshi
b4965d672b fb: cfb: add const modifier for argument of cfb_print
cfb_print does not modify either address and contents of
the pointer that is pointing drawing text.
Thus, it can add a const modifier.

Signed-off-by: TOKITA Hiroshi <tokita.hiroshi@fujitsu.com>
2023-04-06 18:52:40 +02:00
TOKITA Hiroshi
6663b558fa fb: cfb: Restore inverted framebuffer to make able to reuse
cfb_framebuffer_finalize() invert the framebuffer, and it still
leave as inverted after executing the function.

It restores the framebuffer at the end of the cfb_framebuffer_finalize()
for the continued drawing.

Signed-off-by: TOKITA Hiroshi <tokita.hiroshi@fujitsu.com>
2023-04-06 18:52:40 +02:00
Dölker Kim
3e5cca196c fb: cfb: fix cfb_framebuffer_clear() implementation
dev and clear_display parameter are unused and only
the framebuffer was cleared. A condition which calls
cfb_framebuffer_fanalize when clear_display is
true is implemented. Then not only the buffer,
but  buffer and display are cleared.

Signed-off-by: Dölker Kim <KDoelker@baumer.com>
2023-04-06 18:52:21 +02:00
Simon Frank
5d9db9dc65 fb: cfb: cfb_shell command to set font kerning
Using `struct shell *shell` would be more consistent but triggers CI
check on MISRA rule 5.7 "A Tag name shall be a unique identifier"

Signed-off-by: Simon Frank <simon.frank@lohmega.com>
2023-03-02 13:51:55 +01:00
Simon Frank
b50838c66f fb: cfb: add API to set font kerning
Font kerning was used but it was not possible to change it.
Also, font_idx was set to zero twice in init.

Signed-off-by: Simon Frank <simon.frank@lohmega.com>
2023-03-02 13:51:55 +01:00
TOKITA Hiroshi
cccfc8fc8f fb: cfb_shell: set pixel format as MONO10 or MONO01 on initializing
Set the display's pixel format to MONO10 or MONO01 that cfb supports
on cfb initializing.

Signed-off-by: TOKITA Hiroshi <tokita.hiroshi@fujitsu.com>
2023-02-24 09:26:30 +01:00
TOKITA Hiroshi
279c722edb fb: cfb_shell: turn off display_blanking at initializing
Turn off display_blanking to make it able to refresh on a device
even when blanking default off.

Signed-off-by: TOKITA Hiroshi <tokita.hiroshi@fujitsu.com>
2023-02-24 09:26:30 +01:00
Gerard Marull-Paretas
79e6b0e0f6 includes: prefer <zephyr/kernel.h> over <zephyr/zephyr.h>
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>
2022-09-05 16:31:47 +02:00
Gerard Marull-Paretas
b402ac7b82 fb: initialize devices at compile time
Initialize devices at compile time, allowing to constify device pointer.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-08-19 11:51:26 +02:00
Anas Nashif
01582f80b7 scripts: move gen_cfb_font_header.py to scripts/build
Move scripts needed by the build system and not designed to be run
individually or standalone into the build subfolder.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-07-12 10:03:45 +02:00
Gerard Marull-Paretas
5113c1418d subsystems: migrate includes to <zephyr/...>
In order to bring consistency in-tree, migrate all subsystems code to
the new prefix <zephyr/...>. Note that the conversion has been scripted,
refer to zephyrproject-rtos#45388 for more details.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-05-09 12:07:35 +02:00
Karol Duda
5878f55662 cfb: support for HPACKED fonts
The HPACKED fonts are already declared in header.
Extend drawing routine to allow HPACKED fonts
along with VPACKED fonts.

Signed-off-by: Karol Duda <karol.duda@grinn-global.com>
Signed-off-by: Maciej Zagrabski <maciej.zagrabski@grinn-global.com>
2022-04-06 09:49:00 -05:00
Maciej Zagrabski
ac71af1001 cfb: introduce invert area function
Allow user to invert part of a screen, as a part of rendering.

Signed-off-by: Maciej Zagrabski <maciej.zagrabski@grinn-global.com>
2022-03-31 11:58:29 -05:00
Maciej Zagrabski
2ae8e96573 cfb: deprecate use of specific error return values
Replace module specific return values with standard errno values.

Signed-off-by: Maciej Zagrabski <maciej.zagrabski@grinn-global.com>
2022-03-31 11:58:29 -05:00
Nazar Kazakov
f483b1bc4c everywhere: fix typos
Fix a lot of typos

Signed-off-by: Nazar Kazakov <nazar.kazakov.work@gmail.com>
2022-03-18 13:24:08 -04:00