void Settings() {
  if(exit_menu_code == 30) {
    if(new_position < -3) {
      new_position = 0;
    }
    else if(new_position > 0) {
      new_position = -3;
    }
  }

  display.clearDisplay();
  display.setTextColor(WHITE);
  display.setTextSize(1);

  if((new_position == 0) && (exit_menu_code == 30)) {
    display.setTextColor(BLACK, WHITE);
  }
  display.setCursor(0, 0);
  display.print("Ignation Delay");


  display.setTextColor(WHITE);
  if((new_position == -1) && (exit_menu_code == 30)) {
    display.setTextColor(BLACK, WHITE);
  }
  display.setCursor(0, 8);
  display.print("Tx Set");

  display.setTextColor(WHITE);
  display.print(" P");
  if(exit_menu_code == 35) {
    display.setTextColor(BLACK, WHITE);
  }

  display.print(LoRa_power);

  display.setTextColor(WHITE);
  display.print(" dBm / SF");

  if(exit_menu_code == 36) {
    display.setTextColor(BLACK, WHITE);
  }
  display.print(LoRa_SF);

  display.setTextColor(WHITE);
  if((new_position == -2) && (exit_menu_code == 30)) {
    display.setTextColor(BLACK, WHITE);
  }
  display.setCursor(0, 16);
  display.print("Unit LoRa Setting");


  if((new_position == -3) && (exit_menu_code == 30)) {
    display.setTextColor(BLACK, WHITE);
  }
  else {
    display.setTextColor(WHITE);
  }
  display.setCursor(0, 24);
  display.print("Aliases");
}


void setIgnationDelay() {
  display.setTextSize(2);

  if(exit_menu_code == 31) {
    noteIDNumber();
    display.setTextColor(BLACK, WHITE);
  }

  display.setCursor(0, 8);
  if(set_ID_number < 10) {
    display.print("00");
  }
  else if(set_ID_number < 100) {
    display.print("0");
  }
  display.print(set_ID_number);

  display.setTextColor(WHITE);
  display.print("-");
  
  if(exit_menu_code == 32) {
    noteTime(1);
    display.setTextColor(BLACK, WHITE);
  }

  display.setCursor(48, 8);
  if(set_time_m < 10) {
    display.print("0");
  }
  display.print(set_time_m);

  display.setTextColor(WHITE);
  display.setCursor(70, 8);
  display.print(":");

  if(exit_menu_code == 33) {
    noteTime(2);
    display.setTextColor(BLACK, WHITE);
  }

  display.setCursor(80, 8);
  if(set_time_s < 10) {
    display.print("0");
  }
  display.print(set_time_s);

  display.setTextColor(WHITE);
  display.print(".");

  if(exit_menu_code == 34) {
    noteTime(3);
    display.setTextColor(BLACK, WHITE);
  }

  display.setCursor(116, 8);
  display.print(set_time_ms);
}


void setUnitLoRa() {
  display.setTextSize(2);

  if(exit_menu_code == 37) {
    noteIDNumber();
    display.setTextColor(BLACK, WHITE);
  }

  display.setCursor(9, 8);
  if(set_ID_number < 10) {
    display.print("00");
  }
  else if(set_ID_number < 100) {
    display.print("0");
  }
  display.print(set_ID_number);

  display.setTextColor(WHITE);
  display.print("-");

  if(exit_menu_code == 38) {
    noteLoRaUnitPower();
    display.setTextColor(BLACK, WHITE);
  }

  display.setCursor(57, 8);
  if(LoRa_unit_power < 10) {
    display.print("0");
  }
  display.print(LoRa_unit_power);

  display.setTextColor(WHITE);
  display.print("/");

  if(exit_menu_code == 39) {
    noteSF();
    display.setTextColor(BLACK, WHITE);
  }
  display.setCursor(93, 8);
  display.print(LoRa_unit_SF);
}


void setAlias() {
  display.setTextSize(2);

  if(exit_menu_code == 130) {
    noteAlias();
    display.setTextColor(BLACK, WHITE);
  }

  display.setCursor(21, 8);
  if(alias < 10) {
    display.print("00");
  }
  else if(alias < 100) {
    display.print("0");
  }
  display.print(alias);

  display.setTextColor(WHITE);
  display.print("-");

  if(exit_menu_code == 131) {
    noteIDNumber();
    display.setTextColor(BLACK, WHITE);
  }

  display.setCursor(69, 8);
  if(set_ID_number < 10) {
    display.print("00");
  }
  else if(set_ID_number < 100) {
    display.print("0");
  }
  display.print(set_ID_number);
}


void showSettings() {
  if((exit_menu_code == 30) || (exit_menu_code == 35) || (exit_menu_code == 36)) {
    Settings();
  }
  else if((exit_menu_code == 31) || (exit_menu_code == 32) || (exit_menu_code == 33) || (exit_menu_code == 34)) {
    setIgnationDelay();
  }
  else if((exit_menu_code == 37) || (exit_menu_code == 38) || (exit_menu_code == 39)) {
    setUnitLoRa();
  }
  else if((exit_menu_code == 130) || (exit_menu_code == 131)) {
    setAlias();
  }
  else if(exit_menu_code == 255) {
    showIncoming();
  }
  else {
    display.setTextSize(2);
    display.setCursor(15, 8);
    display.print("Settings");
    display.display();
  }
}


void noteLoRaUnitPower() {
  display.setTextSize(1);
  display.setCursor(24, 24);
  display.print("Unit Tx Power");
  display.setTextSize(2);
}

void noteSF() {
  display.setTextSize(1);
  display.setCursor(15, 24);
  display.print("Spreading Factor");
  display.setTextSize(2);
}

void noteAlias() {
  display.setTextSize(1);
  display.setCursor(39, 24);
  display.print("ID Alias");
  display.setTextSize(2);
}
