Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions subsys/fb/cfb.c
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,9 @@ static int draw_text(const struct device *dev, const char *const str, int16_t x,
}

if ((fb->screen_info & SCREEN_INFO_MONO_VTILED)) {
for (size_t i = 0; i < strlen(str); i++) {
const size_t len = strlen(str);

for (size_t i = 0; i < len; i++) {
if ((x + fptr->width > fb->x_res) && wrap) {
x = 0U;
y += fptr->height;
Expand Down Expand Up @@ -434,7 +436,7 @@ int cfb_framebuffer_clear(const struct device *dev, bool clear_display)
{
const struct char_framebuffer *fb = &char_fb;

if (!fb || !fb->buf) {
if (!fb->buf) {
return -ENODEV;
}

Expand Down Expand Up @@ -463,7 +465,7 @@ int cfb_framebuffer_finalize(const struct device *dev)
struct display_buffer_descriptor desc;
int err;

if (!fb || !fb->buf) {
if (!fb->buf) {
return -ENODEV;
}

Expand Down Expand Up @@ -572,7 +574,6 @@ int cfb_framebuffer_init(const struct device *dev)
fb->ppt = 8U;
fb->pixel_format = cfg.current_pixel_format;
fb->screen_info = cfg.screen_info;
fb->buf = NULL;
fb->kerning = 0;
fb->inverted = false;

Expand Down
108 changes: 3 additions & 105 deletions subsys/fb/cfb_shell.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,6 @@ static int cmd_clear(const struct shell *sh, size_t argc, char *argv[])
ARG_UNUSED(argc);
ARG_UNUSED(argv);

if (!dev) {
shell_error(sh, HELP_INIT);
return -ENODEV;
}

err = cfb_framebuffer_clear(dev, true);
if (err) {
shell_error(sh, "Framebuffer clear error=%d", err);
Expand All @@ -62,11 +57,6 @@ static int cmd_cfb_print(const struct shell *sh, int col, int row, char *str)
int err;
uint8_t ppt;

if (!dev) {
shell_error(sh, HELP_INIT);
return -ENODEV;
}

ppt = cfb_get_display_parameter(dev, CFB_DISPLAY_PPT);

err = cfb_framebuffer_clear(dev, false);
Expand Down Expand Up @@ -97,11 +87,6 @@ static int cmd_print(const struct shell *sh, size_t argc, char *argv[])
int err;
int col, row;

if (!dev) {
shell_error(sh, HELP_INIT);
return -ENODEV;
}

col = strtol(argv[1], NULL, 10);
if (col > cfb_get_display_parameter(dev, CFB_DISPLAY_COLS)) {
shell_error(sh, "Invalid col=%d position", col);
Expand All @@ -128,11 +113,6 @@ static int cmd_draw_text(const struct shell *sh, size_t argc, char *argv[])
int err;
int x, y;

if (!dev) {
shell_error(sh, HELP_INIT);
return -ENODEV;
}

x = strtol(argv[1], NULL, 10);
y = strtol(argv[2], NULL, 10);
err = cfb_draw_text(dev, argv[3], x, y);
Expand All @@ -151,11 +131,6 @@ static int cmd_draw_point(const struct shell *sh, size_t argc, char *argv[])
int err;
struct cfb_position pos;

if (!dev) {
shell_error(sh, HELP_INIT);
return -ENODEV;
}

pos.x = strtol(argv[1], NULL, 10);
pos.y = strtol(argv[2], NULL, 10);

Expand All @@ -175,11 +150,6 @@ static int cmd_draw_line(const struct shell *sh, size_t argc, char *argv[])
int err;
struct cfb_position start, end;

if (!dev) {
shell_error(sh, HELP_INIT);
return -ENODEV;
}

start.x = strtol(argv[1], NULL, 10);
start.y = strtol(argv[2], NULL, 10);
end.x = strtol(argv[3], NULL, 10);
Expand All @@ -201,11 +171,6 @@ static int cmd_draw_rect(const struct shell *sh, size_t argc, char *argv[])
int err;
struct cfb_position start, end;

if (!dev) {
shell_error(sh, HELP_INIT);
return -ENODEV;
}

start.x = strtol(argv[1], NULL, 10);
start.y = strtol(argv[2], NULL, 10);
end.x = strtol(argv[3], NULL, 10);
Expand All @@ -228,11 +193,6 @@ static int cmd_scroll_vert(const struct shell *sh, size_t argc, char *argv[])
int col, row;
int boundary;

if (!dev) {
shell_error(sh, HELP_INIT);
return -ENODEV;
}

col = strtol(argv[1], NULL, 10);
if (col > cfb_get_display_parameter(dev, CFB_DISPLAY_COLS)) {
shell_error(sh, "Invalid col=%d position", col);
Expand Down Expand Up @@ -269,11 +229,6 @@ static int cmd_scroll_horz(const struct shell *sh, size_t argc, char *argv[])
int col, row;
int boundary;

if (!dev) {
shell_error(sh, HELP_INIT);
return -ENODEV;
}

col = strtol(argv[1], NULL, 10);
if (col > cfb_get_display_parameter(dev, CFB_DISPLAY_COLS)) {
shell_error(sh, "Invalid col=%d position", col);
Expand Down Expand Up @@ -312,11 +267,6 @@ static int cmd_set_font(const struct shell *sh, size_t argc, char *argv[])
uint8_t height;
uint8_t width;

if (!dev) {
shell_error(sh, HELP_INIT);
return -ENODEV;
}

idx = strtol(argv[1], NULL, 10);

err = cfb_get_font_size(dev, idx, &width, &height);
Expand All @@ -340,18 +290,11 @@ static int cmd_set_font(const struct shell *sh, size_t argc, char *argv[])

static int cmd_set_kerning(const struct shell *sh, size_t argc, char *argv[])
{
int err;
char *ep = NULL;
int err = 0;
long kerning;

if (!dev) {
shell_error(sh, HELP_INIT);
return -ENODEV;
}

errno = 0;
kerning = strtol(argv[1], &ep, 10);
if (errno || ep == argv[1]) {
kerning = shell_strtol(argv[1], 10, &err);
if (err) {
shell_error(sh, HELP_INIT);
return -EINVAL;
}
Expand All @@ -369,11 +312,6 @@ static int cmd_invert(const struct shell *sh, size_t argc, char *argv[])
{
int err;

if (!dev) {
shell_error(sh, HELP_INIT);
return -ENODEV;
}

if (argc == 1) {
err = cfb_framebuffer_invert(dev);
if (err) {
Expand Down Expand Up @@ -414,11 +352,6 @@ static int cmd_get_fonts(const struct shell *sh, size_t argc, char *argv[])
ARG_UNUSED(argc);
ARG_UNUSED(argv);

if (!dev) {
shell_error(sh, HELP_INIT);
return -ENODEV;
}

for (int idx = 0; idx < cfb_get_numof_fonts(dev); idx++) {
if (cfb_get_font_size(dev, idx, &font_width, &font_height)) {
break;
Expand All @@ -437,11 +370,6 @@ static int cmd_get_device(const struct shell *sh, size_t argc, char *argv[])
ARG_UNUSED(argc);
ARG_UNUSED(argv);

if (!dev) {
shell_error(sh, HELP_INIT);
return -ENODEV;
}

shell_print(sh, "Framebuffer Device: %s", dev->name);

return err;
Expand All @@ -453,11 +381,6 @@ static int cmd_get_param_all(const struct shell *sh, size_t argc,
ARG_UNUSED(argc);
ARG_UNUSED(argv);

if (!dev) {
shell_error(sh, HELP_INIT);
return -ENODEV;
}

for (unsigned int i = 0; i <= CFB_DISPLAY_COLS; i++) {
shell_print(sh, "param: %s=%d", param_name[i],
cfb_get_display_parameter(dev, i));
Expand All @@ -473,11 +396,6 @@ static int cmd_get_param_height(const struct shell *sh, size_t argc,
ARG_UNUSED(argc);
ARG_UNUSED(argv);

if (!dev) {
shell_error(sh, HELP_INIT);
return -ENODEV;
}

shell_print(sh, "param: %s=%d", param_name[CFB_DISPLAY_HEIGH],
cfb_get_display_parameter(dev, CFB_DISPLAY_HEIGH));

Expand All @@ -490,11 +408,6 @@ static int cmd_get_param_width(const struct shell *sh, size_t argc,
ARG_UNUSED(argc);
ARG_UNUSED(argv);

if (!dev) {
shell_error(sh, HELP_INIT);
return -ENODEV;
}

shell_print(sh, "param: %s=%d", param_name[CFB_DISPLAY_WIDTH],
cfb_get_display_parameter(dev, CFB_DISPLAY_WIDTH));

Expand All @@ -507,11 +420,6 @@ static int cmd_get_param_ppt(const struct shell *sh, size_t argc,
ARG_UNUSED(argc);
ARG_UNUSED(argv);

if (!dev) {
shell_error(sh, HELP_INIT);
return -ENODEV;
}

shell_print(sh, "param: %s=%d", param_name[CFB_DISPLAY_PPT],
cfb_get_display_parameter(dev, CFB_DISPLAY_PPT));

Expand All @@ -524,11 +432,6 @@ static int cmd_get_param_rows(const struct shell *sh, size_t argc,
ARG_UNUSED(argc);
ARG_UNUSED(argv);

if (!dev) {
shell_error(sh, HELP_INIT);
return -ENODEV;
}

shell_print(sh, "param: %s=%d", param_name[CFB_DISPLAY_ROWS],
cfb_get_display_parameter(dev, CFB_DISPLAY_ROWS));

Expand All @@ -541,11 +444,6 @@ static int cmd_get_param_cols(const struct shell *sh, size_t argc,
ARG_UNUSED(argc);
ARG_UNUSED(argv);

if (!dev) {
shell_error(sh, HELP_INIT);
return -ENODEV;
}

shell_print(sh, "param: %s=%d", param_name[CFB_DISPLAY_COLS],
cfb_get_display_parameter(dev, CFB_DISPLAY_COLS));

Expand Down
Loading