first commit

This commit is contained in:
stuce-bot 2025-06-30 20:47:33 +02:00
commit 5893b00dd2
1669 changed files with 1982740 additions and 0 deletions

View file

@ -0,0 +1,114 @@
# Steps to run M5GFX on a PC. ( VisualStudioCode + PlatformIO + SDL2 environment. )
## Step 1. install Visual Studio Code and make PlatformIO ready for use.
https://docs.m5stack.com/ja/quick_start/m5unified/intro_vscode
---
## Step 2. PlatformIO to allow `platform = native` to be built.
https://docs.platformio.org/en/latest/platforms/native.html#installation
#### for Windows
follow the [MSYS2](https://www.msys2.org/) installation guide .
Run the following command on msys2 to install gcc and gdb .
``` msys2
pacman -S mingw-w64-ucrt-x86_64-gcc mingw-w64-ucrt-x86_64-gdb
```
Add the following paths to the `PATH` system environment variable:
```
C:\msys64\mingw64\bin
C:\msys64\ucrt64\bin
C:\msys64\usr\bin
```
#### for Linux
open the system terminal and run the following commands:
```
sudo apt update
sudo apt install build-essential
```
#### for macOS
open the system terminal and install Xcode Command Line Tools
```
xcode-select --install
```
---
## Step 3. Enable `SDL2` on PlatformIO.
#### for Windows
Go to the [SDL repository on github and obtain the release package (SDL2-devel-x.x.x-mingw.zip).](https://github.com/libsdl-org/SDL/releases)
Unzip the zip file and copy the following four files to `C:\msys64\ucrt64`
- share
- bin
- include
- lib
#### for Linux
open the system terminal and run the following commands:
```
sudo apt-get install libsdl2 libsdl2-dev
```
#### for macOS
Install `sdl2` using [Homebrew](https://brew.sh/).
```
brew install sdl2
```
---
## Step 4. Execute !
Open the `PlatformIO_SDL` folder containing this document in PlatformIO.
Click on the ![PlatformIO](img_pio.png) icon on the left side of the screen.
Click `PROJECT TASKS` -> `native` -> `General` -> `Upload`
※ If you are using arm processor, use `native_arm` instead of `native` (e.g. M1mac)
![execute](img_00.png)
※ The window may start up with the window hidden behind. Check the task tray.
---
## Step 5. Use debugger.
#### for macOS
If you want to use the debugger on a mac, lldb is available.
![setup lldb](img_01.png)
`EXPLORER` -> `.vscode` -> `launch.json` -> `Add Configuration...` -> `C/C++: (lldb) Launch`
![setup lldb](img_02.png)
Rewrite the `"program"` : `"${workspaceRoot}/.pio/build/native/program"`
(The `native` part should match the environment name in `PlatformIO`)
![setup lldb](img_03.png)
Pressing the `F5` key allows debugging execution.
---

Binary file not shown.

After

Width:  |  Height:  |  Size: 607 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 556 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 202 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 144 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 961 B

View file

@ -0,0 +1,66 @@
; PlatformIO Project Configuration File
;
; Build options: build flags, source filter
; Upload options: custom upload port, speed and extra flags
; Library options: dependencies, extra library storages
; Advanced options: extra scripting
;
; Please visit documentation for the other options and examples
; https://docs.platformio.org/page/projectconf.html
[platformio]
default_envs = native
[env]
lib_extra_dirs=../../../
[env:native]
platform = native
build_type = debug
build_flags = -O0 -xc++ -std=c++14 -lSDL2
-I"/usr/local/include/SDL2" ; for intel mac homebrew SDL2
-L"/usr/local/lib" ; for intel mac homebrew SDL2
-DM5GFX_SHOW_FRAME ; Display frame image.
-DM5GFX_BACK_COLOR=0x222222u ; Color outside the frame image
[env:native_arm]
platform = native
build_type = debug
build_flags = -O0 -xc++ -std=c++14 -lSDL2
-arch arm64 ; for arm mac
-I"${sysenv.HOMEBREW_PREFIX}/include/SDL2" ; for arm mac homebrew SDL2
-L"${sysenv.HOMEBREW_PREFIX}/lib" ; for arm mac homebrew SDL2
-DM5GFX_SHOW_FRAME ; Display frame image.
-DM5GFX_BACK_COLOR=0x222222u ; Color outside the frame image
[env:native_StickCPlus]
extends = native
platform = native
build_flags = ${env:native.build_flags}
-DM5GFX_SCALE=2
-DM5GFX_ROTATION=0
-DM5GFX_BOARD=board_M5StickCPlus
[env:native_Paper]
extends = native
platform = native
build_flags = ${env:native.build_flags}
-DM5GFX_ROTATION=0
-DM5GFX_BOARD=board_M5Paper
[esp32_base]
build_type = debug
platform = espressif32
board = esp32dev
upload_speed = 1500000
monitor_speed = 115200
monitor_filters = esp32_exception_decoder
[env:esp32_arduino]
extends = esp32_base
framework = arduino
[env:esp32_idf]
extends = esp32_base
framework = espidf

View file

@ -0,0 +1,25 @@
#include <M5GFX.h>
#if defined ( SDL_h_ )
void setup(void);
void loop(void);
__attribute__((weak))
int user_func(bool* running)
{
setup();
do
{
loop();
} while (*running);
return 0;
}
int main(int, char**)
{
// The second argument is effective for step execution with breakpoints.
// You can specify the time in milliseconds to perform slow execution that ensures screen updates.
return lgfx::Panel_sdl::main(user_func, 128);
}
#endif

View file

@ -0,0 +1,29 @@
#include <M5GFX.h>
static M5GFX gfx;
void setup(void)
{
gfx.init();
}
void loop(void)
{
gfx.fillCircle(rand()%gfx.width(), rand()%gfx.height(), 16, rand());
}
#if defined ( ESP_PLATFORM ) && !defined ( ARDUINO )
extern "C" {
int app_main(int, char**)
{
setup();
for (;;) {
loop();
}
return 0;
}
}
#endif