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

GOV MODE SENSOR #89

Merged
merged 7 commits into from
Mar 27, 2024
Merged
Changes from 6 commits
Commits
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
30 changes: 29 additions & 1 deletion src/main/telemetry/smartport.c
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@
#include "flight/mixer.h"
#include "flight/pid.h"
#include "flight/position.h"
#include "flight/motors.h"
#include "flight/governor.h"

#include "io/beeper.h"
#include "io/gps.h"
Expand Down Expand Up @@ -130,6 +132,7 @@ enum
FSSP_DATAID_ADJFUNC = 0x5110 , // custom
FSSP_DATAID_ADJVALUE = 0x5111 , // custom
FSSP_DATAID_CAP_USED = 0x5250 ,
FSSP_DATAID_GOV_MODE = 0x5450 , //custom
#if defined(USE_ACC)
FSSP_DATAID_PITCH = 0x5230 , // custom
FSSP_DATAID_ROLL = 0x5240 , // custom
Expand Down Expand Up @@ -157,7 +160,7 @@ enum
};

// if adding more sensors then increase this value (should be equal to the maximum number of ADD_SENSOR calls)
#define MAX_DATAIDS 24
#define MAX_DATAIDS 25

static uint16_t frSkyDataIdTable[MAX_DATAIDS];

Expand Down Expand Up @@ -331,6 +334,9 @@ static void initSmartPortSensors(void)
{
frSkyDataIdTableInfo.index = 0;

//prob need configurator option for these?
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's right, you need to add a telemetry "sensor" for this.

ADD_SENSOR(FSSP_DATAID_GOV_MODE);

if (telemetryIsSensorEnabled(SENSOR_MODE)) {
ADD_SENSOR(FSSP_DATAID_T1);
ADD_SENSOR(FSSP_DATAID_T2);
Expand Down Expand Up @@ -630,6 +636,28 @@ void processSmartPortTelemetry(smartPortPayload_t *payload, volatile bool *clear
#endif

switch (id) {
case FSSP_DATAID_GOV_MODE :
if (!ARMING_FLAG(ARMED)) {
if (isArmingDisabled())
smartPortSendPackage(id, 100); //DISABLED
else
smartPortSendPackage(id, 101); //DISAMED
} else {
/*
0, //"OFF",
1, //"IDLE",
2, // "SPOOLUP",
3, //"RECOVERY",
4, //"ACTIVE",
5, //"THR-OFF",
6, //"LOST-HS",
7, //"AUTOROT",
8, //"BAILOUT",
*/
smartPortSendPackage(id, getGovernorState());
}
*clearToSend = false;
break;
case FSSP_DATAID_VFAS :
vfasVoltage = telemetryConfig()->report_cell_voltage ? getBatteryAverageCellVoltage() : getBatteryVoltage();
smartPortSendPackage(id, vfasVoltage); // in 0.01V according to SmartPort spec
Expand Down