mirror of
https://gitlab.waag.org/make/fablab/interns/2025/sam.git
synced 2025-08-03 11:54:58 +00:00
code update and presentation stuff
This commit is contained in:
BIN
docs/presentation.mp4
Normal file
BIN
docs/presentation.mp4
Normal file
Binary file not shown.
@@ -42,6 +42,8 @@ void scrollingText(String text, int speed, int color);
|
|||||||
void playGif(const uint16_t* gifData[], int frameCount, int frameDelay);
|
void playGif(const uint16_t* gifData[], int frameCount, int frameDelay);
|
||||||
void displayFullScreenBMP(const uint16_t* bitmap);
|
void displayFullScreenBMP(const uint16_t* bitmap);
|
||||||
void bootSequence();
|
void bootSequence();
|
||||||
|
void matrixSerialLoop();
|
||||||
|
void matrixSerialSetup();
|
||||||
|
|
||||||
Adafruit_NeoMatrix matrix = Adafruit_NeoMatrix(32, 8, PIN,
|
Adafruit_NeoMatrix matrix = Adafruit_NeoMatrix(32, 8, PIN,
|
||||||
NEO_MATRIX_BOTTOM + NEO_MATRIX_RIGHT +
|
NEO_MATRIX_BOTTOM + NEO_MATRIX_RIGHT +
|
||||||
@@ -56,15 +58,18 @@ void setup() {
|
|||||||
matrix.setTextWrap(false);
|
matrix.setTextWrap(false);
|
||||||
matrix.setBrightness(25);
|
matrix.setBrightness(25);
|
||||||
matrix.setTextColor(matrix.Color(255, 255, 255));
|
matrix.setTextColor(matrix.Color(255, 255, 255));
|
||||||
|
matrixSerialSetup();
|
||||||
|
Serial.begin(9600);
|
||||||
|
|
||||||
bootSequence();
|
// bootSequence();
|
||||||
}
|
}
|
||||||
|
|
||||||
int x = matrix.width();
|
int x = matrix.width();
|
||||||
int pass = 0;
|
int pass = 0;
|
||||||
|
|
||||||
void loop() {
|
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) {
|
void scrollingText(String text, int speed, int color) {
|
||||||
@@ -130,4 +135,28 @@ void bootSequence() {
|
|||||||
|
|
||||||
delay(5000);
|
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()
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
@@ -19,4 +19,5 @@ lib_deps =
|
|||||||
paulstoffregen/PWMServo@^2.1
|
paulstoffregen/PWMServo@^2.1
|
||||||
sparkfun/SparkFun BNO080 Cortex Based IMU@^1.1.12
|
sparkfun/SparkFun BNO080 Cortex Based IMU@^1.1.12
|
||||||
madhephaestus/ESP32Servo@^3.0.6
|
madhephaestus/ESP32Servo@^3.0.6
|
||||||
build_flags = -DCORE_DEBUG_LEVEL=5
|
plerup/EspSoftwareSerial@^8.2.0
|
||||||
|
build_flags = -DCORE_DEBUG_LEVEL=5
|
||||||
|
@@ -4,6 +4,7 @@
|
|||||||
#include <esp_now.h>
|
#include <esp_now.h>
|
||||||
#include <WiFi.h>
|
#include <WiFi.h>
|
||||||
#include <driver/ledc.h>
|
#include <driver/ledc.h>
|
||||||
|
#include <softwareSerial.h>
|
||||||
// Arduino/Teensy Flight Controller - dRehmFlight
|
// Arduino/Teensy Flight Controller - dRehmFlight
|
||||||
// Author: Nicholas Rehm
|
// Author: Nicholas Rehm
|
||||||
// Project Start: 1/6/2020
|
// 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 ch1Pin = 15; // throttle
|
||||||
const int ch2Pin = 16; // ail
|
const int ch2Pin = 16; // ail
|
||||||
const int ch3Pin = 17; // ele
|
const int ch3Pin = 17; // ele
|
||||||
const int ch4Pin = 20; // rudd
|
const int ch4Pin = 17; // rudd
|
||||||
const int ch5Pin = D7; // gear (throttle cut)
|
const int ch5Pin = 17; // gear (throttle cut)
|
||||||
const int ch6Pin = D7; // aux1 (free aux channel)
|
const int ch6Pin = 17; // aux1 (free aux channel)
|
||||||
const int PPM_Pin = D7;
|
const int PPM_Pin = 17;
|
||||||
// OneShot125 ESC pin outputs:
|
// OneShot125 ESC pin outputs:
|
||||||
const int m1Pin = D2;
|
const int m1Pin = D10;
|
||||||
const int m2Pin = D3;
|
const int m2Pin = D9;
|
||||||
const int m3Pin = D9;
|
const int m3Pin = D3;
|
||||||
const int m4Pin = D10;
|
const int m4Pin = D2;
|
||||||
const int m5Pin = D7;
|
const int m5Pin = D7; //for some readon D9 doesnt work
|
||||||
const int m6Pin = D8;
|
const int m6Pin = D8;
|
||||||
|
|
||||||
|
|
||||||
@@ -356,6 +357,7 @@ void ESPNowSetup();
|
|||||||
void printDebugInfo();
|
void printDebugInfo();
|
||||||
void setupMotorPWM();
|
void setupMotorPWM();
|
||||||
int pulseWidthToDutyCycle(int pulseWidth);
|
int pulseWidthToDutyCycle(int pulseWidth);
|
||||||
|
void setupMatrixSerial();
|
||||||
//========================================================================================================================//
|
//========================================================================================================================//
|
||||||
// VOID SETUP //
|
// VOID SETUP //
|
||||||
//========================================================================================================================//
|
//========================================================================================================================//
|
||||||
@@ -365,14 +367,15 @@ void setup()
|
|||||||
Serial.begin(9600); // USB serial
|
Serial.begin(9600); // USB serial
|
||||||
Serial.println("Serial started");
|
Serial.println("Serial started");
|
||||||
|
|
||||||
|
Serial.println("Initiating ESC");
|
||||||
|
setupMotorPWM();
|
||||||
|
|
||||||
// Initialize IMU communication
|
// Initialize IMU communication
|
||||||
Serial.println("Initiating IMU");
|
Serial.println("Initiating IMU");
|
||||||
IMUinit();
|
IMUinit();
|
||||||
|
|
||||||
Serial.println("Initiating ESC");
|
|
||||||
setupMotorPWM();
|
|
||||||
Serial.println("Attach servos");
|
|
||||||
|
|
||||||
|
setupMatrixSerial();
|
||||||
// servo7.attach(servo7Pin, 900, 2100);
|
// servo7.attach(servo7Pin, 900, 2100);
|
||||||
|
|
||||||
// Set built in LED to turn on to signal startup
|
// Set built in LED to turn on to signal startup
|
||||||
@@ -505,10 +508,10 @@ void controlMixer()
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
// Quad mixing - EXAMPLE
|
// Quad mixing - EXAMPLE
|
||||||
m1_command_scaled = thro_des - pitch_PID + roll_PID + yaw_PID; // Front 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
|
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
|
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
|
m4_command_scaled = thro_des + pitch_PID + roll_PID - yaw_PID; // Back Left (CCW)
|
||||||
m5_command_scaled = 0;
|
m5_command_scaled = 0;
|
||||||
m6_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
|
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()
|
void ESPNowSetup()
|
||||||
{
|
{
|
||||||
WiFi.mode(WIFI_STA);
|
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
|
// For debugging - uncomment if needed
|
||||||
// Serial.print("KillSwitch: ");
|
// Serial.print("KillSwitch: ");
|
||||||
// Serial.println(ControllerData.killSwitch);
|
// Serial.println(ControllerData.killSwitch);
|
||||||
|
}
|
||||||
|
|
||||||
|
void setupMatrixSerial()
|
||||||
|
{
|
||||||
|
SoftwareSerial MatrixSerial(D0, D8); //RX is unconnected
|
||||||
|
MatrixSerial.begin(115200);
|
||||||
|
MatrixSerial.println("Hi");
|
||||||
}
|
}
|
Reference in New Issue
Block a user