Skip to content

Commit

Permalink
Improved ESPNow boards IDs structure. Extra validation to ESPNow data…
Browse files Browse the repository at this point in the history
… sent to display
  • Loading branch information
casainho committed Apr 5, 2024
1 parent 6c09c29 commit a8e511e
Show file tree
Hide file tree
Showing 20 changed files with 588 additions and 152 deletions.
Empty file added __init__.py
Empty file.
Empty file added diy_display/__init__.py
Empty file.
5 changes: 2 additions & 3 deletions diy_display/firmware/front_lights_espnow.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import espnow as ESPNow
from ...firmware_common.boards_ids import BoardsIds

class FrontLights(object):

def __init__(self, _espnow, mac_address, system_data):
self._system_data = system_data
self.message_id = 16 # front lights ESPNow messages ID

self._espnow = _espnow
self._peer = ESPNow.Peer(mac=bytes(mac_address), channel=1)

Expand All @@ -15,7 +14,7 @@ def update(self):
# add peer before sending the message
self._espnow.peers.append(self._peer)

self._espnow.send(f"{self.message_id} {int(self._system_data.front_lights_board_pins_state)}")
self._espnow.send(f"{int(BoardsIds.FRONT_LIGHTS)} {int(self._system_data.front_lights_board_pins_state)}")

# now remove the peer
self._espnow.peers.remove(self._peer)
Expand Down
Loading

0 comments on commit a8e511e

Please sign in to comment.