Replace nested MIN/MAX macro calls with the min3/max3 APIs which are
safer (evaluate arguments only once) and cleaner.
Assisted-by: Gemini:gemini-3.1-pro
Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
The changes introduced in #67881 not support fonts whose heights are
not integer multiples of 8.
This commit removes the old restriction.
Signed-off-by: TOKITA Hiroshi <tokita.hiroshi@gmail.com>
Correcting the HPACKED glyph addressing used by the CFB renderer.
HPACKED font data stores 8 horizontal pixels per byte,
so glyph stride must be based on the rounded-up byte width and
bit extraction must use the glyph x coordinate.
Also make generated tofu glyph bytes follow the selected font packing,
so missing glyph rendering uses the same layout as normal glyph data.
Signed-off-by: TOKITA Hiroshi <tokita.hiroshi@gmail.com>
Characters not present in the font were replaced with a space character.
This is changed to draw **tofu** instead.
Signed-off-by: TOKITA Hiroshi <tokita.hiroshi@gmail.com>
Change the arguments of `cfb_invert_area`, `cfb_print`, and
`cfb_draw_(point|line|rect|circle)`, which used unsigned integers to
specify coordinates to signed integers.
This is because coordinate are usually specify with real numbers,
so it is difficult to use unless negative numbers are accepted.
We clip drawings outside the drawable area on the implementation side.
Accordingly, we will update the API version to 0.10.0.
Signed-off-by: TOKITA Hiroshi <tokita.hiroshi@gmail.com>
Fix draw_char_htmono() to compute byte offsets with row-based
HTILED addressing and keep g_y controlled by the outer loop.
This avoids row-skips and broken rendering near clipping boundaries.
Signed-off-by: TOKITA Hiroshi <tokita.hiroshi@gmail.com>
Fix cfb_framebuffer_finalize() to invert the software framebuffer
only when pixel format polarity and cfb inversion state differ.
This restores the expected behavior for MONO01/MONO10 finalize output.
Signed-off-by: TOKITA Hiroshi <tokita.hiroshi@gmail.com>
Handle both VTILED and HTILED framebuffer layouts in cfb_invert_area().
Also update the basic cfb test helper to read pixels correctly for
HTILED buffers.
Signed-off-by: TOKITA Hiroshi <tokita.hiroshi@gmail.com>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>