Bläddra i källkod

First version of code (no metta button yet)

`talismetta` is the arduino project (Lilygo TTGO v1)
`graphics` contains `.png` files we convert to `.h` files
and the source `.xcf` files of some
master
The Dod 4 månader sedan
förälder
incheckning
615f358885
50 ändrade filer med 12701 tillägg och 6 borttagningar
  1. 3
    0
      .gitignore
  2. 2
    6
      README.md
  3. Binär
      graphics/birds/bird1.png
  4. Binär
      graphics/birds/bird2.png
  5. Binär
      graphics/metta.png
  6. Binär
      graphics/mira-awad-shalom-salam-240x135.xcf
  7. Binär
      graphics/mira-awad-shalom-salam.png
  8. Binär
      graphics/mira-awad-shalom-salam.xcf
  9. Binär
      graphics/no-birds-salam.png
  10. Binär
      graphics/no-birds-shalom.png
  11. Binär
      graphics/no-birds-together.png
  12. Binär
      graphics/peace-with-birds/salam.png
  13. Binär
      graphics/peace-with-birds/shalom.png
  14. Binär
      graphics/peace-with-birds/together.png
  15. 50
    0
      graphics/peace/morph/salam.mesh
  16. Binär
      graphics/peace/morph/salam.tga
  17. Binär
      graphics/peace/morph/salam0000.tga
  18. Binär
      graphics/peace/morph/salam0001.tga
  19. Binär
      graphics/peace/morph/salam0002.tga
  20. 50
    0
      graphics/peace/morph/shalom.mesh
  21. Binär
      graphics/peace/morph/shalom.tga
  22. Binär
      graphics/peace/morph/shalom0000.tga
  23. Binär
      graphics/peace/morph/shalom0001.tga
  24. Binär
      graphics/peace/morph/shalom0002.tga
  25. 50
    0
      graphics/peace/morph/together-shalom.mesh
  26. 50
    0
      graphics/peace/morph/together.mesh
  27. Binär
      graphics/peace/morph/together.tga
  28. Binär
      graphics/peace/peace-morph.gif
  29. Binär
      graphics/peace/salam.png
  30. Binär
      graphics/peace/salamorph.png
  31. Binär
      graphics/peace/shalom.png
  32. Binär
      graphics/peace/shalomorph.png
  33. Binär
      graphics/peace/together.png
  34. Binär
      graphics/talis.png
  35. Binär
      graphics/talismetta-salam.jpg
  36. Binär
      graphics/talismetta-shalom.jpg
  37. Binär
      graphics/talismetta-together.jpg
  38. Binär
      graphics/talismetta.png
  39. Binär
      talis-metta-cat.jpg
  40. 16
    0
      talismetta/README.md
  41. 12
    0
      talismetta/config.h
  42. 11
    0
      talismetta/config_example.h
  43. 1030
    0
      talismetta/metta.h
  44. 2042
    0
      talismetta/salam.h
  45. 2042
    0
      talismetta/salamorph.h
  46. 2042
    0
      talismetta/shalom.h
  47. 2042
    0
      talismetta/shalomorph.h
  48. 1030
    0
      talismetta/talis.h
  49. 187
    0
      talismetta/talismetta.ino
  50. 2042
    0
      talismetta/together.h

+ 3
- 0
.gitignore Visa fil

@@ -1,2 +1,5 @@
1 1
 *.backup
2 2
 *.swp
3
+*.tmp
4
+work/
5
+

+ 2
- 6
README.md Visa fil

@@ -2,9 +2,5 @@
2 2
 
3 3
 #### _[Work in Progress]_
4 4
 
5
-Talis-Metta is a collaborative talisman whose virtue is [metta](https://en.wikipedia.org/wiki/Mettā) - intention, prayer and wishes for unconditional love - for myself, my loved ones and everyone else.
6
-From inner peace - through others - to world peace.
7
-
8
-As the bearer of such a talisman, I can choose my intention, which it will represent. As soon as a bearer of another such talisman approaches me (within WiFi range), the intention they choose will affect me and the display of my talisman, which will become more diverse. The beauty of containing the other. When there are more than two Talismans in our environment - the inner peace will increase for all of us. This will be expressed in the visual display of each of the talismans, which will deepen in meaning and universality.
9
-
10
-![embroidery and hardware we plan to use](talis-metta-materials.jpg)
5
+To convert images from [graphics/](graphics) to `.h` files under [talismetta/](talismetta),
6
+use [Rinky-Dink Electronics converter](http://www.rinkydinkelectronics.com/t_imageconverter565.php)

Binär
graphics/birds/bird1.png Visa fil


Binär
graphics/birds/bird2.png Visa fil


Binär
graphics/metta.png Visa fil


Binär
graphics/mira-awad-shalom-salam-240x135.xcf Visa fil


Binär
graphics/mira-awad-shalom-salam.png Visa fil


Binär
graphics/mira-awad-shalom-salam.xcf Visa fil


Binär
graphics/no-birds-salam.png Visa fil


Binär
graphics/no-birds-shalom.png Visa fil


Binär
graphics/no-birds-together.png Visa fil


Binär
graphics/peace-with-birds/salam.png Visa fil


Binär
graphics/peace-with-birds/shalom.png Visa fil


Binär
graphics/peace-with-birds/together.png Visa fil


+ 50
- 0
graphics/peace/morph/salam.mesh Visa fil

@@ -0,0 +1,50 @@
1
+M2
2
+8 6
3
+0 0 0
4
+344 0 0
5
+688 0 0
6
+1032 0 0
7
+1377 0 0
8
+1721 0 0
9
+2065 0 0
10
+2390 0 0
11
+0 272 0
12
+344 272 0
13
+688 272 0
14
+1222 222 0
15
+1277 262 0
16
+1651 332 0
17
+2085 232 0
18
+2390 272 0
19
+0 544 0
20
+444 634 0
21
+748 624 0
22
+822 384 0
23
+1337 544 0
24
+1671 584 0
25
+2055 574 0
26
+2390 544 0
27
+0 816 0
28
+384 896 0
29
+688 866 0
30
+1002 896 0
31
+1427 626 0
32
+1351 816 0
33
+2055 886 0
34
+2390 816 0
35
+0 1088 0
36
+344 1088 0
37
+618 1068 0
38
+882 908 0
39
+1227 918 0
40
+1721 1088 0
41
+2065 1088 0
42
+2390 1088 0
43
+0 1340 0
44
+344 1340 0
45
+688 1340 0
46
+1032 1340 0
47
+1377 1340 0
48
+1721 1340 0
49
+2065 1340 0
50
+2390 1340 0

Binär
graphics/peace/morph/salam.tga Visa fil


Binär
graphics/peace/morph/salam0000.tga Visa fil


Binär
graphics/peace/morph/salam0001.tga Visa fil


Binär
graphics/peace/morph/salam0002.tga Visa fil


+ 50
- 0
graphics/peace/morph/shalom.mesh Visa fil

@@ -0,0 +1,50 @@
1
+M2
2
+8 6
3
+0 0 0
4
+344 0 0
5
+688 0 0
6
+1032 0 0
7
+1377 0 0
8
+1721 0 0
9
+2065 0 0
10
+2390 0 0
11
+0 272 0
12
+344 272 0
13
+688 272 0
14
+982 372 0
15
+1207 342 0
16
+1651 332 0
17
+2045 382 0
18
+2390 272 0
19
+0 544 0
20
+414 414 0
21
+838 484 0
22
+962 464 0
23
+1207 434 0
24
+1581 464 0
25
+2055 464 0
26
+2390 544 0
27
+0 816 0
28
+344 966 0
29
+808 886 0
30
+962 966 0
31
+1437 516 0
32
+1571 926 0
33
+2115 906 0
34
+2390 816 0
35
+0 1088 0
36
+344 1088 0
37
+688 1088 0
38
+1032 1088 0
39
+1407 818 0
40
+1721 1088 0
41
+2065 1088 0
42
+2390 1088 0
43
+0 1340 0
44
+344 1340 0
45
+688 1340 0
46
+1032 1340 0
47
+1377 1340 0
48
+1721 1340 0
49
+2065 1340 0
50
+2390 1340 0

Binär
graphics/peace/morph/shalom.tga Visa fil


Binär
graphics/peace/morph/shalom0000.tga Visa fil


Binär
graphics/peace/morph/shalom0001.tga Visa fil


Binär
graphics/peace/morph/shalom0002.tga Visa fil


+ 50
- 0
graphics/peace/morph/together-shalom.mesh Visa fil

@@ -0,0 +1,50 @@
1
+M2
2
+8 6
3
+0 0 0
4
+344 0 0
5
+688 0 0
6
+1032 0 0
7
+1377 0 0
8
+1721 0 0
9
+2065 0 0
10
+2390 0 0
11
+0 272 0
12
+344 272 0
13
+688 272 0
14
+1252 292 0
15
+1487 292 0
16
+1721 272 0
17
+2085 312 0
18
+2390 272 0
19
+0 544 0
20
+384 584 0
21
+728 584 0
22
+832 384 0
23
+1337 434 0
24
+1581 604 0
25
+2095 574 0
26
+2390 544 0
27
+0 816 0
28
+374 996 0
29
+738 956 0
30
+952 856 0
31
+1437 576 0
32
+1351 866 0
33
+2065 956 0
34
+2390 816 0
35
+0 1088 0
36
+344 1088 0
37
+688 1088 0
38
+862 938 0
39
+1197 938 0
40
+1721 1088 0
41
+2065 1088 0
42
+2390 1088 0
43
+0 1340 0
44
+344 1340 0
45
+688 1340 0
46
+1032 1340 0
47
+1377 1340 0
48
+1721 1340 0
49
+2065 1340 0
50
+2390 1340 0

+ 50
- 0
graphics/peace/morph/together.mesh Visa fil

@@ -0,0 +1,50 @@
1
+M2
2
+8 6
3
+0 0 0
4
+345 0 0
5
+690 0 0
6
+1036 0 0
7
+1382 0 0
8
+1728 0 0
9
+2073 0 0
10
+2390 0 0
11
+0 274 0
12
+345 274 0
13
+690 274 0
14
+1257 294 0
15
+1493 294 0
16
+1728 274 0
17
+2093 314 0
18
+2390 274 0
19
+0 548 0
20
+385 588 0
21
+731 588 0
22
+835 386 0
23
+1342 437 0
24
+1587 608 0
25
+2103 578 0
26
+2390 548 0
27
+0 822 0
28
+375 1003 0
29
+741 963 0
30
+955 862 0
31
+1443 580 0
32
+1356 872 0
33
+2073 963 0
34
+2390 822 0
35
+0 1096 0
36
+345 1096 0
37
+690 1096 0
38
+865 944 0
39
+1202 944 0
40
+1728 1096 0
41
+2073 1096 0
42
+2390 1096 0
43
+0 1340 0
44
+345 1340 0
45
+690 1340 0
46
+1036 1340 0
47
+1382 1340 0
48
+1728 1340 0
49
+2073 1340 0
50
+2390 1340 0

Binär
graphics/peace/morph/together.tga Visa fil


Binär
graphics/peace/peace-morph.gif Visa fil


Binär
graphics/peace/salam.png Visa fil


Binär
graphics/peace/salamorph.png Visa fil


Binär
graphics/peace/shalom.png Visa fil


Binär
graphics/peace/shalomorph.png Visa fil


Binär
graphics/peace/together.png Visa fil


Binär
graphics/talis.png Visa fil


Binär
graphics/talismetta-salam.jpg Visa fil


Binär
graphics/talismetta-shalom.jpg Visa fil


Binär
graphics/talismetta-together.jpg Visa fil


Binär
graphics/talismetta.png Visa fil


Binär
talis-metta-cat.jpg Visa fil


+ 16
- 0
talismetta/README.md Visa fil

@@ -0,0 +1,16 @@
1
+
2
+#### Configuring a new pair of talismettas
3
+You should copy [config_example.h](config_example.h) to `config.h` and edit it with the MAC addresses of both `SHALOM` and `SALAM` talismettas.
4
+
5
+In order to figure out the address, upload the code to the talismetta, then you can see the MAC address by openning the serial monitor to it at 115200 baud. You should see something like
6
+
7
+```
8
+=== Talis-Metta ===
9
+My MAC:
10
+0B:0A:0D:0A:05:05
11
+```
12
+
13
+Copy this to the `SALAM` or `SHALOM` definition at `config.h`
14
+
15
+#### .png to .h convertion
16
+Use [Rinky-Dink Electronics converter](http://www.rinkydinkelectronics.com/t_imageconverter565.php)

+ 12
- 0
talismetta/config.h Visa fil

@@ -0,0 +1,12 @@
1
+#define DEBUG true
2
+
3
+// [If you haven't done so already] copy config-example.h to config.h
4
+
5
+// When DEBUG is true, board's MAC address is printed to serial
6
+// Once you copy MAC addresses of both mates, use them as YIN/YANG below.
7
+// You can then upload the same code to both mates (each would know to
8
+// scan for the other one, and not for itself).
9
+
10
+
11
+#define SHALOM "30:C6:F7:1D:A6:20"
12
+#define SALAM "30:C6:F7:1D:A2:5C"

+ 11
- 0
talismetta/config_example.h Visa fil

@@ -0,0 +1,11 @@
1
+#define DEBUG true
2
+
3
+// [If you haven't done so already] copy config-example.h to config.h
4
+
5
+// When DEBUG is true, board's MAC address is printed to serial
6
+// Once you copy MAC addresses of both mates, use them as YIN/YANG below.
7
+// You can then upload the same code to both mates (each would know to
8
+// scan for the other one, and not for itself).
9
+
10
+#define SHALOM "11:22:33:44:55:66"
11
+#define SALAM "ff:ee:dd:cc:bb:aa"

+ 1030
- 0
talismetta/metta.h
Filskillnaden har hållits tillbaka eftersom den är för stor
Visa fil


+ 2042
- 0
talismetta/salam.h
Filskillnaden har hållits tillbaka eftersom den är för stor
Visa fil


+ 2042
- 0
talismetta/salamorph.h
Filskillnaden har hållits tillbaka eftersom den är för stor
Visa fil


+ 2042
- 0
talismetta/shalom.h
Filskillnaden har hållits tillbaka eftersom den är för stor
Visa fil


+ 2042
- 0
talismetta/shalomorph.h
Filskillnaden har hållits tillbaka eftersom den är för stor
Visa fil


+ 1030
- 0
talismetta/talis.h
Filskillnaden har hållits tillbaka eftersom den är för stor
Visa fil


+ 187
- 0
talismetta/talismetta.ino Visa fil

@@ -0,0 +1,187 @@
1
+#include <WiFi.h>
2
+#include <esp_now.h>
3
+#include <TFT_eSPI.h>
4
+#include "config.h"
5
+#include "shalomorph.h"
6
+#include "shalom.h"
7
+#include "salam.h"
8
+#include "salamorph.h"
9
+#include "together.h"
10
+#include "talis.h"
11
+#include "metta.h"
12
+
13
+#define DEBUG false
14
+
15
+#define BUTTON1PIN ((gpio_num_t)35)
16
+#define BUTTON2PIN ((gpio_num_t)0)
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
21
+
22
+
23
+
24
+#define SEND_INTERVAL 3000
25
+unsigned long next_send = 0;
26
+
27
+
28
+String my_mac;
29
+bool is_salam;
30
+
31
+uint8_t peer_mac_addr[6];
32
+esp_now_peer_info_t peerInfo;
33
+
34
+bool nearby = false;
35
+
36
+
37
+#define NUM_FRAMES 21
38
+enum frameType {
39
+  FRAME_ME,
40
+  FRAME_ME2US,
41
+  FRAME_US,
42
+  FRAME_US2U,
43
+  FRAME_U
44
+};
45
+
46
+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
55
+};
56
+
57
+const unsigned short *frame2image(frameType frame, bool is_salam) {
58
+  switch (frame) {
59
+    case FRAME_ME:
60
+      return is_salam ? salam : shalom;
61
+    case FRAME_ME2US:
62
+      return is_salam ? salamorph : shalomorph;
63
+    case FRAME_US:
64
+      return together;
65
+    case FRAME_US2U:
66
+      return is_salam ? shalomorph : salamorph;
67
+    case FRAME_U:
68
+      return is_salam ? shalom : salam;
69
+  }
70
+}
71
+
72
+int current_frame = 0;
73
+unsigned long last_flip = 0;
74
+
75
+#define DURATION 100
76
+
77
+
78
+TFT_eSPI tft = TFT_eSPI();
79
+TFT_eSprite background = TFT_eSprite(&tft);
80
+TFT_eSprite talisSprite = TFT_eSprite(&tft);
81
+TFT_eSprite mettaSprite = TFT_eSprite(&tft);
82
+
83
+
84
+// lifted from MacAddress.c
85
+bool str2mac(char *buf, uint8_t *mac) {
86
+  char cs[18];
87
+  char *token;
88
+  char *next; //Unused but required
89
+  int i;
90
+  strncpy(cs, buf, sizeof(cs)); //strtok modifies the buffer: copy to working buffer.
91
+  for (i = 0; i < 6; i++) {
92
+    token = strtok((i == 0) ? cs : NULL, ":");  //Find first or next token
93
+    if (!token) {                               //No more tokens found
94
+      return false;
95
+    }
96
+    mac[i] = strtol(token, &next, 16);
97
+  }
98
+  return true;
99
+}
100
+
101
+void OnDataSent(const uint8_t *mac_addr, esp_now_send_status_t status) {
102
+  nearby = (status == ESP_NOW_SEND_SUCCESS);
103
+  if (DEBUG) {
104
+    Serial.println(nearby ? "Nearby" : "Not nearby");
105
+  }
106
+}
107
+
108
+void setup() {
109
+  pinMode(BUTTON1PIN, INPUT_PULLUP);
110
+  pinMode(BUTTON2PIN, INPUT_PULLUP);
111
+  Serial.begin(115200);
112
+  delay(1000);
113
+  Serial.println("=== Talis-Metta ===");
114
+
115
+  // determine peer mac address
116
+  my_mac = WiFi.macAddress();
117
+  Serial.println("My MAC:");
118
+  Serial.println(my_mac);
119
+  if (my_mac.equals(SHALOM)) {
120
+    if (DEBUG) {
121
+      Serial.println("Shalom");
122
+    }
123
+    is_salam = false;
124
+    str2mac(SALAM, peer_mac_addr);
125
+  } else {
126
+    if (DEBUG) {
127
+      Serial.println("Salam");
128
+    }
129
+    is_salam = true;
130
+    str2mac(SHALOM, peer_mac_addr);
131
+  }
132
+
133
+  WiFi.mode(WIFI_STA);
134
+  esp_now_init();
135
+  memcpy(peerInfo.peer_addr, peer_mac_addr, 6);
136
+  peerInfo.channel = 0;
137
+  peerInfo.encrypt = false;
138
+  esp_now_add_peer(&peerInfo);
139
+  esp_now_register_send_cb(OnDataSent);
140
+
141
+  tft.init();
142
+  tft.setRotation(3); // was 1
143
+  tft.setSwapBytes(true);
144
+
145
+  background.createSprite(240, 135);
146
+  background.setSwapBytes(true);
147
+
148
+  talisSprite.createSprite(120, 135);
149
+  talisSprite.setSwapBytes(true);
150
+  talisSprite.pushImage(0, 0, 120, 135, talis);
151
+
152
+  mettaSprite.createSprite(120, 135);
153
+  mettaSprite.setSwapBytes(true);
154
+  mettaSprite.pushImage(0, 0, 120, 135, metta);
155
+}
156
+
157
+void loop() {
158
+  if (digitalRead(BUTTON1PIN) == LOW) {
159
+    esp_sleep_enable_ext0_wakeup(BUTTON2PIN, LOW);
160
+    esp_deep_sleep_start();
161
+  }
162
+  unsigned long nowmillis = millis();
163
+  if (nowmillis > next_send) {
164
+    if (DEBUG) {
165
+      Serial.println("Pinging...");
166
+    }    esp_now_send(peerInfo.peer_addr, (const uint8_t *)"<3", 2);
167
+    next_send = nowmillis + SEND_INTERVAL;
168
+  }
169
+  if ((nowmillis > PING_START_MILLIS) && nearby) {
170
+    if ((nowmillis - last_flip) > DURATION || nowmillis < last_flip) {
171
+      current_frame = (current_frame + 1) % NUM_FRAMES;
172
+      last_flip = nowmillis;
173
+    }
174
+  } else {
175
+    current_frame = 0;
176
+  }
177
+  background.pushImage(0, 0, 240, 135, frame2image(frames[current_frame], is_salam));
178
+  if (nowmillis < SCROLL_START_MILLIS) {
179
+    talisSprite.pushToSprite(&background, 0, 0);
180
+    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);
183
+    talisSprite.pushToSprite(&background, -scrollPixels, 0);
184
+    mettaSprite.pushToSprite(&background, 120 + scrollPixels, 0);
185
+  }
186
+  background.pushSprite(0, 0);
187
+}

+ 2042
- 0
talismetta/together.h
Filskillnaden har hållits tillbaka eftersom den är för stor
Visa fil


Laddar…
Avbryt
Spara