diff --git a/docs/presentation.mp4 b/docs/presentation.mp4 new file mode 100644 index 0000000..67ee58e Binary files /dev/null and b/docs/presentation.mp4 differ diff --git a/src/Fab Matrixes/src/main.cpp b/src/Fab Matrixes/src/main.cpp index 036f5b4..b39f54c 100644 --- a/src/Fab Matrixes/src/main.cpp +++ b/src/Fab Matrixes/src/main.cpp @@ -42,6 +42,8 @@ void scrollingText(String text, int speed, int color); void playGif(const uint16_t* gifData[], int frameCount, int frameDelay); void displayFullScreenBMP(const uint16_t* bitmap); void bootSequence(); +void matrixSerialLoop(); +void matrixSerialSetup(); Adafruit_NeoMatrix matrix = Adafruit_NeoMatrix(32, 8, PIN, NEO_MATRIX_BOTTOM + NEO_MATRIX_RIGHT + @@ -56,15 +58,18 @@ void setup() { matrix.setTextWrap(false); matrix.setBrightness(25); matrix.setTextColor(matrix.Color(255, 255, 255)); + matrixSerialSetup(); + Serial.begin(9600); - bootSequence(); + // bootSequence(); } int x = matrix.width(); int pass = 0; void loop() { - scrollingText("BOO AAAA!", 50, matrix.Color(255, 0, 255)); + scrollingText("Hello World!", 50, matrix.Color(255, 0, 255)); + // matrixSerialLoop(); } void scrollingText(String text, int speed, int color) { @@ -130,4 +135,28 @@ void bootSequence() { delay(5000); +} + +void matrixSerialSetup(){ + Serial1.begin(115200); + } + +void matrixSerialLoop() { + if (Serial1.available()) { + String command = Serial1.readStringUntil('\n'); + command.trim(); // Remove any trailing newline or spaces + Serial.println("Received command: " + command); + if (command.startsWith("scroll:")) { + String text = command.substring(7); // Get the text after "scroll:" + scrollingText(text, 50, matrix.Color(255, 0, 255)); + } else if (command.startsWith("gif:")) { + // Handle GIF command + // Example: gif:frame1,frame2,frame3 + // You would need to parse the frames and call playGif() + } else if (command.startsWith("bmp:")) { + // Handle BMP command + // Example: bmp:bitmapData + // You would need to parse the bitmap data and call displayFullScreenBMP() + } + } } \ No newline at end of file diff --git a/src/drone/platformio.ini b/src/drone/platformio.ini index 10c3b2e..6ff5a19 100644 --- a/src/drone/platformio.ini +++ b/src/drone/platformio.ini @@ -19,4 +19,5 @@ lib_deps = paulstoffregen/PWMServo@^2.1 sparkfun/SparkFun BNO080 Cortex Based IMU@^1.1.12 madhephaestus/ESP32Servo@^3.0.6 -build_flags = -DCORE_DEBUG_LEVEL=5 \ No newline at end of file + plerup/EspSoftwareSerial@^8.2.0 +build_flags = -DCORE_DEBUG_LEVEL=5 diff --git a/src/drone/src/main.cpp b/src/drone/src/main.cpp index b0a1ab8..7de97e4 100644 --- a/src/drone/src/main.cpp +++ b/src/drone/src/main.cpp @@ -4,6 +4,7 @@ #include #include #include +#include // Arduino/Teensy Flight Controller - dRehmFlight // Author: Nicholas Rehm // Project Start: 1/6/2020 @@ -231,16 +232,16 @@ float Kd_yaw = 0.00015; // Yaw D-gain (be careful when increasing too high, moto const int ch1Pin = 15; // throttle const int ch2Pin = 16; // ail const int ch3Pin = 17; // ele -const int ch4Pin = 20; // rudd -const int ch5Pin = D7; // gear (throttle cut) -const int ch6Pin = D7; // aux1 (free aux channel) -const int PPM_Pin = D7; +const int ch4Pin = 17; // rudd +const int ch5Pin = 17; // gear (throttle cut) +const int ch6Pin = 17; // aux1 (free aux channel) +const int PPM_Pin = 17; // OneShot125 ESC pin outputs: -const int m1Pin = D2; -const int m2Pin = D3; -const int m3Pin = D9; -const int m4Pin = D10; -const int m5Pin = D7; +const int m1Pin = D10; +const int m2Pin = D9; +const int m3Pin = D3; +const int m4Pin = D2; +const int m5Pin = D7; //for some readon D9 doesnt work const int m6Pin = D8; @@ -356,6 +357,7 @@ void ESPNowSetup(); void printDebugInfo(); void setupMotorPWM(); int pulseWidthToDutyCycle(int pulseWidth); +void setupMatrixSerial(); //========================================================================================================================// // VOID SETUP // //========================================================================================================================// @@ -365,14 +367,15 @@ void setup() Serial.begin(9600); // USB serial Serial.println("Serial started"); + Serial.println("Initiating ESC"); + setupMotorPWM(); + // Initialize IMU communication Serial.println("Initiating IMU"); IMUinit(); - Serial.println("Initiating ESC"); - setupMotorPWM(); - Serial.println("Attach servos"); + setupMatrixSerial(); // servo7.attach(servo7Pin, 900, 2100); // Set built in LED to turn on to signal startup @@ -505,10 +508,10 @@ void controlMixer() */ // Quad mixing - EXAMPLE - m1_command_scaled = thro_des - pitch_PID + roll_PID + yaw_PID; // Front Left - m2_command_scaled = thro_des - pitch_PID - roll_PID - yaw_PID; // Front Right - m3_command_scaled = thro_des + pitch_PID - roll_PID + yaw_PID; // Back Right - m4_command_scaled = thro_des + pitch_PID + roll_PID - yaw_PID; // Back Left + m1_command_scaled = thro_des - pitch_PID + roll_PID + yaw_PID; // Front Left (CW) Check + m2_command_scaled = thro_des - pitch_PID - roll_PID - yaw_PID; // Front Right (CCW) check + m3_command_scaled = thro_des + pitch_PID - roll_PID + yaw_PID; // Back Right (CW) check + m4_command_scaled = thro_des + pitch_PID + roll_PID - yaw_PID; // Back Left (CCW) m5_command_scaled = 0; m6_command_scaled = 0; @@ -1915,6 +1918,8 @@ float invSqrt(float x) return 1.0 / sqrtf(x); // Teensy is fast enough to just take the compute penalty lol suck it arduino nano } + +/// ESP stuff lol void ESPNowSetup() { WiFi.mode(WIFI_STA); @@ -1965,4 +1970,11 @@ void OnDataRecv(const uint8_t *mac, const uint8_t *incomingData, int len) // For debugging - uncomment if needed // Serial.print("KillSwitch: "); // Serial.println(ControllerData.killSwitch); +} + +void setupMatrixSerial() +{ +SoftwareSerial MatrixSerial(D0, D8); //RX is unconnected +MatrixSerial.begin(115200); +MatrixSerial.println("Hi"); } \ No newline at end of file