Skip to content

Commit f30a47f

Browse files
committed
repl works
1 parent b7966b6 commit f30a47f

File tree

1 file changed

+58
-55
lines changed

1 file changed

+58
-55
lines changed

src/flight-software/repl.py

Lines changed: 58 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -44,23 +44,25 @@
4444
software_version=__version__,
4545
)
4646

47+
watchdog = Watchdog(logger, board.WDT_WDI)
48+
watchdog.pet()
49+
50+
logger.debug("Initializing Config")
51+
config: Config = Config("config.json")
4752

4853
def get_temp(sensor):
4954
for i in range(1000):
5055
print(sensor.get_temperature().value)
5156
time.sleep(0.1)
5257

53-
initialize_pin(logger, board.SPI0_CS0, digitalio.Direction.OUTPUT, True),
58+
SPI0_CS0 = initialize_pin(logger, board.SPI0_CS0, digitalio.Direction.OUTPUT, True)
59+
SPI1_CS0 = initialize_pin(logger, board.SPI1_CS0, digitalio.Direction.OUTPUT, True)
5460

55-
watchdog = Watchdog(logger, board.WDT_WDI)
56-
watchdog.pet()
5761

58-
logger.debug("Initializing Config")
59-
config: Config = Config("config.json")
6062

61-
mux_reset = initialize_pin(
62-
logger, board.MUX_RESET, digitalio.Direction.OUTPUT, False
63-
)
63+
#manually set the pin high to allow mcp to be detected
64+
GPIO_RESET = initialize_pin(logger, board.GPIO_EXPANDER_RESET, digitalio.Direction.OUTPUT, True),
65+
6466

6567

6668
i2c1 = initialize_i2c_bus(
@@ -78,10 +80,10 @@ def get_temp(sensor):
7880
)
7981

8082

81-
mcp = MCP23017(i2c1)
83+
mcp = MCP23017(i2c1) # x1e or x52 or 0x6b
8284

8385

84-
#GPB
86+
# #GPB
8587
FACE4_ENABLE = mcp.get_pin(8)
8688
FACE0_ENABLE = mcp.get_pin(9)
8789
FACE1_ENABLE = mcp.get_pin(10)
@@ -101,26 +103,18 @@ def get_temp(sensor):
101103
RF2_IO0 = mcp.get_pin(6)
102104
RF2_IO3 = mcp.get_pin(7)
103105

104-
# This defines the direction of the GPIO pins
106+
# # This defines the direction of the GPIO pins
105107
FACE4_ENABLE.direction = digitalio.Direction.OUTPUT
106108
FACE0_ENABLE.direction = digitalio.Direction.OUTPUT
107109
FACE1_ENABLE.direction = digitalio.Direction.OUTPUT
108110
FACE2_ENABLE.direction = digitalio.Direction.OUTPUT
109111
FACE3_ENABLE.direction = digitalio.Direction.OUTPUT
110-
ENAB_RF.direction = digitalio.Direction.OUTPUT
111-
VBUS_RESET.direction = digitalio.Direction.OUTPUT
112112
ENABLE_HEATER.direction = digitalio.Direction.OUTPUT
113113
PAYLOAD_PWR_ENABLE.direction = digitalio.Direction.OUTPUT
114114

115-
watchdog = Watchdog(logger, board.WDT_WDI)
116-
watchdog.pet()
117-
118-
logger.debug("Initializing Config")
119-
config: Config = Config("config.json")
120115

121-
mux_reset = initialize_pin(logger, board.MUX_RESET, digitalio.Direction.OUTPUT, False)
122116

123-
# TODO(nateinaction): fix spi init
117+
# # TODO(nateinaction): fix spi init
124118
spi0 = _spi_init(
125119
logger,
126120
board.SPI0_SCK,
@@ -139,23 +133,22 @@ def get_temp(sensor):
139133
logger,
140134
config.radio,
141135
spi1,
142-
initialize_pin(logger, board.SPI1_CS0, digitalio.Direction.OUTPUT, True),
136+
SPI1_CS0,
143137
initialize_pin(logger, board.RF2_RST, digitalio.Direction.OUTPUT, True),
144-
initialize_pin(logger, board.RF2_IO0, digitalio.Direction.OUTPUT, True),
138+
RF2_IO0,
145139
2.4,
146140
initialize_pin(logger, board.RF2_TX_EN, digitalio.Direction.OUTPUT, False),
147141
initialize_pin(logger, board.RF2_RX_EN, digitalio.Direction.OUTPUT, False),
148142
)
149143

150144

151-
152-
sleep_helper = SleepHelper(logger, config, watchdog)
145+
#sleep_helper = SleepHelper(logger, config, watchdog)
153146

154147
uhf_radio = RFM9xManager(
155148
logger,
156149
config.radio,
157150
spi0,
158-
initialize_pin(logger, board.SPI0_CS0, digitalio.Direction.OUTPUT, True),
151+
SPI0_CS0,
159152
initialize_pin(logger, board.RF1_RST, digitalio.Direction.OUTPUT, True),
160153
)
161154

@@ -184,13 +177,6 @@ def get_temp(sensor):
184177
sband_radio,
185178
)
186179

187-
## Initialize the MCP23017 GPIO Expander and its pins ##
188-
GPIO_RESET = initialize_pin(
189-
logger, board.GPIO_EXPANDER_RESET, digitalio.Direction.OUTPUT, True
190-
)
191-
192-
193-
194180

195181

196182
# Face Control Helper Functions
@@ -219,12 +205,15 @@ def all_faces_on():
219205
## Face Sensor Stuff ##
220206

221207
# This is the TCA9548A I2C Multiplexer
208+
209+
mux_reset = initialize_pin(logger, board.MUX_RESET, digitalio.Direction.OUTPUT, False)
222210
all_faces_on()
211+
time.sleep(0.1)
223212
mux_reset.value = True
224-
tca = TCA9548A(i2c1, address=int(0x77))
213+
tca = TCA9548A(i2c0, address=int(0x77)) #all 3 connected to high
225214

226215

227-
# Light Sensors
216+
# # Light Sensors
228217
light_sensors = []
229218
try:
230219
sensor = VEML7700Manager(logger, tca[0])
@@ -251,7 +240,7 @@ def all_faces_on():
251240
logger.debug("WARNING!!! Light sensor 3 failed to initialize")
252241
light_sensors.append(None)
253242
try:
254-
sensor = VEML7700Manager(logger, tca[4])
243+
sensor = VEML7700Manager(logger, tca[5])
255244
light_sensors.append(sensor)
256245
except Exception:
257246
logger.debug("WARNING!!! Light sensor 4 failed to initialize")
@@ -261,20 +250,20 @@ def all_faces_on():
261250
# Onboard Temp Sensors
262251
temp_sensors = []
263252

264-
# Direct I2C sensors
265-
try:
266-
temp_sensor5 = MCP9808Manager(logger, i2c0, addr=25) # Antenna Board
267-
except Exception:
268-
logger.debug("WARNING!!! Temp sensor 5 (Antenna Board) failed")
269-
temp_sensor5 = None
270-
temp_sensors.append(temp_sensor5)
271-
272-
try:
273-
temp_sensor6 = MCP9808Manager(logger, i2c1, addr=27) # Flight Controller Board
274-
except Exception:
275-
logger.debug("WARNING!!! Temp sensor 6 (Flight Controller Board) failed")
276-
temp_sensor6 = None
277-
temp_sensors.append(temp_sensor6)
253+
# # Direct I2C sensors
254+
# try:
255+
# temp_sensor5 = MCP9808Manager(logger, i2c0, addr=40) # Antenna Board
256+
# except Exception:
257+
# logger.debug("WARNING!!! Temp sensor (Antenna Board) failed")
258+
# temp_sensor5 = None
259+
# temp_sensors.append(temp_sensor5)
260+
261+
# try:
262+
# temp_sensor6 = MCP9808Manager(logger, i2c1, addr=41) # Flight Controller Board
263+
# except Exception:
264+
# logger.debug("WARNING!!! Temp sensor (Flight Controller Board) failed")
265+
# temp_sensor6 = None
266+
# temp_sensors.append(temp_sensor6)
278267

279268
# TCA-connected temp sensors
280269
try:
@@ -287,7 +276,7 @@ def all_faces_on():
287276
sensor = MCP9808Manager(logger, tca[1], addr=27)
288277
temp_sensors.append(sensor)
289278
except Exception:
290-
logger.debug("WARNING!!! Temp sensor 1]) failed")
279+
logger.debug("WARNING!!! Temp sensor 1 failed")
291280
temp_sensors.append(None)
292281
try:
293282
sensor = MCP9808Manager(logger, tca[2], addr=27)
@@ -299,17 +288,31 @@ def all_faces_on():
299288
sensor = MCP9808Manager(logger, tca[3], addr=27)
300289
temp_sensors.append(sensor)
301290
except Exception:
302-
logger.debug("WARNING!!! Temp sensor3 failed")
291+
logger.debug("WARNING!!! Temp sensor 3 failed")
292+
temp_sensors.append(None)
293+
try:
294+
sensor = MCP9808Manager(logger, tca[5], addr=24)
295+
temp_sensors.append(sensor)
296+
except Exception:
297+
logger.debug("WARNING!!! Temp sensor 4 failed (Z- Face Bottom pins")
303298
temp_sensors.append(None)
299+
300+
#these are the bottom 6 pins on the z- face connection, uncomment if that is where you plug in a face for the z- board
301+
# try:
302+
# sensor = MCP9808Manager(logger, tca[6], addr=24)
303+
# temp_sensors.append(sensor)
304+
# except Exception:
305+
# logger.debug("WARNING!!! Temp sensor 4 failed (Z- Face Top pins)")
306+
# # temp_sensors.append(None)
304307
try:
305-
sensor = MCP9808Manager(logger, tca[4], addr=27)
308+
sensor = MCP9808Manager(logger, tca[7], addr=25)
306309
temp_sensors.append(sensor)
307310
except Exception:
308-
logger.debug("WARNING!!! Temp sensor 4 failed")
311+
logger.debug("WARNING!!! Temp sensor 5 failed (Antenna Board)")
309312
temp_sensors.append(None)
310313

311-
battery_power_monitor: PowerMonitorProto = INA219Manager(logger, i2c1, 0x40)
312-
solar_power_monitor: PowerMonitorProto = INA219Manager(logger, i2c1, 0x44)
314+
battery_power_monitor: PowerMonitorProto = INA219Manager(logger, i2c0, 0x40)
315+
solar_power_monitor: PowerMonitorProto = INA219Manager(logger, i2c0, 0x41)
313316

314317
## Init Misc Pins ##
315318
burnwire_heater_enable = initialize_pin(

0 commit comments

Comments
 (0)