Start timestamp compare, better timeout countdown

This commit is contained in:
jimzah 2024-10-30 21:45:42 +00:00
parent 71248ea83e
commit bfdaae8c1c
4 changed files with 45 additions and 19 deletions

View File

@ -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; i<sizeof(io)/sizeof(io[0]); i++){
pinMode(io[i][0], io[i][1]);
}
}
void loop() {
@ -54,7 +51,7 @@ void loop() {
kc = millis();
}
if (myrpt->state == 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);

View File

@ -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

View File

@ -8,7 +8,8 @@ typedef enum {
HANG,
GW,
TT,
TOT,
PEN_T,
TIMEOUT,
}state;
typedef enum {

View File

@ -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: