Skip to content

Commit

Permalink
Add WirelessModule class
Browse files Browse the repository at this point in the history
  • Loading branch information
ZodiusInfuser committed Dec 12, 2024
1 parent 07a23a1 commit 8fb6c64
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 2 deletions.
6 changes: 4 additions & 2 deletions lib/pimoroni_yukon/modules/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# SPDX-FileCopyrightText: 2023 Christopher Parrott for Pimoroni Ltd
# SPDX-FileCopyrightText: 2025 Christopher Parrott for Pimoroni Ltd
#
# SPDX-License-Identifier: MIT

Expand All @@ -12,6 +12,7 @@
from .quad_servo_direct import QuadServoDirectModule
from .quad_servo_reg import QuadServoRegModule
from .serial_servo import SerialServoModule
from .rm2_wireless import WirelessModule


KNOWN_MODULES = (
Expand All @@ -24,4 +25,5 @@
ProtoPotModule,
QuadServoDirectModule,
QuadServoRegModule,
SerialServoModule)
SerialServoModule,
WirelessModule)
31 changes: 31 additions & 0 deletions lib/pimoroni_yukon/modules/rm2_wireless.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# SPDX-FileCopyrightText: 2025 Christopher Parrott for Pimoroni Ltd
#
# SPDX-License-Identifier: MIT

from .common import YukonModule, ADC_LOW, ADC_FLOAT, IO_LOW, IO_HIGH


class WirelessModule(YukonModule):
NAME = "RM2 Wireless"

# | ADC1 | ADC2 | SLOW1 | SLOW2 | SLOW3 | Module | Condition (if any) |
# |-------|-------|-------|-------|-------|----------------------|-----------------------------|
# | LOW | FLOAT | 1 | 0 | 1 | RM2 Wireless | |
@staticmethod
def is_module(adc1_level, adc2_level, slow1, slow2, slow3):
return adc1_level == ADC_LOW and adc2_level == ADC_FLOAT and slow1 is IO_HIGH and slow2 is IO_LOW and slow3 is IO_HIGH

def __init__(self):
super().__init__()

try:
import network
except ImportError:
raise RuntimeError("This build does not contain wireless networking support. Please flash your Yukon with a build that supports wireless in order to use this module.")

def initialise(self, slot, adc1_func, adc2_func):
if slot.ID != 5:
raise RuntimeError("Currently the wireless module is only supported in Slot 5. Please relocate your module.")

# Pass the slot and adc functions up to the parent now that module specific initialisation has finished
super().initialise(slot, adc1_func, adc2_func)

0 comments on commit 8fb6c64

Please sign in to comment.