-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
18 changed files
with
321 additions
and
90 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
; 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=../../../ | ||
lib_deps = m5stack/M5Unified@^0.1.11 | ||
|
||
[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 | ||
-I"${sysenv.HOMEBREW_PREFIX}/include/SDL2" ; for arm mac homebrew SDL2 | ||
-L"${sysenv.HOMEBREW_PREFIX}/lib" ; for arm mac homebrew SDL2 | ||
|
||
[env:native_m5stack] | ||
extends = native | ||
platform = native | ||
build_flags = ${env:native.build_flags} | ||
-DM5GFX_BOARD=board_M5Stack | ||
|
||
[env:native_stickCPlus] | ||
extends = native | ||
platform = native | ||
build_flags = ${env:native.build_flags} | ||
-DM5GFX_SCALE=2 | ||
-DM5GFX_ROTATION=0 | ||
-DM5GFX_BOARD=board_M5StickCPlus | ||
|
||
[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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
#include <M5Unified.h> | ||
#include <Avatar.h> | ||
|
||
using namespace m5avatar; | ||
|
||
Avatar avatar; | ||
|
||
void setup() | ||
{ | ||
M5.begin(); | ||
avatar.init(); // start drawing | ||
|
||
// adjust position | ||
const auto r = avatar.getFace()->getBoundingRect(); | ||
const auto scale_w = M5.Display.width() / (float)r->getWidth(); | ||
const auto scale_h = M5.Display.height() / (float)r->getHeight(); | ||
const auto scale = std::min(scale_w, scale_h); | ||
avatar.setScale(scale); | ||
const auto offs_x = (r->getWidth() - M5.Display.width()) / 2; | ||
const auto offs_y = (r->getHeight() - M5.Display.height()) / 2; | ||
avatar.setPosition(-offs_y, -offs_x); | ||
} | ||
|
||
void loop() | ||
{ | ||
// avatar's face updates in another thread | ||
// so no need to loop-by-loop rendering | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.