Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master' into voice_diet2
Browse files Browse the repository at this point in the history
  • Loading branch information
TheRealMoeder committed Apr 28, 2019
2 parents 15ddfeb + 85ed88d commit 6dfc826
Show file tree
Hide file tree
Showing 14 changed files with 162 additions and 58 deletions.
4 changes: 2 additions & 2 deletions src/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ ALLTARGETS = $(filter-out common,$(notdir $(wildcard target/tx/*/*)))
TXS ?= devo6 devo7e devo7e-256 devo8 devo10 devo12e devo12 devof7 devof7-XMS devof4 devof4-XMS devof12e devof12e-XMS at9 at10 t8sg t8sg_v2 t8sg_v2_plus ir8m

#Filter non-existant emus
EMUS = $(foreach dir,$(TXS:%=emu_%),$(if $(wildcard target/$(dir)),$(dir),))
ALLEMUS = $(foreach dir,$(ALLTXS:%=emu_%),$(if $(wildcard target/$(dir)),$(dir),))
EMUS = $(foreach dir,$(TXS:%=emu_%),$(if $(wildcard target/tx/*/$(dir)),$(dir),))
ALLEMUS = $(foreach dir,$(ALLTXS:%=emu_%),$(if $(wildcard target/tx/*/$(dir)),$(dir),))

txs: $(TXS)
emus: $(EMUS)
Expand Down
2 changes: 1 addition & 1 deletion src/chanutils.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ void CHAN_Init()

s32 CHAN_ReadRawInput(int channel)
{
if (channel < INP_HAS_CALIBRATION) {
if (channel <= INP_HAS_CALIBRATION) {
return ADC_ReadRawInput(channel);
}
return SWITCH_ReadRawInput(channel);
Expand Down
6 changes: 5 additions & 1 deletion src/pages/128x64x1/guiobj.h
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,11 @@ struct telemcfg_obj {
struct telemtest_obj {
guiLabel_t msg;
guiLabel_t header[7];
guiLabel_t box[31];
#if HAS_EXTENDED_TELEMETRY
guiLabel_t box[36];
#else
guiLabel_t box[10];
#endif
guiScrollable_t scrollable;
};

Expand Down
8 changes: 7 additions & 1 deletion src/pages/128x64x1/telemtest_page.c
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,12 @@ const struct telem_layout frsky_layout_basic[] = {
{TYPE_INDEX | 7, LBL1_X, LBL1_WIDTH, 8},
{TYPE_VALUE | 7, FRSKY1_X, FRSKY1_WIDTH, TELEM_FRSKY_LQI},
{TYPE_VALUE | 7, FRSKY2_X, FRSKY1_WIDTH, TELEM_FRSKY_LRSSI},
{TYPE_VALUE | 7, FRSKY3_X, FRSKY1_WIDTH, TELEM_FRSKY_SPEED},

{TYPE_INDEX | 8, LBL1_X, LBL1_WIDTH, 9},
{TYPE_VALUE | 8, FRSKY1_X, FRSKY1_WIDTH, TELEM_FRSKY_ACCX},
{TYPE_VALUE | 8, FRSKY2_X, FRSKY1_WIDTH, TELEM_FRSKY_ACCY},
{TYPE_VALUE | 8, FRSKY3_X, FRSKY1_WIDTH, TELEM_FRSKY_ACCZ},
#endif

{0, 0, 0, 0},
Expand Down Expand Up @@ -318,7 +324,7 @@ const struct telem_layout2 dsm_page[] = {
};
const struct telem_layout2 frsky_page[] = {
#if HAS_EXTENDED_TELEMETRY
{frsky_header_basic, frsky_layout_basic, 8, 1},
{frsky_header_basic, frsky_layout_basic, 9, 1},
#else
{frsky_header_basic, frsky_layout_basic, 2, 1},
#endif
Expand Down
44 changes: 24 additions & 20 deletions src/pages/320x240x16/telemtest_page.c
Original file line number Diff line number Diff line change
Expand Up @@ -54,32 +54,36 @@ const struct telem_layout devo8_layout[] = {
{{0, 0, 0, 0}, {0, 0, 0, 0}, 0},
};
const struct telem_layout frsky_layout[] = {
{{15, 40, 40, 18}, {60, 40, 40, 18}, TELEM_FRSKY_RSSI},
{{15, 60, 40, 18}, {60, 60, 40, 18}, TELEM_FRSKY_TEMP1},
{{15, 80, 40, 18}, {60, 80, 40, 18}, TELEM_FRSKY_TEMP2},
{{15, 100, 40, 18}, {60, 100, 40, 18}, TELEM_FRSKY_RPM},
{{15, 120, 40, 18}, {60, 120, 40, 18}, TELEM_FRSKY_FUEL},

{{115, 40, 40, 18}, {160, 40, 40, 18}, TELEM_FRSKY_VOLT1},
{{115, 60, 40, 18}, {160, 60, 40, 18}, TELEM_FRSKY_VOLT2},
{{115, 80, 40, 18}, {160, 80, 40, 18}, TELEM_FRSKY_VOLT3},
{{115, 100, 40, 18}, {160, 100, 40, 18}, TELEM_FRSKY_MIN_CELL},
{{115, 120, 40, 18}, {160, 120, 40, 18}, TELEM_FRSKY_ALL_CELL},

{{185, 40, 40, 18}, {228, 40, 40, 18}, TELEM_FRSKY_CELL1},
{{185, 60, 40, 18}, {228, 60, 40, 18}, TELEM_FRSKY_CELL2},
{{185, 80, 40, 18}, {228, 80, 40, 18}, TELEM_FRSKY_CELL3},
{{185, 100, 40, 18}, {228, 100, 40, 18}, TELEM_FRSKY_CELL4},
{{185, 120, 40, 18}, {228, 120, 40, 18}, TELEM_FRSKY_CELL5},
{{0, 40, 40, 18}, {40, 40, 40, 18}, TELEM_FRSKY_RSSI},
{{0, 60, 40, 18}, {40, 60, 40, 18}, TELEM_FRSKY_TEMP1},
{{0, 80, 40, 18}, {40, 80, 40, 18}, TELEM_FRSKY_TEMP2},
{{0, 100, 40, 18}, {40, 100, 40, 18}, TELEM_FRSKY_RPM},
{{0, 120, 40, 18}, {40, 120, 40, 18}, TELEM_FRSKY_FUEL},

{{87, 40, 40, 18}, {130, 40, 40, 18}, TELEM_FRSKY_VOLT1},
{{87, 60, 40, 18}, {130, 60, 40, 18}, TELEM_FRSKY_VOLT2},
{{87, 80, 40, 18}, {130, 80, 40, 18}, TELEM_FRSKY_VOLT3},
{{87, 100, 40, 18}, {130, 100, 40, 18}, TELEM_FRSKY_MIN_CELL},
{{87, 120, 40, 18}, {130, 120, 40, 18}, TELEM_FRSKY_ALL_CELL},

{{175, 40, 40, 18}, {195, 40, 40, 18}, TELEM_FRSKY_CELL1},
{{175, 60, 40, 18}, {195, 60, 40, 18}, TELEM_FRSKY_CELL2},
{{175, 80, 40, 18}, {195, 80, 40, 18}, TELEM_FRSKY_CELL3},
{{175, 100, 40, 18}, {195, 100, 40, 18}, TELEM_FRSKY_CELL4},
{{175, 120, 40, 18}, {195, 120, 40, 18}, TELEM_FRSKY_CELL5},

{{241, 40, 40, 18}, {275, 40, 40, 18}, TELEM_FRSKY_LQI},
{{241, 60, 40, 18}, {275, 60, 40, 18}, TELEM_FRSKY_LRSSI},
{{241, 80, 40, 18}, {275, 80, 40, 18}, TELEM_FRSKY_ACCX},
{{241, 100, 40, 18}, {275, 100, 40, 18}, TELEM_FRSKY_ACCY},
{{241, 120, 40, 18}, {275, 120, 40, 18}, TELEM_FRSKY_ACCZ},

{{215, 140, 40, 18}, {260, 140, 40, 18}, TELEM_FRSKY_CURRENT},
{{215, 160, 40, 18}, {260, 160, 40, 18}, TELEM_FRSKY_DISCHARGE},
{{215, 180, 40, 18}, {260, 180, 40, 18}, TELEM_FRSKY_VOLTA},
{{215, 200, 40, 18}, {260, 200, 40, 18}, TELEM_FRSKY_ALTITUDE},
{{215, 220, 40, 18}, {260, 220, 40, 18}, TELEM_FRSKY_VARIO},

{{275, 40, 40, 18}, {275, 60, 40, 18}, TELEM_FRSKY_LQI},
{{275, 80, 40, 18}, {275, 100, 40, 18}, TELEM_FRSKY_LRSSI},

{{0, 140, 55, 18}, {60, 140, 140, 18}, TELEM_GPS_LAT},
{{0, 160, 55, 18}, {60, 160, 140, 18}, TELEM_GPS_LONG},
{{0, 180, 55, 18}, {60, 180, 140, 18}, TELEM_GPS_ALT},
Expand Down
9 changes: 6 additions & 3 deletions src/protocol/bugs3mini_nrf24l01.c
Original file line number Diff line number Diff line change
Expand Up @@ -215,9 +215,12 @@ static void send_packet(u8 bind)
packet[5] = rudder >> 1;
packet[6] = elevator >> 1;
packet[7] = aileron >> 1;
packet[8] = 0x20 | (aileron << 7);
packet[9] = 0x20 | (elevator << 7);
packet[10]= 0x20 | (rudder << 7);
packet[8] = (((aileron / 5) >> 1) + 7) // dynamic trim 0x07 - 0x39
| (aileron << 7);
packet[9] = (((elevator / 5) >> 1) + 7) // dynamic trim 0x07 - 0x39
| (elevator << 7);
packet[10]= (((rudder / 5) >> 1) + 7) // dynamic trim 0x07 - 0x39
| (rudder << 7);
packet[11]= 0x40 | (throttle << 7);
packet[12]= 0x80 | ((packet[12] ^ 0x40) & 0x40) // bugs 3 H doesn't have 0x80 ?
| FLAG_MODE
Expand Down
8 changes: 3 additions & 5 deletions src/protocol/frsky2way_cc2500.c
Original file line number Diff line number Diff line change
Expand Up @@ -511,13 +511,11 @@ uintptr_t FRSKY2WAY_Cmds(enum ProtoCmds cmd)
return (CC2500_Reset() ? 1 : -1);
case PROTOCMD_TELEMETRYTYPE:
return TELEM_FRSKY;
case PROTOCMD_TELEMETRYRESET:
#if HAS_EXTENDED_TELEMETRY
Model.ground_level = 0;
discharge_dAms = 0;
Telemetry.value[TELEM_FRSKY_MIN_CELL] = TELEMETRY_GetMaxValue(TELEM_FRSKY_MIN_CELL);
#endif
case PROTOCMD_TELEMETRYRESET:
frsky_telem_reset();
return 0;
#endif
case PROTOCMD_CHANNELMAP: return AETRG;
default: break;
}
Expand Down
13 changes: 9 additions & 4 deletions src/protocol/frsky_d_telem._c
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@

static u32 discharge_time;
static u32 discharge_dAms; // deciAmp-milliseconds
static u8 last_cell;


static void set_telemetry(frsky_telem_t offset, s32 value) {
Telemetry.value[offset] = value;
TELEMETRY_SetUpdated(offset);
}


// store "before punctuation" and "after punctuation" values locally
// keeps Telemetry.gps compatible with devo and dsm
static struct s_fr_gps {
Expand Down Expand Up @@ -47,12 +47,18 @@ static void update_cell(u8 cell, s32 value) {
static void update_min_cell(u8 num_cells) {
Telemetry.value[TELEM_FRSKY_MIN_CELL] = Telemetry.value[TELEM_FRSKY_CELL1];
for (int i=1; i < MIN(num_cells, 6); i++) {
if (Telemetry.value[TELEM_FRSKY_CELL1 + i] < Telemetry.value[TELEM_FRSKY_MIN_CELL])
if (Telemetry.value[TELEM_FRSKY_CELL1 + i] < Telemetry.value[TELEM_FRSKY_MIN_CELL]) {
Telemetry.value[TELEM_FRSKY_MIN_CELL] = Telemetry.value[TELEM_FRSKY_CELL1 + i];
TELEMETRY_SetUpdated(TELEM_FRSKY_MIN_CELL);
}
}
TELEMETRY_SetUpdated(TELEM_FRSKY_MIN_CELL);
}

static void frsky_telem_reset() {
Model.ground_level = 0;
discharge_dAms = 0;
update_min_cell(last_cell+1);
}

static void processHubPacket(u8 id, u16 value) {
static u8 varioHighPrecision = 0;
Expand Down Expand Up @@ -83,7 +89,6 @@ static void processHubPacket(u8 id, u16 value) {
set_telemetry(TELEM_FRSKY_TEMP2, (s16)value);
break;
case 0x06: { //Battery voltages - CELL# and VOLT
static u8 last_cell;
u8 cell = (value >> 4) & 0x0f;
value = (((value & 0x0F) << 8) + (value >> 8)) / 5;

Expand Down
51 changes: 47 additions & 4 deletions src/protocol/frsky_s_telem._c
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ static u8 sport_crc(u8 *data) {
return 0x00ff - crc;
}


static void processSportPacket(u8 *packet) {
// u8 instance = (packet[0] & 0x1F) + 1; // all instances of same sensor write to same telemetry value
u8 prim = packet[1];
Expand Down Expand Up @@ -107,6 +108,40 @@ static void processSportPacket(u8 *packet) {
}

s32 data = SPORT_DATA_S32(packet);

// sensor ids from Qlrs
switch (id) {
case APID_PITCH:
set_telemetry(TELEM_FRSKY_ACCX, data * 10);
break;
case APID_ROLL:
set_telemetry(TELEM_FRSKY_ACCY, data * 10);
break;
#if 0
case APID_RX_RSSI_REG_VAL:
set_telemetry(TELEM_FRSKY_CELL1, data);
break;
case APID_RX_SNR_REG_VAL:
set_telemetry(TELEM_FRSKY_CELL2, data);
break;
case APID_RX_PACKET_LOST_VAL:
set_telemetry(TELEM_FRSKY_CELL3, data);
break;
case APID_MAV_BASE_MODE:
set_telemetry(TELEM_FRSKY_CELL4, data);
break;
case APID_MAV_SYS_STATUS:
set_telemetry(TELEM_FRSKY_CELL5, data);
break;
case APID_MAV_CUSTOM_MODE:
set_telemetry(TELEM_FRSKY_CELL6, data);
break;
case APID_CUST_RSSI:
set_telemetry(TELEM_FRSKY_ALL_CELL, data);
break;
#endif
}

switch (id & 0xfff0) {
case ALT_FIRST_ID & 0xfff0:
if (Model.ground_level == 0) Model.ground_level = data;
Expand Down Expand Up @@ -195,14 +230,22 @@ static void processSportPacket(u8 *packet) {
TELEMETRY_SetUpdated(TELEM_GPS_TIME);
}
break;
case ACCX_FIRST_ID & 0xfff0:
set_telemetry(TELEM_FRSKY_ACCX, data / 10);
break;
case ACCY_FIRST_ID & 0xfff0:
set_telemetry(TELEM_FRSKY_ACCY, data / 10);
break;
case ACCZ_FIRST_ID & 0xfff0:
set_telemetry(TELEM_FRSKY_ACCZ, data / 10);
break;
case AIR_SPEED_FIRST_ID & 0xfff0:
set_telemetry(TELEM_FRSKY_SPEED, data);
break;
} // switch
// not sure about these
// case A3_FIRST_ID & 0xfff0:
// case A4_FIRST_ID & 0xfff0:
// case AIR_SPEED_FIRST_ID & 0xfff0:
// case ACCX_FIRST_ID & 0xfff0:
// case ACCY_FIRST_ID & 0xfff0:
// case ACCZ_FIRST_ID & 0xfff0:
}


Expand Down
8 changes: 3 additions & 5 deletions src/protocol/frskyx_cc2500.c
Original file line number Diff line number Diff line change
Expand Up @@ -693,13 +693,11 @@ uintptr_t FRSKYX_Cmds(enum ProtoCmds cmd)
return PROTO_TELEM_ON;
case PROTOCMD_TELEMETRYTYPE:
return TELEM_FRSKY;
case PROTOCMD_TELEMETRYRESET:
#if HAS_EXTENDED_TELEMETRY
Model.ground_level = 0;
discharge_dAms = 0;
Telemetry.value[TELEM_FRSKY_MIN_CELL] = TELEMETRY_GetMaxValue(TELEM_FRSKY_MIN_CELL);
#endif
case PROTOCMD_TELEMETRYRESET:
frsky_telem_reset();
return 0;
#endif
case PROTOCMD_RESET:
case PROTOCMD_DEINIT:
#if HAS_EXTENDED_TELEMETRY
Expand Down
34 changes: 22 additions & 12 deletions src/protocol/pxxout.c
Original file line number Diff line number Diff line change
Expand Up @@ -231,22 +231,36 @@ static enum {
#ifndef EMULATOR
PXX_BIND_DONE = 600,
#else
PXX_BIND_DONE = 50,
PXX_BIND_DONE = 5,
#endif
PXX_DATA1,
PXX_DATA2,
} state;

static u16 mixer_runtime;

#if HAS_EXTENDED_TELEMETRY
// Support S.Port telemetry on RX pin
// couple defines to avoid errors from include file
static void serial_echo(u8 *packet) {(void)packet;}
#define PROTO_OPTS_AD2GAIN 0
#include "frsky_d_telem._c"
#include "frsky_s_telem._c"
#endif // HAS_EXTENDED_TELEMETRY

#ifndef EMULATOR
#define STD_DELAY 9000
#else
#define STD_DELAY 300
#endif
static u16 pxxout_cb()
{
switch (state) {
default: // binding
build_data_pkt(1);
PXX_Enable(packet);
state++;
return 9000;
return STD_DELAY;
case PXX_BIND_DONE:
PROTOCOL_SetBindState(0);
state++;
Expand All @@ -256,23 +270,16 @@ static u16 pxxout_cb()
state = PXX_DATA2;
return mixer_runtime;
case PXX_DATA2:
#ifndef EMULATOR
if (mixer_sync != MIX_DONE && mixer_runtime < 2000) mixer_runtime += 50;
#endif
build_data_pkt(0);
PXX_Enable(packet);
state = PXX_DATA1;
return 9000 - mixer_runtime;
return STD_DELAY - mixer_runtime;
}
}

#if HAS_EXTENDED_TELEMETRY
// Support S.Port telemetry on RX pin
// couple defines to avoid errors from include file
static void serial_echo(u8 *packet) {(void)packet;}
#define PROTO_OPTS_AD2GAIN 0
#include "frsky_d_telem._c"
#include "frsky_s_telem._c"
#endif // HAS_EXTENDED_TELEMETRY

static void initialize(u8 bind)
{
CLOCK_StopTimer();
Expand Down Expand Up @@ -328,6 +335,9 @@ uintptr_t PXXOUT_Cmds(enum ProtoCmds cmd)
return PROTO_TELEM_ON;
case PROTOCMD_TELEMETRYTYPE:
return TELEM_FRSKY;
case PROTOCMD_TELEMETRYRESET:
frsky_telem_reset();
return 0;
#endif
case PROTOCMD_CHANNELMAP: return UNCHG;
default: break;
Expand Down
2 changes: 2 additions & 0 deletions src/target/drivers/display/spi/128x64x1_nt7538.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,6 @@ inline static void _lcd_init()
LCD_Cmd(0x2F); // Power Controller: VFollower ON
i = 0x8000;
while (i) i--;
if (HAS_LCD_FLIPPED)
LCD_Cmd(0x26); // Select Internal Resistor Rate (Rb/Ra)
}
16 changes: 16 additions & 0 deletions src/telemetry.h
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,10 @@ typedef enum {
TELEM_FRSKY_ALTITUDE,
TELEM_FRSKY_VARIO,
TELEM_FRSKY_DISCHARGE, // mAh
TELEM_FRSKY_ACCX,
TELEM_FRSKY_ACCY,
TELEM_FRSKY_ACCZ,
TELEM_FRSKY_SPEED,
#endif
TELEM_FRSKY_LAST
} frsky_telem_t;
Expand Down Expand Up @@ -325,6 +329,18 @@ enum {
#define SWR_ID 0xf105
#define XJT_VERSION_ID 0xf106

// Custom S.port sensors reported by Qzcek long range system (Qlrs)
#define APID_PITCH 0x0430
#define APID_ROLL 0x0440
#define APID_MAV_BASE_MODE 0x04A0
#define APID_MAV_SYS_STATUS 0x04A1
#define APID_MAV_CUSTOM_MODE 0x04A2
#define APID_CUST_RSSI 0x04B0
#define APID_RX_RSSI_REG_VAL 0x04B1
#define APID_RX_SNR_REG_VAL 0x04B2
#define APID_RX_PACKET_LOST_VAL 0x04B3


/************************************************************************/
struct TelemetryAlarm {
u8 src;
Expand Down
Loading

0 comments on commit 6dfc826

Please sign in to comment.