Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(devboard): Add support for RP2040 #72

Merged
merged 16 commits into from
Feb 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
16 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/ISSUE_TEMPLATE/bug-report.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,12 @@ body:
- Arduino MKR WiFi 1010
- Arduino MKR ZERO
- Arduino Nano 33 IoT
- Arduino Nano RP2040 Connect
- Arduino Zero
- Espressif ESP32-C3 DevKitC-02
- Espressif ESP32-C3 DevKitM-1
- Espressif ESP32-S3 DevKitC-1-N8
- Raspberry Pi Pico RP2040
- Seeed Studio Xiao ESP32-C3
- Seeed Studio Xiao ESP32-S3
- Seeed Studio XIAO SAMD21
Expand Down
5 changes: 2 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,8 @@
# Artefacts for Visual Studio Code
.vscode/

# PlatformIO specific README files
src/platformio/include/README
src/platformio/test/README
# PlatformIO specific files
test/README

# Template files for CRSF for Arduino
templates/
Expand Down
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,11 @@ Pro tips:
In PlatformIO, CRSF for Arduino's dependencies are automatically installed, when you build your project for the first time.
The `platformio.ini` file contains a list of development boards that is compatible with CRSF for Arduino.

## Installation - Using as a dependency in your PlatformIO project

Simply add `https://github.com/ZZ-Cat/CRSFforArduino.git @^ 1.0.0` to your `lib_deps` section in your `platformio.ini` file.
PlatformIO will take care of the rest. This is fairly new, so any hiccups, don't hesitate to let me know via my Issues tab.

## Installation - Straight from the Main-Trunk

If you want bleeding edge features and want to help me out on developing CRSF for Arduino, this is how you go about it:
Expand Down Expand Up @@ -373,6 +378,9 @@ CRSF for Arduino is compatible with these development boards:
- SparkFun ESP32 Thing
- SparkFun ESP32 Thing Plus
- SparkFun ESP32-S2 Thing Plus
- RP2040 based boards:
- Arduino Nano RP2040 Connect
- Raspberry Pi Pico RP2040
- SAMD21 based boards:
- Adafruit Feather M0 and all of its variants, including the Adafruit Feather M0 Express
- Adafruit ItsyBitsy M0 Express
Expand Down
160 changes: 0 additions & 160 deletions examples/channels/channels.ino

This file was deleted.

47 changes: 21 additions & 26 deletions examples/flight_modes/flight_modes.ino
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
/**
* @file main_flight_modes.ino
* @file flight_modes.ino
* @author Cassandra "ZZ Cat" Robinson (nicad.heli.flier@gmail.com)
* @brief Demonstrates the use of CRSF for Arduino's flight mode functionality.
* @brief Example of how to read flight modes from a receiver.
* @version 1.0.0
* @date 2024-1-20
* @date 2024-2-9
*
* @copyright Copyright (c) 2023, Cassandra "ZZ Cat" Robinson. All rights reserved.
* @copyright Copyright (c) 2024, Cassandra "ZZ Cat" Robinson. All rights reserved.
*
* @section License GNU General Public License v3.0
* This [file type] is a part of the CRSF for Arduino library.
* This example is a part of the CRSF for Arduino library.
* CRSF for Arduino is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
Expand All @@ -23,9 +23,6 @@
* along with CRSF for Arduino. If not, see <https://www.gnu.org/licenses/>.
*
*/
#if defined(ARDUINO) && defined(PLATFORMIO)
#error "This example sketch is not compatible with PlatformIO. Please use the main_rc.cpp example instead."
#elif defined(ARDUINO) && !defined(PLATFORMIO)

#include "CRSFforArduino.hpp"

Expand Down Expand Up @@ -61,7 +58,7 @@

CRSFforArduino crsf = CRSFforArduino(&Serial1);

void onFlightModeUpdate(serialReceiver::flightModeId_t);
void onFlightModeUpdate(serialReceiverLayer::flightModeId_t);

void setup()
{
Expand All @@ -85,7 +82,7 @@ void setup()
}

// Set flight modes.
if (!crsf.setFlightMode(serialReceiver::FLIGHT_MODE_DISARMED, FLIGHT_MODE_ARM_CHANNEL, FLIGHT_MODE_ARM_MIN, FLIGHT_MODE_ARM_MAX))
if (!crsf.setFlightMode(serialReceiverLayer::FLIGHT_MODE_DISARMED, FLIGHT_MODE_ARM_CHANNEL, FLIGHT_MODE_ARM_MIN, FLIGHT_MODE_ARM_MAX))
{
Serial.println("Failed to set \"DISARMED\" flight mode!");
while (1)
Expand All @@ -94,7 +91,7 @@ void setup()
}
}

if (!crsf.setFlightMode(serialReceiver::FLIGHT_MODE_ACRO, FLIGHT_MODE_ACRO_CHANNEL, FLIGHT_MODE_ACRO_MIN, FLIGHT_MODE_ACRO_MAX))
if (!crsf.setFlightMode(serialReceiverLayer::FLIGHT_MODE_ACRO, FLIGHT_MODE_ACRO_CHANNEL, FLIGHT_MODE_ACRO_MIN, FLIGHT_MODE_ACRO_MAX))
{
Serial.println("Failed to set \"ACRO\" flight mode!");
while (1)
Expand All @@ -103,7 +100,7 @@ void setup()
}
}

if (!crsf.setFlightMode(serialReceiver::FLIGHT_MODE_ANGLE, FLIGHT_MODE_ANGLE_CHANNEL, FLIGHT_MODE_ANGLE_MIN, FLIGHT_MODE_ANGLE_MAX))
if (!crsf.setFlightMode(serialReceiverLayer::FLIGHT_MODE_ANGLE, FLIGHT_MODE_ANGLE_CHANNEL, FLIGHT_MODE_ANGLE_MIN, FLIGHT_MODE_ANGLE_MAX))
{
Serial.println("Failed to set \"ANGLE\" flight mode!");
while (1)
Expand All @@ -112,7 +109,7 @@ void setup()
}
}

if (!crsf.setFlightMode(serialReceiver::FLIGHT_MODE_HORIZON, FLIGHT_MODE_HORIZON_CHANNEL, FLIGHT_MODE_HORIZON_MIN, FLIGHT_MODE_HORIZON_MAX))
if (!crsf.setFlightMode(serialReceiverLayer::FLIGHT_MODE_HORIZON, FLIGHT_MODE_HORIZON_CHANNEL, FLIGHT_MODE_HORIZON_MIN, FLIGHT_MODE_HORIZON_MAX))
{
Serial.println("Failed to set \"HORIZON\" flight mode!");
while (1)
Expand All @@ -136,43 +133,43 @@ void loop()
crsf.update();
}

void onFlightModeUpdate(serialReceiver::flightModeId_t flightMode)
void onFlightModeUpdate(serialReceiverLayer::flightModeId_t flightMode)
{
/* Here is where you would put your flight mode implementation.
For this example, we will just print the flight mode to the serial port,
and send it to the controller as telemetry. */
static serialReceiver::flightModeId_t lastFlightMode = serialReceiver::FLIGHT_MODE_DISARMED;
static serialReceiverLayer::flightModeId_t lastFlightMode = serialReceiverLayer::FLIGHT_MODE_DISARMED;

if (flightMode != lastFlightMode)
{
Serial.print("Flight Mode: ");
switch (flightMode)
{
case serialReceiver::FLIGHT_MODE_DISARMED:
case serialReceiverLayer::FLIGHT_MODE_DISARMED:
Serial.println("Disarmed");
break;
case serialReceiver::FLIGHT_MODE_ACRO:
case serialReceiverLayer::FLIGHT_MODE_ACRO:
Serial.println("Acro");
break;
case serialReceiver::FLIGHT_MODE_WAIT:
case serialReceiverLayer::FLIGHT_MODE_WAIT:
Serial.println("Wait for GPS Lock");
break;
case serialReceiver::FLIGHT_MODE_FAILSAFE:
case serialReceiverLayer::FLIGHT_MODE_FAILSAFE:
Serial.println("Failsafe");
break;
case serialReceiver::FLIGHT_MODE_GPS_RESCUE:
case serialReceiverLayer::FLIGHT_MODE_GPS_RESCUE:
Serial.println("GPS Rescue");
break;
case serialReceiver::FLIGHT_MODE_PASSTHROUGH:
case serialReceiverLayer::FLIGHT_MODE_PASSTHROUGH:
Serial.println("Passthrough");
break;
case serialReceiver::FLIGHT_MODE_ANGLE:
case serialReceiverLayer::FLIGHT_MODE_ANGLE:
Serial.println("Angle");
break;
case serialReceiver::FLIGHT_MODE_HORIZON:
case serialReceiverLayer::FLIGHT_MODE_HORIZON:
Serial.println("Horizon");
break;
case serialReceiver::FLIGHT_MODE_AIRMODE:
case serialReceiverLayer::FLIGHT_MODE_AIRMODE:
Serial.println("Airmode");
break;
default:
Expand All @@ -184,5 +181,3 @@ void onFlightModeUpdate(serialReceiver::flightModeId_t flightMode)
crsf.telemetryWriteFlightMode(flightMode);
}
}

#endif
Loading
Loading