Browse Source

Running ESPNow

master
Englebert 2 years ago
parent
commit
771925a3d2
  1. 23
      openscad/BoxMode.scad
  2. 9
      src/ESPNow.cpp
  3. 9
      src/ESPNowRC.cpp
  4. 2
      src/ESPNowRC.h
  5. 4
      src/Screen.cpp

23
openscad/BoxMode.scad

@ -58,11 +58,12 @@ translate([-23.5,-70,13])
/******* Modules *******/
module gimbal_back() {
difference() {
cube([70,70,13], center=true);
translate([0,0,-2])
cube([70,70,9], center=true);
translate([0,0,0.76])
cube([62.5,62.5,11.5], center=true);
translate([0,30,4])
cube([20,20,7], center=true);
cube([20,20,12], center=true);
// Corners
@ -80,18 +81,18 @@ module gimbal_back() {
cube([10,10,40], center=true);
}
translate([0,-30.7,4])
cube([62,1,20], center=true);
translate([0,30.7,4])
translate([0,-30.7,1])
cube([62,1,12], center=true);
translate([0,30.7,1])
difference() {
cube([62,1,20], center=true);
cube([62,1,12], center=true);
translate([0,0,0]);
cube([25,20,100], center=true);
cube([20,20,100], center=true);
}
translate([30.7,0,4])
cube([1,62.4,20], center=true);
translate([-30.7,0,4])
cube([1,62.4,20], center=true);
translate([30.7,0,1])
cube([1,62.4,12], center=true);
translate([-30.7,0,1])
cube([1,62.4,12], center=true);
}
module m5_back() {

9
src/ESPNow.cpp

@ -90,10 +90,11 @@ void ESPNow2::update(void) {
} else {
if((uint32_t)(millis() - last_updated) > 1) {
data_to_send.message_type = DATA;
data_to_send.throttle = map(inputs.throttle, 0, 4096, 1000, 2000); // Throttle
data_to_send.yaw = map(inputs.yaw, 0, 4096, 1000, 2000); // Yaw
data_to_send.pitch = map(inputs.pitch, 0, 4096, 1000, 2000); // Pitch
data_to_send.roll = map(inputs.roll, 0, 4096, 1000, 2000); // Roll
data_to_send.throttle = map(inputs.throttle, stickcalibration.throttle_min, stickcalibration.throttle_max, 1000, 2000); // Throttle
data_to_send.yaw = map(inputs.yaw, stickcalibration.yaw_min, stickcalibration.yaw_max, 1000, 2000); // Yaw
data_to_send.pitch = map(inputs.pitch, stickcalibration.pitch_min, stickcalibration.pitch_max, 1000, 2000); // Pitch
data_to_send.roll = map(inputs.roll, stickcalibration.roll_min, stickcalibration.roll_max, 1000, 2000); // Roll
// Sending Data
esp_now_send(destination_server_address, (uint8_t *) &data_to_send, sizeof(data_to_send));

9
src/ESPNowRC.cpp

@ -28,6 +28,12 @@ void ESPNowRC::draw_gimbal(TFT_eSprite *m, uint16_t x, uint16_t y) {
}
void ESPNowRC::show(TFT_eSprite *m) {
if((uint32_t) (millis() - last_uptime) >= 1000) {
uptime++;
last_uptime = millis();
}
if(espnow2.espnow_begin == false) {
espnow2.espnow_begin = true;
Serial.println("ESPNOW Begin");
@ -55,6 +61,9 @@ void ESPNowRC::show(TFT_eSprite *m) {
m->setCursor(240, 0);
m->printf("CH:%d", espnow2.espnow_channel);
m->setCursor(0, 16);
m->printf("Uptime: %d", uptime);
m->setCursor(74, 0);
m->printf("B:%.1fV %.0fmA", voltage, current);
// m->printf(String(voltage) + "V " + String(current) + "mA");

2
src/ESPNowRC.h

@ -30,6 +30,8 @@ class ESPNowRC {
private:
uint32_t last_updated = 0;
uint32_t last_voltage_read = 0;
uint32_t uptime = 0;
uint32_t last_uptime = 0;
};
extern ESPNowRC espnowrc;

4
src/Screen.cpp

@ -140,10 +140,12 @@ void Screen::menu(void) {
mainscreen_buffer.drawFastHLine(250, 239, 20, TFT_WHITE);
// Just Title
/**
mainscreen_buffer.setTextColor(WHITE, RED);
mainscreen_buffer.setTextSize(4);
mainscreen_buffer.setCursor(0, 183);
mainscreen_buffer.printf("FPVController");
**/
mainscreen_buffer.pushSprite(0,0);
@ -214,6 +216,7 @@ void Screen::menu_reboot(void) {
mainscreen_buffer.fillRoundRect(51, 51, 218, 138, 10, DIALOGBOX_BACKGROUND);
// Show Text
mainscreen_buffer.setTextSize(2);
mainscreen_buffer.setTextColor(DIALOGBOX_FOREGROUND, DIALOGBOX_BACKGROUND);
mainscreen_buffer.setCursor(68, 110);
mainscreen_buffer.print("Reboot Now? ");
@ -267,6 +270,7 @@ void Screen::menu_poweroff(void) {
mainscreen_buffer.fillRoundRect(51, 51, 218, 138, 10, DIALOGBOX_BACKGROUND);
// Show Text
mainscreen_buffer.setTextSize(2);
mainscreen_buffer.setTextColor(DIALOGBOX_FOREGROUND, DIALOGBOX_BACKGROUND);
mainscreen_buffer.setCursor(68, 110);
mainscreen_buffer.print("Power Off? ");

Loading…
Cancel
Save