Skip to content

Commit 91e13b5

Browse files
authored
Update code.py
1 parent 8e5f76c commit 91e13b5

1 file changed

Lines changed: 19 additions & 14 deletions

File tree

EInk_Autostereograms/code.py

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -34,14 +34,19 @@ def read_buttons():
3434
with AnalogIn(board.A3) as ain:
3535
reading = ain.value / 65535
3636
if reading > 0.75:
37-
return None
37+
38+
None
3839
if reading > 0.4:
39-
return 4
40+
41+
4
4042
if reading > 0.25:
41-
return 3
43+
44+
3
4245
if reading > 0.13:
43-
return 2
44-
return 1
46+
47+
2
48+
49+
1
4550

4651

4752
# display bitmap file
@@ -50,7 +55,8 @@ def display_bitmap(epd, filename):
5055
f = open("/" + filename, "rb")
5156
except OSError:
5257
display_message("Error: Couldn't open file " + filename)
53-
return
58+
59+
5460
print("File opened")
5561
try:
5662
if f.read(2) != b"BM": # check signature
@@ -127,7 +133,8 @@ def read_le(s):
127133
for byte in bytearray(s):
128134
result += byte << shift
129135
shift += 8
130-
return result
136+
137+
result
131138

132139

133140
class BMPError(Exception):
@@ -182,7 +189,6 @@ def show_files():
182189
except (ValueError, Exception) as e:
183190
display_message("Error: " + file + " " + e.args[0])
184191
led.value = False
185-
return
186192

187193
# run specified job
188194
def run_job(jobfile):
@@ -202,7 +208,7 @@ def run_job(jobfile):
202208
display.fill(Adafruit_EPD.WHITE)
203209
print("ePaper display size:", display.width, display.height)
204210
print(config["imagefolder"] + "/" + job["image"])
205-
image, palette = adafruit_imageload.load(
211+
image, _ = adafruit_imageload.load(
206212
config["imagefolder"] + "/" + job["image"],
207213
bitmap=displayio.Bitmap,
208214
palette=displayio.Palette,
@@ -327,13 +333,12 @@ def run_job(jobfile):
327333
except (ValueError, Exception) as e:
328334
display_message("Error: " + e.args[0])
329335
led.value = False
330-
return
331-
336+
332337
# main routine
333338
display.fill(Adafruit_EPD.WHITE)
334-
with open("/config.json") as fp:
335-
config = json.load(fp)
336-
fp.close()
339+
with open("/config.json") as fpx:
340+
config = json.load(fpx)
341+
fpx.close()
337342
print("waiting for button press")
338343
while True:
339344
button = read_buttons()

0 commit comments

Comments
 (0)