diff --git a/Platformio/hardware/windows_linux/keypad_gui/keypad_gui.cpp b/Platformio/hardware/windows_linux/keypad_gui/keypad_gui.cpp index 3625b032..2c3f044a 100644 --- a/Platformio/hardware/windows_linux/keypad_gui/keypad_gui.cpp +++ b/Platformio/hardware/windows_linux/keypad_gui/keypad_gui.cpp @@ -2,7 +2,6 @@ #include #include -#include "../util_hal_windows_linux.h" #include "key_map.h" @@ -19,7 +18,7 @@ uint32_t KEY_HOLD_TIME = 500; // Keys are considered held after 500 ms // The state to track a single key since the GUI is mouse based ActiveKey activeKey = {' ', 0, GUI_KEY_IDLE}; guiKeyStates lastGUIKeyState = GUI_KEY_IDLE; -long long holdTimer; +Uint64 holdTimer; // https://wrfranklin.org/Research/Short_Notes/pnpoly.html int pnpoly(int nvert, float *vertx, float *verty, float testx, float testy) @@ -81,7 +80,7 @@ int event_filter(void *userdata, SDL_Event * event) { activeKey.key = key.key; activeKey.state = event->type == SDL_MOUSEBUTTONDOWN ? GUI_KEY_PRESSED : GUI_KEY_RELEASED; activeKey.keyCode = key.id; - holdTimer = SDL_MOUSEBUTTONDOWN ? current_timestamp_hal_windowsLinux() : 0; + holdTimer = SDL_MOUSEBUTTONDOWN ? SDL_GetTicks64() : 0; break; } } @@ -168,7 +167,7 @@ KeyState pumpKeys() { lastGUIKeyState = activeKey.state; // If the key has been pressed long enough to be considered held, change the state - if (activeKey.state == GUI_KEY_PRESSED && (current_timestamp_hal_windowsLinux() - holdTimer) > KEY_HOLD_TIME) { + if (activeKey.state == GUI_KEY_PRESSED && (SDL_GetTicks64() - holdTimer) > KEY_HOLD_TIME) { activeKey.state = GUI_KEY_HOLD; } diff --git a/Platformio/hardware/windows_linux/lvgl_hal_windows_linux.cpp b/Platformio/hardware/windows_linux/lvgl_hal_windows_linux.cpp index 37064005..ff4f2cc3 100644 --- a/Platformio/hardware/windows_linux/lvgl_hal_windows_linux.cpp +++ b/Platformio/hardware/windows_linux/lvgl_hal_windows_linux.cpp @@ -1,10 +1,10 @@ #include +#include #include #include #include "sdl/sdl.h" #include "SDL2/SDL_events.h" -#include "util_hal_windows_linux.h" #include "keypad_gui/keypad_gui.h" /** @@ -14,16 +14,14 @@ */ static int tick_thread(void * data) { - (void)data; - - long long lastTimestamp = current_timestamp_hal_windowsLinux(); - long long newTimestamp = 0; + Uint64 lastTimestamp = SDL_GetTicks64(); + Uint64 newTimestamp = 0; while(1) { // we don't use this blackbox // SDL_Delay(5); /*Sleep for 5 millisecond*/ // lv_tick_inc(5); /*Tell lvgl that 5 milliseconds were elapsed*/ - - newTimestamp = current_timestamp_hal_windowsLinux(); + + newTimestamp = SDL_GetTicks64(); if ((newTimestamp - lastTimestamp) > 5) { lv_tick_inc(newTimestamp - lastTimestamp); lastTimestamp = newTimestamp; diff --git a/Platformio/hardware/windows_linux/util_hal_windows_linux.cpp b/Platformio/hardware/windows_linux/util_hal_windows_linux.cpp deleted file mode 100644 index dc04f3f5..00000000 --- a/Platformio/hardware/windows_linux/util_hal_windows_linux.cpp +++ /dev/null @@ -1,10 +0,0 @@ -#include -#include - -long long current_timestamp_hal_windowsLinux() { - struct timeval te; - gettimeofday(&te, NULL); // get current time - long long milliseconds = te.tv_sec*1000LL + te.tv_usec/1000; // calculate milliseconds - // printf("milliseconds: %lld\r\n", milliseconds); - return milliseconds; -} \ No newline at end of file diff --git a/Platformio/hardware/windows_linux/util_hal_windows_linux.h b/Platformio/hardware/windows_linux/util_hal_windows_linux.h deleted file mode 100644 index 009095eb..00000000 --- a/Platformio/hardware/windows_linux/util_hal_windows_linux.h +++ /dev/null @@ -1 +0,0 @@ -long long current_timestamp_hal_windowsLinux(); \ No newline at end of file