From bfdaae8c1cf11a1ea4ff491172e506303cd623ff Mon Sep 17 00:00:00 2001 From: jimzah Date: Wed, 30 Oct 2024 21:45:42 +0000 Subject: [PATCH] Start timestamp compare, better timeout countdown --- GB3TX/GB3TX.ino | 34 +++++++++++++++++++++++----------- GB3TX/config.h | 19 ++++++++++++++----- GB3TX/repeater.h | 3 ++- GB3TX/repeater.ino | 8 ++++++-- 4 files changed, 45 insertions(+), 19 deletions(-) diff --git a/GB3TX/GB3TX.ino b/GB3TX/GB3TX.ino index 06f60a5..e65cea3 100644 --- a/GB3TX/GB3TX.ino +++ b/GB3TX/GB3TX.ino @@ -2,12 +2,9 @@ #include "repeater.h" void setup() { - pinMode(3, OUTPUT); - pinMode(8, OUTPUT); - pinMode(9, OUTPUT); - pinMode(7, INPUT_PULLUP); - pinMode(6, INPUT_PULLUP); - pinMode(PIP_ATT, OUTPUT); + for (int i=0; istate == KEYCHUNK && compareStamp(&myrpt->receiver.timestamp, KEYCHUNK_TIME)) { + if (myrpt->state == KEYCHUNK && compareStart(&myrpt->receiver.timestamp, KEYCHUNK_TIME)) { if (!myrpt->receiver.rx) { myrpt->state = TT; serial_writer(&myrpt->serial, "RX: RF"); @@ -103,11 +100,9 @@ void loop() { tot = millis(); } - if (millis() - tot >= TIMEOUT && (myrpt->state == TT || myrpt->state == GW)) { + if (compareStart(&myrpt->receiver.timestamp, TOTIME) && myrpt->state == TT ) { serial_writer(&myrpt->serial, "REPEATER: TIMEOUT"); - myrpt->state = TIMEOUT; - tone(PIP, 440, 1000); - delay(1000); + myrpt->state = PEN_T; } if (myrpt->state == HANG && millis() - ht > HANGTIME) { @@ -121,6 +116,23 @@ void loop() { myrpt->state = IDLE; } + if (myrpt->state == PEN_T) { + if (!busy(myrpt)) + myrpt->state = HANG; + static unsigned long pc; + static int c = 0; + unsigned long tick = millis(); + if (tick - pc < 1000) + continue; + + pc = tick; + tone(PIP, 1750, 50); + c++; + if (c >= 10) { + myrpt->state = TIMEOUT; + } + } + if (myrpt->state == TIMEOUT) { myrpt->state = IDLE; tx(myrpt); diff --git a/GB3TX/config.h b/GB3TX/config.h index 947a43f..34101b7 100644 --- a/GB3TX/config.h +++ b/GB3TX/config.h @@ -9,9 +9,18 @@ #define GWPTT 9 #define PIP 3 +uint8_t io[6][2] = { + {PIP_ATT, OUTPUT}, + {GW_COS, INPUT_PULLUP}, + {COS, INPUT_PULLUP}, + {PTT, OUTPUT}, + {GWPTT, OUTPUT}, + {PIP, OUTPUT} +}; + /* CW ID SETTINGS */ #define ID "GB3DL" -#define CW_SPEED 20 +#define CW_SPEED 22 #define CW_PITCH 1375 /* PARAMS */ @@ -32,11 +41,11 @@ /* TIMERS */ #define HANGTIME 2000 -#define KEYCHUNK_TIME 500 -#define TIMEOUT 300000 +#define KEYCHUNK_TIME 750 +#define TOTIME 300000 #define IDTIME 300000 -#define LAST_ID_HOLD 30000 -#define PIP_KEYCHUNK 750 +#define LAST_ID_HOLD 60000 +#define PIP_KEYCHUNK 1000 #define TAIL_PIP_DELAY 3000 #endif \ No newline at end of file diff --git a/GB3TX/repeater.h b/GB3TX/repeater.h index 557c1c4..02b8954 100644 --- a/GB3TX/repeater.h +++ b/GB3TX/repeater.h @@ -8,7 +8,8 @@ typedef enum { HANG, GW, TT, - TOT, + PEN_T, + TIMEOUT, }state; typedef enum { diff --git a/GB3TX/repeater.ino b/GB3TX/repeater.ino index 224d747..41f9e22 100644 --- a/GB3TX/repeater.ino +++ b/GB3TX/repeater.ino @@ -29,8 +29,8 @@ void rx(repeater* myrpt) { if (myrpt->receiver.rx) { myrpt->receiver.timestamp.end = millis(); if (myrpt->gateway.transmitter.tx) { - digitalWrite(GWPTT, false); - myrpt->gateway.transmitter.tx = false; + digitalWrite(GWPTT, false); + myrpt->gateway.transmitter.tx = false; } } } @@ -44,6 +44,10 @@ bool compareStamp(t_stamp* ts, unsigned long cmp) { return ts->end - ts->start > cmp; } +bool compareStart(t_stamp* ts, unsigned long cmp) { + return millis() - ts->start > cmp; +} + void courtesyTone(repeater* myrpt) { switch(myrpt->params.courtesy) { case TONE: