From 1ffe73708f9c107ff4972bf1ca0e24ddad15add8 Mon Sep 17 00:00:00 2001
From: "Hans P. Reiser"
Date: Wed, 17 Apr 2019 14:54:08 +0200
Subject: [PATCH] configurable oled pins, minor spectrum enhancement
---
libraries/SondeLib/RS41.cpp | 15 +++++++++------
libraries/SondeLib/RS41.h | 2 +-
libraries/SondeLib/Scanner.cpp | 6 +++---
libraries/SondeLib/Sonde.cpp | 21 ++++++++++++++-------
libraries/SondeLib/Sonde.h | 3 ++-
5 files changed, 29 insertions(+), 18 deletions(-)
diff --git a/libraries/SondeLib/RS41.cpp b/libraries/SondeLib/RS41.cpp
index 39c6628..4752b37 100644
--- a/libraries/SondeLib/RS41.cpp
+++ b/libraries/SondeLib/RS41.cpp
@@ -357,10 +357,11 @@ static void posrs41(const byte b[], uint32_t b_len, uint32_t p)
-
-void RS41::decode41(byte *data, int maxlen)
+// returns: 0: ok, -1: rs or crc error
+int RS41::decode41(byte *data, int maxlen)
{
- char buf[128];
+ char buf[128];
+ int crcok = 0;
int32_t corr = reedsolomon41(data, 560, 131); // try short frame first
if(corr<0) {
@@ -393,7 +394,8 @@ void RS41::decode41(byte *data, int maxlen)
// check CRC
if(!crcrs(data, 560, p, p+len)) {
Serial.println("###CRC ERROR###");
- } else {
+ } else {
+ crcok = 1;
switch(typ) {
case 'y': // name
{
@@ -421,6 +423,7 @@ void RS41::decode41(byte *data, int maxlen)
p += len;
Serial.println();
}
+ return crcok ? 0 : -1;
}
void RS41::printRaw(uint8_t *data, int len)
{
@@ -473,8 +476,8 @@ int RS41::receiveFrame() {
//printRaw(data, MAXLEN);
for(int i=0; iscanresult[i]) scanresult[i]=rssi;
diff --git a/libraries/SondeLib/Sonde.cpp b/libraries/SondeLib/Sonde.cpp
index a866f58..26ae18a 100644
--- a/libraries/SondeLib/Sonde.cpp
+++ b/libraries/SondeLib/Sonde.cpp
@@ -17,10 +17,10 @@ static unsigned char ms_tiles[] U8X8_PROGMEM = {
0x1F, 0x02, 0x04, 0x02, 0x1F, 0x40, 0x20, 0x10, 0x08, 0x04, 0x12, 0xA4, 0xA4, 0xA4, 0x40, 0x00
};
static unsigned char stattiles[4][4] = {
- 0x00, 0x00, 0x00, 0x00 ,
- 0x00, 0x10, 0x10, 0x00 ,
- 0x1F, 0x15, 0x15, 0x00 ,
- 0x00, 0x1F, 0x00, 0x00 };
+ 0x00, 0x1F, 0x00, 0x00 , // | == ok
+ 0x00, 0x10, 0x10, 0x00 , // . == no header found
+ 0x1F, 0x15, 0x15, 0x00 , // E == decode error
+ 0x00, 0x00, 0x00, 0x00 }; // ' ' == unknown/unassigned
byte myIP_tiles[8*11];
@@ -48,6 +48,11 @@ static uint8_t empty_tile2[8]={0x00, 0x11, 0x02, 0x02, 0x02, 0x01, 0x00, 0x00};
static uint8_t ap_tile[8]={0x00,0x04,0x22,0x92, 0x92, 0x22, 0x04, 0x00};
Sonde::Sonde() {
+ config.button_pin = 0;
+ config.oled_sda = 4;
+ config.oled_scl = 15;
+ config.oled_rst = 16;
+
config.noisefloor = -130;
strcpy(config.call,"NOCALL");
strcpy(config.passcode, "---");
@@ -83,6 +88,8 @@ void Sonde::setConfig(const char *cfg) {
strncpy(config.call, val, 9);
} else if(strcmp(cfg,"passcode")==0) {
strncpy(config.passcode, val, 9);
+ } else if(strcmp(cfg,"button_pin")==0) {
+ config.button_pin = atoi(val);
} else if(strcmp(cfg,"oled_sda")==0) {
config.oled_sda = atoi(val);
} else if(strcmp(cfg,"oled_scl")==0) {
@@ -147,7 +154,7 @@ void Sonde::addSonde(float frequency, SondeType type, int active) {
sondeList[nSonde].type = type;
sondeList[nSonde].freq = frequency;
sondeList[nSonde].active = active;
- memcpy(sondeList[nSonde].rxStat, "\x00\x01\x2\x3\x2\x1\x1\x2\x0\x3\x0\x0\x1\x2\x3\x1\x0", 18);
+ memcpy(sondeList[nSonde].rxStat, "\x3\x3\x3\x3\x3\x3\x3\x3\x3\x3\x3\x3\x3\x3\x3\x3\x3\x3", 18); // unknown/undefined
nSonde++;
}
void Sonde::nextConfig() {
@@ -196,8 +203,8 @@ int Sonde::receiveFrame() {
ret = dfm.receiveFrame();
}
memmove(sonde.si()->rxStat+1, sonde.si()->rxStat, 17);
- sonde.si()->rxStat[0] = ret==0 ? 3 : 1; // OK or Timeout; TODO: add error (2)
- return ret; // 0: OK, 1: Timeuot, 2: Other error (TODO)
+ sonde.si()->rxStat[0] = ret;
+ return ret; // 0: OK, 1: Timeuot, 2: Other error, 3: unknown
}
void Sonde::updateDisplayPos() {
diff --git a/libraries/SondeLib/Sonde.h b/libraries/SondeLib/Sonde.h
index df1eca3..9c39c4c 100644
--- a/libraries/SondeLib/Sonde.h
+++ b/libraries/SondeLib/Sonde.h
@@ -7,12 +7,13 @@
// RX_TIMEOUT: no header detected
// RX_ERROR: header detected, but data not decoded (crc error, etc.)
// RX_OK: header and data ok
-enum RxResult { RX_OK, RX_TIMEOUT, RX_ERROR };
+enum RxResult { RX_OK, RX_TIMEOUT, RX_ERROR, RX_UNKNOWN };
enum SondeType { STYPE_DFM06, STYPE_DFM09, STYPE_RS41 };
extern const char *sondeTypeStr[5];
typedef struct st_rdzconfig {
+ int button_pin;
int oled_sda;
int oled_scl;
int oled_rst;