Skip to content

Commit ec18504

Browse files
committed
fix: change various things for testing on non-brain hardware
1 parent 5eeb855 commit ec18504

4 files changed

Lines changed: 14 additions & 11 deletions

File tree

robot/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
April tags a marker recognition system. Also performs convince functions for use
44
by shepherd"""
55

6-
import importlib
6+
import importlib.util
77

88
has_picamera2 = importlib.util.find_spec("picamera2") is not None
99

robot/greengiant.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -234,15 +234,14 @@ def set_5v_acc_power(self, new_state):
234234
self._bus.write_byte_data(_GG_I2C_ADDR, _GG_ENABLE_5V_ACC, int(new_state))
235235
else:
236236
# for GG versions 5v power is always enabled
237-
raise IOError(f"Attempted to set 5v power to {new_state} on an unsupported BrainBox.")
237+
print(f"WARN: Attempted to set 5v power to {new_state} on an unsupported BrainBox.")
238238

239239
def get_5v_acc_power(self):
240240
if self._version >= 10:
241241
return bool(self._bus.read_byte_data(_GG_I2C_ADDR, _GG_ENABLE_5V_ACC))
242242
else:
243243
# for GG versions 5v power is always enabled
244-
raise IOError(f"Attempted to get 5v power on an unsupported BrainBox.")
245-
244+
print(f"WARN: Attempted to set 5v power to {new_state} on an unsupported BrainBox.")
246245

247246
def set_user_led(self, on):
248247
self._bus.write_byte_data(_GG_I2C_ADDR, _GG_USER_LED, int(on))

robot/mock_picamera2.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,28 +6,33 @@ class Picamera2:
66
camera_properties = {"Model": "Mock Picamera2"}
77

88
def __init__(self):
9-
pass
9+
print("mock_picamera2.Picamera2.__init__()")
1010

1111
def configure(self, _):
12-
pass
12+
print("mock_picamera2.Picamera2.configure(_)")
1313

1414
def start(self):
15+
print("mock_picamera2.Picamera2.start()")
1516
pass
1617

1718
def stop(self):
19+
print("mock_picamera2.Picamera2.stop()")
1820
pass
1921

2022
def close(self):
23+
print("mock_picamera2.Picamera2.close()")
2124
pass
2225

2326
def capture_array(self):
27+
print("mock_picamera2.Picamera2.capture_array(): None")
2428
return None
2529

2630
def create_still_configuration(self, _):
31+
print("mock_picamera2.Picamera2.create_still_configuration(_): {}")
2732
return {}
2833

2934
@staticmethod
3035
def set_logging(_):
31-
pass
36+
print("mock_picamera2.Picamera2.set_logging(_)")
3237

3338
print("<<< WARN: using mock picamera2 >>>")

robot/reset.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ def reset():
1919
Used by Shepherd when the Stop button is pressed.
2020
"""
2121
bus = SMBus(1)
22-
version = gg.GreenGiantInternal(bus).get_version()
22+
internal = gg.GreenGiantInternal(bus)
23+
version = internal.get_version()
2324

2425
if version < 10:
2526
c.CytronBoard(1).stop()
@@ -31,10 +32,8 @@ def reset():
3132
gg.GreenGiantGPIOPinList(bus, version, 5, gg._GG_GPIO_GPIO_BASE, gg._GG_GPIO_PWM_BASE).off()
3233

3334
# probably should wrap this all up in a .off()
34-
internal = gg.GreenGiantInternal(bus)
3535
internal.enable_motors(False)
36-
#internal.set_motor_power(False)
37-
internal.set_12v_acc_power(False) # Not sure, should this be controlled by user?
36+
internal.set_12v_acc_power(False)
3837
internal.set_5v_acc_power(False)
3938
internal.set_user_led(False)
4039

0 commit comments

Comments
 (0)