Skip to content

Commit 9aa83ee

Browse files
authored
Merge pull request #2 from 3110/develop
v0.0.3
2 parents afc72a0 + 1499ccc commit 9aa83ee

File tree

4 files changed

+51
-34
lines changed

4 files changed

+51
-34
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ ATOM Babies は M5Stack 社の<a href="https://shop.m5stack.com/collections/atom
2222

2323
### Arduino IDE
2424

25-
[https://github.com/3110/atom-babies-arduino/archive/refs/tags/v0.0.2.zip](https://github.com/3110/atom-babies-arduino/archive/refs/tags/v0.0.2.zip) をダウンロードし,メニューの「スケッチ」-「ライブラリをインクルード」-「.ZIP 形式のライブラリをインストール...」を選択して ZIP ファイルを読み込みます。読み込み後,念のために Arduino IDE を再起動してください。
25+
[https://github.com/3110/atom-babies-arduino/archive/refs/tags/v0.0.3.zip](https://github.com/3110/atom-babies-arduino/archive/refs/tags/v0.0.3.zip) をダウンロードし,メニューの「スケッチ」-「ライブラリをインクルード」-「.ZIP 形式のライブラリをインストール...」を選択して ZIP ファイルを読み込みます。読み込み後,念のために Arduino IDE を再起動してください。
2626

2727
サンプルはメニューの「ファイル」-「スケッチ例」にある「カスタムライブラリのスケッチ例」から「ATOM Babies」を選択し,「AllFaces」「Blink」「Bow」「Greeting」のいずれかを選びます。
2828

src/AtomBabies.cpp

Lines changed: 42 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,32 @@ void AtomBabies::setBlinkParam(const BlinkParam& param) {
138138
this->_blinkParam = param;
139139
}
140140

141+
void AtomBabies::setOrientation(FaceOrientation orientation) {
142+
clearFace();
143+
this->_orientation = orientation;
144+
setFace(this->_position);
145+
}
146+
147+
void AtomBabies::setFace(FacePosition position) {
148+
clearFace();
149+
this->_position = position;
150+
setEyes(this->_eyeColor);
151+
setCheeks(this->_cheekColor);
152+
}
153+
154+
void AtomBabies::clearFace(bool partial) {
155+
if (partial) {
156+
setEyes(this->_backgroundColor);
157+
setCheeks(this->_backgroundColor);
158+
} else {
159+
fillFace(this->_backgroundColor);
160+
}
161+
}
162+
163+
void AtomBabies::fillFace(const CRGB& color) {
164+
M5.dis.fillpix(color);
165+
}
166+
141167
void AtomBabies::bow(bool deep) {
142168
setFace(FaceNormal);
143169
delay(this->_bowParam.before);
@@ -150,6 +176,18 @@ void AtomBabies::setBowParam(const BowParam& param) {
150176
this->_bowParam = param;
151177
}
152178

179+
void AtomBabies::setEyesColor(const CRGB& color) {
180+
this->_eyeColor = color;
181+
}
182+
183+
void AtomBabies::setCheeksColor(const CRGB& color) {
184+
this->_cheekColor = color;
185+
}
186+
187+
void AtomBabies::setBackgroundColor(const CRGB& color) {
188+
this->_backgroundColor = color;
189+
}
190+
153191
void AtomBabies::_doBlink(void) {
154192
for (int i = 0, n = random(1, this->_blinkParam.loop + 1); i < n; ++i) {
155193
if (!isBlinking()) {
@@ -165,30 +203,12 @@ void AtomBabies::_doBlink(void) {
165203
}
166204
}
167205

168-
void AtomBabies::setOrientation(FaceOrientation orientation) {
169-
clearFace();
170-
this->_orientation = orientation;
171-
setFace(this->_position);
172-
}
173-
174-
void AtomBabies::setFace(FacePosition position) {
175-
clearFace();
176-
this->_position = position;
177-
setEyes(this->_eyeColor);
178-
setCheeks(this->_cheekColor);
179-
}
180-
181-
void AtomBabies::clearFace(bool partial) {
182-
if (partial) {
183-
setEyes(this->_backgroundColor);
184-
setCheeks(this->_backgroundColor);
185-
} else {
186-
fillFace(this->_backgroundColor);
187-
}
206+
void AtomBabies::setEyes(const CRGB& color) {
207+
setLEDs(color, EYE_POSITIONS[this->_position]);
188208
}
189209

190-
void AtomBabies::fillFace(const CRGB& color) {
191-
M5.dis.fillpix(color);
210+
void AtomBabies::setCheeks(const CRGB& color) {
211+
setLEDs(color, CHEEK_POSITIONS[this->_position]);
192212
}
193213

194214
void AtomBabies::setLED(const CRGB& color, uint8_t position) {
@@ -206,14 +226,6 @@ void AtomBabies::setLEDs(const CRGB& color,
206226
}
207227
}
208228

209-
void AtomBabies::setEyes(const CRGB& color) {
210-
setLEDs(color, EYE_POSITIONS[this->_position]);
211-
}
212-
213-
void AtomBabies::setCheeks(const CRGB& color) {
214-
setLEDs(color, CHEEK_POSITIONS[this->_position]);
215-
}
216-
217229
uint8_t AtomBabies::getLEDPosition(uint8_t position) {
218230
if (position == 0) {
219231
return 0;

src/AtomBabies.h

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,14 +77,19 @@ class AtomBabies {
7777
virtual void bow(bool deep = false);
7878
virtual void setBowParam(const BowParam& param);
7979

80+
virtual void setEyesColor(const CRGB& color);
81+
virtual void setCheeksColor(const CRGB& color);
82+
virtual void setBackgroundColor(const CRGB& color);
83+
8084
virtual void _doBlink(void); // called from thread
8185

8286
protected:
87+
virtual void setEyes(const CRGB& color);
88+
virtual void setCheeks(const CRGB& color);
89+
8390
virtual void setLED(const CRGB& color, uint8_t position);
8491
virtual void setLEDs(const CRGB& color,
8592
const uint8_t (&position)[N_POSITIONS]);
86-
virtual void setEyes(const CRGB& color);
87-
virtual void setCheeks(const CRGB& color);
8893
virtual uint8_t getLEDPosition(uint8_t position);
8994

9095
private:

src/AtomBabiesVersion.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
#define VER_STR(x, y, z) (STR(x) "." STR(y) "." STR(z))
55
#define ATOM_BABIES_VERSION_MAJOR 0
66
#define ATOM_BABIES_VERSION_MINOR 0
7-
#define ATOM_BABIES_VERSION_REVISION 2
7+
#define ATOM_BABIES_VERSION_REVISION 3
88
#define ATOM_BABIES_VERSION \
99
VER_STR(ATOM_BABIES_VERSION_MAJOR, ATOM_BABIES_VERSION_MINOR, \
1010
ATOM_BABIES_VERSION_REVISION)

0 commit comments

Comments
 (0)