Browse Source

Partially rework input/eeprom + further cleanup

master
Schoenberger, Philipp 6 years ago
parent
commit
c1d2b9b0f2
  1. 4
      remote/include/FrSkyD_cc2500.h
  2. 1
      remote/include/Multiprotocol.h
  3. 12
      remote/include/common.h
  4. 7
      remote/include/crc.h
  5. 92
      remote/include/eeprom.h
  6. 48
      remote/include/input.h
  7. 44
      remote/src/FrSkyD_cc2500.cpp
  8. 1
      remote/src/Multiprotocol.cpp
  9. 117
      remote/src/common.cpp
  10. 22
      remote/src/crc.cpp
  11. 102
      remote/src/eeprom.cpp
  12. 47
      remote/src/input.cpp
  13. 7
      remote/src/state.cpp

4
remote/include/FrSkyD_cc2500.h

@ -17,6 +17,7 @@
#define _FRSKYD_CC2500_H_ #define _FRSKYD_CC2500_H_
#include <stdint.h> #include <stdint.h>
void Frsky_init_hop(void);
void frsky2way_init(uint8_t bind); void frsky2way_init(uint8_t bind);
void frsky2way_build_bind_packet(); void frsky2way_build_bind_packet();
@ -26,6 +27,5 @@ void frsky2way_data_frame(void);
uint16_t initFrSky_2way(void); uint16_t initFrSky_2way(void);
uint16_t ReadFrSky_2way(void); uint16_t ReadFrSky_2way(void);
uint16_t convert_channel_frsky(uint8_t num);
#endif #endif

1
remote/include/Multiprotocol.h

@ -33,7 +33,6 @@ extern uint8_t protocol_flags;
extern uint8_t protocol_flags2; extern uint8_t protocol_flags2;
extern uint8_t pkt[MAX_PKT];//telemetry receiving packets extern uint8_t pkt[MAX_PKT];//telemetry receiving packets
extern uint8_t prev_option; extern uint8_t prev_option;
extern uint8_t hopping_frequency[50];
extern uint8_t crc8; extern uint8_t crc8;
extern uint8_t packet_count; extern uint8_t packet_count;
extern uint8_t RX_num; extern uint8_t RX_num;

12
remote/include/common.h

@ -19,17 +19,6 @@
#include "tx_def.h" #include "tx_def.h"
void InitChannel(void); void InitChannel(void);
void reverse_channel(uint8_t num);
uint16_t convert_channel_ppm(uint8_t num);
uint16_t convert_channel_10b(uint8_t num);
uint8_t convert_channel_8b(uint8_t num);
int16_t convert_channel_16b_limit(uint8_t num, int16_t min, int16_t max);
int16_t convert_channel_16b_nolimit(uint8_t num, int16_t min, int16_t max);
uint8_t convert_channel_s8b(uint8_t num);
uint16_t limit_channel_100(uint8_t num);
void convert_channel_HK310(uint8_t num, uint8_t *low, uint8_t *high);
void convert_failsafe_HK310(uint8_t num, uint8_t *low, uint8_t *high);
uint16_t convert_channel_frsky(uint8_t num);
/******************************/ /******************************/
/** FrSky D and X routines **/ /** FrSky D and X routines **/
@ -44,7 +33,6 @@ enum {
FRSKY_DATA5 FRSKY_DATA5
}; };
void Frsky_init_hop(void);
/******************************/ /******************************/
/** FrSky V, D and X routines **/ /** FrSky V, D and X routines **/
/******************************/ /******************************/

7
remote/include/crc.h

@ -0,0 +1,7 @@
#ifndef __CRC_H_H__
#define __CRC_H_H__
#include <stdint.h>
uint32_t crc_update (uint32_t crc, uint8_t data);
#endif

92
remote/include/eeprom.h

@ -1,81 +1,37 @@
#ifndef _EEPROM_H_ #ifndef _EEPROM_H_
#define _EEPROM_H_ #define _EEPROM_H_
#include <EEPROM.h>
#include <Arduino.h>
#include <stdint.h>
#include "tx_def.h"
#include "input.h"
extern class Eeprom_config eeprom_config;
#define CURRENT_VERSION 0x01
struct eeprom_data_v1 {
uint8_t version;
uint32_t crc;
struct {
struct {
uint16_t max;
uint16_t min;
uint8_t inverted;
} throttle, yaw, roll, pitch, aux[5];
uint32_t master_id;
} data;
class Eeprom_config {
public:
};
Eeprom_config(void);
~Eeprom_config(void);
int validate(void);
int read(void);
int write(void);
const static uint32_t crc_table[16] = {
0x00000000, 0x1db71064, 0x3b6e20c8, 0x26d930ac,
0x76dc4190, 0x6b6b51f4, 0x4db26158, 0x5005713c,
0xedb88320, 0xf00f9344, 0xd6d6a3e8, 0xcb61b38c,
0x9b64c2b0, 0x86d3d2d4, 0xa00ae278, 0xbdbdf21c
};
int get_ch_config(struct Input::ch_config* config);
int set_ch_config(struct Input::ch_config* config);
uint32_t crc_update (uint32_t crc, uint8_t data)
{
uint8_t tbl_idx;
int get_master_id(uint32_t* master_id);
int set_master_id(uint32_t master_id);
tbl_idx = crc ^ (data >> (0 * 4));
crc = (crc_table + (tbl_idx & 0x0f)) ^ (crc >> 4);
tbl_idx = crc ^ (data >> (1 * 4));
crc = (crc_table + (tbl_idx & 0x0f)) ^ (crc >> 4);
return crc;
private:
#define CURRENT_VERSION 0x01
struct eeprom_data_v1 {
uint8_t version;
uint32_t data_crc;
struct {
uint32_t master_id;
struct Input::ch_config[CH_COUNT];
} data;
} current_config;
bool sucessfull_read;
} }
int read_eeprom(struct eeprom_data_v1 *eeprom_data) {
uint8_t *data = NULL;
uint8_t start_address = 0x10;
EEPROM.PageBase0 = 0x801F000;
EEPROM.PageBase1 = 0x801F800;
EEPROM.PageSize = 0x400;
EEPROM.init();
data = (uint8_t*) eeprom_data;
for (uint8_t i = 0; i < sizeof(eeprom_data) ; i = 0) {
EEPROM.read(0x10 + i , data);
data+=1;
}
// validate version
if (eeprom_data->version != CURRENT_VERSION) {
return -1;
}
data = (uint8_t*) &(eeprom_data->data);
uint32_t crc = ~0L;
for (uint8_t i = 0; i < sizeof(eeprom_data->data) ; i = 0) {
crc = crc_update(crc, *data);
data+=1;
}
// validate crc
if (eeprom_data->crc != crc) {
return -1;
}
}
#endif #endif

48
remote/include/input.h

@ -5,8 +5,7 @@
#define NUM_TX_CHN 16 #define NUM_TX_CHN 16
extern uint16_t Channel_data[NUM_TX_CHN];
extern uint16_t Failsafe_data[NUM_TX_CHN];
extern Input input;
extern const char* ch_name[NUM_TX_CHN]; extern const char* ch_name[NUM_TX_CHN];
class Input { class Input {
public: public:
@ -29,20 +28,17 @@ class Input {
MENU_UP_DOWN = CH_PITCH, MENU_UP_DOWN = CH_PITCH,
MENU_LEFT_RIGHT = CH_ROLL, MENU_LEFT_RIGHT = CH_ROLL,
}; };
struct data {
uint16_t ch_data[CH_COUNT];
bool menu;
struct ch_config {
uint16_t max;
uint16_t min;
bool inverted;
bool is_analog;
}; };
Input(void); Input(void);
void init(void); void init(void);
void do_calibration(void);
void update(void); void update(void);
struct data* get_curr_input(void);
struct data* get_old_input(void);
void update_inputs(void); void update_inputs(void);
void mark_processed(void); void mark_processed(void);
@ -55,25 +51,37 @@ class Input {
void invert_ch(enum input_channels ch); void invert_ch(enum input_channels ch);
void print_ch(enum input_channels ch); void print_ch(enum input_channels ch);
void calibration_init(void);
void calibration_reset(void);
bool calibration_update(void); bool calibration_update(void);
void set_calibration(struct ch_config *new_config);
void get_calibration(struct ch_config *curr_config);
uint16_t *get_channel_data(void);
private: private:
// raw sticks input
uint16_t ch_raw[CH_COUNT];
// calculated inputs (my be inverted
struct data {
uint16_t ch_data[CH_COUNT];
bool menu;
};
// actual tx channel data
uint16_t channel_data[CH_COUNT];
struct data input[2]; struct data input[2];
struct data* curr; struct data* curr;
struct data* old; struct data* old;
uint16_t ch_raw[CH_COUNT];
struct {
uint16_t max;
uint16_t min;
bool inverted;
bool is_analog;
} ch_config[CH_COUNT];
// config of each channel
struct ch_config ch_config[CH_COUNT];
// pin setttings
uint32_t pins[CH_COUNT]; uint32_t pins[CH_COUNT];
}; };
extern uint16_t Channel_data[NUM_TX_CHN];
extern Input input;
#endif #endif

44
remote/src/FrSkyD_cc2500.cpp

@ -17,7 +17,9 @@
#include "cc2500_spi.h" #include "cc2500_spi.h"
#include "Multiprotocol.h" #include "Multiprotocol.h"
uint8_t hopping_frequency[50];
uint16_t counter; uint16_t counter;
void frsky2way_init(uint8_t bind) void frsky2way_init(uint8_t bind)
{ {
//debugln("frsky2way_init"); //debugln("frsky2way_init");
@ -80,17 +82,13 @@ void frsky2way_data_frame()
packet[11] = 0; packet[11] = 0;
packet[16] = 0; packet[16] = 0;
packet[17] = 0; packet[17] = 0;
for(uint8_t i = 0; i < 8; i++)
{
for(uint8_t i = 0; i < 8; i++) {
uint16_t value; uint16_t value;
value = convert_channel_frsky(i); value = convert_channel_frsky(i);
if(i < 4)
{
if(i < 4) {
packet[6+i] = value & 0xff; packet[6+i] = value & 0xff;
packet[10+(i>>1)] |= ((value >> 8) & 0x0f) << (4 *(i & 0x01)); packet[10+(i>>1)] |= ((value >> 8) & 0x0f) << (4 *(i & 0x01));
}
else
{
} else {
packet[8+i] = value & 0xff; packet[8+i] = value & 0xff;
packet[16+((i-4)>>1)] |= ((value >> 8) & 0x0f) << (4 * ((i-4) & 0x01)); packet[16+((i-4)>>1)] |= ((value >> 8) & 0x0f) << (4 * ((i-4) & 0x01));
} }
@ -200,3 +198,35 @@ uint16_t ReadFrSky_2way()
} }
return state == FRSKY_DATA4 ? 7500 : 9000; return state == FRSKY_DATA4 ? 7500 : 9000;
} }
uint16_t convert_channel_frsky(uint8_t num)
{
uint16_t val = input.get_channel_data()[num];
return ((val * 15) >> 4) + 1290;
}
void Frsky_init_hop(void)
{
uint8_t val;
uint8_t channel = rx_tx_addr[0] & 0x07;
uint8_t channel_spacing = rx_tx_addr[1];
//Filter bad tables
if (channel_spacing < 0x02)
channel_spacing += 0x02;
if (channel_spacing > 0xE9)
channel_spacing -= 0xE7;
if (channel_spacing % 0x2F == 0)
channel_spacing++;
hopping_frequency[0] = channel;
for (uint8_t i = 1; i < 50; i++) {
channel = (channel + channel_spacing) % 0xEB;
val = channel;
if ((val == 0x00) || (val == 0x5A) || (val == 0xDC))
val++;
hopping_frequency[i] = i > 46 ? 0 : val;
}
}

1
remote/src/Multiprotocol.cpp

@ -66,7 +66,6 @@ uint16_t packet_period;
uint8_t packet_count; uint8_t packet_count;
uint8_t packet_sent; uint8_t packet_sent;
uint8_t packet_length; uint8_t packet_length;
uint8_t hopping_frequency[50];
uint8_t *hopping_frequency_ptr; uint8_t *hopping_frequency_ptr;
uint8_t hopping_frequency_no=0; uint8_t hopping_frequency_no=0;
uint8_t rf_ch_num; uint8_t rf_ch_num;

117
remote/src/common.cpp

@ -21,128 +21,11 @@
#include "input.h" #include "input.h"
/************************/
/** Convert routines **/
/************************/
// Revert a channel and store it
void reverse_channel(uint8_t num)
{
uint16_t val = 2048 - Channel_data[num];
if (val >= 2048)
val = 2047;
Channel_data[num] = val;
}
// Channel value is converted to ppm 860<->2140 -125%<->+125% and 988<->2012 -100%<->+100%
uint16_t convert_channel_ppm(uint8_t num)
{
uint16_t val = Channel_data[num];
return (((val << 2) + val) >> 3) + 860; //value range 860<->2140 -125%<->+125%
}
// Channel value 100% is converted to 10bit values 0<->1023
uint16_t convert_channel_10b(uint8_t num)
{
uint16_t val = Channel_data[num];
val = ((val << 2) + val) >> 3;
if (val <= 128)
return 0;
if (val >= 1152)
return 1023;
return val - 128;
}
// Channel value 100% is converted to 8bit values 0<->255
uint8_t convert_channel_8b(uint8_t num)
{
uint16_t val = Channel_data[num];
val = ((val << 2) + val) >> 5;
if (val <= 32)
return 0;
if (val >= 288)
return 255;
return val - 32;
}
// Channel value 100% is converted to value scaled
int16_t convert_channel_16b_limit(uint8_t num, int16_t min, int16_t max)
{
int32_t val = limit_channel_100(num); // 204<->1844
val = (val - CHANNEL_MIN_100) * (max - min) / (CHANNEL_MAX_100 - CHANNEL_MIN_100) + min;
return (uint16_t)val;
}
// Channel value -125%<->125% is scaled to 16bit value with no limit
int16_t convert_channel_16b_nolimit(uint8_t num, int16_t min, int16_t max)
{
int32_t val = Channel_data[num]; // 0<->2047
val = (val - CHANNEL_MIN_100) * (max - min) / (CHANNEL_MAX_100 - CHANNEL_MIN_100) + min;
return (uint16_t)val;
}
// Channel value is converted sign + magnitude 8bit values
uint8_t convert_channel_s8b(uint8_t num)
{
uint8_t ch;
ch = convert_channel_8b(num);
return (ch < 128 ? 127 - ch : ch);
}
// Channel value is limited to 100%
uint16_t limit_channel_100(uint8_t num)
{
if (Channel_data[num] >= CHANNEL_MAX_100)
return CHANNEL_MAX_100;
if (Channel_data[num] <= CHANNEL_MIN_100)
return CHANNEL_MIN_100;
return Channel_data[num];
}
// Channel value is converted for HK310
void convert_channel_HK310(uint8_t num, uint8_t *low, uint8_t *high)
{
uint16_t temp = 0xFFFF - (3440 + ((Channel_data[num] * 5) >> 1)) / 3;
*low = (uint8_t)(temp & 0xFF);
*high = (uint8_t)(temp >> 8);
}
// Failsafe value is converted for HK310
void convert_failsafe_HK310(uint8_t num, uint8_t *low, uint8_t *high)
{
uint16_t temp = 0xFFFF - (3440 + ((Failsafe_data[num] * 5) >> 1)) / 3;
*low = (uint8_t)(temp & 0xFF);
*high = (uint8_t)(temp >> 8);
}
// Channel value for FrSky (PPM is multiplied by 1.5)
uint16_t convert_channel_frsky(uint8_t num)
{
uint16_t val = Channel_data[num];
return ((val * 15) >> 4) + 1290;
}
/******************************/ /******************************/
/** FrSky D and X routines **/ /** FrSky D and X routines **/
/******************************/ /******************************/
#if defined(FRSKYD_CC2500_INO) || defined(FRSKYX_CC2500_INO) #if defined(FRSKYD_CC2500_INO) || defined(FRSKYX_CC2500_INO)
void Frsky_init_hop(void)
{
uint8_t val;
uint8_t channel = rx_tx_addr[0] & 0x07;
uint8_t channel_spacing = rx_tx_addr[1];
//Filter bad tables
if (channel_spacing < 0x02) channel_spacing += 0x02;
if (channel_spacing > 0xE9) channel_spacing -= 0xE7;
if (channel_spacing % 0x2F == 0) channel_spacing++;
hopping_frequency[0] = channel;
for (uint8_t i = 1; i < 50; i++)
{
channel = (channel + channel_spacing) % 0xEB;
val = channel;
if ((val == 0x00) || (val == 0x5A) || (val == 0xDC))
val++;
hopping_frequency[i] = i > 46 ? 0 : val;
}
}
#endif #endif
/******************************/ /******************************/
/** FrSky V, D and X routines **/ /** FrSky V, D and X routines **/

22
remote/src/crc.cpp

@ -0,0 +1,22 @@
#include "Arduino.h"
static uint32_t crc_table[16] = {
0x00000000, 0x1db71064, 0x3b6e20c8, 0x26d930ac,
0x76dc4190, 0x6b6b51f4, 0x4db26158, 0x5005713c,
0xedb88320, 0xf00f9344, 0xd6d6a3e8, 0xcb61b38c,
0x9b64c2b0, 0x86d3d2d4, 0xa00ae278, 0xbdbdf21c
};
uint32_t crc_update (uint32_t crc, uint8_t data)
{
uint8_t tbl_idx;
uint8_t mask = 0x0f;
tbl_idx = crc ^ (data >> (0 * 4));
crc = (crc_table + (tbl_idx & mask)) ^ (crc >> 4);
tbl_idx = crc ^ (data >> (1 * 4));
crc = (crc_table + (tbl_idx & mask)) ^ (crc >> 4);
return crc;
}

102
remote/src/eeprom.cpp

@ -0,0 +1,102 @@
#include <EEPROM.h>
#include <Arduino.h>
#include <stdint.h>
#include "tx_def.h"
#include "eeprom.h"
#include "crc.h"
class Eeprom_config eeprom_config;
Eeprom_config::Eeprom_config() {
EEPROM.PageBase0 = 0x801F000;
EEPROM.PageBase1 = 0x801F800;
EEPROM.PageSize = 0x400;
EEPROM.init();
memset(&this->current_config, 0, sizeof(this->current_config));
this->sucessfull_read = false;
}
Eeprom_config::~Eeprom_config() {
/* nope */
}
int Eeprom_config::validate() {
if (this->sucessfull_read == false) {
return -1;
}
if (this->current_config.version != CURRENT_VERSION) {
return -1;
}
uint32_t crc_calc = 0;
uint8_t * data = &(this->current_config.data);
for (uint8_t i = 0; i < sizeof(struct eeprom_data_v1) ; i = 0) {
crc_calc = crc_update(crc_calc, data[i]);
}
if (crc_calc != this->current_config.data_crc) {
return -1;
}
return 0;
}
int Eeprom_config::read(void) {
uint8_t *data = NULL;
data = (uint8_t *) &this->current_config;
for (uint8_t i = 0; i < sizeof(struct eeprom_data_v1) ; i = 0) {
EEPROM.read(0x10 + i , data);
data+=1;
}
this->sucessfull_read = true;
return 0;
}
int Eeprom_config::write(void) {
uint8_t *data = NULL;
data = (uint8_t *) &this->current_config;
for (uint8_t i = 0; i < sizeof(struct eeprom_data_v1) ; i = 0) {
EEPROM.write(0x10 + i , data);
data+=1;
}
return 0;
}
int Eeprom_config::get_ch_config(struct ch_config* config) {
if (this->sucessfull_read == false && config != NULL) {
return -1;
}
memcpy(config, this->current_config.data.ch, sizeof(struct ch_config) * CH_COUNT);
return 0;
}
int Eeprom_config::set_ch_config(struct ch_config* config) {
if (this->sucessfull_read == false && config != NULL) {
return -1;
}
memcpy(this->current_config.data.ch, config, sizeof(struct ch_config) * CH_COUNT);
return 0;
}
int Eeprom_config::get_master_id(uint32_t* master_id)
{
if (this->sucessfull_read == false && master_id != NULL) {
return -1;
}
*master_id = this->current_config.data.master_id;
return 0;
}
int Eeprom_config::set_master_id(uint32_t master_id)
{
if (this->sucessfull_read == false) {
return -1;
}
this->current_config.data.master_id = master_id;
return 0;
}

47
remote/src/input.cpp

@ -8,8 +8,6 @@
#include "state.h" #include "state.h"
Input input; Input input;
uint16_t Channel_data[NUM_TX_CHN];
uint16_t Failsafe_data[NUM_TX_CHN];
const char* ch_name[NUM_TX_CHN] = { const char* ch_name[NUM_TX_CHN] = {
"CH_ROLL", "CH_ROLL",
@ -29,6 +27,7 @@ Input::Input(void) {
this->curr = &(this->input[0]); this->curr = &(this->input[0]);
this->old = &(this->input[1]); this->old = &(this->input[1]);
memset(this->input,0, sizeof(this->input)); memset(this->input,0, sizeof(this->input));
//InitFailsafe //InitFailsafe
for (uint8_t i = 0; i < NUM_TX_CHN; i++) for (uint8_t i = 0; i < NUM_TX_CHN; i++)
Failsafe_data[i] = (CHANNEL_MAX_100 - CHANNEL_MIN_100) / 2 + CHANNEL_MIN_100; Failsafe_data[i] = (CHANNEL_MAX_100 - CHANNEL_MIN_100) / 2 + CHANNEL_MIN_100;
@ -37,8 +36,12 @@ Input::Input(void) {
// init channel // init channel
for (uint8_t i = 0; i < NUM_TX_CHN; i++) for (uint8_t i = 0; i < NUM_TX_CHN; i++)
Channel_data[i] = 1024;
Channel_data[CH_THROTTLE] = 204;
this->channel_data[i] = 1024;
this->channel_data[CH_THROTTLE] = 204;
}
uint16_t *Input::get_channel_data(void) {
return this->channel_data;
} }
void Input::mark_processed(void) { void Input::mark_processed(void) {
struct data* temp = this->old; struct data* temp = this->old;
@ -102,14 +105,10 @@ void Input::init() {
this->ch_config[CH_AUX3].inverted = false; this->ch_config[CH_AUX3].inverted = false;
this->ch_config[CH_AUX4].inverted = false; this->ch_config[CH_AUX4].inverted = false;
this->ch_config[CH_AUX5].inverted = false; this->ch_config[CH_AUX5].inverted = false;
}
void Input::do_calibration(void) {
} }
bool Input::is_centered(void) { bool Input::is_centered(void) {
return
this->is_centered(CH_ROLL) &&
return this->is_centered(CH_ROLL) &&
this->is_centered(CH_PITCH) && this->is_centered(CH_PITCH) &&
this->is_centered(CH_THROTTLE) && this->is_centered(CH_THROTTLE) &&
this->is_centered(CH_YAW); this->is_centered(CH_YAW);
@ -190,14 +189,26 @@ bool Input::calibration_update(void) {
return changed; return changed;
} }
void Input::calibration_init(void) {
void Input::calibration_reset(void) {
for (uint8_t ch = 0; ch < CH_COUNT; ch++) { for (uint8_t ch = 0; ch < CH_COUNT; ch++) {
this->ch_config[ch].min = this->ch_raw[ch]; this->ch_config[ch].min = this->ch_raw[ch];
this->ch_config[ch].max = this->ch_raw[ch]; this->ch_config[ch].max = this->ch_raw[ch];
} }
} }
void Input::update(void) {
void Input::set_calibration(struct ch_config *new_config)
{
if (new_config != NULL) {
memcpy(this->ch_config, new_config, sizeof(ch_config));
}
}
void Input::get_calibration(struct ch_config *curr_config)
{
if (curr_config != NULL) {
memcpy(curr_config, this->ch_config, sizeof(ch_config));
}
}
void Input::update(void) {
for (uint8_t ch = 0; ch < CH_MAX; ch ++) { for (uint8_t ch = 0; ch < CH_MAX; ch ++) {
if (this->ch_config[ch].is_analog) if (this->ch_config[ch].is_analog)
@ -212,7 +223,6 @@ void Input::update(void) {
this->curr->ch_data[ch] = this->ch_raw[ch]; this->curr->ch_data[ch] = this->ch_raw[ch];
// cap on max // cap on max
if (this->ch_config[ch].min > this->curr->ch_data[ch]) { if (this->ch_config[ch].min > this->curr->ch_data[ch]) {
this->curr->ch_data[ch] = this->ch_config[ch].min; this->curr->ch_data[ch] = this->ch_config[ch].min;
} else if (this->ch_config[ch].max < this->curr->ch_data[ch]) { } else if (this->ch_config[ch].max < this->curr->ch_data[ch]) {
@ -222,17 +232,14 @@ void Input::update(void) {
this->curr->menu = digitalRead(Menu_pin) == HIGH; this->curr->menu = digitalRead(Menu_pin) == HIGH;
for (uint8_t ch = 0; ch < CH_COUNT; ++ch) {
this->channel_data[ch] = map(this->curr->ch_data[ch], this->ch_config[ch].min, this->ch_config[ch].max, CHANNEL_MAX_100, CHANNEL_MIN_100);
}
/*debug_input("t%d y%d r%d p%d a1_%d a2_%d a3_%d a4_%d a5_%d m%d", /*debug_input("t%d y%d r%d p%d a1_%d a2_%d a3_%d a4_%d a5_%d m%d",
this->curr->throttle,this->curr->yaw,this->curr->roll,this->curr->pitch, this->curr->throttle,this->curr->yaw,this->curr->roll,this->curr->pitch,
this->curr->aux[0],this->curr->aux[1],this->curr->aux[2],this->curr->aux[3], this->curr->aux[0],this->curr->aux[1],this->curr->aux[2],this->curr->aux[3],
this->curr->aux[4],this->curr->aux[5],this->curr->menu this->curr->aux[4],this->curr->aux[5],this->curr->menu
);*/ );*/
// only do channeloutpu if needed
if (curr_state != s_fly)
return;
for (uint8_t ch = 0; ch < CH_COUNT; ++ch) {
Channel_data[ch] = map(this->curr->ch_data[ch], this->ch_config[ch].min, this->ch_config[ch].max, CHANNEL_MAX_100, CHANNEL_MIN_100);
}
} }
// Channel value for FrSky (PPM is multiplied by 1.5)

7
remote/src/state.cpp

@ -4,6 +4,7 @@
#include "FrSkyD_cc2500.h" #include "FrSkyD_cc2500.h"
#include "state.h" #include "state.h"
#include "input.h" #include "input.h"
#include "eeprom.h"
#include "debug.h" #include "debug.h"
#include "tx_def.h" #include "tx_def.h"
@ -212,7 +213,7 @@ void LCD_state_joy_calibration::update(void) {
int8_t i; int8_t i;
// init min/max // init min/max
input.calibration_init();
input.calibration_reset();
// min max calibration // min max calibration
lcd.setCursor(0,0); lcd.setCursor(0,0);
@ -274,6 +275,10 @@ void LCD_state_joy_calibration::update(void) {
} }
} }
struct ch_config ch_config[CH_COUNT];
input.get_calibration(ch_config);
lcd.setCursor(0,0); lcd.setCursor(0,0);
lcd.print("center again "); lcd.print("center again ");
lcd.setCursor(0,1); lcd.setCursor(0,1);

Loading…
Cancel
Save