2019-04-03 15:16:51 +00:00
|
|
|
|
|
|
|
#ifndef Sonde_h
|
2019-05-22 11:50:47 +00:00
|
|
|
#define Sonde_h
|
2019-04-03 15:16:51 +00:00
|
|
|
|
2019-04-15 18:28:50 +00:00
|
|
|
#include "aprs.h"
|
|
|
|
|
2019-04-05 18:05:18 +00:00
|
|
|
// RX_TIMEOUT: no header detected
|
|
|
|
// RX_ERROR: header detected, but data not decoded (crc error, etc.)
|
|
|
|
// RX_OK: header and data ok
|
2019-04-17 12:54:08 +00:00
|
|
|
enum RxResult { RX_OK, RX_TIMEOUT, RX_ERROR, RX_UNKNOWN };
|
2019-04-05 18:05:18 +00:00
|
|
|
|
2019-05-24 21:49:50 +00:00
|
|
|
// Events that change what is displayed (mode, sondenr)
|
|
|
|
// Keys:
|
|
|
|
// 1 Button (short) or Touch (short)
|
|
|
|
// 2 Button (double) or Touch (double)
|
|
|
|
// 3 Button (mid) or Touch (mid)
|
|
|
|
// 4 Button (long) or Touch (long)
|
|
|
|
// 5 Touch1/2 (short)
|
|
|
|
// 6 Touch1/2 (double)
|
|
|
|
// 7 Touch1/2 (mid)
|
|
|
|
// 8 Touch1/2 (long)
|
|
|
|
|
|
|
|
/* Keypress => Sonde++ / Sonde-- / Display:=N*/
|
|
|
|
enum Events { EVT_NONE, EVT_KEY1SHORT, EVT_KEY1DOUBLE, EVT_KEY1MID, EVT_KEY1LONG,
|
|
|
|
EVT_KEY2SHORT, EVT_KEY2DOUBLE, EVT_KEY2MID, EVT_KEY2LONG,
|
|
|
|
EVT_VIEWTO, EVT_RXTO, EVT_NORXTO,
|
|
|
|
EVT_MAX };
|
|
|
|
extern const char *evstring[];
|
2019-05-30 20:19:45 +00:00
|
|
|
extern const char *RXstr[];
|
2019-05-24 21:49:50 +00:00
|
|
|
#define EVENTNAME(s) evstring[s]
|
|
|
|
|
|
|
|
//int8_t actions[EVT_MAX];
|
|
|
|
#define ACT_NONE -1
|
|
|
|
#define ACT_DISPLAY(n) (n)
|
|
|
|
#define ACT_DISPLAY_DEFAULT 15
|
|
|
|
#define ACT_DISPLAY_SPECTRUM 14
|
|
|
|
#define ACT_DISPLAY_WIFI 13
|
|
|
|
#define ACT_NEXTSONDE 65
|
|
|
|
#define ACT_PREVSONDE 64
|
|
|
|
|
|
|
|
// 0000nnnn => goto display nnnn
|
|
|
|
// 01000000 => goto sonde -1
|
|
|
|
// 01000001 => goto sonde +1
|
|
|
|
|
2019-05-30 20:19:45 +00:00
|
|
|
enum SondeType { STYPE_DFM06, STYPE_DFM09, STYPE_RS41, STYPE_RS92 };
|
2019-04-05 18:05:18 +00:00
|
|
|
extern const char *sondeTypeStr[5];
|
|
|
|
|
2019-05-30 20:19:45 +00:00
|
|
|
// Used for interacting with the RX background task
|
|
|
|
typedef struct st_RXTask {
|
|
|
|
// Variables set by Arduino main loop to value >=0 for requesting
|
|
|
|
// mode change in RXTask. Will be reset to -1 by RXTask
|
|
|
|
int activate;
|
|
|
|
int requestSonde;
|
|
|
|
// Variables set by RXTask, corresponding to activate
|
|
|
|
// and requestSonde
|
|
|
|
int mainState;
|
|
|
|
int currentSonde;
|
|
|
|
int lastSonde;
|
|
|
|
// Variable set by RXTask to communicate status to Arduino task
|
|
|
|
// via waitRXcomplete function
|
|
|
|
uint16_t receiveResult;
|
|
|
|
// status variabe set by decoder to indicate something is broken
|
|
|
|
int fifoOverflo;
|
|
|
|
} RXTask;
|
|
|
|
|
|
|
|
extern RXTask rxtask;
|
|
|
|
|
2019-05-05 23:18:41 +00:00
|
|
|
struct st_rs41config {
|
|
|
|
int agcbw;
|
|
|
|
int rxbw;
|
|
|
|
};
|
|
|
|
|
2019-04-15 18:28:50 +00:00
|
|
|
typedef struct st_rdzconfig {
|
2019-05-24 21:49:50 +00:00
|
|
|
int button_pin; // PIN port number menu button (+128 for touch mode)
|
|
|
|
int button2_pin; // PIN port number menu button (+128 for touch mode)
|
2019-05-25 08:49:26 +00:00
|
|
|
int touch_thresh; // Threshold value (0..100) for touch input button
|
2019-04-26 17:21:11 +00:00
|
|
|
int led_pout; // POUT port number of LED (used as serial monitor)
|
2019-04-23 11:08:02 +00:00
|
|
|
int oled_sda; // OLED data pin
|
|
|
|
int oled_scl; // OLED clock pin
|
|
|
|
int oled_rst; // OLED reset pin
|
|
|
|
int debug; // show port and config options after reboot
|
|
|
|
int wifi; // connect to known WLAN 0=skip
|
|
|
|
int wifiap; // enable/disable WiFi AccessPoint mode 0=disable
|
2019-05-22 11:50:47 +00:00
|
|
|
int display; // select display mode (0=default, 1=default, 2=fieldmode)
|
2019-04-23 11:08:02 +00:00
|
|
|
int startfreq; // spectrum display start freq (400, 401, ...)
|
|
|
|
int channelbw; // spectrum channel bandwidth (valid: 5, 10, 20, 25, 50, 100 kHz)
|
|
|
|
int spectrum; // show freq spectrum for n seconds 0=disable
|
|
|
|
int timer; // show remaining time in spectrum 0=disable
|
|
|
|
int marker; // show freq marker in spectrum 0=disable
|
|
|
|
int maxsonde; // number of max sonde in scan (range=1-99)
|
2019-05-05 23:18:41 +00:00
|
|
|
int norx_timeout; // Time after which rx mode switches to scan mode (without rx signal)
|
2019-04-15 18:28:50 +00:00
|
|
|
int noisefloor; // for spectrum display
|
2019-05-05 23:18:41 +00:00
|
|
|
int showafc; // show afc value in rx screen
|
2019-05-06 15:25:54 +00:00
|
|
|
int freqofs; // frequency offset (tuner config = rx frequency + freqofs) in Hz
|
2019-04-23 11:08:02 +00:00
|
|
|
char call[9]; // APRS callsign
|
|
|
|
char passcode[9]; // APRS passcode
|
2019-05-05 23:18:41 +00:00
|
|
|
struct st_rs41config rs41; // configuration options specific for RS41 receiver
|
2019-04-15 18:28:50 +00:00
|
|
|
// for now, one feed for each type is enough, but might get extended to more?
|
|
|
|
struct st_feedinfo udpfeed; // target for AXUDP messages
|
|
|
|
struct st_feedinfo tcpfeed; // target for APRS-IS TCP connections
|
|
|
|
} RDZConfig;
|
|
|
|
|
2019-04-03 15:16:51 +00:00
|
|
|
typedef struct st_sondeinfo {
|
|
|
|
// receiver configuration
|
2019-04-23 11:08:02 +00:00
|
|
|
bool active;
|
2019-04-05 18:05:18 +00:00
|
|
|
SondeType type;
|
2019-04-03 15:16:51 +00:00
|
|
|
float freq;
|
|
|
|
// decoded ID
|
|
|
|
char id[10];
|
|
|
|
bool validID;
|
2019-05-03 11:34:35 +00:00
|
|
|
char launchsite[18];
|
2019-04-03 15:16:51 +00:00
|
|
|
// decoded position
|
2019-04-23 11:08:02 +00:00
|
|
|
float lat; // latitude
|
|
|
|
float lon; // longitude
|
|
|
|
float alt; // altitude
|
|
|
|
float vs; // vertical speed
|
|
|
|
float hs; // horizontal speed
|
|
|
|
float dir; // 0..360
|
2019-04-05 21:32:26 +00:00
|
|
|
uint8_t validPos; // bit pattern for validity of above 6 fields
|
2019-04-03 15:16:51 +00:00
|
|
|
// RSSI from receiver
|
2019-04-23 11:08:02 +00:00
|
|
|
int rssi; // signal strength
|
2019-05-05 23:18:41 +00:00
|
|
|
int32_t afc; // afc correction value
|
2019-05-24 21:49:50 +00:00
|
|
|
// statistics
|
2019-04-05 18:05:18 +00:00
|
|
|
uint8_t rxStat[20];
|
2019-05-24 21:49:50 +00:00
|
|
|
uint32_t rxStart; // millis() timestamp of continuous rx start
|
|
|
|
uint32_t norxStart; // millis() timestamp of continuous no rx start
|
|
|
|
uint32_t viewStart; // millis() timestamp of viewinf this sonde with current display
|
|
|
|
int8_t lastState; // -1: disabled; 0: norx; 1: rx
|
2019-04-03 15:16:51 +00:00
|
|
|
} SondeInfo;
|
2019-05-24 21:49:50 +00:00
|
|
|
// rxStat: 0=undef[empty] 1=timeout[.] 2=errro[E] 3=ok[1]
|
2019-04-03 15:16:51 +00:00
|
|
|
|
2019-04-05 18:05:18 +00:00
|
|
|
|
2019-04-23 11:08:02 +00:00
|
|
|
#define MAXSONDE 99
|
2019-04-03 15:16:51 +00:00
|
|
|
|
|
|
|
class Sonde
|
|
|
|
{
|
|
|
|
private:
|
|
|
|
public:
|
2019-04-15 18:28:50 +00:00
|
|
|
RDZConfig config;
|
2019-04-09 22:29:11 +00:00
|
|
|
int currentSonde = 0;
|
2019-04-08 17:22:08 +00:00
|
|
|
int nSonde;
|
|
|
|
SondeInfo sondeList[MAXSONDE+1];
|
|
|
|
|
2019-04-15 18:59:30 +00:00
|
|
|
Sonde();
|
2019-04-16 15:51:41 +00:00
|
|
|
void setConfig(const char *str);
|
2019-04-15 18:59:30 +00:00
|
|
|
|
2019-04-05 18:05:18 +00:00
|
|
|
void clearSonde();
|
2019-04-23 11:08:02 +00:00
|
|
|
void addSonde(float frequency, SondeType type, int active, char *launchsite);
|
2019-04-05 18:05:18 +00:00
|
|
|
void nextConfig();
|
2019-05-30 20:19:45 +00:00
|
|
|
void nextRxSonde();
|
2019-04-05 18:05:18 +00:00
|
|
|
|
2019-05-30 20:19:45 +00:00
|
|
|
/* new interface */
|
|
|
|
void setup();
|
|
|
|
void receive();
|
|
|
|
uint16_t waitRXcomplete();
|
|
|
|
/* old and temp interface */
|
|
|
|
#if 0
|
|
|
|
void processRXbyte(uint8_t data);
|
2019-04-05 18:05:18 +00:00
|
|
|
int receiveFrame();
|
2019-05-30 20:19:45 +00:00
|
|
|
#endif
|
|
|
|
|
2019-04-05 18:05:18 +00:00
|
|
|
SondeInfo *si();
|
|
|
|
|
2019-05-24 21:49:50 +00:00
|
|
|
uint8_t timeoutEvent();
|
|
|
|
int updateState(int8_t event);
|
|
|
|
|
2019-04-03 15:16:51 +00:00
|
|
|
void updateDisplayPos();
|
|
|
|
void updateDisplayPos2();
|
|
|
|
void updateDisplayID();
|
|
|
|
void updateDisplayRSSI();
|
|
|
|
void updateDisplayRXConfig();
|
2019-04-05 18:05:18 +00:00
|
|
|
void updateStat();
|
|
|
|
void updateDisplayIP();
|
2019-04-03 15:16:51 +00:00
|
|
|
void updateDisplay();
|
2019-04-05 18:05:18 +00:00
|
|
|
void updateDisplayScanner();
|
|
|
|
void clearDisplay();
|
2019-04-08 17:22:08 +00:00
|
|
|
void setIP(const char *ip, bool isAP);
|
2019-04-26 21:09:09 +00:00
|
|
|
void clearIP();
|
2019-04-03 15:16:51 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
extern Sonde sonde;
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|