Show Cursor settings

This commit is contained in:
fvanroie 2020-11-12 19:48:19 +01:00
parent e10a3af21c
commit 5011e5c063
3 changed files with 33 additions and 44 deletions

View File

@ -411,10 +411,12 @@ bool IRAM_ATTR my_touchpad_read(lv_indev_drv_t * indev_driver, lv_indev_data_t *
// Serial.print(F(" / y: ")); // Serial.print(F(" / y: "));
// Serial.println(touchY); // Serial.println(touchY);
// } else { // } else {
/*Save the state and save the pressed coordinate*/ /*Save the state and save the pressed coordinate for cursor position */
data->state = touched ? LV_INDEV_STATE_PR : LV_INDEV_STATE_REL; data->state = touched ? LV_INDEV_STATE_PR : LV_INDEV_STATE_REL;
data->point.x = touchX; if(touched) {
data->point.y = touchY; data->point.x = touchX;
data->point.y = touchY;
}
/* Serial.print("Data x"); /* Serial.print("Data x");
Serial.println(touchX); Serial.println(touchX);
Serial.print("Data y"); Serial.print("Data y");
@ -594,49 +596,31 @@ void guiSetup()
indev_drv.type = LV_INDEV_TYPE_POINTER; indev_drv.type = LV_INDEV_TYPE_POINTER;
indev_drv.read_cb = my_touchpad_read; indev_drv.read_cb = my_touchpad_read;
lv_indev_t * mouse_indev = lv_indev_drv_register(&indev_drv); lv_indev_t * mouse_indev = lv_indev_drv_register(&indev_drv);
mouse_indev->driver.type = LV_INDEV_TYPE_POINTER;
/*Set a cursor for the mouse*/
if(guiShowPointer) { if(guiShowPointer) {
lv_obj_t * label = lv_label_create(lv_layer_sys(), NULL); // lv_obj_t * label = lv_label_create(lv_layer_sys(), NULL);
lv_label_set_text(label, "<"); // lv_label_set_text(label, "<");
lv_indev_set_cursor(mouse_indev, label); // connect the object to the driver // lv_indev_set_cursor(mouse_indev, label); // connect the object to the driver
/*Set a cursor for the mouse*/ Log.verbose(TAG_GUI, F("Initialize Cursor"));
// LV_IMG_DECLARE(mouse_cursor_icon); /*Declare the image file.*/ lv_obj_t * cursor;
// lv_obj_t * cursor_obj = lv_obj_t * mouse_layer = lv_disp_get_layer_sys(NULL); // default display
// lv_img_create(lv_disp_get_scr_act(NULL), NULL); /*Create an image object for the cursor */
// lv_img_set_src(cursor_obj, &mouse_cursor_icon); /*Set the image source*/
// lv_indev_set_cursor(mouse_indev, cursor_obj); /*Connect the image object to the driver*/
}
/* #if defined(ARDUINO_ARCH_ESP32)
lv_obj_t * cursor = lv_obj_create(lv_layer_sys(), NULL); // show on every page LV_IMG_DECLARE(mouse_cursor_icon); /*Declare the image file.*/
cursor = lv_img_create(mouse_layer, NULL); /*Create an image object for the cursor */
lv_img_set_src(cursor_obj, &mouse_cursor_icon); /*Set the image source*/
#else
cursor = lv_obj_create(mouse_layer, NULL); // show cursor object on every page
lv_obj_set_size(cursor, 9, 9); lv_obj_set_size(cursor, 9, 9);
static lv_style_t style_cursor; lv_obj_set_style_local_radius(cursor, LV_OBJ_PART_MAIN, LV_STATE_DEFAULT, LV_RADIUS_CIRCLE);
lv_style_copy(&style_cursor, &lv_style_pretty); lv_obj_set_style_local_bg_color(cursor, LV_OBJ_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_RED);
style_cursor.body.radius = LV_RADIUS_CIRCLE; lv_obj_set_style_local_bg_opa(cursor, LV_OBJ_PART_MAIN, LV_STATE_DEFAULT, LV_OPA_COVER);
style_cursor.body.main_color = LV_COLOR_RED; #endif
style_cursor.body.opa = LV_OPA_COVER; lv_indev_set_cursor(mouse_indev, cursor); /*Connect the image object to the driver*/
lv_obj_set_style(cursor, &style_cursor); }
// lv_obj_set_click(cursor, false);
lv_indev_set_cursor(mouse_indev, cursor); // connect the object to the driver
*/
/* Initialize mouse pointer */
/*// if(true) {
debugPrintln(PSTR("Initialize Cursor"));
lv_obj_t * cursor;
lv_obj_t * mouse_layer = lv_disp_get_layer_sys(NULL); // default display
// cursor = lv_obj_create(lv_scr_act(), NULL);
cursor = lv_obj_create(mouse_layer, NULL); // show on every page
lv_obj_set_size(cursor, 9, 9);
static lv_style_t style_round;
lv_style_copy(&style_round, &lv_style_plain);
style_round.body.radius = LV_RADIUS_CIRCLE;
style_round.body.main_color = LV_COLOR_RED;
style_round.body.opa = LV_OPA_COVER;
lv_obj_set_style(cursor, &style_round);
lv_obj_set_click(cursor, false); // don't click on the cursor
lv_indev_set_cursor(mouse_indev, cursor);
// }*/
} }
void IRAM_ATTR guiLoop() void IRAM_ATTR guiLoop()
@ -916,7 +900,7 @@ static void gui_screenshot_to_file(lv_disp_drv_t * disp, const lv_area_t * area,
my_flush_cb(disp, area, color_p); my_flush_cb(disp, area, color_p);
} }
/** Take Screenshot. /** Take Screenshot.
* *
* Flush buffer into a binary file. * Flush buffer into a binary file.
* *

View File

@ -911,6 +911,7 @@ void webHandleConfig()
#endif #endif
} else if(save == String(PSTR("gui"))) { } else if(save == String(PSTR("gui"))) {
settings[FPSTR(F_GUI_POINTER)] = webServer.hasArg(PSTR("pointer"));
guiSetConfig(settings.as<JsonObject>()); guiSetConfig(settings.as<JsonObject>());
} else if(save == String(PSTR("debug"))) { } else if(save == String(PSTR("debug"))) {
@ -1073,6 +1074,10 @@ void webHandleGuiConfig()
httpMessage += getOption(5, F("270 degrees - mirrored"), rotation == 5); httpMessage += getOption(5, F("270 degrees - mirrored"), rotation == 5);
httpMessage += F("</select></p>"); httpMessage += F("</select></p>");
httpMessage += F("<p><input id='pointer' name='pointer' type='checkbox' ");
if(settings[FPSTR(F_GUI_POINTER)].as<bool>()) httpMessage += F(" checked");
httpMessage += F("><b>Show Pointer</b>");
int8_t bcklpin = settings[FPSTR(F_GUI_BACKLIGHTPIN)].as<int8_t>(); int8_t bcklpin = settings[FPSTR(F_GUI_BACKLIGHTPIN)].as<int8_t>();
httpMessage += F("<p><b>Backlight Control</b> <select id='bcklpin' name='bcklpin'>"); httpMessage += F("<p><b>Backlight Control</b> <select id='bcklpin' name='bcklpin'>");
httpMessage += getOption(-1, F("None"), bcklpin == -1); httpMessage += getOption(-1, F("None"), bcklpin == -1);

View File

@ -1,5 +1,5 @@
#include "lvgl.h" #include "lvgl.h"
#if 0 #if defined(ARDUINO_ARCH_ESP32)
const uint8_t mouse_cursor_icon_map[] = { const uint8_t mouse_cursor_icon_map[] = {
#if LV_COLOR_DEPTH == 1 || LV_COLOR_DEPTH == 8 #if LV_COLOR_DEPTH == 1 || LV_COLOR_DEPTH == 8
/*Pixel format: Alpha 8 bit, Red: 3 bit, Green: 3 bit, Blue: 2 bit*/ /*Pixel format: Alpha 8 bit, Red: 3 bit, Green: 3 bit, Blue: 2 bit*/