summaryrefslogtreecommitdiffstats
path: root/baresp.py
diff options
context:
space:
mode:
Diffstat (limited to 'baresp.py')
-rw-r--r--baresp.py21
1 files changed, 9 insertions, 12 deletions
diff --git a/baresp.py b/baresp.py
index 30d5001..b58c2e2 100644
--- a/baresp.py
+++ b/baresp.py
@@ -76,10 +76,10 @@ class BarESP():
if (not machine.reset_cause() == machine.DEEPSLEEP_RESET):
self._log.info('non DS reset')
- self.adxl.setup()
else:
self._log.info('DS Reset')
- self.adxl.setup()
+
+ self.adxl.setup()
self.adxl.activity_intr(False)
self.adxl.inactivity_intr(True)
@@ -96,9 +96,8 @@ class BarESP():
if (self.adxl.is_active()):
BCEN_PIN.on()
- self.bar.state = BarState.WAIT_FOR_BARCODE
-
self.connect()
+ self.bar.state = BarState.WAIT_FOR_BARCODE
self.esp.state = ESPState.IDLE_ON
else:
@@ -106,28 +105,28 @@ class BarESP():
self.deepsleep(0)
elif (self.esp.state == ESPState.IDLE_ON):
- #self._log.debug(b'IDLE_ON\n')
+ #self._log.debug(b'IDLE_ON')
if (not self.adxl.is_active()):
if (self.bar.state == BarState.WAIT_FOR_BARCODE):
BCEN_PIN.off()
self.bar.state = BarState.OFF
- self._log.debug(b'->BAR_OFF\n')
+ self._log.debug(b'->BAR_OFF')
if (len(self._cache) == 0):
if (not self.bar.state == BarState.READING_BARCODE):
self.esp.state = ESPState.WAIT_FOR_ACTIVITY
- self._log.debug(b'->WFA\n')
+ self._log.debug(b'->WFA')
if (len(self._cache) > 0):
self.esp.state = ESPState.PENDING_DATA
- self._log.debug(b'->PDb\n')
+ self._log.debug(b'->PDb')
elif (self.esp.state == ESPState.PENDING_DATA):
if (len(self._cache) == 0):
self.esp.state = ESPState.IDLE_ON
self.ack_data_sent()
- self._log.debug(b'->IO\n')
+ self._log.debug(b'->IO')
else:
if (not (self.wlan.active() and self.wlan.isconnected())):
@@ -138,7 +137,6 @@ class BarESP():
bc = self._cache.pop(0)
self._log.debug(b'PD.pop')
self._log.debug(bc)
- self._log.debug(b'\n')
try:
s = usocket.socket()
@@ -147,7 +145,7 @@ class BarESP():
s.close()
utime.sleep_ms(100)
except Exception as e:
- self._log.debug(b'Sending bc failed.\n')
+ self._log.debug(b'Sending bc failed.')
self._log.debug(e)
self._cache.append(bc)
break
@@ -162,7 +160,6 @@ class BarESP():
def run_bar(self):
if (self.bar.state == BarState.WAIT_FOR_BARCODE):
bc = self.try_barcode()
-
if (bc):
self._cache.append(bc)