Skip to content

Commit 4fc060f

Browse files
Mikefly123Copilothrfarmer
authored
Update repl Functionality (#20)
* Mirror main.py Boot to repl.py * Update Readme and Appease Linter * Apply suggestions from code review Co-authored-by: Copilot <[email protected]> * Update repl.py Removed unnecessary initial boot sequence Co-authored-by: aychar <[email protected]> * Appeased the linter --------- Co-authored-by: Copilot <[email protected]> Co-authored-by: aychar <[email protected]>
1 parent 2408ac8 commit 4fc060f

File tree

2 files changed

+94
-4
lines changed

2 files changed

+94
-4
lines changed

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,11 @@
33
[![License](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE)
44
![CI](https://github.com/proveskit/CircuitPython_RP2040_v4/actions/workflows/ci.yaml/badge.svg)
55

6-
Software for the v4 PROVES Kit flight control board.
6+
This is the reference software for the v4x PROVES Kit Flight Controller boards. Clone this repository and use the `make install ...` tooling to get your v4x Flight Controller Board up and running!
77

88
# Development Getting Started
99
We welcome contributions, so please feel free to join us. If you have any questions about contributing please open an issue or a discussion.
1010

1111
You can find our Getting Started Guide [here](https://github.com/proveskit/pysquared/blob/main/docs/dev-guide.md).
12+
13+
If you have a mission specific usecase for the CircuitPython Flight Software you can fork this repo and use it as a baseline for developing your own system!

repl.py

Lines changed: 91 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,101 @@
1+
"""
2+
Built for the PySquared FC Board V4x
3+
Published: May, 2025
4+
"""
5+
6+
import digitalio
7+
from busio import SPI
8+
9+
try:
10+
from board_definitions import proveskit_rp2040_v4 as board
11+
except ImportError:
12+
import board
13+
14+
import os
15+
16+
import lib.pysquared.functions as functions
117
import lib.pysquared.nvm.register as register
18+
from lib.pysquared.cdh import CommandDataHandler
219
from lib.pysquared.config.config import Config
20+
from lib.pysquared.hardware.busio import _spi_init, initialize_i2c_bus
21+
from lib.pysquared.hardware.digitalio import initialize_pin
22+
from lib.pysquared.hardware.imu.manager.lsm6dsox import LSM6DSOXManager
23+
from lib.pysquared.hardware.magnetometer.manager.lis2mdl import LIS2MDLManager
24+
from lib.pysquared.hardware.radio.manager.rfm9x import RFM9xManager
325
from lib.pysquared.logger import Logger
426
from lib.pysquared.nvm.counter import Counter
27+
from lib.pysquared.nvm.flag import Flag
28+
from lib.pysquared.rtc.manager.microcontroller import MicrocontrollerManager
529
from lib.pysquared.satellite import Satellite
30+
from lib.pysquared.sleep_helper import SleepHelper
31+
from lib.pysquared.watchdog import Watchdog
32+
from version import __version__
33+
34+
rtc = MicrocontrollerManager()
635

736
logger: Logger = Logger(
837
error_counter=Counter(index=register.ERRORCNT),
938
colorized=False,
1039
)
11-
config: Config = Config("config.json")
12-
logger.info("Initializing a cubesat object as `c` in the REPL...")
13-
c: Satellite = Satellite(logger, config)
40+
41+
logger.info(
42+
"Booting",
43+
hardware_version=os.uname().version,
44+
software_version=__version__,
45+
)
46+
47+
try:
48+
watchdog = Watchdog(logger, board.WDT_WDI)
49+
watchdog.pet()
50+
51+
logger.debug("Initializing Config")
52+
config: Config = Config("config.json")
53+
54+
# TODO(nateinaction): fix spi init
55+
spi0: SPI = _spi_init(
56+
logger,
57+
board.SPI0_SCK,
58+
board.SPI0_MOSI,
59+
board.SPI0_MISO,
60+
)
61+
62+
radio = RFM9xManager(
63+
logger,
64+
config.radio,
65+
Flag(index=register.FLAG, bit_index=7),
66+
spi0,
67+
initialize_pin(logger, board.SPI0_CS0, digitalio.Direction.OUTPUT, True),
68+
initialize_pin(logger, board.RF1_RST, digitalio.Direction.OUTPUT, True),
69+
)
70+
71+
i2c1 = initialize_i2c_bus(
72+
logger,
73+
board.I2C1_SCL,
74+
board.I2C1_SDA,
75+
100000,
76+
)
77+
78+
magnetometer = LIS2MDLManager(logger, i2c1)
79+
80+
imu = LSM6DSOXManager(logger, i2c1, 0x6B)
81+
82+
c = Satellite(logger, config)
83+
84+
sleep_helper = SleepHelper(c, logger, watchdog, config)
85+
86+
cdh = CommandDataHandler(config, logger, radio)
87+
88+
f = functions.functions(
89+
c,
90+
logger,
91+
config,
92+
sleep_helper,
93+
radio,
94+
magnetometer,
95+
imu,
96+
watchdog,
97+
cdh,
98+
)
99+
100+
except Exception as e:
101+
logger.critical("An exception occurred within repl.py", e)

0 commit comments

Comments
 (0)