Skip to content

Commit 145bf7b

Browse files
committed
Small changes, fixed servo instantiation error on beta board
1 parent 28abebe commit 145bf7b

File tree

3 files changed

+14
-4
lines changed

3 files changed

+14
-4
lines changed

XRPLib/board.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,16 @@ def led_blink(self, frequency: int=0):
110110
self.is_led_blinking = False
111111

112112
def set_rgb_led(self, r:int, g:int, b:int):
113+
"""
114+
Sets the Neopixel RGB LED to a specified color. Throws a NotImplementedError on the XRP Beta
115+
116+
:param r: The amount of red in the desired color
117+
:type r: int
118+
:param g: The amount of green in the desired color
119+
:type g: int
120+
:param b: The amount of blue in the desired color
121+
:type b: int
122+
"""
113123
if "rgb_led" in self.__dict__:
114124
self.rgb_led[0] = (r, g, b)
115125
self.rgb_led.write()

XRPLib/reflectance.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22

33
class Reflectance:
44

5-
6-
75
_DEFAULT_REFLECTANCE_INSTANCE = None
86

97
@classmethod

XRPLib/servo.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
from machine import Pin, PWM
2+
import sys
23

34
class Servo:
45

@@ -22,11 +23,12 @@ def get_default_servo(cls, index:int):
2223
if cls._DEFAULT_SERVO_TWO_INSTANCE is None:
2324
cls._DEFAULT_SERVO_TWO_INSTANCE = cls("SERVO_2")
2425
servo = cls._DEFAULT_SERVO_TWO_INSTANCE
25-
elif index == 3:
26+
return Exception("Invalid servo index")
27+
elif index == 3 and "RP2350" in sys.implementation._machine:
2628
if cls._DEFAULT_SERVO_THREE_INSTANCE is None:
2729
cls._DEFAULT_SERVO_THREE_INSTANCE = cls("SERVO_3")
2830
servo = cls._DEFAULT_SERVO_THREE_INSTANCE
29-
elif index == 4:
31+
elif index == 4 and "RP2350" in sys.implementation._machine:
3032
if cls._DEFAULT_SERVO_FOUR_INSTANCE is None:
3133
cls._DEFAULT_SERVO_FOUR_INSTANCE = cls("SERVO_4")
3234
servo = cls._DEFAULT_SERVO_FOUR_INSTANCE

0 commit comments

Comments
 (0)