gustavonihei commented on a change in pull request #591: URL: https://github.com/apache/incubator-nuttx-apps/pull/591#discussion_r596064267
########## File path: examples/lvgldemo/lcddev.c ########## @@ -0,0 +1,200 @@ +/**************************************************************************** + * apps/examples/lvgldemo/lcddev.c + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include "lcddev.h" + +#include <nuttx/config.h> +#include <nuttx/lcd/lcd_dev.h> + +#include <sys/ioctl.h> +#include <sys/mman.h> +#include <unistd.h> +#include <stdlib.h> +#include <stdio.h> +#include <fcntl.h> +#include <errno.h> + +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + +#ifndef LCDDEV_PATH +# define LCDDEV_PATH "/dev/lcd0" +#endif + +/**************************************************************************** + * Private Types + ****************************************************************************/ + +struct lcd_state_s +{ + int fd; + struct fb_videoinfo_s vinfo; + struct lcd_planeinfo_s pinfo; + bool rotated; +}; + +/**************************************************************************** + * Private Data + ****************************************************************************/ + +static struct lcd_state_s state; + +/**************************************************************************** + * Private Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: lcddev_flush + * + * Description: + * Flush a buffer to the marked area + * + * Input Parameters: + * x1 - Left coordinate + * y1 - Top coordinate + * x2 - Right coordinate + * y2 - Bottom coordinate + * color_p - A n array of colors + * + * Returned Value: + * None + * + ****************************************************************************/ + +static void lcddev_flush(struct _disp_drv_t *disp_drv, const lv_area_t *area, + lv_color_t *color_p) +{ + int ret; + struct lcddev_area_s lcd_area; + + lcd_area.row_start = area->y1; + lcd_area.row_end = area->y2; + lcd_area.col_start = area->x1; + lcd_area.col_end = area->x2; + + lcd_area.data = (uint8_t *)color_p; + + ret = ioctl(state.fd, LCDDEVIO_PUTAREA, + (unsigned long)((uintptr_t)&lcd_area)); + + if (ret < 0) + { + int errcode = errno; + + fprintf(stderr, "ERROR: ioctl(LCDDEVIO_PUTAREA) failed: %d\n", + errcode); + close(state.fd); + return; + } + + /* Tell the flushing is ready */ + + lv_disp_flush_ready(disp_drv); +} + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: lcddev_init + * + * Description: + * + * Input Parameters: + * lv_drvr -- lvgl driver interface Review comment: ```suggestion * lv_drvr -- LVGL driver interface ``` ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org