Browse Source

add hf cfg state

master
Schoenberger, Philipp 6 years ago
parent
commit
257cae4711
  1. 12
      remote/include/state.h
  2. 1
      remote/src/Multiprotocol.cpp
  3. 69
      remote/src/state_hd_calib.cpp
  4. 6
      remote/src/state_menu.cpp

12
remote/include/state.h

@ -112,6 +112,18 @@ public:
extern State *s_usb;
#endif
class LCD_state_hf_cfg: public State {
private:
unsigned long time_enter;
bool changed;
public:
LCD_state_hf_cfg(void);
void enter(void);
void update(void);
void leave(void);
};
extern State *s_hf_cfg;
extern State *curr_state;
extern State *new_state;

1
remote/src/Multiprotocol.cpp

@ -99,7 +99,6 @@ void setup()
//frquency offset initialization
{
freq_offset = 0;
debug("freq offset: %d\n", freq_offset);
CC2500_Reset();
//Wait for cc2500 to reset

69
remote/src/state_hd_calib.cpp

@ -0,0 +1,69 @@
#include <LiquidCrystal_I2C.h>
#include <stdio.h>
#include "Arduino.h"
#include "FrSkyD_cc2500.h"
#include "state.h"
#include "input.h"
#include "eeprom.h"
#include "debug.h"
#include "tx_def.h"
#include "config.h"
LCD_state_hf_cfg::LCD_state_hf_cfg(void) {
}
void LCD_state_hf_cfg::enter(void) {
lcd.setCursor(0,0);
lcd.print("enter hf config ");
lcd.setCursor(0,1);
lcd.print(" ");
this->time_enter = millis();
this->changed = false;
}
void LCD_state_hf_cfg::update(void)
{
char line[17];
input.update();
lcd.setCursor(0,0);
lcd.print("freq offset: ");
// print on lcd
lcd.setCursor(0,1);
snprintf(line,sizeof(line),"%02lu",freq_offset);
lcd.print(line);
if (input.is_menu_triggered()) {
debug("%lu menu button trigger\n", millis);
new_state = s_menu;
}
bool wait = false;
if (input.is_high(Input::MENU_UP_DOWN)) {
freq_offset +=1;
this->changed = true;
wait = true;
}
if (input.is_low(Input::MENU_UP_DOWN)) {
freq_offset -=1;
this->changed = true;
wait = true;
}
if(wait)
delay(150);
}
void LCD_state_hf_cfg::leave(void)
{
if (this->changed) {
eeprom_config.set_freq_offset(freq_offset);
eeprom_config.write();
eeprom_config.read();
if (eeprom_config.validate()) {
debugln("ok calib\n");
}else {
debugln("failed calib\n");
}
this->changed = false;
}
lcd.clear();
}

6
remote/src/state_menu.cpp

@ -30,7 +30,7 @@ void LCD_state_menu::update(void)
{ "Joy usb ", s_usb},
#endif
{ "Joy calib ", s_joy },
{ "HF calib ", NULL },
{ "HF config ", s_hf_cfg },
{ " ", NULL },
};
@ -48,8 +48,8 @@ void LCD_state_menu::update(void)
if (false == input.is_centered(Input::MENU_UP_DOWN)) {
if (input.is_low(Input::MENU_UP_DOWN)){
this->curr_selected +=1;
if ( this->curr_selected > 3)
this->curr_selected = 3;
if ( this->curr_selected > 4)
this->curr_selected = 4;
else
wait = true;
}

Loading…
Cancel
Save