Skip to content

Commit 6afe461

Browse files
committed
Fix pylint & black diagnostics
1 parent 8957115 commit 6afe461

7 files changed

+37
-37
lines changed

examples/ov2640_aio_kaluga1_3.py

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,24 +10,28 @@
1010
The audio board must be mounted between the Kaluga and the LCD, it provides the
1111
I2C pull-ups(!)
1212
13-
This example requires that your WIFI and Adafruit IO credentials be configured in CIRCUITPY/secrets.py, and that you have created a feed called "image" with history disabled.
13+
This example requires that your WIFI and Adafruit IO credentials be configured
14+
in CIRCUITPY/secrets.py, and that you have created a feed called "image" with
15+
history disabled.
1416
15-
The maximum image size is 100kB after base64 encoding, or about 65kB before base64 encoding. In practice, "SVGA" (800x600) images are typically around 40kB even though the "capture_buffer_size" (theoretical maximum size) is (width*height/5) bytes or 96kB.
17+
The maximum image size is 100kB after base64 encoding, or about 65kB before
18+
base64 encoding. In practice, "SVGA" (800x600) images are typically around
19+
40kB even though the "capture_buffer_size" (theoretical maximum size) is
20+
(width*height/5) bytes or 96kB.
1621
"""
1722

18-
import os
19-
import time
2023
import binascii
24+
import ssl
25+
import time
26+
from secrets import secrets # pylint: disable=no-name-in-module
2127

2228
import board
2329
import busio
2430
import wifi
2531
import socketpool
26-
import ssl
27-
import adafruit_ov2640
28-
from secrets import secrets
2932
import adafruit_minimqtt.adafruit_minimqtt as MQTT
3033
from adafruit_io.adafruit_io import IO_MQTT
34+
import adafruit_ov2640
3135

3236
feed_name = "image"
3337

examples/ov2640_bmp_sd_kaluga1_3.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -127,22 +127,22 @@ def exists(filename):
127127
try:
128128
os.stat(filename)
129129
return True
130-
except OSError as e:
130+
except OSError:
131131
return False
132132

133133

134134
_image_counter = 0
135135

136136

137137
def open_next_image(extension="jpg"):
138-
global _image_counter
138+
global _image_counter # pylint: disable=global-statement
139139
while True:
140140
filename = f"/sd/img{_image_counter:04d}.{extension}"
141141
_image_counter += 1
142142
if exists(filename):
143143
continue
144144
print("#", filename)
145-
return open(filename, "wb")
145+
return open(filename, "wb") # pylint: disable=consider-using-with
146146

147147

148148
### These routines are for writing BMP files in the RGB565 or BGR565 formats.
@@ -197,19 +197,19 @@ def put_padding(length):
197197
put_dword(144179) # 2.2 gamma blue
198198

199199

200-
def capture_image_bmp(bitmap):
200+
def capture_image_bmp(the_bitmap):
201201
with open_next_image("bmp") as f:
202-
swapped = np.frombuffer(bitmap, dtype=np.uint16)
202+
swapped = np.frombuffer(the_bitmap, dtype=np.uint16)
203203
swapped.byteswap(inplace=True)
204-
write_header(f, bitmap.width, bitmap.height, _bitmask_rgb565)
204+
write_header(f, the_bitmap.width, the_bitmap.height, _bitmask_rgb565)
205205
f.write(swapped)
206206

207207

208208
display.auto_refresh = False
209209
old_record_pressed = True
210210

211211
while True:
212-
a_voltage = a.value * a.reference_voltage / 65535
212+
a_voltage = a.value * a.reference_voltage / 65535 # pylint: disable=no-member
213213
cam.capture(bitmap)
214214
bitmap.dirty()
215215

examples/ov2640_directio_kaluga1_3_ili9341.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -116,22 +116,22 @@ def exists(filename):
116116
try:
117117
os.stat(filename)
118118
return True
119-
except OSError as e:
119+
except OSError:
120120
return False
121121

122122

123123
_image_counter = 0
124124

125125

126126
def open_next_image():
127-
global _image_counter
127+
global _image_counter # pylint: disable=global-statement
128128
while True:
129129
filename = f"/sd/img{_image_counter:04d}.jpg"
130130
_image_counter += 1
131131
if exists(filename):
132132
continue
133133
print("#", filename)
134-
return open(filename, "wb")
134+
return open(filename, "wb") # pylint: disable=consider-using-with
135135

136136

137137
def capture_image():
@@ -160,7 +160,7 @@ def main():
160160
display_bus.send(43, struct.pack(">hh", 0, 239))
161161
t0 = time.monotonic_ns()
162162
while True:
163-
a_voltage = a.value * a.reference_voltage / 65535
163+
a_voltage = a.value * a.reference_voltage / 65535 # pylint: disable=no-member
164164
record_pressed = abs(a_voltage - V_RECORD) < 0.05
165165
if record_pressed:
166166
capture_image()

examples/ov2640_jpeg_kaluga1_3.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@
5050
except OSError as e:
5151
print(e)
5252
print(
53-
"A 'read-only filesystem' error occurs if you did not correctly install\nov2640_jpeg_kaluga1_3_boot.py as CIRCUITPY/boot.py and reset the board"
53+
"A 'read-only filesystem' error occurs if you did not correctly install"
54+
"\nov2640_jpeg_kaluga1_3_boot.py as CIRCUITPY/boot.py and reset the board"
5455
)
5556
print("Wrote to CIRCUITPY/jpeg.jpg")

examples/ov2640_jpeg_kaluga1_3_boot.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
V_RECORD = 2.41
1818

1919
a = analogio.AnalogIn(board.IO6)
20-
a_voltage = a.value * a.reference_voltage / 65535
20+
a_voltage = a.value * a.reference_voltage / 65535 # pylint: disable=no-member
2121
if abs(a_voltage - V_MODE) > 0.05: # If mode is NOT pressed...
2222
print("storage writable by CircuitPython")
2323
storage.remount("/", readonly=False)

examples/ov2640_jpeg_sd_kaluga1_3.py

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -95,22 +95,22 @@ def exists(filename):
9595
try:
9696
os.stat(filename)
9797
return True
98-
except OSError as e:
98+
except OSError:
9999
return False
100100

101101

102102
_image_counter = 0
103103

104104

105105
def open_next_image():
106-
global _image_counter
106+
global _image_counter # pylint: disable=global-statement
107107
while True:
108108
filename = f"/sd/img{_image_counter:04d}.jpg"
109109
_image_counter += 1
110110
if exists(filename):
111111
continue
112112
print("#", filename)
113-
return open(filename, "wb")
113+
return open(filename, "wb") # pylint: disable=consider-using-with
114114

115115

116116
def capture_image():
@@ -131,16 +131,12 @@ def capture_image():
131131
cam.colorspace = old_colorspace
132132

133133

134-
def main():
135-
display.auto_refresh = False
136-
while True:
137-
a_voltage = a.value * a.reference_voltage / 65535
138-
record_pressed = abs(a_voltage - V_RECORD) < 0.05
139-
if record_pressed:
140-
capture_image()
141-
cam.capture(bitmap)
142-
bitmap.dirty()
143-
display.refresh(minimum_frames_per_second=0)
144-
145-
146-
main()
134+
display.auto_refresh = False
135+
while True:
136+
a_voltage = a.value * a.reference_voltage / 65535 # pylint: disable=no-member
137+
record_pressed = abs(a_voltage - V_RECORD) < 0.05
138+
if record_pressed:
139+
capture_image()
140+
cam.capture(bitmap)
141+
bitmap.dirty()
142+
display.refresh(minimum_frames_per_second=0)

examples/ov2640_simpletest.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
import sys
2424
import time
2525

26-
import digitalio
2726
import busio
2827
import board
2928

0 commit comments

Comments
 (0)