Tidy
This commit is contained in:
parent
ff89787d39
commit
0ca501dce6
@ -44,9 +44,6 @@ void loop() {
|
||||
myrpt->id_time = 0;
|
||||
serial_writer(&myrpt->serial, "READY");
|
||||
digitalWrite(PIP_ATT, LOW);
|
||||
myrpt->stats.gw_time = 0;
|
||||
myrpt->stats.tx_time = 0;
|
||||
myrpt->stats.rx_time = 0;
|
||||
while (1) {
|
||||
serial_command(&myrpt->serial, myrpt);
|
||||
rx(myrpt);
|
||||
@ -64,7 +61,6 @@ void loop() {
|
||||
} else {
|
||||
myrpt->state = GW;
|
||||
serial_writer(&myrpt->serial, "RX: GATEWAY");
|
||||
myrpt->timer.gw_start = millis();
|
||||
}
|
||||
tot = millis();
|
||||
if (myrpt->params.start_up && millis() - myrpt->last_id >= LAST_ID_HOLD)
|
||||
@ -79,7 +75,6 @@ void loop() {
|
||||
if ((myrpt->receiver.rx && myrpt->gateway.receiver.rx) && myrpt->state > HANG) {
|
||||
serial_writer(&myrpt->serial, "HANG");
|
||||
if (myrpt->state == GW)
|
||||
myrpt->stats.gw_time += millis() - myrpt->timer.gw_start;
|
||||
delay(500);
|
||||
myrpt->last = myrpt->state;
|
||||
myrpt->state = HANG;
|
||||
|
@ -52,9 +52,6 @@ void sendID(repeater* myrpt) {
|
||||
|
||||
delay(500);
|
||||
|
||||
//if (myrpt->state == SLEEP)
|
||||
// digitalWrite(PIP_ATT, HIGH);
|
||||
|
||||
for (int i=0; i < sizeof ID/sizeof ID[0]; i++) {
|
||||
sendChar(myrpt, myrpt->callsign[i]);
|
||||
delay(myrpt->params.cw_speed * 3);
|
||||
|
@ -32,27 +32,13 @@ typedef struct {
|
||||
int start_up;
|
||||
}params;
|
||||
|
||||
typedef struct {
|
||||
unsigned long tx_start;
|
||||
unsigned long rx_start;
|
||||
unsigned long gw_start;
|
||||
}timer;
|
||||
|
||||
typedef struct {
|
||||
unsigned long tx_time;
|
||||
unsigned long rx_time;
|
||||
unsigned long gw_time;
|
||||
}stats;
|
||||
|
||||
typedef struct {
|
||||
bool tx;
|
||||
unsigned long long tx_time;
|
||||
}transmitter;
|
||||
|
||||
typedef struct {
|
||||
int id;
|
||||
bool rx;
|
||||
unsigned long long rx_time;
|
||||
}receiver;
|
||||
|
||||
typedef struct {
|
||||
@ -75,19 +61,9 @@ typedef struct {
|
||||
params params;
|
||||
receiver receiver;
|
||||
serial serial;
|
||||
stats stats;
|
||||
state state;
|
||||
timer timer;
|
||||
transmitter transmitter;
|
||||
unsigned long tail;
|
||||
}repeater;
|
||||
|
||||
typedef struct {
|
||||
byte type;
|
||||
stats* stats;
|
||||
bool transmitter;
|
||||
bool receiver;
|
||||
bool gateway;
|
||||
}info;
|
||||
|
||||
#endif
|
@ -4,14 +4,12 @@ void tx(repeater* myrpt) {
|
||||
myrpt->transmitter.tx = true;
|
||||
digitalWrite(PTT,LOW);
|
||||
delay(100);
|
||||
myrpt->timer.tx_start = millis();
|
||||
return;
|
||||
}
|
||||
|
||||
if (myrpt->state < KEYCHUNK && myrpt->transmitter.tx) {
|
||||
serial_writer(&myrpt->serial, "REPEATER: TX OFF");
|
||||
myrpt->transmitter.tx = false;
|
||||
myrpt->stats.tx_time += millis() - myrpt->timer.tx_start;
|
||||
digitalWrite(PTT,HIGH);
|
||||
}
|
||||
}
|
||||
@ -24,14 +22,12 @@ void rx(repeater* myrpt) {
|
||||
serial_writer(&myrpt->serial, "REPEATER: COS");
|
||||
digitalWrite(GWPTT, true);
|
||||
myrpt->gateway.transmitter.tx = true;
|
||||
myrpt->timer.rx_start = millis();
|
||||
return;
|
||||
}
|
||||
|
||||
if (myrpt->receiver.rx && myrpt->gateway.transmitter.tx) {
|
||||
digitalWrite(GWPTT, false);
|
||||
myrpt->gateway.transmitter.tx = false;
|
||||
myrpt->stats.rx_time += millis() - myrpt->timer.rx_start;
|
||||
}
|
||||
}
|
||||
|
||||
@ -87,21 +83,11 @@ void serial_command(serial* s, repeater* myrpt) {
|
||||
}
|
||||
break;
|
||||
case '3':
|
||||
Serial.print("RX: "); Serial.println((myrpt->stats.rx_time /1000));
|
||||
Serial.print("TX: "); Serial.println((myrpt->stats.tx_time /1000));
|
||||
Serial.print("GW: "); Serial.println((myrpt->stats.gw_time /1000));
|
||||
Serial.print("RX Status: "); Serial.println(!myrpt->receiver.rx);
|
||||
Serial.print("TX Status: "); Serial.println(myrpt->transmitter.tx);
|
||||
Serial.print("GW Status: "); Serial.println(!myrpt->gateway.receiver.rx);
|
||||
break;
|
||||
case '4':
|
||||
info inf;
|
||||
inf.type = 254;
|
||||
inf.stats = &myrpt->stats;
|
||||
inf.receiver = !myrpt->receiver.rx;
|
||||
inf.transmitter = myrpt->transmitter.tx;
|
||||
inf.gateway = !myrpt->gateway.receiver.rx;
|
||||
Serial.write((byte*)&inf, sizeof(info) + sizeof(stats) - 4);
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user