Browse Source

fix typo + fix invert add min max check for dead range

master
Schoenberger, Philipp 6 years ago
parent
commit
c1cc8fcf16
  1. 4
      remote/include/config.h
  2. 2
      remote/include/eeprom.h
  3. 28
      remote/src/input.cpp
  4. 2
      remote/src/state_init.cpp

4
remote/include/config.h

@ -17,11 +17,11 @@
#include <stdint.h>
//#define REMOE_OWNER "phschoen"
#define REMOE_OWNER "Marleen"
//#define REMOE_OWNER "Marleen"
//#define REMOE_OWNER "Sina"
//#define REMOE_OWNER "Malaika"
//#define REMOE_OWNER "Pauline"
//#define REMOE_OWNER "Mara"
#define REMOE_OWNER "Mara"
#define DEFAULT_BIND_TIME 13 /*seconds*/

2
remote/include/eeprom.h

@ -23,7 +23,7 @@ public:
int get_freq_offset(uint8_t* freq_offset);
int set_freq_offset(uint8_t freq_offset);
private:
#define CURRENT_VERSION 0x02
#define CURRENT_VERSION 0x01
struct eeprom_data_v1 {
uint8_t version;
uint32_t data_crc;

28
remote/src/input.cpp

@ -91,7 +91,7 @@ void Input::init() {
this->ch_config[CH_YAW].inverted = false;
this->ch_config[CH_ROLL].inverted = false;
this->ch_config[CH_PITCH].inverted = false;
this->ch_config[CH_AUX1].inverted = true;
this->ch_config[CH_AUX1].inverted = false;
this->ch_config[CH_AUX2].inverted = true;
this->ch_config[CH_AUX3].inverted = true;
this->ch_config[CH_AUX4].inverted = true;
@ -226,19 +226,19 @@ void Input::update(void) {
} else {
this->ch_raw[ch] = digitalRead(this->pins[ch]) == HIGH ? CHANNEL_MIN_100 : CHANNEL_MAX_100;
}
// do inverting
if (this->ch_config[ch].inverted)
this->curr->ch_data[ch] = this->ch_config[ch].max - this->ch_raw[ch];
else
this->curr->ch_data[ch] = this->ch_raw[ch];
// cap on max
if (this->ch_config[ch].min > this->curr->ch_data[ch]) {
this->curr->ch_data[ch] = this->ch_config[ch].min;
} else if (this->ch_config[ch].max < this->curr->ch_data[ch]) {
this->curr->ch_data[ch] = this->ch_config[ch].max;
}
// do inverting
if (this->ch_config[ch].inverted)
this->curr->ch_data[ch] = map(this->ch_raw[ch], this->ch_config[ch].min, this->ch_config[ch].max, this->ch_config[ch].max, this->ch_config[ch].min);
else
this->curr->ch_data[ch] = this->ch_raw[ch];
}
this->curr->menu = digitalRead(Menu_pin) == HIGH;
@ -265,6 +265,11 @@ void Input::update(void) {
}
}
}
if (this->channel_data[ch] < CHANNEL_MIN_100 )
this->channel_data[ch] = CHANNEL_MIN_100;
if (this->channel_data[ch] > CHANNEL_MAX_100 )
this->channel_data[ch] = CHANNEL_MAX_100;
}
/* debug_input("t%d y%d r%d p%d \n", */
/* this->channel_data[CH_THROTTLE], */
@ -272,4 +277,11 @@ void Input::update(void) {
/* this->channel_data[CH_ROLL], */
/* this->channel_data[CH_PITCH] */
/* ); */
int ch = CH_AUX1;
debug_input("raw t%d min %d max %d -> %d\n",
this->ch_raw[ch],
this->ch_config[ch].min,
this->ch_config[ch].max,
this->channel_data[ch]
);
}

2
remote/src/state_init.cpp

@ -15,7 +15,7 @@ LCD_state_init::LCD_state_init(void) {
void LCD_state_init::enter(void) {
lcd.clear();
lcd.setCursor(0,0);
lcd.print(" wellcome ");
lcd.print(" welcome ");
lcd.setCursor(0,1);
lcd_centerText(REMOE_OWNER);

Loading…
Cancel
Save