Skip to content

Commit

Permalink
updated with Climb Rate in the OSD
Browse files Browse the repository at this point in the history
  • Loading branch information
Qrome committed Dec 30, 2022
1 parent 41cd501 commit 40c2727
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 9 deletions.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
10 changes: 5 additions & 5 deletions QLiteOSD/OSD_positions_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

//currently working elements
const uint16_t osd_altitude_pos = 2240;
const uint16_t osd_numerical_vario_pos = 2273;
const uint16_t osd_avg_cell_voltage_pos = 2145;
const uint16_t osd_main_batt_voltage_pos = 2113;
const uint16_t osd_crosshairs_pos = 2254;
Expand All @@ -22,10 +23,10 @@ const uint16_t osd_craft_name_pos = 2048;
#ifdef USE_GPS
uint16_t osd_gps_sats_pos = 2074;
const uint16_t osd_home_dir_pos = 2095;
const uint16_t osd_home_dist_pos = 2305;
const uint16_t osd_gps_speed_pos = 2273;
const uint16_t osd_gps_lat_pos = 2400;
const uint16_t osd_gps_lon_pos = 2432;
const uint16_t osd_home_dist_pos = 2337;
const uint16_t osd_gps_speed_pos = 2305;
const uint16_t osd_gps_lat_pos = 2432;
const uint16_t osd_gps_lon_pos = 2464;
#else
uint16_t osd_gps_sats_pos = 234;
const uint16_t osd_home_dir_pos = 234;
Expand All @@ -42,7 +43,6 @@ const uint16_t osd_display_name_pos = 234;
const uint16_t osd_flymode_pos = 234;
const uint16_t osd_current_draw_pos = 234;
const uint16_t osd_mah_drawn_pos = 234;
const uint16_t osd_numerical_vario_pos = 234;

//not implemented or not available
const uint16_t osd_throttle_pos_pos = 234;
Expand Down
12 changes: 8 additions & 4 deletions QLiteOSD/QLiteOSD.ino
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
#include "OSD_positions_config.h"
#include <Adafruit_BMP280.h> // May need to adjust for I2C address #define BMP280_ADDRESS (0x76)

#define VERSION "1.2"
#define VERSION "1.3"
#define BMP_ADDRESS 0x76 // default is 0x77
#define MAH_CALIBRATION_FACTOR 1.0f //used to calibrate mAh reading.
#define SPEED_IN_KILOMETERS_PER_HOUR //if commented out defaults to m/s
Expand Down Expand Up @@ -109,6 +109,7 @@ int sampleCount = 0;
int lastCount = 0;
float altSamples = 0.0;
static const uint8_t armAltitude = 150; // Centimeters high at witch arm signal is sent to DJI goggles
int16_t lastAltRead = 0; //cm
boolean lightOn = true;

//Voltage and Battery Reading
Expand Down Expand Up @@ -177,7 +178,7 @@ uint8_t thr_position = 0;
float wind_direction = 0; // wind direction (degrees)
float wind_speed = 0; // wind speed in ground plane (m/s)
float relative_wind_direction = 0;
float climb_rate = 0;
int16_t climb_rate = 0;

msp_battery_state_t battery_state = { 0 };
msp_name_t name = { 0 };
Expand Down Expand Up @@ -444,10 +445,12 @@ void readAltitude() {
}

void getAltitudeSample() {
lastAltRead = (int16_t)relative_alt;
relative_alt = (int)round(((altSamples / sampleCount) - HomeAlt) * 100);
lastCount = sampleCount;
sampleCount = 0;
altSamples = 0.0;
climb_rate = (lastAltRead - relative_alt) * 5; // assuming 200ms samples needs to be cm/s
}

void calibrateHome() {
Expand All @@ -469,7 +472,6 @@ void calibrateHome() {
void readVoltage() {
int readValue = analogRead(alanogPin);
averageVoltage += (readValue * (arduinoVCC / 1024)) * (1 + (ValueR2 / ValueR1));
;
sampleVoltageCount++;
}

Expand Down Expand Up @@ -529,7 +531,7 @@ void loop() {
logGPS();
#endif

if (general_counter % 300 == 0) { // update the altitude and voltage values every 300ms
if (general_counter % 200 == 0) { // update the altitude and voltage values every 200ms
getAltitudeSample();
getVoltageSample();
if (lightOn) {
Expand Down Expand Up @@ -573,6 +575,8 @@ void debugPrint() {
mspSerial.println(((double)vbat / 10), 1);
mspSerial.print("Altitude (cm): ");
mspSerial.println(relative_alt);
mspSerial.print("Climb Rate (cm/s): ");
mspSerial.println(climb_rate);
mspSerial.print("Sample Count / transmit: ");
mspSerial.println(lastCount);
#ifdef USE_GPS
Expand Down

0 comments on commit 40c2727

Please sign in to comment.