Skip to content

Commit bcc4a36

Browse files
authored
Merge pull request #149 from lucidcode/feature/image-quality
Improve rapid eye movement image quality
2 parents 8a9638e + ac0f065 commit bcc4a36

File tree

5 files changed

+12
-15
lines changed

5 files changed

+12
-15
lines changed

images/settings/network.png

9.43 KB
Loading

release/firmware.bin

-16 Bytes
Binary file not shown.

software/config.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ def __init__(self):
1515
self.default['WiFi'] = False
1616
self.default['WiFiNetworkName'] = "INSPEC"
1717
self.default['WiFiKey'] = "1234567890"
18+
self.default['WiFiImageQuality'] = 50
1819
self.default['PixelFormat'] = 'Grayscale'
1920
self.default['PixelThreshold'] = 6
2021
self.default['PixelRange'] = 6

software/inspec.py

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -118,11 +118,10 @@ def monitor(self):
118118
self.process_api("variance", self.variance)
119119

120120
if (utime.ticks_ms() - self.last_update > 128):
121-
self.send_stream()
122-
123121
face = "1" if self.face.has_face else "0"
124122
data = f'{str(self.peak_variance)};{self.rem.eye_movements};{face};{self.quality.indicator}'
125123
self.comms.send_data(data)
124+
self.send_stream()
126125
self.peak_variance = 0
127126
self.last_update = utime.ticks_ms()
128127

@@ -269,12 +268,8 @@ def process_trigger(self):
269268
def init_stream(self):
270269
try:
271270
self.stream = None
272-
if self.config.get('AccessPoint'):
273-
self.stream = inspec_stream("AccessPoint", self.config.get('AccessPointName'), self.config.get('AccessPointPassword'))
271+
self.stream = inspec_stream(self.config)
274272

275-
if self.config.get('WiFi'):
276-
self.stream = inspec_stream("Station", self.config.get('WiFiNetworkName'), self.config.get('WiFiKey'))
277-
278273
except Exception as e:
279274
self.error = str(e)
280275
print("init_stream error: ", self.error)

software/wifi.py

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,15 @@
55

66
class inspec_stream:
77

8-
def __init__(self, interface, ssid, password):
8+
def __init__(self, config):
9+
self.config = config
910
self.error = None
1011

11-
if interface == "AccessPoint":
12-
self.start_access_point(ssid, password)
12+
if self.config.get('WiFi'):
13+
self.connect_network(self.config.get('WiFiNetworkName'), self.config.get('WiFiKey'))
1314

14-
if interface == "Station":
15-
self.connect_network(ssid, password)
15+
if self.config.get('AccessPoint'):
16+
self.start_access_point(self.config.get('AccessPointName'), self.config.get('AccessPointPassword'))
1617

1718
self.ip = self.wlan.ifconfig()[0]
1819
print("IP", self.ip)
@@ -35,9 +36,9 @@ def connect_network(self, ssid, password):
3536
attempts = 0
3637
while not self.wlan.isconnected():
3738
print("Connecting to " + ssid)
38-
time.sleep_ms(1000)
39+
time.sleep_ms(1024)
3940
attempts = attempts + 1
40-
if attempts > 10:
41+
if attempts > 12:
4142
raise Exception("Failed to connect to " + ssid)
4243

4344
def start_server(self, id):
@@ -91,7 +92,7 @@ def send_image(self, image):
9192
if self.connected[0] == False:
9293
return
9394

94-
cframe = image.to_jpeg(quality=35, copy=True)
95+
cframe = image.to_jpeg(quality=self.config.get('WiFiImageQuality'), copy=True)
9596
header = (
9697
"\r\n--inspec\r\n"
9798
"Content-Type: image/jpeg\r\n"

0 commit comments

Comments
 (0)