Skip to content

Commit

Permalink
Rename wireless module for clarity
Browse files Browse the repository at this point in the history
  • Loading branch information
ZodiusInfuser committed Dec 17, 2024
1 parent 64e1dc6 commit de3b0e5
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 26 deletions.
16 changes: 8 additions & 8 deletions docs/modules/rm2_wireless.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,27 +13,27 @@ This is the library reference for the [RM2 Wireless Module for Yukon](https://pi

## Getting Started

To start using a Wireless Module, you first need to import the class from `pimoroni_yukon.modules`.
To start using a RM2 Wireless Module, you first need to import the class from `pimoroni_yukon.modules`.

```python
from pimoroni_yukon.modules import WirelessModule
from pimoroni_yukon.modules import RM2WirelessModule
```

Then create an instance of `WirelessModule`. This will also confirm that you have a wireless capable build flashed to your Yukon.
Then create an instance of `RM2WirelessModule`. This will also confirm that you have a wireless capable build flashed to your Yukon.

```python
module = WirelessModule()
module = RM2WirelessModule()
```


## Initialising the Module

As with all Yukon modules, `WirelessModule` must be initialised before it can be used. This is achieved by first registering the module with the `Yukon` class, with the slot it is attached to.
As with all Yukon modules, `RM2WirelessModule` must be initialised before it can be used. This is achieved by first registering the module with the `Yukon` class, with the slot it is attached to.

```python
from pimoroni_yukon import SLOT5 as SLOT # Only SLOT5 supports the RM2 Wireless Module at present

# Import and set up Yukon and WirelessModule instances
# Import and set up Yukon and RM2WirelessModule instances

yukon.register_with_slot(module, SLOT)
```
Expand All @@ -44,7 +44,7 @@ Then `Yukon` can verify and initialise its modules.
yukon.verify_and_initialise()
```

This checks each slot on the board to see if the modules expected by your program are physically attached to the board. Only if they match will the `WirelessModule` be initialised.
This checks each slot on the board to see if the modules expected by your program are physically attached to the board. Only if they match will the `RM2WirelessModule` be initialised.

The RM2 Wireless Module is now ready to use. It can be interacted with using Micropython's `network` libraries, see Raspberry Pi's [Pico W tutorial](https://projects.raspberrypi.org/en/projects/get-started-pico-w/2).

Expand All @@ -71,6 +71,6 @@ NAME = "RM2 Wireless"
is_module(adc1_level: int, adc2_level: int, slow1: bool, slow2: bool, slow3: bool) -> bool

# Initialisation
WirelessModule()
RM2WirelessModule()
initialise(slot: SLOT, adc1_func: Callable, adc2_func: Callable) -> None
```
6 changes: 3 additions & 3 deletions examples/modules/rm2_wireless/cheerlights.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from pimoroni_yukon import Yukon
from pimoroni_yukon import SLOT2 as STRIP_SLOT
from pimoroni_yukon import SLOT5 as RM2_SLOT
from pimoroni_yukon.modules import LEDStripModule, WirelessModule
from pimoroni_yukon.modules import LEDStripModule, RM2WirelessModule


"""
Expand Down Expand Up @@ -41,13 +41,13 @@
STRIP_SM,
LEDS_PER_STRIP,
BRIGHTNESS)
wireless = WirelessModule() # Create a WirelessModule object
wireless = RM2WirelessModule() # Create a RM2WirelessModule object


# Wrap the code in a try block, to catch any exceptions (including KeyboardInterrupt)
try:
yukon.register_with_slot(leds, STRIP_SLOT) # Register the LEDStripModule object with the slot
yukon.register_with_slot(wireless, RM2_SLOT) # Register the WirelessModule object with the slot
yukon.register_with_slot(wireless, RM2_SLOT) # Register the RM2WirelessModule object with the slot
yukon.verify_and_initialise() # Verify that the modules are attached to Yukon, and initialise them

wlan = network.WLAN(network.STA_IF) # Create a new network object for interacting with WiFi
Expand Down
10 changes: 5 additions & 5 deletions examples/modules/rm2_wireless/detect_module.py
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
from pimoroni_yukon import Yukon
from pimoroni_yukon import SLOT5 as SLOT
from pimoroni_yukon.modules import WirelessModule
from pimoroni_yukon.modules import RM2WirelessModule

"""
A boilerplate example showing how to detect if the RM2 Wireless Module
is attached to Yukon prior to performing any wireless operations.
"""

# Variables
yukon = Yukon() # Create a new Yukon object, with a lower voltage limit set
module = WirelessModule() # Create a WirelessModule object
yukon = Yukon() # Create a new Yukon object, with a lower voltage limit set
module = RM2WirelessModule() # Create a RM2WirelessModule object

# Wrap the code in a try block, to catch any exceptions (including KeyboardInterrupt)
try:
yukon.register_with_slot(module, SLOT) # Register the WirelessModule object with the slot
yukon.verify_and_initialise() # Verify that a WirelessModule is attached to Yukon, and initialise it
yukon.register_with_slot(module, SLOT) # Register the RM2WirelessModule object with the slot
yukon.verify_and_initialise() # Verify that a RM2WirelessModule is attached to Yukon, and initialise it

# Do wireless things here

Expand Down
12 changes: 6 additions & 6 deletions examples/modules/rm2_wireless/wifi_scan.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import binascii
from pimoroni_yukon import Yukon
from pimoroni_yukon import SLOT5 as SLOT
from pimoroni_yukon.modules import WirelessModule
from pimoroni_yukon.modules import RM2WirelessModule

"""
Periodically scan for available WiFi networks using a RM2 Wireless Module connected to Slot 5,
Expand All @@ -12,17 +12,17 @@
"""

# Constants
SCAN_INTERVAL = 5.0 # The time to sleep between each network scan
SCAN_INTERVAL = 5.0 # The time to sleep between each network scan

# Variables
yukon = Yukon() # Create a new Yukon object, with a lower voltage limit set
module = WirelessModule() # Create a WirelessModule object
yukon = Yukon() # Create a new Yukon object, with a lower voltage limit set
module = RM2WirelessModule() # Create a RM2WirelessModule object


# Wrap the code in a try block, to catch any exceptions (including KeyboardInterrupt)
try:
yukon.register_with_slot(module, SLOT) # Register the WirelessModule object with the slot
yukon.verify_and_initialise() # Verify that a WirelessModule is attached to Yukon, and initialise it
yukon.register_with_slot(module, SLOT) # Register the RM2WirelessModule object with the slot
yukon.verify_and_initialise() # Verify that a RM2WirelessModule is attached to Yukon, and initialise it

wlan = network.WLAN(network.STA_IF) # Create a new network object for interacting with WiFi
wlan.active(True) # Turn on WLAN communications
Expand Down
6 changes: 3 additions & 3 deletions lib/pimoroni_yukon/modules/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
from .proto import ProtoPotModule
from .quad_servo_direct import QuadServoDirectModule
from .quad_servo_reg import QuadServoRegModule
from .rm2_wireless import RM2WirelessModule
from .serial_servo import SerialServoModule
from .rm2_wireless import WirelessModule


KNOWN_MODULES = (
Expand All @@ -25,5 +25,5 @@
ProtoPotModule,
QuadServoDirectModule,
QuadServoRegModule,
SerialServoModule,
WirelessModule)
RM2WirelessModule,
SerialServoModule)
2 changes: 1 addition & 1 deletion lib/pimoroni_yukon/modules/rm2_wireless.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from .common import YukonModule, ADC_LOW, ADC_FLOAT, IO_LOW, IO_HIGH


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

# | ADC1 | ADC2 | SLOW1 | SLOW2 | SLOW3 | Module | Condition (if any) |
Expand Down

0 comments on commit de3b0e5

Please sign in to comment.