|
@@ -2,11 +2,11 @@
|
2
|
2
|
#include <esp_now.h>
|
3
|
3
|
#include <TFT_eSPI.h>
|
4
|
4
|
#include "config.h"
|
5
|
|
-#include "shalomorph.h"
|
6
|
|
-#include "shalom.h"
|
7
|
|
-#include "salam.h"
|
8
|
|
-#include "salamorph.h"
|
9
|
|
-#include "together.h"
|
|
5
|
+//#include "shalom.h"
|
|
6
|
+#include "shalombg.h"
|
|
7
|
+//#include "salam.h"
|
|
8
|
+#include "salambg.h"
|
|
9
|
+#include "togetherbg.h"
|
10
|
10
|
#include "talis.h"
|
11
|
11
|
#include "metta.h"
|
12
|
12
|
#include "loving.h"
|
|
@@ -14,7 +14,7 @@
|
14
|
14
|
#include "mybird.h"
|
15
|
15
|
#include "yourbird.h"
|
16
|
16
|
|
17
|
|
-#define DEBUG true
|
|
17
|
+#define DEBUG false // note: it's easier to read the MAC address if DEBUG is false
|
18
|
18
|
|
19
|
19
|
#define BUTTON1PIN ((gpio_num_t)35)
|
20
|
20
|
#define BUTTON2PIN ((gpio_num_t)0)
|
|
@@ -63,41 +63,37 @@ esp_now_peer_info_t peerInfo;
|
63
|
63
|
bool nearby = false;
|
64
|
64
|
|
65
|
65
|
|
66
|
|
-#define NUM_FRAMES 23
|
|
66
|
+#define NUM_FRAMES 9
|
67
|
67
|
enum frameType {
|
68
|
68
|
FRAME_ME,
|
69
|
|
- FRAME_ME2US,
|
70
|
69
|
FRAME_US,
|
71
|
|
- FRAME_US2U,
|
72
|
70
|
FRAME_U
|
73
|
71
|
};
|
74
|
72
|
|
75
|
73
|
frameType frames[NUM_FRAMES] = {
|
76
|
|
- FRAME_ME, FRAME_ME2US, FRAME_US, FRAME_US2U, FRAME_U, FRAME_U, FRAME_U,
|
77
|
|
- FRAME_US2U, FRAME_US, FRAME_US, FRAME_US2U, FRAME_U, FRAME_U, FRAME_U,
|
78
|
|
- FRAME_US2U, FRAME_US, FRAME_ME2US, FRAME_ME, FRAME_ME, FRAME_ME,
|
79
|
|
- FRAME_ME, FRAME_ME, FRAME_ME
|
|
74
|
+ FRAME_ME, FRAME_US, FRAME_U,
|
|
75
|
+ FRAME_U, FRAME_US, FRAME_U,
|
|
76
|
+ FRAME_U, FRAME_US, FRAME_ME
|
80
|
77
|
};
|
81
|
78
|
|
82
|
|
-const unsigned short *frame2image(frameType frame, bool is_salam) {
|
|
79
|
+const unsigned short *frame2image(frameType frame, bool is_salam, bool metta_from_me, bool metta_from_you) {
|
|
80
|
+ if (!metta_from_me || !metta_from_you) {
|
|
81
|
+ return is_salam ? salambg : shalombg;
|
|
82
|
+ }
|
83
|
83
|
switch (frame) {
|
84
|
84
|
case FRAME_ME:
|
85
|
|
- return is_salam ? salam : shalom;
|
86
|
|
- case FRAME_ME2US:
|
87
|
|
- return is_salam ? salamorph : shalomorph;
|
|
85
|
+ return is_salam ? salambg : shalombg;
|
88
|
86
|
case FRAME_US:
|
89
|
|
- return together;
|
90
|
|
- case FRAME_US2U:
|
91
|
|
- return is_salam ? shalomorph : salamorph;
|
|
87
|
+ return togetherbg;
|
92
|
88
|
case FRAME_U:
|
93
|
|
- return is_salam ? shalom : salam;
|
|
89
|
+ return is_salam ? shalombg : salambg;
|
94
|
90
|
}
|
95
|
91
|
}
|
96
|
92
|
|
97
|
93
|
int current_frame = 0;
|
98
|
94
|
unsigned long last_flip = 0;
|
99
|
95
|
|
100
|
|
-#define DURATION 100
|
|
96
|
+#define DURATION 250
|
101
|
97
|
|
102
|
98
|
|
103
|
99
|
TFT_eSPI tft = TFT_eSPI();
|
|
@@ -266,14 +262,15 @@ void loop() {
|
266
|
262
|
// FRAME_ME or animation frame
|
267
|
263
|
background.pushImage(
|
268
|
264
|
0, 0, 240, 135,
|
269
|
|
- frame2image((metta_from_me_since && metta_from_you) ? frames[current_frame] : FRAME_ME, is_salam));
|
|
265
|
+ frame2image(frames[current_frame], is_salam, metta_from_me_since, metta_from_you));
|
270
|
266
|
|
271
|
|
- // mybird
|
272
|
|
- if (metta_from_me_since) {
|
|
267
|
+ // mybird (steady, pulse if metta_from_me_Since)
|
|
268
|
+ if (!metta_from_me_since || frames[current_frame] == FRAME_ME) {
|
273
|
269
|
mybirdSprite.pushToSprite(&background, MYBIRD_X, MYBIRD_Y, TFT_BLACK);
|
274
|
270
|
}
|
275
|
271
|
|
276
|
|
- if (nearby && frames[current_frame] == FRAME_U) {
|
|
272
|
+ // yourbird (steady if nearby, heart beat if metta_from_you)
|
|
273
|
+ if (nearby && (!metta_from_you || frames[current_frame] == FRAME_U)) {
|
277
|
274
|
yourbirdSprite.pushToSprite(&background, YOURBIRD_X, YOURBIRD_Y, TFT_BLACK);
|
278
|
275
|
}
|
279
|
276
|
|