697 lines
22 KiB
Arduino
697 lines
22 KiB
Arduino
|
void circularList_incrementBy(byte *value, byte minimun, byte maximun, byte incrementBy) {
|
||
|
|
||
|
if (*value+incrementBy > maximun) *value = minimun;
|
||
|
else *value = *value+incrementBy;
|
||
|
}
|
||
|
|
||
|
// decrement the value of a variable using minimun and maximun limits
|
||
|
void circularList_decrementBy(byte *value, byte minimun, byte maximun, byte decrementBy) {
|
||
|
|
||
|
if ((*value < minimun) || (*value < decrementBy)) *value = maximun;
|
||
|
else *value = *value-decrementBy;
|
||
|
}
|
||
|
|
||
|
// increment the value of a variable using minimun and maximun limits
|
||
|
void circularList_incrementBy(unsigned int *value, unsigned int minimun, unsigned int maximun, byte incrementBy) {
|
||
|
|
||
|
if (*value+incrementBy > maximun) *value = minimun;
|
||
|
else *value = *value+incrementBy;
|
||
|
}
|
||
|
|
||
|
// decrement the value of a variable using minimun and maximun limits
|
||
|
void circularList_decrementBy(unsigned int *value, unsigned int minimun, unsigned int maximun, byte decrementBy) {
|
||
|
|
||
|
if ((*value < minimun) || (*value < decrementBy)) *value = maximun;
|
||
|
else *value = *value-decrementBy;
|
||
|
}
|
||
|
|
||
|
void circularList_incrementBy_ASCII(char *value) {
|
||
|
|
||
|
if (*value >= 122) *value = 32;
|
||
|
else if (*value <= 32) *value = 48;
|
||
|
else if (*value == 57) *value = 65;
|
||
|
else if (*value == 90) *value = 97;
|
||
|
else *value = *value + 1;
|
||
|
}
|
||
|
|
||
|
void circularList_decrementBy_ASCII(char *value) {
|
||
|
if (*value <= 32) *value = 122;
|
||
|
else if (*value <= 48) *value = 32;
|
||
|
else if (*value == 65) *value = 57;
|
||
|
else if (*value == 97) *value = 90;
|
||
|
else *value = *value - 1;
|
||
|
}
|
||
|
|
||
|
|
||
|
//Pantalla principal.
|
||
|
|
||
|
void controller_run(){
|
||
|
lcd.clear();
|
||
|
do{ keyboard_scan();
|
||
|
//Serial.println("Hola!!!");
|
||
|
lcd.setCursor(0, 0);
|
||
|
level_bat(batmin,batmax);
|
||
|
lcd.setCursor(0, 1);
|
||
|
lcd.print("TC: ");
|
||
|
|
||
|
int temp = hours;
|
||
|
if (temp<10) lcd.print("0");
|
||
|
lcd.print(temp);
|
||
|
lcd.print(":");
|
||
|
|
||
|
temp = minutes;
|
||
|
if (temp<10) lcd.print("0");
|
||
|
lcd.print(temp);
|
||
|
lcd.print(":");
|
||
|
|
||
|
temp = seconds;
|
||
|
if (temp<10) lcd.print("0");
|
||
|
lcd.print(temp);
|
||
|
lcd.print(":");
|
||
|
|
||
|
temp = frame;
|
||
|
if (temp<10) lcd.print("0");
|
||
|
lcd.print(temp);
|
||
|
|
||
|
if(lastKey==KEY_C) backlight_toggle();
|
||
|
} while ((lastKey==NO_KEY)||(lastKey==KEY_C));
|
||
|
controller_showMainMenu();
|
||
|
}
|
||
|
|
||
|
// Menu principal
|
||
|
|
||
|
void controller_showMainMenu(){
|
||
|
|
||
|
byte currentOption = 0;
|
||
|
|
||
|
for(boolean exit = false;!exit;){
|
||
|
|
||
|
display_printTitle(MSG_MAIN_MENU); //MSG_MAIN_MENU
|
||
|
//display_printEnumeration(currentOption, &MSG_SHOWMAINMENU[currentOption + 1]);
|
||
|
if(currentOption==0) display_printEnumeration(0, MSG_SYSTEM_CONFIG);
|
||
|
if(currentOption==1) display_printEnumeration(1, MSG_GRAB_VIDEO);
|
||
|
if(currentOption==2) display_printEnumeration(2, MSG_CAPT_FOTO);
|
||
|
|
||
|
keyboard_waitForAnyKey();
|
||
|
|
||
|
if(lastKey==KEY_A) circularList_decrementBy(¤tOption, 0, 2, 1);
|
||
|
if(lastKey==KEY_B) circularList_incrementBy(¤tOption, 0, 2, 1);
|
||
|
if(lastKey==KEY_C) exit = true;
|
||
|
if(lastKey==KEY_D) {
|
||
|
|
||
|
if(currentOption==0) controller_showSystemConfig();
|
||
|
if(currentOption==1) controller_showVideoMenu();
|
||
|
if(currentOption==2) controller_showPhotoMenu();
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
|
||
|
void controller_VideoSelect(){
|
||
|
|
||
|
byte currentOption = 0;
|
||
|
unsigned int address_model;
|
||
|
for(boolean exit = false;!exit;)
|
||
|
{
|
||
|
display_printTitle(MSG_MODEL);
|
||
|
if (system_num_models>0)
|
||
|
{
|
||
|
if(currentOption < system_num_models){
|
||
|
address_model = EEI2C_ADDR_MODELS + 80*currentOption;
|
||
|
display_model_EEPROM(address_model);
|
||
|
}
|
||
|
keyboard_waitForAnyKey();
|
||
|
|
||
|
if(lastKey==KEY_A) circularList_decrementBy(¤tOption, 0, system_num_models - 1, 1);
|
||
|
if(lastKey==KEY_B) circularList_incrementBy(¤tOption, 0, system_num_models - 1, 1);
|
||
|
if(lastKey==KEY_C) { exit = true; }
|
||
|
if(lastKey==KEY_D) {
|
||
|
system_sel_model=currentOption;
|
||
|
config_saveBackup_system();
|
||
|
}
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
lcd.print(F("Vacio"));
|
||
|
keyboard_waitForAnyKey();
|
||
|
if(lastKey==KEY_C) { exit = true; }
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
// Menu de Video
|
||
|
|
||
|
void controller_showVideoMenu(){
|
||
|
|
||
|
byte currentOption = 0;
|
||
|
|
||
|
for(boolean exit = false;!exit;){
|
||
|
display_printTitle(MSG_GRAB_VIDEO);
|
||
|
// Show menu option
|
||
|
if (currentOption==0) { display_print_Model();}
|
||
|
else if (currentOption==1) {lcd.print(F("TT: ")); display_time(timetotalvideo);}
|
||
|
else if (currentOption==2) {lcd.print(F("TR: ")); display_time(timerecvideo);}
|
||
|
else if (currentOption==3) {lcd.print(F("TP: ")); display_time(timepausevideo);}
|
||
|
else if (currentOption==4) {if(!start_video) lcd.print(F("Iniciar")); else lcd.print(F("Parar"));}
|
||
|
keyboard_waitForAnyKey();
|
||
|
if(lastKey==KEY_A) circularList_decrementBy(¤tOption, 0, 4, 1);
|
||
|
if(lastKey==KEY_B) circularList_incrementBy(¤tOption, 0, 4, 1);
|
||
|
if(lastKey==KEY_C) { config_saveBackup_system(); exit = true; }
|
||
|
if(lastKey==KEY_D) {
|
||
|
|
||
|
if(currentOption==0) controller_VideoSelect();
|
||
|
if(currentOption==1) edit_time(&timetotalvideo);
|
||
|
if(currentOption==2) edit_time(&timerecvideo);
|
||
|
if(currentOption==3) edit_time(&timepausevideo);
|
||
|
if(currentOption==4)
|
||
|
{
|
||
|
if(!start_video)
|
||
|
{
|
||
|
timecode=0;
|
||
|
timeseconds = 0;
|
||
|
frame = 0;
|
||
|
seconds = 0;
|
||
|
frames_ant=timecode;
|
||
|
minutes = 0;
|
||
|
hours = 0;
|
||
|
timeant = timerecvideo;
|
||
|
frec=false;
|
||
|
fpau=true;
|
||
|
lanc.println();
|
||
|
delay(100);
|
||
|
bit_count = 0;
|
||
|
morse_count = 0;
|
||
|
lanc.println(lancrec, HEX);
|
||
|
start_video=true;
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
start_video=false;
|
||
|
digitalWrite(PINS_BUZZER,LOW);
|
||
|
lanc.println();
|
||
|
delay(100);
|
||
|
lanc.println(lancstop, HEX);
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
// Menu de foto
|
||
|
|
||
|
void controller_showPhotoMenu(){
|
||
|
|
||
|
byte currentOption = 0;
|
||
|
|
||
|
for(boolean exit = false;!exit;){
|
||
|
|
||
|
display_printTitle(MSG_CAPT_FOTO);
|
||
|
if (currentOption==0) {lcd.print(F("TT: ")); display_time(timetotalphoto);}
|
||
|
else if (currentOption==1) {lcd.print(F("TF: ")); display_time(timeflash);}
|
||
|
else if (currentOption==2) {if(!start_photo) lcd.print(F("Iniciar")); else lcd.print(F("Parar"));}
|
||
|
keyboard_waitForAnyKey();
|
||
|
if(lastKey==KEY_A) circularList_decrementBy(¤tOption, 0, 2, 1);
|
||
|
if(lastKey==KEY_B) circularList_incrementBy(¤tOption, 0, 2, 1);
|
||
|
if(lastKey==KEY_C) { config_saveBackup_system(); exit = true; }
|
||
|
if(lastKey==KEY_D) {
|
||
|
if(currentOption==0) edit_time(&timetotalphoto);
|
||
|
if(currentOption==1) edit_time(&timeflash);
|
||
|
if(currentOption==2)
|
||
|
{
|
||
|
if(!start_photo)
|
||
|
{
|
||
|
timecode=0;
|
||
|
timeseconds = 0;
|
||
|
frame = 0;
|
||
|
seconds = 0;
|
||
|
minutes = 0;
|
||
|
hours = 0;
|
||
|
//lanc.println(lancrec, HEX);
|
||
|
start_photo=true;
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
start_photo=false;
|
||
|
//lanc.println();
|
||
|
delay(100);
|
||
|
//lanc.println(lancstop, HEX);
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
// Menu de Configuracion
|
||
|
|
||
|
void controller_showSystemConfig(){
|
||
|
|
||
|
byte currentOption = 0;
|
||
|
|
||
|
for(boolean exit = false;!exit;){
|
||
|
|
||
|
display_printTitle(MSG_SYSTEM_CONFIG);
|
||
|
|
||
|
// Show menu option
|
||
|
if (currentOption==0) { display_print(MSG_BACKLIGHT); display_printBoolean(system_useBacklight); }
|
||
|
else if (currentOption==1) { display_print(MSG_SPEAKER); display_printBoolean(system_useSpeaker); }
|
||
|
else if (currentOption==2){ display_print(MSG_CFG_VIDEO); }
|
||
|
else if (currentOption==3){ display_print(MSG_CFG_NETWORK); }
|
||
|
else if (currentOption==4){ display_print(MSG_VERSION); }
|
||
|
|
||
|
keyboard_waitForAnyKey();
|
||
|
|
||
|
if(lastKey==KEY_A) circularList_decrementBy(¤tOption, 0, 4, 1);
|
||
|
if(lastKey==KEY_B) circularList_incrementBy(¤tOption, 0, 4, 1);
|
||
|
if(lastKey==KEY_C) { config_saveBackup_system(); exit = true; }
|
||
|
if(lastKey==KEY_D) {
|
||
|
|
||
|
if(currentOption==0) backlight_toggle();
|
||
|
if(currentOption==1) system_useSpeaker = !system_useSpeaker;
|
||
|
if(currentOption==2) controller_videoConfig();
|
||
|
if(currentOption==3) controller_cfg_network();
|
||
|
if(currentOption==4) ver_version();
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
//Seleccion de modelo de Camara
|
||
|
|
||
|
void controller_videoConfig(){
|
||
|
|
||
|
byte currentOption = 0;
|
||
|
unsigned int address_model;
|
||
|
for(boolean exit = false;!exit;){
|
||
|
|
||
|
display_printTitle(MSG_CFG_VIDEO);
|
||
|
|
||
|
// Show menu option
|
||
|
if (currentOption==system_num_models)
|
||
|
{
|
||
|
display_print(MSG_NEW_MODEL);
|
||
|
address_model = EEI2C_ADDR_MODELS + 80*currentOption;
|
||
|
}
|
||
|
else if(currentOption < system_num_models){
|
||
|
address_model = EEI2C_ADDR_MODELS + 80*currentOption;
|
||
|
display_model_EEPROM(address_model);
|
||
|
}
|
||
|
else if(currentOption==system_num_models + 1) display_print(MSG_ERASE_MODEL);
|
||
|
|
||
|
keyboard_waitForAnyKey();
|
||
|
|
||
|
if(lastKey==KEY_A) circularList_decrementBy(¤tOption, 0, system_num_models + 1, 1);
|
||
|
if(lastKey==KEY_B) circularList_incrementBy(¤tOption, 0, system_num_models + 1, 1);
|
||
|
if(lastKey==KEY_C) { /*config_saveBackup_system()*/; exit = true; }
|
||
|
if(lastKey==KEY_D) {
|
||
|
if (currentOption < system_num_models)controller_videoModel(address_model);
|
||
|
if (currentOption == system_num_models) {clear_model(address_model); system_num_models = system_num_models + 1; controller_videoModel(address_model);}
|
||
|
if (currentOption == system_num_models + 1) {if (system_num_models>0){remove_model(); currentOption=0;}};
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
//Control de los diferentes modelos (Editar, borrar, etc)
|
||
|
|
||
|
void controller_videoModel(long int address_model){
|
||
|
|
||
|
byte currentOption = 0;
|
||
|
unsigned long temp_remote;
|
||
|
unsigned int temp_address;
|
||
|
boolean print_ir = false;
|
||
|
|
||
|
for(boolean exit = false;!exit;){
|
||
|
lcd.clear();
|
||
|
// Show menu option
|
||
|
if (currentOption==0) { print_ir = false; display_printTitle(MSG_MODEL); display_model_EEPROM(address_model);}
|
||
|
if (currentOption==1) {
|
||
|
display_printTitle(MSG_STOP_REMOTE);
|
||
|
temp_address = address_model+16;
|
||
|
if (print_ir == false)
|
||
|
{
|
||
|
remotestop = display_printEEPROM(temp_address);
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
saveEEPROM(results.value,temp_address);
|
||
|
temp_remote = display_printEEPROM(temp_address);
|
||
|
print_ir = false;
|
||
|
}
|
||
|
}
|
||
|
if (currentOption==2) {
|
||
|
display_printTitle(MSG_REC_REMOTE);
|
||
|
temp_address = address_model+32;
|
||
|
if (print_ir == false)
|
||
|
{
|
||
|
temp_remote=display_printEEPROM(temp_address);
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
saveEEPROM(results.value,temp_address);
|
||
|
remoterec=display_printEEPROM(temp_address);
|
||
|
print_ir = false;
|
||
|
}
|
||
|
}
|
||
|
if (currentOption==3) {
|
||
|
print_ir = false;
|
||
|
display_printTitle(MSG_STOP_LANC);
|
||
|
temp_address = address_model+48;
|
||
|
display_printEEPROM(temp_address);
|
||
|
}
|
||
|
if (currentOption==4) {
|
||
|
print_ir = false;
|
||
|
display_printTitle(MSG_REC_LANC);
|
||
|
temp_address = address_model+64;
|
||
|
display_printEEPROM(temp_address);
|
||
|
}
|
||
|
|
||
|
keyboard_IR(&print_ir);
|
||
|
|
||
|
if(lastKey==KEY_A) circularList_decrementBy(¤tOption, 0, 4, 1);
|
||
|
if(lastKey==KEY_B) circularList_incrementBy(¤tOption, 0, 4, 1);
|
||
|
if(lastKey==KEY_C) {exit = true; config_saveBackup_system();}
|
||
|
if(lastKey==KEY_D) {
|
||
|
if(currentOption==0) edit_name(address_model);
|
||
|
if(currentOption==1) irsend.sendNEC(temp_remote, 32);
|
||
|
if(currentOption==2) irsend.sendNEC(temp_remote, 32);
|
||
|
if(currentOption==3) edit_code(temp_address);
|
||
|
if(currentOption==4) edit_code(temp_address);
|
||
|
irrecv.enableIRIn();
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
void remove_model(){
|
||
|
byte currentOption = 0;
|
||
|
unsigned int address_model;
|
||
|
for(boolean exit = false;!exit;){
|
||
|
display_printTitle(MSG_ERASE_MODEL);
|
||
|
if(currentOption < system_num_models){
|
||
|
address_model = EEI2C_ADDR_MODELS + 80*currentOption;
|
||
|
display_model_EEPROM(address_model);
|
||
|
}
|
||
|
keyboard_waitForAnyKey();
|
||
|
if(lastKey==KEY_A) circularList_decrementBy(¤tOption, 0, system_num_models-1, 1);
|
||
|
if(lastKey==KEY_B) circularList_incrementBy(¤tOption, 0, system_num_models-1, 1);
|
||
|
if(lastKey==KEY_C) exit = true;
|
||
|
if(lastKey==KEY_D) {erase_model(currentOption); currentOption--; exit = true;}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
void edit_name(long int address_model){
|
||
|
byte pos=0;
|
||
|
char currentOption = readEEPROM(eeprom, address_model+pos);
|
||
|
for(boolean exit = false;!exit;){
|
||
|
writeEEPROM(eeprom, address_model + pos, currentOption);
|
||
|
display_printTitle(MSG_EDIT_NAME); //MSG_EDIT_NAME
|
||
|
display_model_EEPROM(address_model);
|
||
|
keyboard_waitForAnyKey();
|
||
|
if(lastKey==KEY_A) circularList_decrementBy_ASCII(¤tOption);
|
||
|
if(lastKey==KEY_B) circularList_incrementBy_ASCII(¤tOption);
|
||
|
if(lastKey==KEY_C) {exit = true;}
|
||
|
if(lastKey==KEY_D) {pos=pos+1; currentOption=readEEPROM(eeprom, address_model+pos);}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
void edit_code(long int address_model){
|
||
|
byte pos=0;
|
||
|
byte currentOption = readEEPROM(eeprom, address_model);
|
||
|
for(boolean exit = false;!exit;){
|
||
|
if (pos < 2) writeEEPROM(eeprom, address_model + pos, currentOption);
|
||
|
writeEEPROM(eeprom, address_model + 2, 0x0D);
|
||
|
display_printTitle(MSG_EDIT_LANC);
|
||
|
display_printEEPROM(address_model);
|
||
|
keyboard_waitForAnyKey();
|
||
|
if(lastKey==KEY_A) circularList_incrementBy(¤tOption, 0, 255, 1);
|
||
|
if(lastKey==KEY_B) circularList_decrementBy(¤tOption, 0, 255, 1);
|
||
|
if(lastKey==KEY_C) {exit = true;}
|
||
|
if(lastKey==KEY_D) {
|
||
|
pos=pos+1;
|
||
|
currentOption = readEEPROM(eeprom, address_model + pos);
|
||
|
if(pos>=2) {
|
||
|
//lanc.print(readEEPROM(eeprom, address_model),HEX); lanc.println(readEEPROM(eeprom, address_model+1),HEX);
|
||
|
int lanctemp = word(readEEPROM(eeprom, address_model),readEEPROM(eeprom, address_model + 1));
|
||
|
lanc.println(lanctemp, HEX);
|
||
|
Serial.println(lanctemp, HEX);
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
void edit_pass(){
|
||
|
byte pos=0;
|
||
|
char currentOption = pass[pos];
|
||
|
for(boolean exit = false;!exit;){
|
||
|
pass[pos]=currentOption;
|
||
|
display_printTitle(MSG_EDIT_PASS);
|
||
|
lcd.print(pass);
|
||
|
keyboard_waitForAnyKey();
|
||
|
if(lastKey==KEY_A) circularList_decrementBy_ASCII(¤tOption);
|
||
|
if(lastKey==KEY_B) circularList_incrementBy_ASCII(¤tOption);
|
||
|
if(lastKey==KEY_C) {/*pass[pos+1]='\x00';*/ exit = true;}
|
||
|
if(lastKey==KEY_D) {pos=pos+1; currentOption=pass[pos];}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
void edit_time(unsigned long *time){
|
||
|
long int currentOption = 3600;
|
||
|
int pos=0;
|
||
|
for(boolean exit = false;!exit;){
|
||
|
display_printTitle(MSG_EDIT_TIME);
|
||
|
display_time(*time) ;
|
||
|
keyboard_waitForAnyKey();
|
||
|
if(lastKey==KEY_A) *time=*time+currentOption;
|
||
|
else if(lastKey==KEY_B) {if (*time<currentOption) *time=0; else *time=*time-currentOption;}
|
||
|
else if(lastKey==KEY_C) {
|
||
|
if (pos==0) {config_saveBackup_system(); exit = true;}
|
||
|
else pos--;
|
||
|
if (pos==1) currentOption = 60;
|
||
|
else if (pos==2) currentOption = 1;
|
||
|
else currentOption = 3600;
|
||
|
}
|
||
|
else if(lastKey==KEY_D) {
|
||
|
if (pos<2) pos++;
|
||
|
if (pos==1) currentOption = 60;
|
||
|
else if (pos==2) currentOption = 1;
|
||
|
}
|
||
|
else if(lastKey==KEY_CH) {config_saveBackup_system(); exit = true;}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
void edit_id(){
|
||
|
for(boolean exit = false;!exit;){
|
||
|
//writeEEPROM(eeprom, address_model, currentOption);
|
||
|
display_printTitle(MSG_EDIT_ID);
|
||
|
lcd.print(system_id,HEX);
|
||
|
keyboard_waitForAnyKey();
|
||
|
if(lastKey==KEY_A) circularList_incrementBy(&system_id, 0, 255, 1);
|
||
|
if(lastKey==KEY_B) circularList_decrementBy(&system_id, 0, 255, 1);
|
||
|
if(lastKey==KEY_C) {config_saveBackup_system(); exit = true;}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
void edit_port(uint16_t *port){
|
||
|
for(boolean exit = false;!exit;){
|
||
|
//writeEEPROM(eeprom, address_model, currentOption);
|
||
|
display_printTitle(MSG_EDIT_PORT);
|
||
|
lcd.print(*port);
|
||
|
keyboard_waitForAnyKey();
|
||
|
if(lastKey==KEY_A) circularList_incrementBy(port, 0, 65535, 1);
|
||
|
else if(lastKey==KEY_B) circularList_decrementBy(port, 0, 65535, 1);
|
||
|
else if(lastKey==KEY_C) {config_saveBackup_system(); exit = true;}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
//Visualizacion de la version del sistema operativo
|
||
|
|
||
|
void ver_version(){
|
||
|
display_vdossier();
|
||
|
for(boolean exit = false;!exit;){
|
||
|
keyboard_waitForAnyKey();
|
||
|
if(lastKey==KEY_C) { exit = true; }
|
||
|
}
|
||
|
}
|
||
|
|
||
|
//Menu de Red
|
||
|
|
||
|
void controller_cfg_network(){
|
||
|
|
||
|
byte currentOption = 0;
|
||
|
|
||
|
for(boolean exit = false;!exit;){
|
||
|
|
||
|
display_printTitle(MSG_CFG_NETWORK);
|
||
|
// Show menu option
|
||
|
if (currentOption==0) { display_print(MSG_ID);}
|
||
|
if (currentOption==1) { display_print(MSG_IP);}
|
||
|
if (currentOption==2) { display_print(MSG_REMOTE);}
|
||
|
if (currentOption==3) { display_print(MSG_LOCAL);}
|
||
|
if (currentOption==4) { display_print(MSG_NETWORK);}
|
||
|
if (currentOption==5) { display_print(MSG_NEW_NETWORK);}
|
||
|
if (currentOption==6) { display_print(MSG_BAUDRATE); }
|
||
|
|
||
|
keyboard_waitForAnyKey();
|
||
|
|
||
|
if(lastKey==KEY_A) circularList_decrementBy(¤tOption, 0, 6, 1);
|
||
|
if(lastKey==KEY_B) circularList_incrementBy(¤tOption, 0, 6, 1);
|
||
|
if(lastKey==KEY_C) { config_saveBackup_system(); exit = true; }
|
||
|
if(lastKey==KEY_D) {
|
||
|
|
||
|
if(currentOption==0) controller_id();
|
||
|
if(currentOption==1) controller_ip();
|
||
|
if(currentOption==2) controller_remote();
|
||
|
if(currentOption==3) controller_local();
|
||
|
if(currentOption==4) controller_network();
|
||
|
if(currentOption==5) controller_new_network();
|
||
|
if(currentOption==6) controller_baudrate();
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
void controller_id(){
|
||
|
for(boolean exit = false;!exit;){
|
||
|
display_printTitle(MSG_ID);
|
||
|
lcd.print(system_id, HEX);
|
||
|
keyboard_waitForAnyKey();
|
||
|
if(lastKey==KEY_C) { config_saveBackup_system(); exit = true; }
|
||
|
if(lastKey==KEY_D) edit_id();
|
||
|
}
|
||
|
}
|
||
|
|
||
|
void controller_ip(){
|
||
|
for(boolean exit = false;!exit;){
|
||
|
display_printTitle(MSG_IP);
|
||
|
lcd.print(udp.ip());
|
||
|
keyboard_waitForAnyKey();
|
||
|
if(lastKey==KEY_C) { exit = true; }
|
||
|
}
|
||
|
}
|
||
|
|
||
|
void controller_remote()
|
||
|
{
|
||
|
for(boolean exit = false;!exit;){
|
||
|
display_printTitle(MSG_REMOTE);
|
||
|
lcd.print(remote_Port);
|
||
|
keyboard_waitForAnyKey();
|
||
|
if(lastKey==KEY_C) { config_saveBackup_system(); exit = true; }
|
||
|
if(lastKey==KEY_D) edit_port(&remote_Port);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
void controller_local()
|
||
|
{
|
||
|
for(boolean exit = false;!exit;){
|
||
|
display_printTitle(MSG_LOCAL);
|
||
|
lcd.print(local_Port);
|
||
|
keyboard_waitForAnyKey();
|
||
|
if(lastKey==KEY_C) { config_saveBackup_system(); exit = true; }
|
||
|
if(lastKey==KEY_D) edit_port(&local_Port);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
void controller_baudrate(){
|
||
|
byte currentOption = 0;
|
||
|
while (currentOption<4)
|
||
|
{
|
||
|
if (system_baudrate==currentOption) break;
|
||
|
else currentOption++;
|
||
|
}
|
||
|
for(boolean exit = false;!exit;){
|
||
|
display_printTitle(MSG_BAUDRATE);
|
||
|
lcd.print(vel[currentOption]);
|
||
|
keyboard_waitForAnyKey();
|
||
|
if(lastKey==KEY_A) circularList_decrementBy(¤tOption, 0, 3, 1);
|
||
|
if(lastKey==KEY_B) circularList_incrementBy(¤tOption, 0, 3, 1);
|
||
|
if(lastKey==KEY_C) { exit = true; }
|
||
|
if(lastKey==KEY_D)
|
||
|
{
|
||
|
byte baudrate_temp=currentOption;
|
||
|
if (udp.baudrate(vel[baudrate_temp]))
|
||
|
{
|
||
|
system_baudrate=baudrate_temp;
|
||
|
config_saveBackup_system();
|
||
|
Serial.begin(vel[system_baudrate]);
|
||
|
lcd.clear();
|
||
|
display_print(MSG_CHANGE_VEL);
|
||
|
delay(2000);
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
lcd.clear();
|
||
|
display_print(MSG_FAIL_VEL);
|
||
|
delay(2000);
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
void controller_network(){
|
||
|
byte currentOption = 0;
|
||
|
for(boolean exit = false;!exit;){
|
||
|
display_printTitle(MSG_NETWORK);
|
||
|
if (currentOption==0) { display_print(MSG_SSID);}
|
||
|
else if (currentOption==1) { display_print(MSG_PASS);}
|
||
|
else if (currentOption==2) { display_print(MSG_RECONNECT);}
|
||
|
|
||
|
keyboard_waitForAnyKey();
|
||
|
|
||
|
if(lastKey==KEY_A) circularList_decrementBy(¤tOption, 0, 2, 1);
|
||
|
if(lastKey==KEY_B) circularList_incrementBy(¤tOption, 0, 2, 1);
|
||
|
if(lastKey==KEY_C) { exit = true; }
|
||
|
if(lastKey==KEY_D) {
|
||
|
|
||
|
if(currentOption==0) controller_ssid();
|
||
|
if(currentOption==1) controller_pass();
|
||
|
if(currentOption==2) display_WiFlyConnecting(&system_baudrate);
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
void controller_ssid(){
|
||
|
for(boolean exit = false;!exit;){
|
||
|
display_printTitle(MSG_SSID);
|
||
|
lcd.print(ssid);
|
||
|
keyboard_waitForAnyKey();
|
||
|
if(lastKey==KEY_C) exit = true;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
void controller_pass(){
|
||
|
for(boolean exit = false;!exit;){
|
||
|
display_printTitle(MSG_PASS);
|
||
|
lcd.print(pass);
|
||
|
keyboard_waitForAnyKey();
|
||
|
if(lastKey==KEY_C) {config_saveBackup_system(); exit = true;}
|
||
|
if(lastKey==KEY_D) edit_pass();
|
||
|
}
|
||
|
}
|
||
|
|
||
|
void controller_new_network(){
|
||
|
byte currentOption = 0;
|
||
|
display_printTitle(MSG_NEW_NETWORK);
|
||
|
display_print(MSG_SEARCH);
|
||
|
byte nets = udp.scan(&networks);
|
||
|
if (nets == 0)
|
||
|
{
|
||
|
display_printTitle(MSG_NEW_NETWORK);
|
||
|
display_print(MSG_ANY);
|
||
|
for(boolean exit = false;!exit;){
|
||
|
keyboard_waitForAnyKey();
|
||
|
if(lastKey==KEY_C) { exit = true; }
|
||
|
}
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
for(boolean exit = false;!exit;){
|
||
|
display_printTitle(MSG_NEW_NETWORK);
|
||
|
lcd.print(currentOption);
|
||
|
lcd.print(".");
|
||
|
lcd.print(networks.ssid[currentOption]);
|
||
|
keyboard_waitForAnyKey();
|
||
|
if(lastKey==KEY_A) if (nets>1) circularList_decrementBy(¤tOption, 0, nets-1, 1);
|
||
|
if(lastKey==KEY_B) if (nets>1) circularList_incrementBy(¤tOption, 0, nets-1, 1);
|
||
|
if(lastKey==KEY_C) { config_saveBackup_system(); exit = true; }
|
||
|
if(lastKey==KEY_D) { char* ssid_temp = networks.ssid[currentOption]; for(int i=0; i<32; i++) ssid[i]='\x00'; for(int i=0; i<strlen(ssid_temp); i++) ssid[i]=ssid_temp[i];for (int i=0; i<=33; i++) pass[i]='\x00'; edit_pass();}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|