ソースを参照

missing image dump modifications

Thomas Buck 1年前
コミット
59766fa62d
3個のファイルの変更28行の追加3行の削除
  1. 4
    0
      copy.sh
  2. 22
    1
      image.py
  3. 2
    2
      qr.py

+ 4
- 0
copy.sh ファイルの表示

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

+ 22
- 1
image.py ファイルの表示

@@ -107,7 +107,28 @@ if __name__ == "__main__":
107 107
     imageDir = os.path.join(scriptDir, "images")
108 108
     for f in os.listdir(os.fsencode(imageDir)):
109 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 133
     m.restart()
113 134
     t.loop(m.draw)

+ 2
- 2
qr.py ファイルの表示

@@ -113,8 +113,8 @@ if __name__ == "__main__":
113 113
     d = QRScreen(t, "http://ubabot.frubar.net", 10.0, "Drinks:", "tom-thumb", (255, 255, 255), (0, 0, 0))
114 114
 
115 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 118
         f.write("# QR code image for \"" + d.data + "\"" + os.linesep)
119 119
         f.write("# size:" + str(d.image.width) + "x" + str(d.image.height) + os.linesep)
120 120
         f.write("qr_data = [" + os.linesep)

読み込み中…
キャンセル
保存