Kaynağa Gözat

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

master
The Dod 4 ay önce
ebeveyn
işleme
849d2f467c

BIN
graphics/NewDelhi-nRnRY.otf Dosyayı Görüntüle


BIN
graphics/NewDelhiItalic-51l1a.otf Dosyayı Görüntüle


BIN
graphics/NewDelhiLeft-9YBYB.otf Dosyayı Görüntüle


BIN
graphics/goodwill.png Dosyayı Görüntüle


BIN
graphics/goodwill.xcf Dosyayı Görüntüle


BIN
graphics/talismetta.xcf Dosyayı Görüntüle


+ 36
- 19
talismetta/talismetta.ino Dosyayı Görüntüle

@@ -15,10 +15,13 @@
15 15
 #define BUTTON1PIN ((gpio_num_t)35)
16 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 27
 #define SEND_INTERVAL 3000
@@ -34,7 +37,7 @@ esp_now_peer_info_t peerInfo;
34 37
 bool nearby = false;
35 38
 
36 39
 
37
-#define NUM_FRAMES 21
40
+#define NUM_FRAMES 23
38 41
 enum frameType {
39 42
   FRAME_ME,
40 43
   FRAME_ME2US,
@@ -44,14 +47,10 @@ enum frameType {
44 47
 };
45 48
 
46 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 56
 const unsigned short *frame2image(frameType frame, bool is_salam) {
@@ -129,6 +128,7 @@ void setup() {
129 128
     is_salam = true;
130 129
     str2mac(SHALOM, peer_mac_addr);
131 130
   }
131
+  outro_start = 0;
132 132
 
133 133
   WiFi.mode(WIFI_STA);
134 134
   esp_now_init();
@@ -141,6 +141,7 @@ void setup() {
141 141
   tft.init();
142 142
   tft.setRotation(3); // was 1
143 143
   tft.setSwapBytes(true);
144
+  tft.fillScreen(TFT_BLACK);
144 145
 
145 146
   background.createSprite(240, 135);
146 147
   background.setSwapBytes(true);
@@ -155,11 +156,10 @@ void setup() {
155 156
 }
156 157
 
157 158
 void loop() {
159
+  unsigned long nowmillis = millis();
158 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 163
   if (nowmillis > next_send) {
164 164
     if (DEBUG) {
165 165
       Serial.println("Pinging...");
@@ -170,18 +170,35 @@ void loop() {
170 170
     if ((nowmillis - last_flip) > DURATION || nowmillis < last_flip) {
171 171
       current_frame = (current_frame + 1) % NUM_FRAMES;
172 172
       last_flip = nowmillis;
173
+      background.pushSprite(0, 0);
173 174
     }
174 175
   } else {
175 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 195
     talisSprite.pushToSprite(&background, 0, 0);
180 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 199
     talisSprite.pushToSprite(&background, -scrollPixels, 0);
184 200
     mettaSprite.pushToSprite(&background, 120 + scrollPixels, 0);
185 201
   }
186 202
   background.pushSprite(0, 0);
203
+
187 204
 }

Loading…
İptal
Kaydet