Better time stamp
This commit is contained in:
parent
0ca501dce6
commit
71248ea83e
@ -54,7 +54,7 @@ void loop() {
|
||||
kc = millis();
|
||||
}
|
||||
|
||||
if (myrpt->state == KEYCHUNK && millis() - kc > KEYCHUNK_TIME) {
|
||||
if (myrpt->state == KEYCHUNK && compareStamp(&myrpt->receiver.timestamp, KEYCHUNK_TIME)) {
|
||||
if (!myrpt->receiver.rx) {
|
||||
myrpt->state = TT;
|
||||
serial_writer(&myrpt->serial, "RX: RF");
|
||||
@ -74,13 +74,12 @@ void loop() {
|
||||
|
||||
if ((myrpt->receiver.rx && myrpt->gateway.receiver.rx) && myrpt->state > HANG) {
|
||||
serial_writer(&myrpt->serial, "HANG");
|
||||
if (myrpt->state == GW)
|
||||
delay(500);
|
||||
myrpt->last = myrpt->state;
|
||||
myrpt->state = HANG;
|
||||
ht = millis();
|
||||
myrpt->tail = ht;
|
||||
if (ht - tot < PIP_KEYCHUNK || busy(myrpt))
|
||||
if (!compareStamp(&myrpt->receiver.timestamp, PIP_KEYCHUNK) || busy(myrpt))
|
||||
continue;
|
||||
courtesyTone(myrpt);
|
||||
}
|
||||
|
@ -50,8 +50,6 @@ void sendID(repeater* myrpt) {
|
||||
return;
|
||||
}
|
||||
|
||||
delay(500);
|
||||
|
||||
for (int i=0; i < sizeof ID/sizeof ID[0]; i++) {
|
||||
sendChar(myrpt, myrpt->callsign[i]);
|
||||
delay(myrpt->params.cw_speed * 3);
|
||||
|
@ -32,6 +32,11 @@ typedef struct {
|
||||
int start_up;
|
||||
}params;
|
||||
|
||||
typedef struct {
|
||||
unsigned long start;
|
||||
unsigned long end;
|
||||
}t_stamp;
|
||||
|
||||
typedef struct {
|
||||
bool tx;
|
||||
}transmitter;
|
||||
@ -39,6 +44,7 @@ typedef struct {
|
||||
typedef struct {
|
||||
int id;
|
||||
bool rx;
|
||||
t_stamp timestamp;
|
||||
}receiver;
|
||||
|
||||
typedef struct {
|
||||
@ -47,7 +53,6 @@ typedef struct {
|
||||
}serial;
|
||||
|
||||
typedef struct {
|
||||
bool enable;
|
||||
receiver receiver;
|
||||
transmitter transmitter;
|
||||
}gateway;
|
||||
|
@ -20,14 +20,18 @@ void rx(repeater* myrpt) {
|
||||
|
||||
if (!myrpt->receiver.rx && !myrpt->gateway.transmitter.tx) {
|
||||
serial_writer(&myrpt->serial, "REPEATER: COS");
|
||||
myrpt->receiver.timestamp.start = millis();
|
||||
digitalWrite(GWPTT, true);
|
||||
myrpt->gateway.transmitter.tx = true;
|
||||
return;
|
||||
}
|
||||
|
||||
if (myrpt->receiver.rx && myrpt->gateway.transmitter.tx) {
|
||||
if (myrpt->receiver.rx) {
|
||||
myrpt->receiver.timestamp.end = millis();
|
||||
if (myrpt->gateway.transmitter.tx) {
|
||||
digitalWrite(GWPTT, false);
|
||||
myrpt->gateway.transmitter.tx = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -36,6 +40,10 @@ bool busy(repeater* myrpt) {
|
||||
return (!myrpt->receiver.rx || !myrpt->gateway.receiver.rx);
|
||||
}
|
||||
|
||||
bool compareStamp(t_stamp* ts, unsigned long cmp) {
|
||||
return ts->end - ts->start > cmp;
|
||||
}
|
||||
|
||||
void courtesyTone(repeater* myrpt) {
|
||||
switch(myrpt->params.courtesy) {
|
||||
case TONE:
|
||||
|
Loading…
Reference in New Issue
Block a user