     Receiver::setChannel(EepromSettings.channel);
 }
 
-// === Main Loop ===============================================================
-
-#ifndef OLD_LOOP
-
 
 void loop() {
     Receiver::update();

#include "settings_internal.h"
#include "settings_eeprom.h"

//#include "screens.h"
#include "channels.h"
#include "receiver.h"
#include "buttons.h"

#include "state.h"
#include "state_scan.h"
#include "state_manual.h"
#include "state_screensaver.h"
#include "state_auto.h"

#include "ui.h"


#ifdef OLD_LOOP
//screens drawScreen;
char channel = 0;
uint8_t channelIndex = 0;
uint8_t rssi = 0;
#ifdef USE_DIVERSITY
    uint8_t diversity_mode = RECEIVER_AUTO;
    char diversity_check_count = 0; // used to decide when to change antennas.
#endif
uint8_t rssi_seek_threshold = RSSI_SEEK_TRESHOLD;
uint8_t state = START_STATE;
uint8_t state_last_used=START_STATE;
uint8_t last_state= START_STATE+1; // force screen draw
uint8_t switch_count = 0;
uint8_t last_channel_index = 0;
uint8_t force_seek=0;
uint8_t seek_direction=1;
unsigned long time_of_tune = 0;        // will store last time when tuner was changed
unsigned long time_screen_saver = 0;
unsigned long time_next_payload = 0;
uint8_t seek_found=0;
uint8_t scan_start=0;
uint8_t first_tune=1;
bool force_menu_redraw=0;
uint16_t rssi_best=0; // used for band scaner
uint16_t rssi_min_a=RSSI_MIN_VAL;
uint16_t rssi_max_a=RSSI_MAX_VAL;
uint16_t rssi_setup_min_a=RSSI_MIN_VAL;
uint16_t rssi_setup_max_a=RSSI_MAX_VAL;
#ifdef USE_DIVERSITY
    uint16_t rssi_min_b=RSSI_MIN_VAL;
    uint16_t rssi_max_b=RSSI_MAX_VAL;
    uint16_t rssi_setup_min_b=RSSI_MIN_VAL;
    uint16_t rssi_setup_max_b=RSSI_MAX_VAL;
#endif
uint8_t rssi_setup_run=0;

#ifdef USE_VOLTAGE_MONITORING
int vbat_scale = VBAT_SCALE;
uint8_t warning_voltage = WARNING_VOLTAGE;
uint8_t critical_voltage = CRITICAL_VOLTAGE;
bool critical_alarm = false;
bool warning_alarm = false;
uint8_t beep_times = 0;
bool beeping = false;
unsigned long time_last_vbat_alarm = 0;
unsigned long last_beep = 0;

uint8_t voltage_reading_index = 0;
uint16_t voltages[VBAT_SMOOTH];
uint16_t voltages_sum;
uint16_t voltage;
#endif

char call_sign[10];
bool settings_beeps = true;
bool settings_orderby_channel = true;

void beep(uint8_t count = 1, uint16_t milliseconds = 100);
uint8_t readRSSI(char receiver = -1);
#endif


#ifndef OLD_LOOP


//screens drawScreen;


#endif


// === Setup ===================================================================

void setup()
{


    Receiver::setActiveReceiver(RECEIVER_A);
    setupSettings();

    Ui::setup();

