Browse Source

Add outro, more "me time". Add xcf [+ font]

master
The Dod 2 months ago
parent
commit
849d2f467c

BIN
graphics/NewDelhi-nRnRY.otf View File


BIN
graphics/NewDelhiItalic-51l1a.otf View File


BIN
graphics/NewDelhiLeft-9YBYB.otf View File


BIN
graphics/goodwill.png View File


BIN
graphics/goodwill.xcf View File


BIN
graphics/talismetta.xcf View File


+ 36
- 19
talismetta/talismetta.ino View File

15
 #define BUTTON1PIN ((gpio_num_t)35)
15
 #define BUTTON1PIN ((gpio_num_t)35)
16
 #define BUTTON2PIN ((gpio_num_t)0)
16
 #define BUTTON2PIN ((gpio_num_t)0)
17
 
17
 
18
-#define SCROLL_START_MILLIS 4000
19
-#define SCROLL_END_MILLIS 6000 // should be > SCROLL_START_MILLIS
20
-#define PING_START_MILLIS 8000 // should be > SCROLL_END_MILLIS
18
+#define INTRO_START_MILLIS 4000
19
+#define INTRO_END_MILLIS 6000 // should be > INTRO_START_MILLIS
20
+#define PING_START_MILLIS 8000 // should be > INTRO_END_MILLIS
21
 
21
 
22
+#define OUTRO_DURATION_MILLIS 2000
23
+#define POST_OUTRO_MILLIS 1000
24
+unsigned long outro_start = 0;
22
 
25
 
23
 
26
 
24
 #define SEND_INTERVAL 3000
27
 #define SEND_INTERVAL 3000
34
 bool nearby = false;
37
 bool nearby = false;
35
 
38
 
36
 
39
 
37
-#define NUM_FRAMES 21
40
+#define NUM_FRAMES 23
38
 enum frameType {
41
 enum frameType {
39
   FRAME_ME,
42
   FRAME_ME,
40
   FRAME_ME2US,
43
   FRAME_ME2US,
44
 };
47
 };
45
 
48
 
46
 frameType frames[NUM_FRAMES] = {
49
 frameType frames[NUM_FRAMES] = {
47
-  FRAME_ME, FRAME_ME2US, FRAME_US, FRAME_US2U,
48
-  FRAME_U, FRAME_U, FRAME_U,
49
-  FRAME_US2U,
50
-  FRAME_US, FRAME_US,
51
-  FRAME_US2U,
52
-  FRAME_U, FRAME_U, FRAME_U,
53
-  FRAME_US2U, FRAME_US, FRAME_ME2US,
54
-  FRAME_ME, FRAME_ME, FRAME_ME, FRAME_ME
50
+  FRAME_ME, FRAME_ME2US, FRAME_US, FRAME_US2U, FRAME_U, FRAME_U, FRAME_U,
51
+  FRAME_US2U,  FRAME_US, FRAME_US,  FRAME_US2U, FRAME_U, FRAME_U, FRAME_U,
52
+  FRAME_US2U, FRAME_US, FRAME_ME2US, FRAME_ME, FRAME_ME, FRAME_ME,
53
+  FRAME_ME, FRAME_ME, FRAME_ME
55
 };
54
 };
56
 
55
 
57
 const unsigned short *frame2image(frameType frame, bool is_salam) {
56
 const unsigned short *frame2image(frameType frame, bool is_salam) {
129
     is_salam = true;
128
     is_salam = true;
130
     str2mac(SHALOM, peer_mac_addr);
129
     str2mac(SHALOM, peer_mac_addr);
131
   }
130
   }
131
+  outro_start = 0;
132
 
132
 
133
   WiFi.mode(WIFI_STA);
133
   WiFi.mode(WIFI_STA);
134
   esp_now_init();
134
   esp_now_init();
141
   tft.init();
141
   tft.init();
142
   tft.setRotation(3); // was 1
142
   tft.setRotation(3); // was 1
143
   tft.setSwapBytes(true);
143
   tft.setSwapBytes(true);
144
+  tft.fillScreen(TFT_BLACK);
144
 
145
 
145
   background.createSprite(240, 135);
146
   background.createSprite(240, 135);
146
   background.setSwapBytes(true);
147
   background.setSwapBytes(true);
155
 }
156
 }
156
 
157
 
157
 void loop() {
158
 void loop() {
159
+  unsigned long nowmillis = millis();
158
   if (digitalRead(BUTTON1PIN) == LOW) {
160
   if (digitalRead(BUTTON1PIN) == LOW) {
159
-    esp_sleep_enable_ext0_wakeup(BUTTON2PIN, LOW);
160
-    esp_deep_sleep_start();
161
+    outro_start = nowmillis;
161
   }
162
   }
162
-  unsigned long nowmillis = millis();
163
   if (nowmillis > next_send) {
163
   if (nowmillis > next_send) {
164
     if (DEBUG) {
164
     if (DEBUG) {
165
       Serial.println("Pinging...");
165
       Serial.println("Pinging...");
170
     if ((nowmillis - last_flip) > DURATION || nowmillis < last_flip) {
170
     if ((nowmillis - last_flip) > DURATION || nowmillis < last_flip) {
171
       current_frame = (current_frame + 1) % NUM_FRAMES;
171
       current_frame = (current_frame + 1) % NUM_FRAMES;
172
       last_flip = nowmillis;
172
       last_flip = nowmillis;
173
+      background.pushSprite(0, 0);
173
     }
174
     }
174
   } else {
175
   } else {
175
     current_frame = 0;
176
     current_frame = 0;
176
   }
177
   }
177
-  background.pushImage(0, 0, 240, 135, frame2image(frames[current_frame], is_salam));
178
-  if (nowmillis < SCROLL_START_MILLIS) {
178
+  // FRAMEW_ME or morph
179
+  if (nowmillis >= INTRO_START_MILLIS && (!outro_start || nowmillis < outro_start + OUTRO_DURATION_MILLIS)) {
180
+    background.pushImage(0, 0, 240, 135, frame2image(frames[current_frame], is_salam));
181
+  }
182
+  if (outro_start) { // Outro scroll overlay
183
+    if (nowmillis - outro_start > OUTRO_DURATION_MILLIS + POST_OUTRO_MILLIS) { // outro over. shut down
184
+      esp_sleep_enable_ext0_wakeup(BUTTON1PIN, LOW);
185
+      esp_deep_sleep_start();
186
+    } else if (nowmillis - outro_start > OUTRO_DURATION_MILLIS) {
187
+      talisSprite.pushToSprite(&background, 0, 0);
188
+      mettaSprite.pushToSprite(&background, 120, 0);
189
+    } else { // do outro
190
+      long scrollPixels = 123 - (123 * (nowmillis - outro_start) / OUTRO_DURATION_MILLIS);
191
+      talisSprite.pushToSprite(&background, -scrollPixels, 0);
192
+      mettaSprite.pushToSprite(&background, 120 + scrollPixels, 0);
193
+    }
194
+  } else if (nowmillis < INTRO_START_MILLIS) { // Intro scroll overlay
179
     talisSprite.pushToSprite(&background, 0, 0);
195
     talisSprite.pushToSprite(&background, 0, 0);
180
     mettaSprite.pushToSprite(&background, 120, 0);
196
     mettaSprite.pushToSprite(&background, 120, 0);
181
-  } else if (nowmillis < SCROLL_END_MILLIS) {
182
-    long scrollPixels = 123 * (nowmillis - SCROLL_START_MILLIS) / (SCROLL_END_MILLIS - SCROLL_START_MILLIS);
197
+  } else if (nowmillis < INTRO_END_MILLIS) {
198
+    long scrollPixels = 123 * (nowmillis - INTRO_START_MILLIS) / (INTRO_END_MILLIS - INTRO_START_MILLIS);
183
     talisSprite.pushToSprite(&background, -scrollPixels, 0);
199
     talisSprite.pushToSprite(&background, -scrollPixels, 0);
184
     mettaSprite.pushToSprite(&background, 120 + scrollPixels, 0);
200
     mettaSprite.pushToSprite(&background, 120 + scrollPixels, 0);
185
   }
201
   }
186
   background.pushSprite(0, 0);
202
   background.pushSprite(0, 0);
203
+
187
 }
204
 }

Loading…
Cancel
Save