configurable oled pins, minor spectrum enhancement

This commit is contained in:
Hans P. Reiser 2019-04-17 14:54:08 +02:00
parent 500679bdc5
commit 1ffe73708f
5 changed files with 29 additions and 18 deletions

View File

@ -357,10 +357,11 @@ static void posrs41(const byte b[], uint32_t b_len, uint32_t p)
// returns: 0: ok, -1: rs or crc error
void RS41::decode41(byte *data, int maxlen) 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 int32_t corr = reedsolomon41(data, 560, 131); // try short frame first
if(corr<0) { if(corr<0) {
@ -393,7 +394,8 @@ void RS41::decode41(byte *data, int maxlen)
// check CRC // check CRC
if(!crcrs(data, 560, p, p+len)) { if(!crcrs(data, 560, p, p+len)) {
Serial.println("###CRC ERROR###"); Serial.println("###CRC ERROR###");
} else { } else {
crcok = 1;
switch(typ) { switch(typ) {
case 'y': // name case 'y': // name
{ {
@ -421,6 +423,7 @@ void RS41::decode41(byte *data, int maxlen)
p += len; p += len;
Serial.println(); Serial.println();
} }
return crcok ? 0 : -1;
} }
void RS41::printRaw(uint8_t *data, int len) void RS41::printRaw(uint8_t *data, int len)
{ {
@ -473,8 +476,8 @@ int RS41::receiveFrame() {
//printRaw(data, MAXLEN); //printRaw(data, MAXLEN);
for(int i=0; i<RS41MAXLEN; i++) { data[i] = data[i] ^ scramble[i&0x3F]; } for(int i=0; i<RS41MAXLEN; i++) { data[i] = data[i] ^ scramble[i&0x3F]; }
//printRaw(data, MAXLEN); //printRaw(data, MAXLEN);
decode41(data, RS41MAXLEN); int res = decode41(data, RS41MAXLEN);
return RX_OK; return res==0 ? RX_OK : RX_ERROR;
} }
RS41 rs41 = RS41(); RS41 rs41 = RS41();

View File

@ -23,7 +23,7 @@ private:
uint32_t bits2val(const uint8_t *bits, int len); uint32_t bits2val(const uint8_t *bits, int len);
void printRaw(uint8_t *data, int len); void printRaw(uint8_t *data, int len);
int bitsToBytes(uint8_t *bits, uint8_t *bytes, int len); int bitsToBytes(uint8_t *bits, uint8_t *bytes, int len);
void decode41(byte *data, int maxlen); int decode41(byte *data, int maxlen);
#define B 8 #define B 8
#define S 4 #define S 4

View File

@ -6,7 +6,7 @@ extern U8X8_SSD1306_128X64_NONAME_SW_I2C *u8x8;
#define CHANBW 10 #define CHANBW 10
#define PIXSAMPL (50/CHANBW) #define PIXSAMPL (50/CHANBW)
#define SMOOTH 4 #define SMOOTH 3
#define STARTF 400000000 #define STARTF 400000000
#define NCHAN ((int)(6000/CHANBW)) #define NCHAN ((int)(6000/CHANBW))
@ -16,7 +16,7 @@ int scandisp[NCHAN/PIXSAMPL];
#define PLOT_N 120 #define PLOT_N 120
#define TICK1 (120/6) #define TICK1 (120/6)
#define TICK2 (TICK1/4) #define TICK2 (TICK1/4)
#define PLOT_MIN -220 #define PLOT_MIN -250
#define PLOT_SCALE(x) (x<PLOT_MIN?0:(x-PLOT_MIN)/2) #define PLOT_SCALE(x) (x<PLOT_MIN?0:(x-PLOT_MIN)/2)
const byte tilepatterns[9]={0,0x80,0xC0,0xE0,0xF0,0xF8,0xFC,0xFE,0xFF}; const byte tilepatterns[9]={0,0x80,0xC0,0xE0,0xF0,0xF8,0xFC,0xFE,0xFF};
@ -82,7 +82,7 @@ void Scanner::scan()
lastfrf = frf; lastfrf = frf;
// Wait TS_HOP (20us) + TS_RSSI ( 2^(SMOOTH+1) / 4 / CHANBW us) // Wait TS_HOP (20us) + TS_RSSI ( 2^(SMOOTH+1) / 4 / CHANBW us)
int wait = 20 + 1000*(1<<(SMOOTH+1))/4/CHANBW; int wait = 20 + 1000*(1<<(SMOOTH+1))/4/CHANBW;
delayMicroseconds(wait); delayMicroseconds(wait+5);
int rssi = -(int)sx1278.readRegister(REG_RSSI_VALUE_FSK); int rssi = -(int)sx1278.readRegister(REG_RSSI_VALUE_FSK);
if(iter==0) { scanresult[i] = rssi; } else { if(iter==0) { scanresult[i] = rssi; } else {
if(rssi>scanresult[i]) scanresult[i]=rssi; if(rssi>scanresult[i]) scanresult[i]=rssi;

View File

@ -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 0x1F, 0x02, 0x04, 0x02, 0x1F, 0x40, 0x20, 0x10, 0x08, 0x04, 0x12, 0xA4, 0xA4, 0xA4, 0x40, 0x00
}; };
static unsigned char stattiles[4][4] = { static unsigned char stattiles[4][4] = {
0x00, 0x00, 0x00, 0x00 , 0x00, 0x1F, 0x00, 0x00 , // | == ok
0x00, 0x10, 0x10, 0x00 , 0x00, 0x10, 0x10, 0x00 , // . == no header found
0x1F, 0x15, 0x15, 0x00 , 0x1F, 0x15, 0x15, 0x00 , // E == decode error
0x00, 0x1F, 0x00, 0x00 }; 0x00, 0x00, 0x00, 0x00 }; // ' ' == unknown/unassigned
byte myIP_tiles[8*11]; 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}; static uint8_t ap_tile[8]={0x00,0x04,0x22,0x92, 0x92, 0x22, 0x04, 0x00};
Sonde::Sonde() { Sonde::Sonde() {
config.button_pin = 0;
config.oled_sda = 4;
config.oled_scl = 15;
config.oled_rst = 16;
config.noisefloor = -130; config.noisefloor = -130;
strcpy(config.call,"NOCALL"); strcpy(config.call,"NOCALL");
strcpy(config.passcode, "---"); strcpy(config.passcode, "---");
@ -83,6 +88,8 @@ void Sonde::setConfig(const char *cfg) {
strncpy(config.call, val, 9); strncpy(config.call, val, 9);
} else if(strcmp(cfg,"passcode")==0) { } else if(strcmp(cfg,"passcode")==0) {
strncpy(config.passcode, val, 9); strncpy(config.passcode, val, 9);
} else if(strcmp(cfg,"button_pin")==0) {
config.button_pin = atoi(val);
} else if(strcmp(cfg,"oled_sda")==0) { } else if(strcmp(cfg,"oled_sda")==0) {
config.oled_sda = atoi(val); config.oled_sda = atoi(val);
} else if(strcmp(cfg,"oled_scl")==0) { } 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].type = type;
sondeList[nSonde].freq = frequency; sondeList[nSonde].freq = frequency;
sondeList[nSonde].active = active; 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++; nSonde++;
} }
void Sonde::nextConfig() { void Sonde::nextConfig() {
@ -196,8 +203,8 @@ int Sonde::receiveFrame() {
ret = dfm.receiveFrame(); ret = dfm.receiveFrame();
} }
memmove(sonde.si()->rxStat+1, sonde.si()->rxStat, 17); memmove(sonde.si()->rxStat+1, sonde.si()->rxStat, 17);
sonde.si()->rxStat[0] = ret==0 ? 3 : 1; // OK or Timeout; TODO: add error (2) sonde.si()->rxStat[0] = ret;
return ret; // 0: OK, 1: Timeuot, 2: Other error (TODO) return ret; // 0: OK, 1: Timeuot, 2: Other error, 3: unknown
} }
void Sonde::updateDisplayPos() { void Sonde::updateDisplayPos() {

View File

@ -7,12 +7,13 @@
// RX_TIMEOUT: no header detected // RX_TIMEOUT: no header detected
// RX_ERROR: header detected, but data not decoded (crc error, etc.) // RX_ERROR: header detected, but data not decoded (crc error, etc.)
// RX_OK: header and data ok // 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 }; enum SondeType { STYPE_DFM06, STYPE_DFM09, STYPE_RS41 };
extern const char *sondeTypeStr[5]; extern const char *sondeTypeStr[5];
typedef struct st_rdzconfig { typedef struct st_rdzconfig {
int button_pin;
int oled_sda; int oled_sda;
int oled_scl; int oled_scl;
int oled_rst; int oled_rst;