|
31 | 31 |
|
32 | 32 | # read buttons from ePaper shield |
33 | 33 | def read_buttons(): |
| 34 | + button = 1 |
34 | 35 | with AnalogIn(board.A3) as ain: |
35 | 36 | reading = ain.value / 65535 |
36 | 37 | if reading > 0.75: |
37 | | - return None |
| 38 | + button = None |
38 | 39 | if reading > 0.4: |
39 | | - return 4 |
| 40 | + button = 4 |
40 | 41 | if reading > 0.25: |
41 | | - return 3 |
| 42 | + button = 3 |
42 | 43 | if reading > 0.13: |
43 | | - return 2 |
44 | | - return 1 |
45 | | - return None |
| 44 | + button = 2 |
| 45 | + button = 1 |
| 46 | + return button |
46 | 47 |
|
47 | 48 | # display bitmap file |
48 | 49 | def display_bitmap(epd, filename): |
@@ -101,15 +102,15 @@ def display_bitmap(epd, filename): |
101 | 102 | else: |
102 | 103 | led.value = True |
103 | 104 | if flip: # Bitmap is stored bottom-to-top order (normal BMP) |
104 | | - pos = bmpImageoffset + (bmpHeight - 1 - row) * rowSize |
| 105 | + f.seek(bmpImageoffset + (bmpHeight - 1 - row) * rowSize) |
105 | 106 | else: # Bitmap is stored top-to-bottom |
106 | | - pos = bmpImageoffset + row * rowSize |
107 | | - f.seek(pos) |
| 107 | + f.seek(bmpImageoffset + row * rowSize) |
| 108 | + |
108 | 109 | rowdata = f.read(bmpWidth) |
109 | 110 | for col in range(bmpWidth): |
110 | 111 | for b in range(8): |
111 | 112 | if (rowdata[col] & (0x80 >> b) != 0 and blkpixel == 0) or ( |
112 | | - rowdata[col] & (0x80 >> b) == 0 and blkpixel == 1): |
| 113 | + rowdata[col] & (0x80 >> b) == 0 and blkpixel == 1): |
113 | 114 | epd.pixel(col * 8 + b, row, Adafruit_EPD.BLACK) |
114 | 115 | except (ValueError) as e: |
115 | 116 | display_message("Error: " + e.args[0]) |
@@ -278,13 +279,13 @@ def run_job(jobfile): |
278 | 279 | for x2 in range(panelwidth): |
279 | 280 | tpanel[x2] = tcanvas[x + x2 - panelwidth] |
280 | 281 | offset = 0 |
281 | | - if (x >= 22 and |
| 282 | + if (x >= 22 and |
282 | 283 | x < (image.width + panelwidth // 2) |
283 | 284 | and y < image.height): |
284 | 285 | if ( |
285 | | - (image[x - panelwidth // 2, y] != 0 and not inv |
| 286 | + (image[x - panelwidth // 2, y] != 0 and not inv |
286 | 287 | ) or ( |
287 | | - image[x - panelwidth // 2, y] == 0 and inv) |
| 288 | + image[x - panelwidth // 2, y] == 0 and inv) |
288 | 289 | ): |
289 | 290 | # offset = 4 |
290 | 291 | if job["imagegrayscale"] == 0: |
|
0 commit comments