Browse Source

missing image dump modifications

Thomas Buck 1 year ago
parent
commit
59766fa62d
3 changed files with 28 additions and 3 deletions
  1. 4
    0
      copy.sh
  2. 22
    1
      image.py
  3. 2
    2
      qr.py

+ 4
- 0
copy.sh View File

14
 cp qr.py /pyboard
14
 cp qr.py /pyboard
15
 cp camp_pico.py /pyboard
15
 cp camp_pico.py /pyboard
16
 cp scroll.py /pyboard
16
 cp scroll.py /pyboard
17
+cp qr_tmp.py /pyboard
18
+cp img_tmp.py /pyboard
17
 cp $1 /pyboard/main.py
19
 cp $1 /pyboard/main.py
18
 EOF
20
 EOF
19
 else
21
 else
31
 cp qr.py /pyboard
33
 cp qr.py /pyboard
32
 cp camp_pico.py /pyboard
34
 cp camp_pico.py /pyboard
33
 cp scroll.py /pyboard
35
 cp scroll.py /pyboard
36
+cp qr_tmp.py /pyboard
37
+cp img_tmp.py /pyboard
34
 EOF
38
 EOF
35
 fi
39
 fi

+ 22
- 1
image.py View File

107
     imageDir = os.path.join(scriptDir, "images")
107
     imageDir = os.path.join(scriptDir, "images")
108
     for f in os.listdir(os.fsencode(imageDir)):
108
     for f in os.listdir(os.fsencode(imageDir)):
109
         filename = os.fsdecode(f)
109
         filename = os.fsdecode(f)
110
-        m.add(ImageScreen(t, filename))
110
+
111
+        d = ImageScreen(t, filename)
112
+        m.add(d)
113
+
114
+        if filename != "Favicon.png":
115
+            continue
116
+
117
+        # dump generated image to console, for embedding in Pico script
118
+        print()
119
+        print("Dumping image to img_tmp.py")
120
+        with open("img_tmp.py", "w") as f:
121
+            f.write("# Image \"" + filename + "\"" + os.linesep)
122
+            f.write("# size:" + str(d.image.width) + "x" + str(d.image.height) + os.linesep)
123
+            f.write("img_data = [" + os.linesep)
124
+            for y in range(0, d.image.height):
125
+                f.write("    [" + os.linesep)
126
+                for x in range(0, d.image.width):
127
+                    s = str(d.image.getpixel((x, y)))
128
+                    f.write("        " + s + "," + os.linesep)
129
+                f.write("    ]," + os.linesep)
130
+            f.write("]" + os.linesep)
131
+        print()
111
 
132
 
112
     m.restart()
133
     m.restart()
113
     t.loop(m.draw)
134
     t.loop(m.draw)

+ 2
- 2
qr.py View File

113
     d = QRScreen(t, "http://ubabot.frubar.net", 10.0, "Drinks:", "tom-thumb", (255, 255, 255), (0, 0, 0))
113
     d = QRScreen(t, "http://ubabot.frubar.net", 10.0, "Drinks:", "tom-thumb", (255, 255, 255), (0, 0, 0))
114
 
114
 
115
     # dump generated QR image to console, for embedding in Pico script
115
     # dump generated QR image to console, for embedding in Pico script
116
-    print("Dumping QR image to qr_tmp.txt")
117
-    with open("qr_tmp.txt", "w") as f:
116
+    print("Dumping QR image to qr_tmp.py")
117
+    with open("qr_tmp.py", "w") as f:
118
         f.write("# QR code image for \"" + d.data + "\"" + os.linesep)
118
         f.write("# QR code image for \"" + d.data + "\"" + os.linesep)
119
         f.write("# size:" + str(d.image.width) + "x" + str(d.image.height) + os.linesep)
119
         f.write("# size:" + str(d.image.width) + "x" + str(d.image.height) + os.linesep)
120
         f.write("qr_data = [" + os.linesep)
120
         f.write("qr_data = [" + os.linesep)

Loading…
Cancel
Save