diff --git a/examples/arduino/ESP32_TFT_eSPI/ESP32_TFT_eSPI.ino b/examples/arduino/ESP32_TFT_eSPI/ESP32_TFT_eSPI.ino deleted file mode 100644 index 4e777c19e..000000000 --- a/examples/arduino/ESP32_TFT_eSPI/ESP32_TFT_eSPI.ino +++ /dev/null @@ -1,119 +0,0 @@ -#include -#include - -TFT_eSPI tft = TFT_eSPI(); /* TFT instance */ -static lv_disp_buf_t disp_buf; -static lv_color_t buf[LV_HOR_RES_MAX * 10]; - -#if USE_LV_LOG != 0 -/* Serial debugging */ -void my_print(lv_log_level_t level, const char * file, uint32_t line, const char * dsc) -{ - - Serial.printf("%s@%d->%s\r\n", file, line, dsc); - Serial.flush(); -} -#endif - -/* Display flushing */ -void my_disp_flush(lv_disp_drv_t *disp, const lv_area_t *area, lv_color_t *color_p) -{ - uint32_t w = (area->x2 - area->x1 + 1); - uint32_t h = (area->y2 - area->y1 + 1); - - tft.startWrite(); - tft.setAddrWindow(area->x1, area->y1, w, h); - tft.pushColors(&color_p->full, w * h, true); - tft.endWrite(); - - lv_disp_flush_ready(disp); -} - -/*Read the touchpad*/ -bool my_touchpad_read(lv_indev_drv_t * indev_driver, lv_indev_data_t * data) -{ - uint16_t touchX, touchY; - - bool touched = tft.getTouch(&touchX, &touchY, 600); - - if(!touched) - { - data->state = LV_INDEV_STATE_REL; - return false; - } - else - { - data->state = LV_INDEV_STATE_PR; - } - - if(touchX>screenWidth || touchY > screenHeight) - { - Serial.println("Y or y outside of expected parameters.."); - Serial.print("y:"); - Serial.print(touchX); - Serial.print(" x:"); - Serial.print(touchY); - } - else - { - /*Set the coordinates*/ - data->point.x = touchX; - data->point.y = touchY; - - Serial.print("Data x"); - Serial.println(touchX); - - Serial.print("Data y"); - Serial.println(touchY); - - } - - return false; /*Return `false` because we are not buffering and no more data to read*/ -} - -void setup() -{ - Serial.begin(115200); /* prepare for possible serial debug */ - - lv_init(); - -#if USE_LV_LOG != 0 - lv_log_register_print_cb(my_print); /* register print function for debugging */ -#endif - - tft.begin(); /* TFT init */ - tft.setRotation(1); /* Landscape orientation */ - - uint16_t calData[5] = { 275, 3620, 264, 3532, 1 }; - tft.setTouch(calData); - - lv_disp_buf_init(&disp_buf, buf, NULL, LV_HOR_RES_MAX * 10); - - /*Initialize the display*/ - lv_disp_drv_t disp_drv; - lv_disp_drv_init(&disp_drv); - disp_drv.hor_res = 320; - disp_drv.ver_res = 240; - disp_drv.flush_cb = my_disp_flush; - disp_drv.buffer = &disp_buf; - lv_disp_drv_register(&disp_drv); - - /*Initialize the (dummy) input device driver*/ - lv_indev_drv_t indev_drv; - lv_indev_drv_init(&indev_drv); - indev_drv.type = LV_INDEV_TYPE_POINTER; - indev_drv.read_cb = my_touchpad_read; - lv_indev_drv_register(&indev_drv); - - /* Try an example from the lv_examples repository - * https://github.com/lvgl/lv_examples*/ - lv_ex_btn_1(); -} - - -void loop() -{ - - lv_task_handler(); /* let the GUI do its work */ - delay(5); -} diff --git a/examples/arduino/ESP32_TFT_eSPI/README.md b/examples/arduino/ESP32_TFT_eSPI/README.md deleted file mode 100644 index 10f583d42..000000000 --- a/examples/arduino/ESP32_TFT_eSPI/README.md +++ /dev/null @@ -1,44 +0,0 @@ -# Example for lv_arduino using a slider - -This example has the screen set to 320x480 (ILI9488), change this by altering the following lines in the main ino file: - -```C -int screenWidth = 480; -int screenHeight = 320; -``` - -## Backlight - -Change pin 32 to your preferred backlight pin using a PNP transistor (2N3906) or remove the following code and connect directly to +ve: - -```C - ledcSetup(10, 5000/*freq*/, 10 /*resolution*/); - ledcAttachPin(32, 10); - analogReadResolution(10); - ledcWrite(10,768); -``` - -## Theme selection - -Change the following to change the theme: - -```C - lv_theme_t * th = lv_theme_night_init(210, NULL); //Set a HUE value and a Font for the Night Theme - lv_theme_set_current(th); -``` - -## Calibration - -This is using the bodmer tft_espi driver for touch. To correctly set the calibration load the calibration sketch and replace the following with your values: - -```C -uint16_t calData[5] = { 275, 3620, 264, 3532, 1 }; -``` - -## Screen rotation - -Check the following if you need to alter your screen rotation: - -```C - tft.setRotation(3); -``` diff --git a/examples/arduino/README.md b/examples/arduino/README.md deleted file mode 100644 index c5938a664..000000000 --- a/examples/arduino/README.md +++ /dev/null @@ -1,37 +0,0 @@ -# LVGL Arduino examples - -LVGL can be installed via Arduino IDE Library Manager or as an .ZIP library. -It will install [lv_exmaples](https://github.com/lvgl/lv_examples) which contains a lot of examples and demos to try LVGL. - -## Example - -There are simple examples which use the [TFT_eSPI](https://github.com/Bodmer/TFT_eSPI) library as a TFT driver to simplify testing. -To get all this to work you have to setup TFT_eSPI to work with your TFT display type via editing the `User_Setup.h` file in TFT_eSPI library folder, or by selecting your own configurtion in the `User_Setup_Select.h` file in TFT_eSPI library folder. - -LVGL library has its own configuration file called `lv_conf.h`. When LVGL is installed to followings needs to be done to configure it: -1. Go to directory of the installed Arduno libraries -2. Go to `lvgl` and copy `lv_conf_template.h` as `lv_conf.h` next to the `src` folder. -3. Open `lv_conf.h` and change the first `#if 0` to `#if 1` -4. Set the resolution of your display in `LV_HOR_RES_MAX` and `LV_VER_RES_MAX` -5. Set the color depth of you display in `LV_COLOR_DEPTH` -6. Set `LV_TICK_CUSTOM 1` - -## Debugging - -In case of trouble there are debug informations inside LVGL. In the `ESP32_TFT_eSPI` example there is `my_print` method, which allow to send this debug informations to the serial interface. To enable this feature you have to edit `lv_conf.h` file and enable logging in section `log settings`: - -```c -/*Log settings*/ -#define USE_LV_LOG 1 /*Enable/disable the log module*/ -#if LV_USE_LOG -/* How important log should be added: - * LV_LOG_LEVEL_TRACE A lot of logs to give detailed information - * LV_LOG_LEVEL_INFO Log important events - * LV_LOG_LEVEL_WARN Log if something unwanted happened but didn't cause a problem - * LV_LOG_LEVEL_ERROR Only critical issue, when the system may fail - * LV_LOG_LEVEL_NONE Do not log anything - */ -# define LV_LOG_LEVEL LV_LOG_LEVEL_WARN -``` - -After enabling log module and setting LV_LOG_LEVEL accordingly the output log is sent to the `Serial` port @ 115200 Bd.