From 3234a58a69eac078cff76c45b40b0e4f3c42c79d Mon Sep 17 00:00:00 2001 From: Nate Gay Date: Thu, 3 Apr 2025 17:24:16 -0500 Subject: [PATCH 1/3] Bump pysquared version --- Makefile | 2 +- main.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index 42ef7e4..8348285 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -PYSQUARED_VERSION ?= v2.0.0-alpha-25w14 +PYSQUARED_VERSION ?= v2.0.0-alpha-25w14-2 PYSQUARED ?= git+https://github.com/proveskit/pysquared@$(PYSQUARED_VERSION) .PHONY: all diff --git a/main.py b/main.py index 4196e62..331edb3 100644 --- a/main.py +++ b/main.py @@ -143,9 +143,9 @@ def send_imu_data(): IMUData = [] watchdog.pet() logger.info("IMU has baton") - IMUData = f.get_imu_data() + IMUData = imu.get_gyro_data() watchdog.pet() - f.send(IMUData) + radio.send(IMUData) def main(): f.beacon() From 846355deef9afb9b0dbb8918ad78e4331bd28630 Mon Sep 17 00:00:00 2001 From: Nate Gay Date: Fri, 4 Apr 2025 16:58:16 -0500 Subject: [PATCH 2/3] Update Makefile --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 8348285..dd08543 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -PYSQUARED_VERSION ?= v2.0.0-alpha-25w14-2 +PYSQUARED_VERSION ?= v2.0.0-alpha-25w14-3 PYSQUARED ?= git+https://github.com/proveskit/pysquared@$(PYSQUARED_VERSION) .PHONY: all From f2c010ce4c3c476628a8c425cd74ee498ee5947a Mon Sep 17 00:00:00 2001 From: Nate Gay Date: Fri, 4 Apr 2025 17:27:57 -0500 Subject: [PATCH 3/3] Remove docs, update radio inputs, bump pysquared version, bump sync-time --- Makefile | 2 +- README.md | 61 ++------------------------------------- docs/dev-guide-linux.md | 37 ------------------------ docs/dev-guide-macos.md | 42 --------------------------- docs/dev-guide-windows.md | 58 ------------------------------------- docs/dev-guide.md | 45 ----------------------------- lib/requirements.txt | 2 ++ main.py | 8 ++--- 8 files changed, 10 insertions(+), 245 deletions(-) delete mode 100644 docs/dev-guide-linux.md delete mode 100644 docs/dev-guide-macos.md delete mode 100644 docs/dev-guide-windows.md delete mode 100644 docs/dev-guide.md diff --git a/Makefile b/Makefile index 8348285..0b844fe 100644 --- a/Makefile +++ b/Makefile @@ -32,7 +32,7 @@ pre-commit-install: uv .PHONY: sync-time sync-time: uv ## Syncs the time from your computer to the PROVES Kit board - $(UVX) --from git+https://github.com/proveskit/sync-time@1.0.0 sync-time + $(UVX) --from git+https://github.com/proveskit/sync-time@1.0.1 sync-time .PHONY: fmt fmt: pre-commit-install ## Lint and format files diff --git a/README.md b/README.md index cb260ca..dafb47e 100644 --- a/README.md +++ b/README.md @@ -1,66 +1,11 @@ -# # ProvesKit RP2040 v5 CircuitPython Flight Software +# ProvesKit RP2040 v5 CircuitPython Flight Software [![License](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE) ![CI](https://github.com/proveskit/CircuitPython_RP2040_v5/actions/workflows/ci.yaml/badge.svg) -Software for CircuitPython flight software in the PROVES Kit. - -If this is your first time using CircuitPython, it is highly recommended that you check out Adafruit's [Welcome to CircuitPython](https://learn.adafruit.com/welcome-to-circuitpython/overview?gad_source=1&gbraid=0AAAAADx9JvTRorSR2psQubn32WqebKusM&gclid=CjwKCAiA-Oi7BhA1EiwA2rIu28YArt-jNTE3W3uwE055Tp7hyH9c9pE_NsqIOOh1aopnW00qXGBedRoChysQAvD_BwE) to help you get started! - -# Usage -If you have just received a clean PROVES Board, ensure you have loaded the latest firmware from that board's GitHub Repo. Currently the [latest FC Board firmware](https://github.com/proveskit/flight_controller_board/tree/main/Firmware) is `FC_FIRM_V2.uf2`. +Software for the v5 PROVES Kit flight control board. # Development Getting Started We welcome contributions, so please feel free to join us. If you have any questions about contributing please open an issue or a discussion. -You can find our Getting Started Guide [here](docs/dev-guide.md). - -## Manually Updating CircuitPython Code on a PROVES Board -You can cleanly load new software by doing the following: -1. Clone the branch you wish to put on your board to your local machine. -2. Connect to the target board so it mounts as an external drive. -3. If many files have changed, connect to the target board using a serial terminal and run the following code in the REPL to erase all of the existing code: - ```py - import storage - storage.erase_filesystem() - ``` - > NOTE: If you have only changed one or two files, it is fine to just drag and drop them onto the external drive to overwrite the existing files. -4. The target board will now disappear and remount. Once remounted copy and paste the contents of the flight software folder for the target board from your GitHub repo. -5. When the new files are onboard you can verify that all the hardware on the board is working properly by opening a serial connection and entering the REPL after using `ctrl+c` to interupt the code that is currently running. - -## General Structure: -- **boot.py** This is the code that runs on boot and initializes the stack limit -- **main.py** This code tasks all the functions the satellite should do in a semi-asynchronous manner utilizing the asyncio library -- **safemode.py** This code is unimplemented pending new firmware releases that allow the microconrtoller to perform a routine when in safemode -### pysquared lib -This software library contains all of the libraries required to operate the sensors, PySquared board, and radio module. -- **Big_Data.py** This is a class developed to obtain data from the sensors on the 5 solar faces. Since all the faces maintain the same sensors, this class handles the individual face sensors and returns them all to the main code. -- **flag.py** This is code that allows for some registers within the microcontroller to be written to and saved through power cycles -- **Field.py** This is code that implements the radio module for sending and listening -- **functions.py** This is a library of functions utilized by the satellite to obtain data, detumble, run the battery heater -- **pysquared.py** This is a library that initializes and maintains all the main functions for the pysquared architecture -- **adafruit_rfm.py** This is a library that implements all the radio hardware. This code is a modified version of the pycubed_rfm9x which is a modified version of the adafruit_rfm9x file. -- **cdh.py** This is the code that handles all the commands. A majority of this code is pulled from the cdh file developed by Max Holliday at Stanford. -- **detumble.py** This code implements the B-dot algorithm and returns outputs that allow the system to do a controlled detumble with the satellite's embedded magnetourquer coils -- **payload.py** This code implements any desired payload. On the Pleiades missions, the payload has been the BNO055 IMU. Since the use of a stemmaQT connector allows multiple devices on the same bus, a BNO IMU could be used in conjunction with several other sensors if desired. -- **logger.py** This class emulates the logging abilities of mainline Python and creates .json format logs for all of the satellite activities. -- **config.json** This file is used to configure the system variables for the satellite software. -## Adafruit Libraires -These are open source software libraries that are pull from Adafruit. They don't ship by default anymore in our repo, instead they are installed by our package manager when you run the `make` toolchain. -- **asyncio** This is the library responsible for scheduling tasks in the main code -- **adafruit_bno055.py** This is the library that is responsible for obtaining data from the BNO055 IMU -- **adafruit_drv2605.mpy** This is the pre-compiled library that is responsible for driving the magnetorquer coils using the drv2605 motor driver -- **adafruit_ina219.py** This is the library that is responsible for obtaining data from the INA219 Power Monitor -- **adafruit_mcp9808.mpy** This is the pre-compiled library that is responsible for obtaining data from the MCP9808 Temperature Sensor -- **adafruit_pca9685.py** This is the library that is responsible or driving the power to the satellite faces using the pca9685 LED driver -- **adafruit_tca9548a.mpy** This is the pre-compiled library that multiplexes the I2C line to each satellite face using the tca9548a I2C Multiplexer -- **adafruit_veml7700.py** This is the library that is responsible for obtaining data from the veml7700 Light Sensor -- **adafruit_vl6180.py** This is the library that is responsible for obtaining data from the vl6180 LiDAR sensor -## tests -This software is used for performing tests on the satellite. Currently this is seperated into `repl` (tests that are meant to be run from the REPL enviroment on the board) and `unit` (tests that can be run independently of the hardware). -- **radio_test.py** This is an omnibus radio testing script that will allow you to send, receive, and command boards running the PySquared library. - -## Testing setup - -1. Follow the steps to set up your venv and install packages in the linting setup -2. Run tests with `make test` +You can find our Getting Started Guide [here](https://github.com/proveskit/pysquared/blob/main/docs/dev-guide.md). diff --git a/docs/dev-guide-linux.md b/docs/dev-guide-linux.md deleted file mode 100644 index 80d155a..0000000 --- a/docs/dev-guide-linux.md +++ /dev/null @@ -1,37 +0,0 @@ -# Development Guide for Linux - -## Setup - -To set up your development environment on Linux, follow these steps: - -1. Update your package list and install the necessary packages: - ```sh - sudo apt update && sudo apt install make screen zip - ``` - -You should now be able to run the `make` command in the root of the repo to get started. - -### A note on `make install` -`make install` is a command that can be used to quickly install the code you're working on onto the board. On linux you can use the `findmnt` command to locate your board's mount point. -```sh -findmnt -... -├─/media/username/SOME-VALUE /dev/sdb1 vfat rw,nosuid,nodev,relatime 0 0 -``` - -For example, if the board is mounted at `/media/username/SOME-VALUE` then your install command will look like: -```sh -make install BOARD_MOUNT_POINT=/media/username/SOME-VALUE/ -``` - -## Accessing the Serial Console -To see streaming logs and use the on-board repl you must access the Circuit Python serial console. Accessing the serial console starts with finding the tty port for the board. The easiest way to do that is by plugging in your board and running: -```sh -ls -lah /dev -``` -Look for the file that was created around the same time that you plugged in the board. For Linux users the port typically looks like `/dev/ttyACM0`. You can then connect to the board using the `screen` command: -```sh -screen /dev/ttyACM0 -``` - -For more information visit the [Circuit Python Serial Console documentation](https://learn.adafruit.com/welcome-to-circuitpython/advanced-serial-console-on-linux). diff --git a/docs/dev-guide-macos.md b/docs/dev-guide-macos.md deleted file mode 100644 index 254582e..0000000 --- a/docs/dev-guide-macos.md +++ /dev/null @@ -1,42 +0,0 @@ -# Development Guide for MacOS - -## Setup - -To get started with development on MacOS, follow these steps: - -1. **Install Xcode Command Line Tools**: These tools are necessary for compiling and building software. - ```sh - xcode-select --install - ``` -1. **Install Homebrew**: Homebrew is a package manager for MacOS. Follow the instructions on [brew.sh](https://brew.sh/) to install it. -1. **Install Required Packages**: Open a terminal and run the following command to install required packages: - ```sh - brew install screen - ``` - -You should now be able to run the `make` command in the root of the repo to get started. - -### A note on `make install` -`make install` is a command that can be used to quickly install the code you're working on onto the board. On Mac, you can find the location of your mount by looking for a mount named `PYSQUARED` in your `/Volumes` directory -```sh -ls -lah /Volumes | grep PYSQUARED -... -drwx------@ 1 nate staff 16K Jan 9 08:09 PYSQUARED/ -``` - -For example, if the board is mounted at `/Volumes/PYSQUARED/` then your install command will look like: -```sh -make install BOARD_MOUNT_POINT=/Volumes/PYSQUARED/ -``` - -## Accessing the Serial Console -To see streaming logs and use the on-board repl you must access the Circuit Python serial console. Accessing the serial console starts with finding the tty port for the board. The easiest way to do that is by plugging in your board and running: -```sh -ls -lah /dev -``` -Look for the file that was created around the same time that you plugged in the board. For Mac users the port typically looks like `/dev/tty.usbmodem101`. You can then connect to the board using the `screen` command: -```sh -screen /dev/tty.usbmodem101 -``` - -For more information visit the [Circuit Python Serial Console documentation](https://learn.adafruit.com/welcome-to-circuitpython/advanced-serial-console-on-mac-and-linux). diff --git a/docs/dev-guide-windows.md b/docs/dev-guide-windows.md deleted file mode 100644 index d4ea75a..0000000 --- a/docs/dev-guide-windows.md +++ /dev/null @@ -1,58 +0,0 @@ -# Development Guide for Windows -Welcome to the Windows Development Guide for our project! This guide will help you set up your development environment on a Windows machine and get you started with contributing to the repository. - -Follow the instructions below for either a native Windows setup or using the Windows Subsystem for Linux (WSL). - -## Native Windows Setup (Recommended) - -To set up your development environment on Windows, follow these steps: - -1. **Install Git**: Download and install Git from [git-scm.com](https://git-scm.com/downloads). Make sure to also install the Git Bash terminal during the setup process. -1. **Install Putty**: Download and install Putty from [putty.org](https://putty.org/). -1. **Install Chocolatey**: Chocolatey is a package manager for Windows. Follow the instructions on [chocolatey.org](https://chocolatey.org/install) to install it. -1. **Install Required Packages**: Open a command prompt or Git Bash terminal and run the following command to install required packages: - ```sh - choco install make rsync zip - ``` - -Using the Git Bash terminal, you should now be able to run the `make` command in the root of the repo to get started. - -### A note on `make install` - -`make install` is a command that can be used to quickly install the code you're working on onto the board. In Git Bash your mount point will be the letter of the drive location in windows. For example, if the board is mounted at `D:\` then your install command will look like: -```sh -make install BOARD_MOUNT_POINT=/d/ -``` - -## WSL Setup -Windows Subsystem for Linux (WSL) is a nice way to have a POSIX compatible workspace on your machine, the downside is a cumbersome USB [connecting][connect-usb] and [mounting][mount-disk] process that needs to be performed every time you reconnect the Satellite hardware to your computer. - -1. Download Ubuntu for WSL: - ```sh - wsl --install - ``` -1. Run WSL: - ```sh - wsl - ``` -1. If you have Satellite hardware, [connect][connect-usb] and [mount][mount-disk] it in WSL. -1. Continue with our [Linux Development Guide](docs/dev-guide-linux.md). - -### A note on `make install` - -`make install` is a command that can be used to quickly install the code you're working on onto the board. In WSL your mount point will be the letter of the drive location in windows. For example, if the board is mounted at `D:\` then you must first mount the disk in WSL: -```sh -mkdir /mnt/d -sudo mount -t drvfs D: /mnt/d -``` - -And your install command will look like: -```sh -make install BOARD_MOUNT_POINT=/mnt/d/ -``` - -## Accessing the Serial Console -To see streaming logs and use the on-board repl you must access the Circuit Python serial console. For information on how to access the serial console, visit the [Circuit Python Serial Console documentation](https://learn.adafruit.com/welcome-to-circuitpython/advanced-serial-console-on-windows). - -[connect-usb]: https://learn.microsoft.com/en-us/windows/wsl/connect-usb "How to Connect USB to WSL" -[mount-disk]: https://learn.microsoft.com/en-us/windows/wsl/wsl2-mount-disk "How to Mount a Disk to WSL" diff --git a/docs/dev-guide.md b/docs/dev-guide.md deleted file mode 100644 index f5361a7..0000000 --- a/docs/dev-guide.md +++ /dev/null @@ -1,45 +0,0 @@ -# Development Guide -Welcome to the development guide for our project! This guide will help you set up your development environment and get you started with contributing to the repository. - -## OS Specific Guides -We suggest you get started with the development guide for your operating system: - -- [Windows](/docs/dev-guide-windows.md) -- [MacOS](/docs/dev-guide-macos.md) -- [Linux](/docs/dev-guide-linux.md) - -Once you have your development environment set up, you should be able to run the following command to finish the setup: -```sh -make -``` - -## Manually testing code on the board -We are working on improving our automated testing but right now the best way to test your code is to run it on the board. We have provided the following command to make it easy to install code on the board: -```sh -make install BOARD_MOUNT_POINT=/PATH_TO_YOUR_BOARD -``` - -There is more information in the OS specific guides on how to find your board's mount point. - -To see the output of your code you can connect to the board using the serial console. You can find more information on how to do that in the OS specific guides. - -### Notes on Serial Console -If all you see is a blank screen when you connect to the serial console, try pressing `CTRL+C` to see if you can get a prompt. If that doesn't work, try pressing `CTRL+D` to reset the board. - -## Continuous Integration (CI) -This repo has a continuous integration system using Github Actions. Anytime you push code to the repo, it will run a series of tests. If you see a failure in the CI, you can click on the details to see what went wrong. - -### Common Build Failures -Here are some common build failures you might see and how to fix them: - -#### Lint Failure -Everytime you make a change in git, it's called a commit. We have a tool called a pre-commit hook that will run before you make each commit to ensure your code is safe and formatted correctly. If you experience a lint failure you can run the following to fix it for you or tell you what's wrong. -```sh -make fmt -``` - -#### Test Failure -To ensure our code works as we expect we use automated testing. If you're seeing a testing failure in your build, you can see what's wrong by running those tests yourself with: -```sh -make test -``` diff --git a/lib/requirements.txt b/lib/requirements.txt index 1703932..3ae3597 100644 --- a/lib/requirements.txt +++ b/lib/requirements.txt @@ -1,3 +1,4 @@ +adafruit-circuitpython-74hc595==1.4.6 adafruit-circuitpython-asyncio @ git+https://github.com/adafruit/adafruit_circuitpython_asyncio@1.3.3 adafruit-circuitpython-drv2605==1.3.4 adafruit-circuitpython-lis2mdl==2.1.23 @@ -10,3 +11,4 @@ adafruit-circuitpython-tca9548a @ git+https://github.com/proveskit/Adafruit_Circ adafruit-circuitpython-ticks==1.1.1 adafruit-circuitpython-veml7700==2.0.2 proves-circuitpython-rv3028 @ git+https://github.com/proveskit/PROVES_CircuitPython_RV3028@1.0.0 +proves-circuitpython-sx126 @ git+https://github.com/proveskit/micropySX126X@1.0.0 diff --git a/main.py b/main.py index 331edb3..a964743 100644 --- a/main.py +++ b/main.py @@ -79,10 +79,10 @@ config.radio, Flag(index=register.FLAG, bit_index=7, datastore=microcontroller.nvm), spi0, - initialize_pin(logger, board.SPI0_CS0, digitalio.Direction.OUTPUT), - initialize_pin(logger, board.RF2_IO0, digitalio.Direction.INPUT), - initialize_pin(logger, board.RF1_RST, digitalio.Direction.OUTPUT), - initialize_pin(logger, board.RF2_IO4, digitalio.Direction.INPUT), + initialize_pin(logger, board.SPI0_CS0, digitalio.Direction.OUTPUT, True), + board.RF2_IO0, + initialize_pin(logger, board.RF1_RST, digitalio.Direction.OUTPUT, True), + board.RF2_IO4, ) i2c1 = initialize_i2c_bus(