-
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.
Merge pull request #91 from botamochi6277/wink
Add Right & Left Eye Open Ratio for Wink
- Loading branch information
Showing
6 changed files
with
241 additions
and
121 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,36 @@ | ||
#include <Avatar.h> | ||
#include <M5Unified.h> | ||
|
||
m5avatar::Avatar avatar; | ||
m5avatar::ColorPalette* palettes[2]; | ||
|
||
void setup() { | ||
M5.begin(); | ||
|
||
palettes[0] = new m5avatar::ColorPalette(); | ||
palettes[1] = new m5avatar::ColorPalette(); | ||
palettes[1]->set(COLOR_PRIMARY, TFT_YELLOW); | ||
palettes[1]->set(COLOR_BACKGROUND, TFT_DARKCYAN); | ||
|
||
avatar.init(); // start drawing | ||
} | ||
|
||
void loop() { | ||
M5.update(); | ||
if (M5.BtnA.wasPressed()) { | ||
// switch right eye | ||
avatar.setRightEyeOpenRatio(avatar.getRightEyeOpenRatio() > 0.5f ? 0.0f | ||
: 1.0f); | ||
} | ||
if (M5.BtnB.wasPressed()) { | ||
avatar.setIsAutoBlink(!avatar.getIsAutoBlink()); | ||
avatar.setColorPalette( | ||
*palettes[static_cast<uint8_t>(!avatar.getIsAutoBlink())]); | ||
} | ||
if (M5.BtnC.wasPressed()) { | ||
// switch left eye | ||
avatar.setLeftEyeOpenRatio(avatar.getLeftEyeOpenRatio() > 0.5f ? 0.0f | ||
: 1.0f); | ||
} | ||
delay(10); | ||
} |
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.