Skip to content

Instantly share code, notes, and snippets.

@hollyhockberry
Created December 19, 2023 01:11
Show Gist options
  • Save hollyhockberry/6352d6fe393c4f17e249db8a8ed42c98 to your computer and use it in GitHub Desktop.
Save hollyhockberry/6352d6fe393c4f17e249db8a8ed42c98 to your computer and use it in GitHub Desktop.
回り込みサンプルその2
#include <M5Unified.h>
#include <Avatar.h>
using namespace m5avatar;
namespace {
M5Canvas asset;
// 回り込みするパーツのサンプル
class Test : public m5avatar::Drawable {
public:
void draw(M5Canvas *spi, BoundingRect rect, DrawContext *drawContext) override {
asset.pushSprite(spi, 90, 190);
}
};
// Face生成用に何も表示しないダミーパーツ
class Empty : public m5avatar::Drawable {
public:
void draw(M5Canvas *spi, BoundingRect rect, DrawContext *drawContext) override {}
};
Face face(
new Test(), new BoundingRect(148, 163),
new Empty(), new BoundingRect(93, 90),
new Empty(), new BoundingRect(96, 230),
new Empty(), new BoundingRect(67, 96),
new Empty(), new BoundingRect(72, 230));
Avatar avatar(&face);
}
void setup() {
M5.begin();
asset.setColorDepth(1);
asset.createSprite(60, 25);
asset.drawLine(0, 0, 59, 24, WHITE);
asset.drawLine(0, 24, 59, 0, WHITE);
asset.drawRect(0, 0, 60, 25, WHITE);
avatar.init();
}
void loop() {
}
; 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]
monitor_speed = 115200
monitor_filters = time, esp32_exception_decoder
lib_deps =
https://github.com/m5stack/M5GFX#develop
m5stack/M5Unified@^0.1.11
https://github.com/hollyhockberry/m5stack-avatar#nativeBuild
[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
-DM5GFX_BOARD=board_M5Dial
-DM5GFX_SCALE=1
[env:m5stack-core-esp32]
platform = espressif32
board = m5stack-core-esp32
framework = arduino
[env:m5stack-stamps3]
platform = espressif32
board = m5stack-stamps3
framework = arduino
build_flags =
-DSS=7 -DMOSI=6 -DMISO=5 -DSCK=4
-DARDUINO_USB_CDC_ON_BOOT
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment