Created
June 2, 2024 14:13
-
-
Save mongonta0716/5cf64a29ed5f082ccceb9c71ec587d00 to your computer and use it in GitHub Desktop.
M5Unifed で CoreS3の液晶下部に仮想ボタンA,B,Cを配置する。(他のM5Coreとソースは共通)
This file contains hidden or 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
#include <Arduino.h> | |
#include <M5Unified.h> | |
#include <gob_unifiedButton.hpp> | |
goblib::UnifiedButton unifiedButton; // gob_unifiedButton instance | |
void setup() { | |
auto cfg = M5.config(); | |
M5.begin(cfg); | |
M5.Display.setTextSize(3); | |
unifiedButton.begin(&M5.Display, goblib::UnifiedButton::transparent_bottom); // 画面下部にボタンA,B,Cが配置される。 | |
unifiedButton.setFont(&fonts::Font4); | |
switch(M5.getBoard()) { | |
case m5::board_t::board_M5StackCoreS3: | |
M5.Display.println("Hello I'm M5Stack CoreS3"); | |
break; | |
case m5::board_t::board_M5StackCoreS3SE: | |
M5.Display.println("Hello I'm M5Stack CoreS3 SE"); | |
break; | |
case m5::board_t::board_M5StackCore2: | |
M5.Display.println("Hello I'm M5Stack Core2"); | |
break; | |
default: | |
break; | |
} | |
M5.Speaker.begin(); | |
} | |
void loop() { | |
M5.update(); | |
unifiedButton.update(); | |
if (M5.BtnA.wasClicked()) { | |
M5.Speaker.tone(1000, 100); | |
M5.Display.println("Btn A wasClicked"); | |
} | |
if (M5.BtnB.wasClicked()) { | |
M5.Speaker.tone(2000, 100); | |
M5.Display.println("Btn B wasClicked"); | |
} | |
if (M5.BtnC.wasClicked()) { | |
M5.Speaker.tone(3000, 100); | |
M5.Display.println("Btn C wasClicked"); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment