summaryrefslogtreecommitdiffstats
path: root/baresp.py
diff options
context:
space:
mode:
authorFlorian Baumann <derflob@derflob.de>2017-10-03 13:27:56 +0200
committerFlorian Baumann <derflob@derflob.de>2017-10-04 20:42:31 +0200
commitf6a12c03c221624418d749b7c9a0cce80d9271d8 (patch)
treedabf8a5beca3e2beb0ac2c583b11871f49528993 /baresp.py
parent009fedfe380a1d2a3069a3e9f57d0a18ceb77be6 (diff)
downloadBarESP-f6a12c03c221624418d749b7c9a0cce80d9271d8.tar.gz
BarESP-f6a12c03c221624418d749b7c9a0cce80d9271d8.tar.bz2
some clean-upHEADmaster
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)