Dozingfiretruck пре 1 година
родитељ
комит
542e8cec29

+ 8 - 3
components/lvgl8/porting/lv_port_disp.c

@@ -58,10 +58,15 @@ void lv_port_disp_init(luat_lcd_conf_t* lcd_conf)
     lv_color_t* buf_2_1 = NULL;
     lv_color_t* buf_2_1 = NULL;
     lv_color_t* buf_2_2 = NULL;
     lv_color_t* buf_2_2 = NULL;
 
 
-    buf_2_1 = luat_heap_opt_malloc(LUAT_HEAP_SRAM,lcd_conf->w * 40 * sizeof(lv_color_t));
-    buf_2_2 = luat_heap_opt_malloc(LUAT_HEAP_SRAM,lcd_conf->w * 40 * sizeof(lv_color_t));
+    #define SIZE_IN_PX_CNT     (lcd_conf->w * 10)
+    #define DRAW_BUFFER_SIZE    SIZE_IN_PX_CNT * sizeof(lv_color_t)
 
 
-    lv_disp_draw_buf_init(&lv_disp_draw_buf, buf_2_1, buf_2_2, lcd_conf->w * 40);
+    buf_2_1 = luat_heap_opt_malloc(LUAT_HEAP_SRAM, DRAW_BUFFER_SIZE);
+    buf_2_2 = luat_heap_opt_malloc(LUAT_HEAP_SRAM, DRAW_BUFFER_SIZE);
+
+    lv_disp_draw_buf_init(&lv_disp_draw_buf, buf_2_1, buf_2_2, SIZE_IN_PX_CNT);
+
+    // lv_disp_draw_buf_init(&lv_disp_draw_buf, lcd_conf->buff, lcd_conf->buff1, lcd_conf->w * lcd_conf->h);
 
 
     /*-----------------------------------
     /*-----------------------------------
      * Register the display in LVGL
      * Register the display in LVGL

+ 93 - 83
components/lvgl8/porting/lv_port_indev.c

@@ -4,13 +4,12 @@
  */
  */
 
 
 /*Copy this file as "lv_port_indev.c" and set this value to "1" to enable content*/
 /*Copy this file as "lv_port_indev.c" and set this value to "1" to enable content*/
-#if 0
+#if 1
 
 
 /*********************
 /*********************
  *      INCLUDES
  *      INCLUDES
  *********************/
  *********************/
 #include "lv_port_indev.h"
 #include "lv_port_indev.h"
-#include "../../lvgl.h"
 
 
 /*********************
 /*********************
  *      DEFINES
  *      DEFINES
@@ -24,7 +23,7 @@
  *  STATIC PROTOTYPES
  *  STATIC PROTOTYPES
  **********************/
  **********************/
 
 
-static void touchpad_init(void);
+static void touchpad_init(luat_tp_config_t *luat_tp_config);
 static void touchpad_read(lv_indev_drv_t * indev_drv, lv_indev_data_t * data);
 static void touchpad_read(lv_indev_drv_t * indev_drv, lv_indev_data_t * data);
 static bool touchpad_is_pressed(void);
 static bool touchpad_is_pressed(void);
 static void touchpad_get_xy(lv_coord_t * x, lv_coord_t * y);
 static void touchpad_get_xy(lv_coord_t * x, lv_coord_t * y);
@@ -67,7 +66,7 @@ static lv_indev_state_t encoder_state;
  *   GLOBAL FUNCTIONS
  *   GLOBAL FUNCTIONS
  **********************/
  **********************/
 
 
-void lv_port_indev_init(void)
+void lv_port_indev_init(luat_tp_config_t *luat_tp_config)
 {
 {
     /**
     /**
      * Here you will find example implementation of input devices supported by LittelvGL:
      * Here you will find example implementation of input devices supported by LittelvGL:
@@ -88,87 +87,88 @@ void lv_port_indev_init(void)
      * -----------------*/
      * -----------------*/
 
 
     /*Initialize your touchpad if you have*/
     /*Initialize your touchpad if you have*/
-    touchpad_init();
+    touchpad_init(luat_tp_config);
 
 
     /*Register a touchpad input device*/
     /*Register a touchpad input device*/
     lv_indev_drv_init(&indev_drv);
     lv_indev_drv_init(&indev_drv);
+    indev_drv.user_data = luat_tp_config;
     indev_drv.type = LV_INDEV_TYPE_POINTER;
     indev_drv.type = LV_INDEV_TYPE_POINTER;
     indev_drv.read_cb = touchpad_read;
     indev_drv.read_cb = touchpad_read;
     indev_touchpad = lv_indev_drv_register(&indev_drv);
     indev_touchpad = lv_indev_drv_register(&indev_drv);
 
 
-    /*------------------
-     * Mouse
-     * -----------------*/
-
-    /*Initialize your mouse if you have*/
-    mouse_init();
-
-    /*Register a mouse input device*/
-    lv_indev_drv_init(&indev_drv);
-    indev_drv.type = LV_INDEV_TYPE_POINTER;
-    indev_drv.read_cb = mouse_read;
-    indev_mouse = lv_indev_drv_register(&indev_drv);
-
-    /*Set cursor. For simplicity set a HOME symbol now.*/
-    lv_obj_t * mouse_cursor = lv_img_create(lv_scr_act());
-    lv_img_set_src(mouse_cursor, LV_SYMBOL_HOME);
-    lv_indev_set_cursor(indev_mouse, mouse_cursor);
-
-    /*------------------
-     * Keypad
-     * -----------------*/
-
-    /*Initialize your keypad or keyboard if you have*/
-    keypad_init();
-
-    /*Register a keypad input device*/
-    lv_indev_drv_init(&indev_drv);
-    indev_drv.type = LV_INDEV_TYPE_KEYPAD;
-    indev_drv.read_cb = keypad_read;
-    indev_keypad = lv_indev_drv_register(&indev_drv);
-
-    /*Later you should create group(s) with `lv_group_t * group = lv_group_create()`,
-     *add objects to the group with `lv_group_add_obj(group, obj)`
-     *and assign this input device to group to navigate in it:
-     *`lv_indev_set_group(indev_keypad, group);`*/
-
-    /*------------------
-     * Encoder
-     * -----------------*/
-
-    /*Initialize your encoder if you have*/
-    encoder_init();
-
-    /*Register a encoder input device*/
-    lv_indev_drv_init(&indev_drv);
-    indev_drv.type = LV_INDEV_TYPE_ENCODER;
-    indev_drv.read_cb = encoder_read;
-    indev_encoder = lv_indev_drv_register(&indev_drv);
-
-    /*Later you should create group(s) with `lv_group_t * group = lv_group_create()`,
-     *add objects to the group with `lv_group_add_obj(group, obj)`
-     *and assign this input device to group to navigate in it:
-     *`lv_indev_set_group(indev_encoder, group);`*/
-
-    /*------------------
-     * Button
-     * -----------------*/
-
-    /*Initialize your button if you have*/
-    button_init();
-
-    /*Register a button input device*/
-    lv_indev_drv_init(&indev_drv);
-    indev_drv.type = LV_INDEV_TYPE_BUTTON;
-    indev_drv.read_cb = button_read;
-    indev_button = lv_indev_drv_register(&indev_drv);
-
-    /*Assign buttons to points on the screen*/
-    static const lv_point_t btn_points[2] = {
-        {10, 10},   /*Button 0 -> x:10; y:10*/
-        {40, 100},  /*Button 1 -> x:40; y:100*/
-    };
-    lv_indev_set_button_points(indev_button, btn_points);
+    // /*------------------
+    //  * Mouse
+    //  * -----------------*/
+
+    // /*Initialize your mouse if you have*/
+    // mouse_init();
+
+    // /*Register a mouse input device*/
+    // lv_indev_drv_init(&indev_drv);
+    // indev_drv.type = LV_INDEV_TYPE_POINTER;
+    // indev_drv.read_cb = mouse_read;
+    // indev_mouse = lv_indev_drv_register(&indev_drv);
+
+    // /*Set cursor. For simplicity set a HOME symbol now.*/
+    // lv_obj_t * mouse_cursor = lv_img_create(lv_scr_act());
+    // lv_img_set_src(mouse_cursor, LV_SYMBOL_HOME);
+    // lv_indev_set_cursor(indev_mouse, mouse_cursor);
+
+    // /*------------------
+    //  * Keypad
+    //  * -----------------*/
+
+    // /*Initialize your keypad or keyboard if you have*/
+    // keypad_init();
+
+    // /*Register a keypad input device*/
+    // lv_indev_drv_init(&indev_drv);
+    // indev_drv.type = LV_INDEV_TYPE_KEYPAD;
+    // indev_drv.read_cb = keypad_read;
+    // indev_keypad = lv_indev_drv_register(&indev_drv);
+
+    // /*Later you should create group(s) with `lv_group_t * group = lv_group_create()`,
+    //  *add objects to the group with `lv_group_add_obj(group, obj)`
+    //  *and assign this input device to group to navigate in it:
+    //  *`lv_indev_set_group(indev_keypad, group);`*/
+
+    // /*------------------
+    //  * Encoder
+    //  * -----------------*/
+
+    // /*Initialize your encoder if you have*/
+    // encoder_init();
+
+    // /*Register a encoder input device*/
+    // lv_indev_drv_init(&indev_drv);
+    // indev_drv.type = LV_INDEV_TYPE_ENCODER;
+    // indev_drv.read_cb = encoder_read;
+    // indev_encoder = lv_indev_drv_register(&indev_drv);
+
+    // /*Later you should create group(s) with `lv_group_t * group = lv_group_create()`,
+    //  *add objects to the group with `lv_group_add_obj(group, obj)`
+    //  *and assign this input device to group to navigate in it:
+    //  *`lv_indev_set_group(indev_encoder, group);`*/
+
+    // /*------------------
+    //  * Button
+    //  * -----------------*/
+
+    // /*Initialize your button if you have*/
+    // button_init();
+
+    // /*Register a button input device*/
+    // lv_indev_drv_init(&indev_drv);
+    // indev_drv.type = LV_INDEV_TYPE_BUTTON;
+    // indev_drv.read_cb = button_read;
+    // indev_button = lv_indev_drv_register(&indev_drv);
+
+    // /*Assign buttons to points on the screen*/
+    // static const lv_point_t btn_points[2] = {
+    //     {10, 10},   /*Button 0 -> x:10; y:10*/
+    //     {40, 100},  /*Button 1 -> x:40; y:100*/
+    // };
+    // lv_indev_set_button_points(indev_button, btn_points);
 }
 }
 
 
 /**********************
 /**********************
@@ -179,10 +179,19 @@ void lv_port_indev_init(void)
  * Touchpad
  * Touchpad
  * -----------------*/
  * -----------------*/
 
 
+static luat_tp_data_t lvgl_tp_data[LUAT_TP_TOUCH_MAX]={0};
+
+static int luat_tp_callback(luat_tp_config_t* luat_tp_config, luat_tp_data_t* luat_tp_data){
+    memcpy(lvgl_tp_data, luat_tp_data, sizeof(luat_tp_data_t)*LUAT_TP_TOUCH_MAX);
+    luat_tp_irq_enable(luat_tp_config, 1);
+    return 0;
+}
+
 /*Initialize your touchpad*/
 /*Initialize your touchpad*/
-static void touchpad_init(void)
+static void touchpad_init(luat_tp_config_t *luat_tp_config)
 {
 {
     /*Your code comes here*/
     /*Your code comes here*/
+    luat_tp_config->callback = luat_tp_callback;
 }
 }
 
 
 /*Will be called by the library to read the touchpad*/
 /*Will be called by the library to read the touchpad*/
@@ -209,7 +218,9 @@ static void touchpad_read(lv_indev_drv_t * indev_drv, lv_indev_data_t * data)
 static bool touchpad_is_pressed(void)
 static bool touchpad_is_pressed(void)
 {
 {
     /*Your code comes here*/
     /*Your code comes here*/
-
+    if (lvgl_tp_data[0].event == TP_EVENT_TYPE_DOWN || lvgl_tp_data[0].event == TP_EVENT_TYPE_MOVE){
+        return true;
+    }
     return false;
     return false;
 }
 }
 
 
@@ -217,9 +228,8 @@ static bool touchpad_is_pressed(void)
 static void touchpad_get_xy(lv_coord_t * x, lv_coord_t * y)
 static void touchpad_get_xy(lv_coord_t * x, lv_coord_t * y)
 {
 {
     /*Your code comes here*/
     /*Your code comes here*/
-
-    (*x) = 0;
-    (*y) = 0;
+    (*x) = lvgl_tp_data[0].x_coordinate;
+    (*y) = lvgl_tp_data[0].y_coordinate;
 }
 }
 
 
 /*------------------
 /*------------------

+ 8 - 3
components/lvgl8/porting/lv_port_indev.h

@@ -5,7 +5,7 @@
  */
  */
 
 
 /*Copy this file as "lv_port_indev.h" and set this value to "1" to enable content*/
 /*Copy this file as "lv_port_indev.h" and set this value to "1" to enable content*/
-#if 0
+#if 1
 
 
 #ifndef LV_PORT_INDEV_TEMPL_H
 #ifndef LV_PORT_INDEV_TEMPL_H
 #define LV_PORT_INDEV_TEMPL_H
 #define LV_PORT_INDEV_TEMPL_H
@@ -17,7 +17,12 @@ extern "C" {
 /*********************
 /*********************
  *      INCLUDES
  *      INCLUDES
  *********************/
  *********************/
-#include "lvgl/lvgl.h"
+#if defined(LV_LVGL_H_INCLUDE_SIMPLE)
+#include "lvgl.h"
+#else
+#include "../lvgl.h"
+#endif
+#include "luat_tp.h"
 
 
 /*********************
 /*********************
  *      DEFINES
  *      DEFINES
@@ -30,7 +35,7 @@ extern "C" {
 /**********************
 /**********************
  * GLOBAL PROTOTYPES
  * GLOBAL PROTOTYPES
  **********************/
  **********************/
-void lv_port_indev_init(void);
+void lv_port_indev_init(luat_tp_config_t *luat_tp_config);
 
 
 /**********************
 /**********************
  *      MACROS
  *      MACROS

+ 12 - 5
components/tp/luat_tp.c

@@ -18,19 +18,24 @@ void luat_tp_task_entry(void* param){
         uint8_t touch_num = luat_tp_config->opts->read(luat_tp_config,tp_data);
         uint8_t touch_num = luat_tp_config->opts->read(luat_tp_config,tp_data);
         if (touch_num){
         if (touch_num){
             if (luat_tp_config->callback == NULL){
             if (luat_tp_config->callback == NULL){
-                luat_gpio_irq_enable(luat_tp_config->pin_int, 1);
+                luat_tp_irq_enable(luat_tp_config, 1);
             }else{
             }else{
                 luat_tp_config->callback(luat_tp_config,tp_data);
                 luat_tp_config->callback(luat_tp_config,tp_data);
             }
             }
         }else{
         }else{
-            luat_gpio_irq_enable(luat_tp_config->pin_int, 1);
+            luat_tp_irq_enable(luat_tp_config, 1);
         }
         }
     }
     }
 }
 }
 
 
 int luat_tp_init(luat_tp_config_t* luat_tp_config){
 int luat_tp_init(luat_tp_config_t* luat_tp_config){
-    if (tp_task_handle == 0){
-        luat_rtos_task_create(&tp_task_handle, 4096, 10, "tp", luat_tp_task_entry, NULL, 10);
+    if (tp_task_handle == NULL){
+        int ret = luat_rtos_task_create(&tp_task_handle, 4096, 10, "tp", luat_tp_task_entry, NULL, 10);
+        if (ret){
+            tp_task_handle = NULL;
+            LLOGE("tp task create failed!");
+            return -1;
+        }
     }
     }
     if (luat_tp_config->opts->init){
     if (luat_tp_config->opts->init){
         return luat_tp_config->opts->init(luat_tp_config);
         return luat_tp_config->opts->init(luat_tp_config);
@@ -40,7 +45,9 @@ int luat_tp_init(luat_tp_config_t* luat_tp_config){
     }
     }
 }
 }
 
 
-
+int luat_tp_irq_enable(luat_tp_config_t* luat_tp_config, uint8_t enabled){
+    return luat_gpio_irq_enable(luat_tp_config->pin_int, enabled);
+}
 
 
 
 
 
 

+ 2 - 1
components/tp/luat_tp.h

@@ -24,6 +24,7 @@ typedef struct luat_touch_info{
             uint64_t x2y:1;
             uint64_t x2y:1;
             uint64_t stretch_rank:2;
             uint64_t stretch_rank:2;
             uint64_t :2;
             uint64_t :2;
+            uint64_t :8;
         };
         };
         uint64_t info;
         uint64_t info;
     };
     };
@@ -80,7 +81,7 @@ extern luat_tp_opts_t tp_config_gt911;
 
 
 int luat_tp_init(luat_tp_config_t* luat_tp_config);
 int luat_tp_init(luat_tp_config_t* luat_tp_config);
 
 
-
+int luat_tp_irq_enable(luat_tp_config_t* luat_tp_config, uint8_t enabled);
 
 
 
 
 
 

+ 2 - 1
components/tp/luat_tp_gt911.c

@@ -197,7 +197,8 @@ static int luat_tp_irq_cb(int pin, void *args){
     if (gt911_init_state == 0){
     if (gt911_init_state == 0){
         return -1;
         return -1;
     }
     }
-    luat_gpio_irq_enable(pin, 0);
+    luat_tp_config_t* luat_tp_config = (luat_tp_config_t*)args;
+    luat_tp_irq_enable(luat_tp_config, 0);
     luat_rtos_message_send(tp_task_handle, 1, args);
     luat_rtos_message_send(tp_task_handle, 1, args);
     return 0;
     return 0;
 }
 }