From 53e52cf3a8dfd2d28b10da1685037c9f65c6fc99 Mon Sep 17 00:00:00 2001 From: Michael Haberler Date: Fri, 10 Nov 2023 09:17:14 +0100 Subject: [PATCH 1/4] make the CMake_WASM example work again --- examples_for_PC/CMake_WASM/CMakeLists.txt | 2 +- examples_for_PC/CMake_WASM/LGFX_WASM.cpp | 9 ++++----- examples_for_PC/CMake_WASM/README.md | 15 +++++++++++++++ 3 files changed, 20 insertions(+), 6 deletions(-) diff --git a/examples_for_PC/CMake_WASM/CMakeLists.txt b/examples_for_PC/CMake_WASM/CMakeLists.txt index c189b433..702a9991 100644 --- a/examples_for_PC/CMake_WASM/CMakeLists.txt +++ b/examples_for_PC/CMake_WASM/CMakeLists.txt @@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.12) project (lv_wasm) add_definitions(-DLGFX_SDL) -set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O2 -s USE_SDL=2") +set(CMAKE_CXX_FLAGS " ${CMAKE_CXX_FLAGS} -g -s USE_SDL=2") include_directories(../../../LovyanGFX/src/) diff --git a/examples_for_PC/CMake_WASM/LGFX_WASM.cpp b/examples_for_PC/CMake_WASM/LGFX_WASM.cpp index ed6c041a..804a9307 100644 --- a/examples_for_PC/CMake_WASM/LGFX_WASM.cpp +++ b/examples_for_PC/CMake_WASM/LGFX_WASM.cpp @@ -6,16 +6,15 @@ void setup(void); void loop(void); -void loopThread(void *arg) +void loopThread(void) { + lgfx::Panel_sdl::loop(); loop(); - lgfx::Panel_sdl::sdl_event_handler(); } -int monitor_hor_res, monitor_ver_res; - int main(int argc, char **argv) { setup(); - emscripten_set_main_loop_arg(loopThread, NULL, -1, true); + lgfx::Panel_sdl::setup(); + emscripten_set_main_loop(loopThread, -1, true); } diff --git a/examples_for_PC/CMake_WASM/README.md b/examples_for_PC/CMake_WASM/README.md index 7826996d..4386f8c3 100644 --- a/examples_for_PC/CMake_WASM/README.md +++ b/examples_for_PC/CMake_WASM/README.md @@ -14,4 +14,19 @@ 2. `cd build` 3. `emcmake cmake ..` 4. `emmake make` +5. `http-server` 5. open `index.html` in your browser. + +## Notes +this is a debug build: `set(CMAKE_CXX_FLAGS " ${CMAKE_CXX_FLAGS} -g -s USE_SDL=2")` +It uses the SDL2 library bundled with the Emscripten SDK so I think the `Install SDL`` +is not necessary + +### Debugging +I followed the [Debugging WebAssembly with modern tools](https://developer.chrome.com/blog/wasm-debugging-2020/) tutorial and was able to debug at the C source level just fine + + +Steps: +1. Install Chrome Canary +2. Install the C/C++ DevTools Support (DWARF) as outline +3. serve `index.html` via `http-server` - opening file//wherever/index.html breaks debugging From ed37d35c54983b061f00ec781e0a3929c9beab66 Mon Sep 17 00:00:00 2001 From: tobozo Date: Fri, 10 Nov 2023 13:21:09 +0000 Subject: [PATCH 2/4] build+publish wasm example to github-pages followup for #470 --- .github/workflows/SDLBuild.yml | 47 +++++++++++++++++++++++++++++++++- 1 file changed, 46 insertions(+), 1 deletion(-) diff --git a/.github/workflows/SDLBuild.yml b/.github/workflows/SDLBuild.yml index 1b920915..9f82e084 100644 --- a/.github/workflows/SDLBuild.yml +++ b/.github/workflows/SDLBuild.yml @@ -3,6 +3,7 @@ name: SDLBuild env: PROJECT_DIR: examples_for_PC/CMake_SDL + WASM_DIR: examples_for_PC/CMake_WASM on: @@ -20,6 +21,17 @@ on: workflow_dispatch: +permissions: + contents: write + pages: write + id-token: write + +# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued. +# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete. +concurrency: + group: "pages" + cancel-in-progress: false + jobs: LGFX_SDL2: @@ -68,7 +80,6 @@ jobs: cmake --build build/release --config Release - - name: Build LGFX_SDL2 for Linux if: ${{ matrix.os == 'ubuntu-latest' }} run: | @@ -81,6 +92,28 @@ jobs: cmake .. cmake --build . + - name: Build LGFX_SDL2/WASM for Linux + if: ${{ matrix.os == 'ubuntu-latest' }} + run: | + git clone https://github.com/emscripten-core/emsdk.git + cd emsdk + ./emsdk install latest # any specific version? + ./emsdk activate latest + source ./emsdk_env.sh + cd .. + cd ${{env.WASM_DIR}} + mkdir build + cd build + emcmake cmake .. + emmake make + mkdir -p www/WASM + cp index.html www/WASM/index.html + + - name: Upload WASM artifact + if: ${{ matrix.os == 'ubuntu-latest' }} + uses: actions/upload-pages-artifact@v2 + with: + path: ${{env.WASM_DIR}}/build/www - name: Build LGFX_SDL2 for Mac @@ -94,3 +127,15 @@ jobs: cmake .. cmake --build . + + deploy: + name: Deploy WASM Example 🚀 + environment: + name: github-pages + url: ${{ steps.deployment.outputs.page_url }} + runs-on: ubuntu-latest + needs: LGFX_SDL2 + steps: + - name: Deploy to GitHub Pages + id: deployment + uses: actions/deploy-pages@v2 From 3c1e6bd047cd21a80cf675e29f53abc3d20dec1c Mon Sep 17 00:00:00 2001 From: tobozo Date: Fri, 10 Nov 2023 13:50:00 +0000 Subject: [PATCH 3/4] publish to github page only from master --- .github/workflows/SDLBuild.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/SDLBuild.yml b/.github/workflows/SDLBuild.yml index 9f82e084..86e80faf 100644 --- a/.github/workflows/SDLBuild.yml +++ b/.github/workflows/SDLBuild.yml @@ -130,6 +130,7 @@ jobs: deploy: name: Deploy WASM Example 🚀 + if: github.ref == 'refs/heads/master' environment: name: github-pages url: ${{ steps.deployment.outputs.page_url }} From 044230abbb26168051ae9a129c9610719b19bcbb Mon Sep 17 00:00:00 2001 From: Dominic Date: Sun, 12 Nov 2023 09:06:31 -0500 Subject: [PATCH 4/4] Sunton ESP32-8048S050 config --- src/lgfx_user/LGFX_Sunton_ESP32-8048S050.h | 111 +++++++++++++++++++++ 1 file changed, 111 insertions(+) create mode 100644 src/lgfx_user/LGFX_Sunton_ESP32-8048S050.h diff --git a/src/lgfx_user/LGFX_Sunton_ESP32-8048S050.h b/src/lgfx_user/LGFX_Sunton_ESP32-8048S050.h new file mode 100644 index 00000000..8567383a --- /dev/null +++ b/src/lgfx_user/LGFX_Sunton_ESP32-8048S050.h @@ -0,0 +1,111 @@ + +#define LGFX_USE_V1 +#include + +#include +#include + +#include + +class LGFX : public lgfx::LGFX_Device +{ +public: + + lgfx::Bus_RGB _bus_instance; + lgfx::Panel_RGB _panel_instance; + lgfx::Light_PWM _light_instance; + lgfx::Touch_GT911 _touch_instance; + + LGFX(void) + { + { + auto cfg = _panel_instance.config(); + + cfg.memory_width = 800; + cfg.memory_height = 480; + cfg.panel_width = 800; + cfg.panel_height = 480; + + cfg.offset_x = 0; + cfg.offset_y = 0; + + _panel_instance.config(cfg); + } + + { + auto cfg = _panel_instance.config_detail(); + + cfg.use_psram = 1; + + _panel_instance.config_detail(cfg); + } + + { + auto cfg = _bus_instance.config(); + cfg.panel = &_panel_instance; + cfg.pin_d0 = GPIO_NUM_8; // B0 + cfg.pin_d1 = GPIO_NUM_3; // B1 + cfg.pin_d2 = GPIO_NUM_46; // B2 + cfg.pin_d3 = GPIO_NUM_9; // B3 + cfg.pin_d4 = GPIO_NUM_1; // B4 + cfg.pin_d5 = GPIO_NUM_5; // G0 + cfg.pin_d6 = GPIO_NUM_6; // G1 + cfg.pin_d7 = GPIO_NUM_7; // G2 + cfg.pin_d8 = GPIO_NUM_15; // G3 + cfg.pin_d9 = GPIO_NUM_16; // G4 + cfg.pin_d10 = GPIO_NUM_4; // G5 + cfg.pin_d11 = GPIO_NUM_45; // R0 + cfg.pin_d12 = GPIO_NUM_48; // R1 + cfg.pin_d13 = GPIO_NUM_47; // R2 + cfg.pin_d14 = GPIO_NUM_21; // R3 + cfg.pin_d15 = GPIO_NUM_14; // R4 + + cfg.pin_henable = GPIO_NUM_40; + cfg.pin_vsync = GPIO_NUM_41; + cfg.pin_hsync = GPIO_NUM_39; + cfg.pin_pclk = GPIO_NUM_42; + cfg.freq_write = 16000000; + + cfg.hsync_polarity = 0; + cfg.hsync_front_porch = 8; + cfg.hsync_pulse_width = 4; + cfg.hsync_back_porch = 8; + cfg.vsync_polarity = 0; + cfg.vsync_front_porch = 8; + cfg.vsync_pulse_width = 4; + cfg.vsync_back_porch = 8; + cfg.pclk_idle_high = 1; + _bus_instance.config(cfg); + } + _panel_instance.setBus(&_bus_instance); + + { + auto cfg = _light_instance.config(); + cfg.pin_bl = GPIO_NUM_2; + _light_instance.config(cfg); + } + _panel_instance.light(&_light_instance); + + { + auto cfg = _touch_instance.config(); + cfg.x_min = 0; + cfg.x_max = 800; + cfg.y_min = 0; + cfg.y_max = 480; + cfg.pin_int = GPIO_NUM_NC; + cfg.bus_shared = false; + cfg.offset_rotation = 0; + // I2C接続 + cfg.i2c_port = I2C_NUM_1; + cfg.pin_sda = GPIO_NUM_19; + cfg.pin_scl = GPIO_NUM_20; + cfg.pin_rst = GPIO_NUM_38; + cfg.freq = 400000; + cfg.i2c_addr = 0x14; // 0x5D , 0x14 + _touch_instance.config(cfg); + _panel_instance.setTouch(&_touch_instance); + } + + setPanel(&_panel_instance); + } +};