From 92a60a1e89084d575e7331f448acee50ecfab9ac Mon Sep 17 00:00:00 2001 From: CTCaer Date: Wed, 28 Aug 2019 02:20:48 +0300 Subject: [PATCH] nyx: Various fixes --- nyx/nyx_gui/frontend/gui.c | 42 ++++++++++++------------ nyx/nyx_gui/frontend/gui_emummc_tools.c | 5 +-- nyx/nyx_gui/input/touch.h | 4 +++ nyx/nyx_gui/libs/lvgl/lv_core/lv_indev.c | 7 ++-- nyx/nyx_gui/libs/lvgl/lv_misc/lv_task.h | 1 + 5 files changed, 34 insertions(+), 25 deletions(-) diff --git a/nyx/nyx_gui/frontend/gui.c b/nyx/nyx_gui/frontend/gui.c index 7bdf13e..64865f9 100644 --- a/nyx/nyx_gui/frontend/gui.c +++ b/nyx/nyx_gui/frontend/gui.c @@ -30,6 +30,7 @@ #include "../gfx/gfx.h" #include "../input/touch.h" #include "../libs/fatfs/ff.h" +#include "../mem/heap.h" #include "../mem/minerva.h" #include "../power/bq24193.h" #include "../power/max17050.h" @@ -172,41 +173,39 @@ static void _disp_fb_flush(int32_t x1, int32_t y1, int32_t x2, int32_t y2, const lv_flush_ready(); } -touch_event touchpad; +static touch_event touchpad; static bool _fts_touch_read(lv_indev_data_t *data) { touch_poll(&touchpad); + // Take a screenshot if 3 fingers. if (touchpad.fingers > 2) + { _save_fb_to_bmp(); + msleep(200); + } + + // Always set touch points. + data->point.x = touchpad.x; + data->point.y = touchpad.y; + // Decide touch enable. switch (touchpad.type & STMFTS_MASK_EVENT_ID) { case STMFTS_EV_MULTI_TOUCH_ENTER: case STMFTS_EV_MULTI_TOUCH_MOTION: data->state = LV_INDEV_STATE_PR; - data->point.x = touchpad.x; - data->point.y = touchpad.y; break; case STMFTS_EV_MULTI_TOUCH_LEAVE: data->state = LV_INDEV_STATE_REL; - data->point.x = touchpad.x; - data->point.y = touchpad.y; break; case STMFTS_EV_NO_EVENT: default: if (touchpad.touch) - { data->state = LV_INDEV_STATE_PR; - } else - { - data->point.x = touchpad.x; - data->point.y = touchpad.y; data->state = LV_INDEV_STATE_REL; - //return true; - } break; } @@ -925,7 +924,7 @@ void nyx_create_onoff_button(lv_theme_t *th, lv_obj_t *parent, lv_obj_t *btn, co lv_label_set_text(label_btn, btn_name); - lv_label_set_static_text(label_btnsw, "#00ffc9 OFF#"); + lv_label_set_static_text(label_btnsw, "#D0D0D0 OFF#"); lv_obj_align(label_btn, btn, LV_ALIGN_IN_LEFT_MID, LV_DPI / 4, 0); lv_obj_align(label_btnsw, btn, LV_ALIGN_IN_RIGHT_MID, -LV_DPI / 4, -LV_DPI / 10); @@ -1619,8 +1618,6 @@ static lv_res_t _create_window_home_launch(lv_obj_t *btn) bmp = bmp_to_lvimg_obj(icon_path); // Enable button. - ext = lv_obj_get_ext_attr(launch_ctxt[x]); - ext->idx = i; lv_obj_set_opa_scale(launch_ctxt[x], LV_OPA_COVER); // Default to switch logo if no icon found at all. @@ -1643,6 +1640,8 @@ static lv_res_t _create_window_home_launch(lv_obj_t *btn) lv_obj_align(img, NULL, LV_ALIGN_CENTER, 0, 0); // Set autoboot index. + ext = lv_obj_get_ext_attr(launch_ctxt[x]); + ext->idx = i; ext = lv_obj_get_ext_attr(btn); ext->idx = i; @@ -2046,7 +2045,7 @@ static void _nyx_main_menu(lv_theme_t * th) _create_status_bar(th); // Create tasks. - system_tasks.task.dram_periodic_comp = lv_task_create(minerva_periodic_training, 500, LV_TASK_PRIO_HIGHEST, NULL); + system_tasks.task.dram_periodic_comp = lv_task_create(minerva_periodic_training, EMC_PERIODIC_TRAIN_MS, LV_TASK_PRIO_HIGHEST, NULL); lv_task_ready(system_tasks.task.dram_periodic_comp); system_tasks.task.status_bar = lv_task_create(_update_status_bar, 5000, LV_TASK_PRIO_LOW, NULL); @@ -2103,11 +2102,11 @@ void nyx_load_and_run() // Initialize touch. touch_power_on(); - lv_indev_drv_t indev_drv; - lv_indev_drv_init(&indev_drv); - indev_drv.type = LV_INDEV_TYPE_POINTER; - indev_drv.read = _fts_touch_read; - lv_indev_drv_register(&indev_drv); + lv_indev_drv_t indev_drv_touch; + lv_indev_drv_init(&indev_drv_touch); + indev_drv_touch.type = LV_INDEV_TYPE_POINTER; + indev_drv_touch.read = _fts_touch_read; + lv_indev_drv_register(&indev_drv_touch); touchpad.touch = false; // Initialize temperature sensor. @@ -2118,6 +2117,7 @@ void nyx_load_and_run() lv_theme_t *th = lv_theme_hekate_init(167, NULL); lv_theme_set_current(th); + // Create main menu _nyx_main_menu(th); while (true) diff --git a/nyx/nyx_gui/frontend/gui_emummc_tools.c b/nyx/nyx_gui/frontend/gui_emummc_tools.c index a2d4eaf..599c0cb 100644 --- a/nyx/nyx_gui/frontend/gui_emummc_tools.c +++ b/nyx/nyx_gui/frontend/gui_emummc_tools.c @@ -178,7 +178,7 @@ static void _create_mbox_emummc_raw() u32 curr_part_size = *(u32 *)&mbr[0x0C + (0x10 * i)]; sector_start = *(u32 *)&mbr[0x08 + (0x10 * i)]; u8 type = mbr[0x04 + (0x10 * i)]; - if ((curr_part_size >= (storage.sec_cnt + 0x8000)) && sector_start && type != 0x83) //! TODO: For now it skips linux partitions. + if ((curr_part_size >= (storage.sec_cnt + 0xC000)) && sector_start && type != 0x83) //! TODO: For now it skips linux partitions. { part_idx = i; sector_start += 0x8000; @@ -823,7 +823,8 @@ static lv_res_t _create_change_emummc_window() if(!f_stat(path, NULL)) { - strcpy(&emummc_img->dirlist[file_based_idx * 256], &emummc_img->dirlist[emummc_idx * 256]); + char *tmp = &emummc_img->dirlist[emummc_idx * 256]; + memcpy(&emummc_img->dirlist[file_based_idx * 256], tmp, strlen(tmp) + 1); file_based_idx++; } emummc_idx++; diff --git a/nyx/nyx_gui/input/touch.h b/nyx/nyx_gui/input/touch.h index 2fdff35..7816a71 100644 --- a/nyx/nyx_gui/input/touch.h +++ b/nyx/nyx_gui/input/touch.h @@ -36,6 +36,7 @@ #define STMFTS_MS_MT_SENSE_ON 0x93 #define STMFTS_SS_HOVER_SENSE_OFF 0x94 #define STMFTS_SS_HOVER_SENSE_ON 0x95 +#define STMFTS_LP_TIMER_CALIB 0x97 #define STMFTS_MS_KEY_SENSE_OFF 0x9A #define STMFTS_MS_KEY_SENSE_ON 0x9B #define STMFTS_SYSTEM_RESET 0xA0 @@ -45,7 +46,10 @@ #define STMFTS_SS_CX_TUNING 0xA4 #define STMFTS_RELEASEINFO 0xAA #define STMFTS_WRITE_REG 0xB6 +#define STMFTS_NOISE_WRITE 0xC7 +#define STMFTS_NOISE_READ 0xC8 #define STMFTS_RW_FB_REG 0xD0 // read data +#define STMFTS_SAVE_CX_TUNING 0xFC #define STMFTS_UNK0 0xB8 //Request compensation #define STMFTS_UNK1 0xCF diff --git a/nyx/nyx_gui/libs/lvgl/lv_core/lv_indev.c b/nyx/nyx_gui/libs/lvgl/lv_core/lv_indev.c index d3ae93f..24cc798 100644 --- a/nyx/nyx_gui/libs/lvgl/lv_core/lv_indev.c +++ b/nyx/nyx_gui/libs/lvgl/lv_core/lv_indev.c @@ -143,8 +143,11 @@ void lv_indev_set_cursor(lv_indev_t * indev, lv_obj_t * cur_obj) if(indev->driver.type != LV_INDEV_TYPE_POINTER) return; indev->cursor = cur_obj; - lv_obj_set_parent(indev->cursor, lv_layer_sys()); - lv_obj_set_pos(indev->cursor, indev->proc.act_point.x, indev->proc.act_point.y); + if (indev->cursor) + { + lv_obj_set_parent(indev->cursor, lv_layer_sys()); + lv_obj_set_pos(indev->cursor, indev->proc.act_point.x, indev->proc.act_point.y); + } } #if USE_LV_GROUP diff --git a/nyx/nyx_gui/libs/lvgl/lv_misc/lv_task.h b/nyx/nyx_gui/libs/lvgl/lv_misc/lv_task.h index 51c1a77..aa6c903 100644 --- a/nyx/nyx_gui/libs/lvgl/lv_misc/lv_task.h +++ b/nyx/nyx_gui/libs/lvgl/lv_misc/lv_task.h @@ -36,6 +36,7 @@ extern "C" { /** * Possible priorities for lv_tasks */ +#define LV_TASK_ONESHOT 0 enum { LV_TASK_PRIO_OFF = 0,