first commit
This commit is contained in:
commit
e6a42e28e9
4355 changed files with 4626605 additions and 0 deletions
|
|
@ -0,0 +1,26 @@
|
|||
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")
|
||||
|
||||
include_directories(../../../LovyanGFX/src/)
|
||||
|
||||
file(GLOB MY_SOURCES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} CONFIGURE_DEPENDS
|
||||
*.cpp
|
||||
../../../LovyanGFX/src/lgfx/Fonts/efont/*.c
|
||||
../../../LovyanGFX/src/lgfx/Fonts/IPA/*.c
|
||||
../../../LovyanGFX/src/lgfx/utility/*.c
|
||||
../../../LovyanGFX/src/lgfx/v1/*.cpp
|
||||
../../../LovyanGFX/src/lgfx/v1/misc/*.cpp
|
||||
../../../LovyanGFX/src/lgfx/v1/panel/Panel_Device.cpp
|
||||
../../../LovyanGFX/src/lgfx/v1/panel/Panel_FrameBufferBase.cpp
|
||||
../../../LovyanGFX/src/lgfx/v1/platforms/sdl/*.cpp
|
||||
)
|
||||
set(SOURCES ${MY_SOURCES})
|
||||
|
||||
add_executable(index ${SOURCES} ${INCLUDES})
|
||||
|
||||
set(CMAKE_EXECUTABLE_SUFFIX ".html")
|
||||
target_link_libraries(index -lembind)
|
||||
set_target_properties(index PROPERTIES LINK_FLAGS "--shell-file ${PROJECT_SOURCE_DIR}/lgfx_wasm.html -s SINGLE_FILE=1")
|
||||
|
|
@ -0,0 +1,15 @@
|
|||
{
|
||||
"configurations": [
|
||||
{
|
||||
"name": "x64-Debug",
|
||||
"generator": "Ninja",
|
||||
"configurationType": "Debug",
|
||||
"inheritEnvironments": [ "clang_cl_x64_x64" ],
|
||||
"buildRoot": "${projectDir}\\out\\build\\${name}",
|
||||
"installRoot": "${projectDir}\\out\\install\\${name}",
|
||||
"cmakeCommandArgs": "",
|
||||
"buildCommandArgs": "",
|
||||
"ctestCommandArgs": ""
|
||||
}
|
||||
]
|
||||
}
|
||||
21
libraries/LovyanGFX/examples_for_PC/CMake_WASM/LGFX_WASM.cpp
Normal file
21
libraries/LovyanGFX/examples_for_PC/CMake_WASM/LGFX_WASM.cpp
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
#define LGFX_USE_V1
|
||||
#include <LovyanGFX.hpp>
|
||||
#include <LGFX_AUTODETECT.hpp>
|
||||
#include <emscripten.h>
|
||||
|
||||
void setup(void);
|
||||
void loop(void);
|
||||
|
||||
void loopThread(void *arg)
|
||||
{
|
||||
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);
|
||||
}
|
||||
17
libraries/LovyanGFX/examples_for_PC/CMake_WASM/README.md
Normal file
17
libraries/LovyanGFX/examples_for_PC/CMake_WASM/README.md
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
# WebAssembly port
|
||||
|
||||
# Step
|
||||
|
||||
## Install SDL
|
||||
|
||||
[follow this](https://wiki.libsdl.org/SDL2/Installation)
|
||||
|
||||
## Install Emscripten SDK
|
||||
[follow this](https://emscripten.org/docs/getting_started/downloads.html)
|
||||
|
||||
## Build and Run
|
||||
1. `mkdir build`
|
||||
2. `cd build`
|
||||
3. `emcmake cmake ..`
|
||||
4. `emmake make`
|
||||
5. open `index.html` in your browser.
|
||||
|
|
@ -0,0 +1,47 @@
|
|||
<html>
|
||||
<head>
|
||||
<meta name='viewport' content='width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0, shrink-to-fit=no'/>
|
||||
<style type="text/css">
|
||||
html, body {
|
||||
margin: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
min-width: 100%;
|
||||
min-height: 100%;
|
||||
}
|
||||
|
||||
body {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
#output {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<p id="output">
|
||||
<canvas id="canvas"></canvas>
|
||||
</p>
|
||||
<script>
|
||||
var canvas = document.getElementById('canvas');
|
||||
var Module = {
|
||||
print: function(text) {
|
||||
console.log("log: " + text);
|
||||
},
|
||||
printErr: function(text) {
|
||||
console.error(text);
|
||||
},
|
||||
canvas: (function() {
|
||||
return canvas;
|
||||
})(),
|
||||
};
|
||||
window.addEventListener("click", () => window.focus());
|
||||
</script>
|
||||
{{{ SCRIPT }}}
|
||||
</body>
|
||||
</html>
|
||||
89
libraries/LovyanGFX/examples_for_PC/CMake_WASM/user_code.cpp
Normal file
89
libraries/LovyanGFX/examples_for_PC/CMake_WASM/user_code.cpp
Normal file
|
|
@ -0,0 +1,89 @@
|
|||
|
||||
// If you write this, you can use drawBmpFile / drawJpgFile / drawPngFile
|
||||
// #include <stdio.h>
|
||||
|
||||
// If you write this, you can use drawBmpUrl / drawJpgUrl / drawPngUrl ( for Windows )
|
||||
// #include <windows.h>
|
||||
// #include <winhttp.h>
|
||||
// #pragma comment (lib, "winhttp.lib")
|
||||
|
||||
#define LGFX_USE_V1
|
||||
#include <LovyanGFX.hpp>
|
||||
#include <LGFX_AUTODETECT.hpp>
|
||||
|
||||
#include <emscripten.h>
|
||||
#include <emscripten/bind.h>
|
||||
|
||||
using namespace emscripten;
|
||||
|
||||
LGFX lcd(320, 240);
|
||||
|
||||
int32_t target_x = 160 * 256;
|
||||
int32_t target_y = 120 * 256;
|
||||
int32_t current_x = 0;
|
||||
int32_t current_y = 0;
|
||||
int32_t add_x = 0;
|
||||
int32_t add_y = 0;
|
||||
|
||||
void setup()
|
||||
{
|
||||
lcd.init();
|
||||
lcd.clear(TFT_PINK);
|
||||
lcd.setFont(&fonts::DejaVu24);
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
static int i;
|
||||
++i;
|
||||
lcd.fillCircle(current_x >> 8, current_y >> 8, 5, i);
|
||||
current_x += add_x;
|
||||
current_y += add_y;
|
||||
add_x += (current_x < target_x) ? 1 : -1;
|
||||
add_y += (current_y < target_y) ? 1 : -1;
|
||||
lgfx::touch_point_t new_tp;
|
||||
if (lcd.getTouch(&new_tp))
|
||||
{
|
||||
target_x = new_tp.x * 256;
|
||||
target_y = new_tp.y * 256;
|
||||
lcd.drawCircle(new_tp.x, new_tp.y, 5, TFT_WHITE);
|
||||
}
|
||||
lcd.drawCenterString("LGFX & WASM", 160, 100);
|
||||
lgfx::delay(5);
|
||||
}
|
||||
|
||||
/// exported funcitons
|
||||
void lgfx_clear(int color)
|
||||
{
|
||||
lcd.clear(color);
|
||||
}
|
||||
|
||||
void lgfx_drawString(const std::string &s, uint32_t x, uint32_t y)
|
||||
{
|
||||
lcd.drawString(s.c_str(), x, y);
|
||||
}
|
||||
|
||||
void lgfx_drawRect(int32_t x, int32_t y, int32_t w, int32_t h, int color)
|
||||
{
|
||||
lcd.drawRect(x, y, w, h, color);
|
||||
}
|
||||
|
||||
void lgfx_drawTriangle(int32_t x0, int32_t y0, int32_t x1, int32_t y1, int32_t x2, int32_t y2, int color)
|
||||
{
|
||||
lcd.drawTriangle(x0, y0, x1, y1, x2, y2, color);
|
||||
}
|
||||
|
||||
void lgfx_drawCircle(int32_t x, int32_t y, int32_t r, int color)
|
||||
{
|
||||
lcd.drawCircle(x, y, r, color);
|
||||
}
|
||||
|
||||
/// binding C++ functions to JavaScript
|
||||
EMSCRIPTEN_BINDINGS(lgfx_module)
|
||||
{
|
||||
function("clear", &lgfx_clear);
|
||||
function("drawString", &lgfx_drawString);
|
||||
function("drawRect", &lgfx_drawRect);
|
||||
function("drawTriangle", &lgfx_drawTriangle);
|
||||
function("drawCircle", &lgfx_drawCircle);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue