first commit
This commit is contained in:
Executable
+347
@@ -0,0 +1,347 @@
|
||||
|
||||
/* DFM decoder functions */
|
||||
#include "DFM.h"
|
||||
#include "SX1278FSK.h"
|
||||
#include "Sonde.h"
|
||||
|
||||
#define DFM_DEBUG 1
|
||||
|
||||
#if DFM_DEBUG
|
||||
#define DFM_DBG(x) x
|
||||
#else
|
||||
#define DFM_DBG(x)
|
||||
#endif
|
||||
|
||||
int DFM::setup(float frequency, int inv)
|
||||
{
|
||||
inverse = inv;
|
||||
#if DFM_DEBUG
|
||||
Serial.printf("Setup sx1278 for DFM sonde (inv=%d)\n",inv);
|
||||
#endif
|
||||
if(sx1278.ON()!=0) {
|
||||
DFM_DBG(Serial.println("Setting SX1278 power on FAILED"));
|
||||
return 1;
|
||||
}
|
||||
if(sx1278.setFSK()!=0) {
|
||||
DFM_DBG(Serial.println("Setting FSM mode FAILED"));
|
||||
return 1;
|
||||
}
|
||||
if(sx1278.setBitrate(2500)!=0) {
|
||||
DFM_DBG(Serial.println("Setting bitrate 2500bit/s FAILED"));
|
||||
return 1;
|
||||
}
|
||||
#if DFM_DEBUG
|
||||
float br = sx1278.getBitrate();
|
||||
Serial.print("Exact bitrate is ");
|
||||
Serial.println(br);
|
||||
#endif
|
||||
|
||||
if(sx1278.setAFCBandwidth(sonde.config.dfm.agcbw)!=0) {
|
||||
DFM_DBG(Serial.printf("Setting AFC bandwidth %d Hz FAILED", sonde.config.dfm.agcbw));
|
||||
return 1;
|
||||
}
|
||||
if(sx1278.setRxBandwidth(sonde.config.dfm.rxbw)!=0) {
|
||||
DFM_DBG(Serial.printf("Setting RX bandwidth to %d Hz FAILED", sonde.config.dfm.rxbw));
|
||||
return 1;
|
||||
}
|
||||
// Enable auto-AFC, auto-AGC, RX Trigger by preamble
|
||||
if(sx1278.setRxConf(0x1E)!=0) {
|
||||
DFM_DBG(Serial.println("Setting RX Config FAILED"));
|
||||
return 1;
|
||||
}
|
||||
// Set autostart_RX to 01, preamble 0, SYNC detect==on, syncsize=3 (==4 byte
|
||||
//char header[] = "0110.0101 0110.0110 1010.0101 1010.1010";
|
||||
|
||||
const char *SYNC=inverse?"\x9A\x99\x5A\x55":"\x65\x66\xA5\xAA";
|
||||
if(sx1278.setSyncConf(0x53, 4, (const uint8_t *)SYNC)!=0) {
|
||||
DFM_DBG(Serial.println("Setting SYNC Config FAILED"));
|
||||
return 1;
|
||||
}
|
||||
if(sx1278.setPreambleDetect(0xA8)!=0) {
|
||||
DFM_DBG(Serial.println("Setting PreambleDetect FAILED"));
|
||||
return 1;
|
||||
}
|
||||
|
||||
// Packet config 1: fixed len, mancecer, no crc, no address filter
|
||||
// Packet config 2: packet mode, no home ctrl, no beackn, msb(packetlen)=0)
|
||||
if(sx1278.setPacketConfig(0x28, 0x40)!=0) {
|
||||
DFM_DBG(Serial.println("Setting Packet config FAILED"));
|
||||
return 1;
|
||||
}
|
||||
Serial.print("DFM: setting RX frequency to ");
|
||||
Serial.println(frequency);
|
||||
|
||||
int retval = sx1278.setFrequency(frequency);
|
||||
sx1278.clearIRQFlags();
|
||||
DFM_DBG(Serial.println("Setting SX1278 config for DFM finished\n"); Serial.println());
|
||||
return retval;
|
||||
}
|
||||
|
||||
|
||||
#define bitpick(value,bitpos) (((value)>>(7-(bitpos)))&0x01)
|
||||
// Input: str: packed data, MSB first
|
||||
void DFM::deinterleave(uint8_t *str, int L, uint8_t *block) {
|
||||
int i, j;
|
||||
for (j = 0; j < B; j++) { // L = 7 (CFG), 13 (DAT1, DAT2)
|
||||
for (i = 0; i < L; i++) {
|
||||
block[B*i+j] = bitpick( str[(L*j+i)/8], (L*j+i)&7 )?0:1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
uint32_t DFM::bits2val(const uint8_t *bits, int len) {
|
||||
uint32_t val = 0;
|
||||
for (int j = 0; j < len; j++) {
|
||||
val |= (bits[j] << (len-1-j));
|
||||
}
|
||||
return val;
|
||||
}
|
||||
|
||||
// Error correction for hamming code
|
||||
// returns 0: ok >0: 1 error was corrected -1: uncorrectable error
|
||||
int DFM::check(uint8_t code[8]) {
|
||||
int i, j;
|
||||
uint32_t synval = 0;
|
||||
uint8_t syndrom[4];
|
||||
int ret=0;
|
||||
|
||||
for (i = 0; i < 4; i++) {
|
||||
syndrom[i] = 0;
|
||||
for (j = 0; j < 8; j++) {
|
||||
syndrom[i] ^= H[i][j] & code[j];
|
||||
}
|
||||
}
|
||||
synval = bits2val(syndrom, 4);
|
||||
if (synval) {
|
||||
ret = -1;
|
||||
for (j = 0; j < 8; j++) { // 1-bit-error
|
||||
if (synval == He[j]) { // reicht auf databits zu pruefen, d.h.
|
||||
ret = j+1; // (systematischer Code) He[0..3]
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else ret = 0;
|
||||
if (ret > 0) code[ret-1] ^= 0x1;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
// Extended (8,4) Hamming code
|
||||
// Return number of corrected bits, -1 if uncorrectable error
|
||||
int DFM::hamming(uint8_t *ham, int L, uint8_t *sym) {
|
||||
int i, j;
|
||||
int ret = 0; // DFM: length L = 7 or 13
|
||||
for (i = 0; i < L; i++) { // L bytes (4bit data, 4bit parity)
|
||||
if (use_ecc) {
|
||||
int res = check(ham+8*i);
|
||||
if(ret>=0 && res>=0) ret += res; else ret=-1;
|
||||
}
|
||||
// systematic Hamming code: copy bits 0..3
|
||||
for (j = 0; j < 4; j++) {
|
||||
sym[4*i+j] = ham[8*i+j];
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
DFM::DFM() {
|
||||
}
|
||||
|
||||
void DFM::printRaw(const char *label, int len, int ret, const uint8_t *data)
|
||||
{
|
||||
Serial.print(label); Serial.print("(");
|
||||
Serial.print(ret);
|
||||
Serial.print("):");
|
||||
int i;
|
||||
for(i=0; i<len/2; i++) {
|
||||
char str[10];
|
||||
snprintf(str, 10, "%02X", data[i]);
|
||||
Serial.print(str);
|
||||
}
|
||||
Serial.print(data[i]&0x0F, HEX);
|
||||
Serial.print(" ");
|
||||
}
|
||||
|
||||
void DFM::decodeCFG(uint8_t *cfg)
|
||||
{
|
||||
static int lowid, highid, idgood=0, type=0;
|
||||
if((cfg[0]>>4)==0x06 && type==0) { // DFM-6 ID
|
||||
lowid = ((cfg[0]&0x0F)<<20) | (cfg[1]<<12) | (cfg[2]<<4) | (cfg[3]&0x0f);
|
||||
Serial.print("DFM-06 ID: "); Serial.print(lowid, HEX);
|
||||
snprintf(sonde.si()->id, 10, "%x", lowid);
|
||||
sonde.si()->validID = true;
|
||||
}
|
||||
if((cfg[0]>>4)==0x0A) { // DMF-9 ID
|
||||
type=9;
|
||||
if(cfg[3]==1) {
|
||||
lowid = (cfg[1]<<8) | cfg[2];
|
||||
idgood |= 1;
|
||||
} else {
|
||||
highid = (cfg[1]<<8) | cfg[2];
|
||||
idgood |= 2;
|
||||
}
|
||||
if(idgood==3) {
|
||||
uint32_t dfmid = (highid<<16) | lowid;
|
||||
Serial.print("DFM-09 ID: "); Serial.print(dfmid);
|
||||
snprintf(sonde.si()->ser, 10, "%d", dfmid);
|
||||
// dxlAPRS sonde number (DF6 (why??) and 5 last digits of serial number as hex number
|
||||
snprintf(sonde.si()->id, 9, "DF6%05X", dfmid&0xfffff);
|
||||
sonde.si()->validID = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static int bitCount(int x) {
|
||||
int m4 = 0x1 | (0x1<<8) | (0x1<<16) | (0x1<<24);
|
||||
int m1 = 0xFF;
|
||||
int s4 = (x&m4) + ((x>>1)&m4) + ((x>>2)&m4) + ((x>>3)&m4) + ((x>>4)&m4) + ((x>>5)&m4) + ((x>>6)&m4) + ((x>>7)&m4);
|
||||
int s1 = (s4&m1) + ((s4>>8)&m1) + ((s4>>16)&m1) + ((s4>>24)&m1);
|
||||
return s1;
|
||||
}
|
||||
|
||||
static uint16_t MON[]={0,0,31,59,90,120,151,181,212,243,273,304,334};
|
||||
|
||||
void DFM::decodeDAT(uint8_t *dat)
|
||||
{
|
||||
Serial.print(" DAT["); Serial.print(dat[6]); Serial.print("]: ");
|
||||
switch(dat[6]) {
|
||||
case 0:
|
||||
Serial.print("Packet counter: "); Serial.print(dat[3]);
|
||||
sonde.si()->frame = dat[3];
|
||||
break;
|
||||
case 1:
|
||||
{
|
||||
int val = (((uint16_t)dat[4])<<8) + (uint16_t)dat[5];
|
||||
Serial.print("UTC-msec: "); Serial.print(val);
|
||||
sonde.si()->sec = val/1000;
|
||||
uint32_t tmp = ((uint32_t)dat[0]<<24) + ((uint32_t)dat[1]<<16) + ((uint32_t)dat[2]<<8) + ((uint32_t)dat[3]);
|
||||
sonde.si()->sats = bitCount(tmp); // maybe!?!?!?
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
{
|
||||
float lat, vh;
|
||||
lat = ((uint32_t)dat[0]<<24) + ((uint32_t)dat[1]<<16) + ((uint32_t)dat[2]<<8) + ((uint32_t)dat[3]);
|
||||
vh = ((uint16_t)dat[4]<<8) + dat[5];
|
||||
Serial.print("GPS-lat: "); Serial.print(lat*0.0000001);
|
||||
Serial.print(", hor-V: "); Serial.print(vh*0.01);
|
||||
sonde.si()->lat = lat*0.0000001;
|
||||
sonde.si()->hs = vh*0.01;
|
||||
sonde.si()->validPos |= 0x11;
|
||||
}
|
||||
break;
|
||||
case 3:
|
||||
{
|
||||
float lon, dir;
|
||||
lon = ((uint32_t)dat[0]<<24) + ((uint32_t)dat[1]<<16) + ((uint32_t)dat[2]<<8) + (uint32_t)dat[3];
|
||||
dir = ((uint16_t)dat[4]<<8) + dat[5];
|
||||
Serial.print("GPS-lon: "); Serial.print(lon*0.0000001);
|
||||
Serial.print(", dir: "); Serial.print(dir*0.01);
|
||||
sonde.si()->lon = lon*0.0000001;
|
||||
sonde.si()->dir = dir*0.01;
|
||||
sonde.si()->validPos |= 0x42;
|
||||
}
|
||||
break;
|
||||
case 4:
|
||||
{
|
||||
float alt, vv;
|
||||
alt = ((uint32_t)dat[0]<<24) + ((uint32_t)dat[1]<<16) + ((uint32_t)dat[2]<<8) + dat[3];
|
||||
vv = (int16_t)( ((int16_t)dat[4]<<8) | dat[5] );
|
||||
Serial.print("GPS-height: "); Serial.print(alt*0.01);
|
||||
Serial.print(", vv: "); Serial.print(vv*0.01);
|
||||
sonde.si()->alt = alt*0.01;
|
||||
sonde.si()->vs = vv*0.01;
|
||||
sonde.si()->validPos |= 0x0C;
|
||||
}
|
||||
break;
|
||||
case 8:
|
||||
{
|
||||
int y = (dat[0]<<4) + (dat[1]>>4);
|
||||
int m = dat[1]&0x0F;
|
||||
int d = dat[2]>>3;
|
||||
int h = ((dat[2]&0x07)<<2) + (dat[3]>>6);
|
||||
int mi = (dat[3]&0x3F);
|
||||
char buf[100];
|
||||
snprintf(buf, 100, "%04d-%02d-%02d %02d:%02dz", y, m, d, h, mi);
|
||||
Serial.print("Date: "); Serial.print(buf);
|
||||
// convert to unix time
|
||||
int tt = (y-1970)*365 + (y-1969)/4; // days since 1970
|
||||
if(m<=12) { tt += MON[m]; if((y%4)==0 && m>2) tt++; }
|
||||
tt = (tt+d-1)*(60*60*24) + h*3600 + mi*60;
|
||||
sonde.si()->time = tt;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
Serial.print("(?)");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void DFM::bitsToBytes(uint8_t *bits, uint8_t *bytes, int len)
|
||||
{
|
||||
int i;
|
||||
for(i=0; i<len*4; i++) {
|
||||
//Serial.print(bits[i]?"1":"0");
|
||||
bytes[i/8] = (bytes[i/8]<<1) | (bits[i]?1:0);
|
||||
}
|
||||
bytes[(i-1)/8] &= 0x0F;
|
||||
}
|
||||
|
||||
int DFM::receive() {
|
||||
byte data[1000]; // pending data from previous mode may write more than 33 bytes. TODO.
|
||||
for(int i=0; i<2; i++) {
|
||||
sx1278.setPayloadLength(33); // Expect 33 bytes (7+13+13 bytes)
|
||||
|
||||
sx1278.writeRegister(REG_OP_MODE, FSK_RX_MODE);
|
||||
int e = sx1278.receivePacketTimeout(1000, data);
|
||||
if(e) { return RX_TIMEOUT; } //if timeout... return 1
|
||||
|
||||
Serial.printf("inverse is %d\b", inverse);
|
||||
if(!inverse) { for(int i=0; i<33; i++) { data[i]^=0xFF; } }
|
||||
deinterleave(data, 7, hamming_conf);
|
||||
deinterleave(data+7, 13, hamming_dat1);
|
||||
deinterleave(data+20, 13, hamming_dat2);
|
||||
|
||||
int ret0 = hamming(hamming_conf, 7, block_conf);
|
||||
int ret1 = hamming(hamming_dat1, 13, block_dat1);
|
||||
int ret2 = hamming(hamming_dat2, 13, block_dat2);
|
||||
|
||||
byte byte_conf[4], byte_dat1[7], byte_dat2[7];
|
||||
bitsToBytes(block_conf, byte_conf, 7);
|
||||
bitsToBytes(block_dat1, byte_dat1, 13);
|
||||
bitsToBytes(block_dat2, byte_dat2, 13);
|
||||
|
||||
printRaw("CFG", 7, ret0, byte_conf);
|
||||
printRaw("DAT", 13, ret1, byte_dat1);
|
||||
printRaw("DAT", 13, ret2, byte_dat2);
|
||||
decodeCFG(byte_conf);
|
||||
decodeDAT(byte_dat1);
|
||||
decodeDAT(byte_dat2);
|
||||
}
|
||||
return RX_OK;
|
||||
}
|
||||
|
||||
// moved to a single function in Sonde(). This function can be used for additional
|
||||
// processing here, that takes too long for doing in the RX task loop
|
||||
int DFM::waitRXcomplete() {
|
||||
#if 0
|
||||
int res=0;
|
||||
uint32_t t0 = millis();
|
||||
while( rxtask.receiveResult < 0 && millis()-t0 < 2000) { delay(50); }
|
||||
|
||||
if( rxtask.receiveResult<0 || rxtask.receiveResult==RX_TIMEOUT) {
|
||||
res = RX_TIMEOUT;
|
||||
} else if ( rxtask.receiveResult ==0) {
|
||||
res = RX_OK;
|
||||
} else {
|
||||
res = RX_ERROR;
|
||||
}
|
||||
rxtask.receiveResult = -1;
|
||||
Serial.printf("waitRXcomplete returning %d\n", res);
|
||||
return res;
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
DFM dfm = DFM();
|
||||
Executable
+67
@@ -0,0 +1,67 @@
|
||||
/*
|
||||
* DFM.h
|
||||
* Functions for decoding DFM sondes with SX127x chips
|
||||
* Copyright (C) 2019 Hansi Reiser, dl9rdz
|
||||
*
|
||||
* SPDX-License-Identifier: GPL-2.0+
|
||||
*/
|
||||
|
||||
#ifndef DFM_h
|
||||
#define DFM_h
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdint.h>
|
||||
#include <Arduino.h>
|
||||
#ifndef inttypes_h
|
||||
#include <inttypes.h>
|
||||
#endif
|
||||
|
||||
#define DFM_NORMAL 0
|
||||
#define DFM_INVERSE 1
|
||||
|
||||
/* Main class */
|
||||
class DFM
|
||||
{
|
||||
private:
|
||||
int inverse=0;
|
||||
|
||||
void deinterleave(uint8_t *str, int L, uint8_t *block);
|
||||
uint32_t bits2val(const uint8_t *bits, int len);
|
||||
int check(uint8_t code[8]);
|
||||
int hamming(uint8_t *ham, int L, uint8_t *sym);
|
||||
void printRaw(const char *prefix, int len, int ret, const uint8_t* data);
|
||||
void decodeCFG(uint8_t *cfg);
|
||||
void decodeDAT(uint8_t *dat);
|
||||
void bitsToBytes(uint8_t *bits, uint8_t *bytes, int len);
|
||||
|
||||
#define B 8
|
||||
#define S 4
|
||||
uint8_t hamming_conf[ 7*B]; // 7*8=56
|
||||
uint8_t hamming_dat1[13*B]; // 13*8=104
|
||||
uint8_t hamming_dat2[13*B];
|
||||
|
||||
uint8_t block_conf[ 7*S]; // 7*4=28
|
||||
uint8_t block_dat1[13*S]; // 13*4=52
|
||||
uint8_t block_dat2[13*S];
|
||||
|
||||
uint8_t H[4][8] = // extended Hamming(8,4) particy check matrix
|
||||
{{ 0, 1, 1, 1, 1, 0, 0, 0},
|
||||
{ 1, 0, 1, 1, 0, 1, 0, 0},
|
||||
{ 1, 1, 0, 1, 0, 0, 1, 0},
|
||||
{ 1, 1, 1, 0, 0, 0, 0, 1}};
|
||||
uint8_t He[8] = { 0x7, 0xB, 0xD, 0xE, 0x8, 0x4, 0x2, 0x1}; // Spalten von H:
|
||||
// 1-bit-error-Syndrome
|
||||
|
||||
public:
|
||||
DFM();
|
||||
// main decoder API
|
||||
int setup(float frequency, int inverse);
|
||||
int receive();
|
||||
int waitRXcomplete();
|
||||
|
||||
int use_ecc = 1;
|
||||
};
|
||||
|
||||
extern DFM dfm;
|
||||
|
||||
#endif
|
||||
Executable
+367
@@ -0,0 +1,367 @@
|
||||
// SPDX-License-Identifier: GPL-3.0
|
||||
// original source: https://github.com/Nkawu/TFT_22_ILI9225
|
||||
|
||||
|
||||
#ifdef __AVR__
|
||||
#include <avr/pgmspace.h>
|
||||
#elif defined(ESP8266) || defined(ESP32)
|
||||
#include <pgmspace.h>
|
||||
#endif
|
||||
|
||||
#if defined(ARDUINO_ARCH_SAM) || defined(ARDUINO_ARCH_SAMD) || defined(ARDUINO_ARCH_STM32) || defined(ARDUINO_ARCH_STM32F1) || defined(STM32F1) || defined(ESP32)
|
||||
#define PROGMEM
|
||||
#define fontdatatype const char
|
||||
#else
|
||||
#define fontdatatype const uint8_t
|
||||
#endif
|
||||
|
||||
//Font Generated by MikroElektronika GLCD Font Creator 1.2.0.0
|
||||
//MikroElektronika 2011
|
||||
//http://www.mikroe.com
|
||||
|
||||
//GLCD FontName : Terminal6x8
|
||||
//GLCD FontSize : 6 x 8
|
||||
|
||||
fontdatatype Terminal6x8[] PROGMEM = {
|
||||
0x06, 0x08, 0x20, 0x60,
|
||||
0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char
|
||||
0x05, 0x00, 0x00, 0x06, 0x5F, 0x06, 0x00, // Code for char !
|
||||
0x06, 0x00, 0x07, 0x03, 0x00, 0x07, 0x03, // Code for char "
|
||||
0x06, 0x00, 0x24, 0x7E, 0x24, 0x7E, 0x24, // Code for char #
|
||||
0x05, 0x00, 0x24, 0x2B, 0x6A, 0x12, 0x00, // Code for char $
|
||||
0x06, 0x00, 0x63, 0x13, 0x08, 0x64, 0x63, // Code for char %
|
||||
0x06, 0x00, 0x36, 0x49, 0x56, 0x20, 0x50, // Code for char &
|
||||
0x04, 0x00, 0x00, 0x07, 0x03, 0x00, 0x00, // Code for char '
|
||||
0x04, 0x00, 0x00, 0x3E, 0x41, 0x00, 0x00, // Code for char (
|
||||
0x04, 0x00, 0x00, 0x41, 0x3E, 0x00, 0x00, // Code for char )
|
||||
0x06, 0x00, 0x08, 0x3E, 0x1C, 0x3E, 0x08, // Code for char *
|
||||
0x06, 0x00, 0x08, 0x08, 0x3E, 0x08, 0x08, // Code for char +
|
||||
0x04, 0x00, 0x00, 0xE0, 0x60, 0x00, 0x00, // Code for char ,
|
||||
0x06, 0x00, 0x08, 0x08, 0x08, 0x08, 0x08, // Code for char -
|
||||
0x04, 0x00, 0x00, 0x60, 0x60, 0x00, 0x00, // Code for char .
|
||||
0x06, 0x00, 0x20, 0x10, 0x08, 0x04, 0x02, // Code for char /
|
||||
0x06, 0x00, 0x3E, 0x51, 0x49, 0x45, 0x3E, // Code for char 0
|
||||
0x05, 0x00, 0x00, 0x42, 0x7F, 0x40, 0x00, // Code for char 1
|
||||
0x06, 0x00, 0x62, 0x51, 0x49, 0x49, 0x46, // Code for char 2
|
||||
0x06, 0x00, 0x22, 0x49, 0x49, 0x49, 0x36, // Code for char 3
|
||||
0x06, 0x00, 0x18, 0x14, 0x12, 0x7F, 0x10, // Code for char 4
|
||||
0x06, 0x00, 0x2F, 0x49, 0x49, 0x49, 0x31, // Code for char 5
|
||||
0x06, 0x00, 0x3C, 0x4A, 0x49, 0x49, 0x30, // Code for char 6
|
||||
0x06, 0x00, 0x01, 0x71, 0x09, 0x05, 0x03, // Code for char 7
|
||||
0x06, 0x00, 0x36, 0x49, 0x49, 0x49, 0x36, // Code for char 8
|
||||
0x06, 0x00, 0x06, 0x49, 0x49, 0x29, 0x1E, // Code for char 9
|
||||
0x04, 0x00, 0x00, 0x6C, 0x6C, 0x00, 0x00, // Code for char :
|
||||
0x04, 0x00, 0x00, 0xEC, 0x6C, 0x00, 0x00, // Code for char ;
|
||||
0x05, 0x00, 0x08, 0x14, 0x22, 0x41, 0x00, // Code for char <
|
||||
0x06, 0x00, 0x24, 0x24, 0x24, 0x24, 0x24, // Code for char =
|
||||
0x06, 0x00, 0x00, 0x41, 0x22, 0x14, 0x08, // Code for char >
|
||||
0x06, 0x00, 0x02, 0x01, 0x59, 0x09, 0x06, // Code for char ?
|
||||
0x06, 0x00, 0x3E, 0x41, 0x5D, 0x55, 0x1E, // Code for char @
|
||||
0x06, 0x00, 0x7E, 0x11, 0x11, 0x11, 0x7E, // Code for char A
|
||||
0x06, 0x00, 0x7F, 0x49, 0x49, 0x49, 0x36, // Code for char B
|
||||
0x06, 0x00, 0x3E, 0x41, 0x41, 0x41, 0x22, // Code for char C
|
||||
0x06, 0x00, 0x7F, 0x41, 0x41, 0x41, 0x3E, // Code for char D
|
||||
0x06, 0x00, 0x7F, 0x49, 0x49, 0x49, 0x41, // Code for char E
|
||||
0x06, 0x00, 0x7F, 0x09, 0x09, 0x09, 0x01, // Code for char F
|
||||
0x06, 0x00, 0x3E, 0x41, 0x49, 0x49, 0x7A, // Code for char G
|
||||
0x06, 0x00, 0x7F, 0x08, 0x08, 0x08, 0x7F, // Code for char H
|
||||
0x05, 0x00, 0x00, 0x41, 0x7F, 0x41, 0x00, // Code for char I
|
||||
0x06, 0x00, 0x30, 0x40, 0x40, 0x40, 0x3F, // Code for char J
|
||||
0x06, 0x00, 0x7F, 0x08, 0x14, 0x22, 0x41, // Code for char K
|
||||
0x06, 0x00, 0x7F, 0x40, 0x40, 0x40, 0x40, // Code for char L
|
||||
0x06, 0x00, 0x7F, 0x02, 0x04, 0x02, 0x7F, // Code for char M
|
||||
0x06, 0x00, 0x7F, 0x02, 0x04, 0x08, 0x7F, // Code for char N
|
||||
0x06, 0x00, 0x3E, 0x41, 0x41, 0x41, 0x3E, // Code for char O
|
||||
0x06, 0x00, 0x7F, 0x09, 0x09, 0x09, 0x06, // Code for char P
|
||||
0x06, 0x00, 0x3E, 0x41, 0x51, 0x21, 0x5E, // Code for char Q
|
||||
0x06, 0x00, 0x7F, 0x09, 0x09, 0x19, 0x66, // Code for char R
|
||||
0x06, 0x00, 0x26, 0x49, 0x49, 0x49, 0x32, // Code for char S
|
||||
0x06, 0x00, 0x01, 0x01, 0x7F, 0x01, 0x01, // Code for char T
|
||||
0x06, 0x00, 0x3F, 0x40, 0x40, 0x40, 0x3F, // Code for char U
|
||||
0x06, 0x00, 0x1F, 0x20, 0x40, 0x20, 0x1F, // Code for char V
|
||||
0x06, 0x00, 0x3F, 0x40, 0x3C, 0x40, 0x3F, // Code for char W
|
||||
0x06, 0x00, 0x63, 0x14, 0x08, 0x14, 0x63, // Code for char X
|
||||
0x06, 0x00, 0x07, 0x08, 0x70, 0x08, 0x07, // Code for char Y
|
||||
0x05, 0x00, 0x71, 0x49, 0x45, 0x43, 0x00, // Code for char Z
|
||||
0x05, 0x00, 0x00, 0x7F, 0x41, 0x41, 0x00, // Code for char [
|
||||
0x06, 0x00, 0x02, 0x04, 0x08, 0x10, 0x20, // Code for char BackSlash
|
||||
0x05, 0x00, 0x00, 0x41, 0x41, 0x7F, 0x00, // Code for char ]
|
||||
0x06, 0x00, 0x04, 0x02, 0x01, 0x02, 0x04, // Code for char ^
|
||||
0x06, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, // Code for char _
|
||||
0x04, 0x00, 0x00, 0x03, 0x07, 0x00, 0x00, // Code for char `
|
||||
0x06, 0x00, 0x20, 0x54, 0x54, 0x54, 0x78, // Code for char a
|
||||
0x06, 0x00, 0x7F, 0x44, 0x44, 0x44, 0x38, // Code for char b
|
||||
0x06, 0x00, 0x38, 0x44, 0x44, 0x44, 0x28, // Code for char c
|
||||
0x06, 0x00, 0x38, 0x44, 0x44, 0x44, 0x7F, // Code for char d
|
||||
0x06, 0x00, 0x38, 0x54, 0x54, 0x54, 0x08, // Code for char e
|
||||
0x05, 0x00, 0x08, 0x7E, 0x09, 0x09, 0x00, // Code for char f
|
||||
0x06, 0x00, 0x18, 0xA4, 0xA4, 0xA4, 0x7C, // Code for char g
|
||||
0x05, 0x00, 0x7F, 0x04, 0x04, 0x78, 0x00, // Code for char h
|
||||
0x05, 0x00, 0x00, 0x00, 0x7D, 0x40, 0x00, // Code for char i
|
||||
0x05, 0x00, 0x40, 0x80, 0x84, 0x7D, 0x00, // Code for char j
|
||||
0x05, 0x00, 0x7F, 0x10, 0x28, 0x44, 0x00, // Code for char k
|
||||
0x05, 0x00, 0x00, 0x00, 0x7F, 0x40, 0x00, // Code for char l
|
||||
0x06, 0x00, 0x7C, 0x04, 0x18, 0x04, 0x78, // Code for char m
|
||||
0x05, 0x00, 0x7C, 0x04, 0x04, 0x78, 0x00, // Code for char n
|
||||
0x06, 0x00, 0x38, 0x44, 0x44, 0x44, 0x38, // Code for char o
|
||||
0x06, 0x00, 0xFC, 0x44, 0x44, 0x44, 0x38, // Code for char p
|
||||
0x06, 0x00, 0x38, 0x44, 0x44, 0x44, 0xFC, // Code for char q
|
||||
0x06, 0x00, 0x44, 0x78, 0x44, 0x04, 0x08, // Code for char r
|
||||
0x06, 0x00, 0x08, 0x54, 0x54, 0x54, 0x20, // Code for char s
|
||||
0x05, 0x00, 0x04, 0x3E, 0x44, 0x24, 0x00, // Code for char t
|
||||
0x05, 0x00, 0x3C, 0x40, 0x20, 0x7C, 0x00, // Code for char u
|
||||
0x06, 0x00, 0x1C, 0x20, 0x40, 0x20, 0x1C, // Code for char v
|
||||
0x06, 0x00, 0x3C, 0x60, 0x30, 0x60, 0x3C, // Code for char w
|
||||
0x05, 0x00, 0x6C, 0x10, 0x10, 0x6C, 0x00, // Code for char x
|
||||
0x05, 0x00, 0x9C, 0xA0, 0x60, 0x3C, 0x00, // Code for char y
|
||||
0x05, 0x00, 0x64, 0x54, 0x54, 0x4C, 0x00, // Code for char z
|
||||
0x05, 0x00, 0x08, 0x3E, 0x41, 0x41, 0x00, // Code for char {
|
||||
0x04, 0x00, 0x00, 0x00, 0x77, 0x00, 0x00, // Code for char |
|
||||
0x06, 0x00, 0x00, 0x41, 0x41, 0x3E, 0x08, // Code for char }
|
||||
0x05, 0x00, 0x02, 0x01, 0x02, 0x01, 0x00, // Code for char ~
|
||||
0x06, 0x00, 0x3C, 0x26, 0x23, 0x26, 0x3C // Code for char
|
||||
};
|
||||
|
||||
|
||||
//Font Generated by MikroElektronika GLCD Font Creator 1.2.0.0
|
||||
//MikroElektronika 2011
|
||||
//http://www.mikroe.com
|
||||
|
||||
//GLCD FontName : Terminal11x16
|
||||
//GLCD FontSize : 11 x 16
|
||||
|
||||
fontdatatype Terminal11x16[] PROGMEM = {
|
||||
0x0B, 0x10, 0x20, 0x60,
|
||||
0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char
|
||||
0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7C, 0x00, 0xFF, 0x33, 0xFF, 0x33, 0x7C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char !
|
||||
0x08, 0x00, 0x00, 0x00, 0x00, 0x3C, 0x00, 0x3C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3C, 0x00, 0x3C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char "
|
||||
0x0B, 0x00, 0x02, 0x10, 0x1E, 0x90, 0x1F, 0xF0, 0x03, 0x7E, 0x02, 0x1E, 0x1E, 0x90, 0x1F, 0xF0, 0x03, 0x7E, 0x02, 0x1E, 0x00, 0x10, 0x00, // Code for char #
|
||||
0x09, 0x00, 0x00, 0x78, 0x04, 0xFC, 0x0C, 0xCC, 0x0C, 0xFF, 0x3F, 0xFF, 0x3F, 0xCC, 0x0C, 0xCC, 0x0F, 0x88, 0x07, 0x00, 0x00, 0x00, 0x00, // Code for char $
|
||||
0x0B, 0x00, 0x30, 0x38, 0x38, 0x38, 0x1C, 0x38, 0x0E, 0x00, 0x07, 0x80, 0x03, 0xC0, 0x01, 0xE0, 0x38, 0x70, 0x38, 0x38, 0x38, 0x1C, 0x00, // Code for char %
|
||||
0x0A, 0x00, 0x00, 0x00, 0x1F, 0xB8, 0x3F, 0xFC, 0x31, 0xC6, 0x21, 0xE2, 0x37, 0x3E, 0x1E, 0x1C, 0x1C, 0x00, 0x36, 0x00, 0x22, 0x00, 0x00, // Code for char &
|
||||
0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x27, 0x00, 0x3F, 0x00, 0x1F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char '
|
||||
0x08, 0x00, 0x00, 0x00, 0x00, 0xF0, 0x03, 0xFC, 0x0F, 0xFE, 0x1F, 0x07, 0x38, 0x01, 0x20, 0x01, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char (
|
||||
0x08, 0x00, 0x00, 0x00, 0x00, 0x01, 0x20, 0x01, 0x20, 0x07, 0x38, 0xFE, 0x1F, 0xFC, 0x0F, 0xF0, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char )
|
||||
0x09, 0x00, 0x00, 0x98, 0x0C, 0xB8, 0x0E, 0xE0, 0x03, 0xF8, 0x0F, 0xF8, 0x0F, 0xE0, 0x03, 0xB8, 0x0E, 0x98, 0x0C, 0x00, 0x00, 0x00, 0x00, // Code for char *
|
||||
0x09, 0x00, 0x00, 0x80, 0x01, 0x80, 0x01, 0x80, 0x01, 0xF0, 0x0F, 0xF0, 0x0F, 0x80, 0x01, 0x80, 0x01, 0x80, 0x01, 0x00, 0x00, 0x00, 0x00, // Code for char +
|
||||
0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xB8, 0x00, 0xF8, 0x00, 0x78, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char ,
|
||||
0x09, 0x00, 0x00, 0x80, 0x01, 0x80, 0x01, 0x80, 0x01, 0x80, 0x01, 0x80, 0x01, 0x80, 0x01, 0x80, 0x01, 0x80, 0x01, 0x00, 0x00, 0x00, 0x00, // Code for char -
|
||||
0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x38, 0x00, 0x38, 0x00, 0x38, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char .
|
||||
0x0B, 0x00, 0x18, 0x00, 0x1C, 0x00, 0x0E, 0x00, 0x07, 0x80, 0x03, 0xC0, 0x01, 0xE0, 0x00, 0x70, 0x00, 0x38, 0x00, 0x1C, 0x00, 0x0E, 0x00, // Code for char /
|
||||
0x0B, 0xF8, 0x07, 0xFE, 0x1F, 0x06, 0x1E, 0x03, 0x33, 0x83, 0x31, 0xC3, 0x30, 0x63, 0x30, 0x33, 0x30, 0x1E, 0x18, 0xFE, 0x1F, 0xF8, 0x07, // Code for char 0
|
||||
0x0A, 0x00, 0x00, 0x00, 0x00, 0x0C, 0x30, 0x0C, 0x30, 0x0E, 0x30, 0xFF, 0x3F, 0xFF, 0x3F, 0x00, 0x30, 0x00, 0x30, 0x00, 0x30, 0x00, 0x00, // Code for char 1
|
||||
0x0B, 0x1C, 0x30, 0x1E, 0x38, 0x07, 0x3C, 0x03, 0x3E, 0x03, 0x37, 0x83, 0x33, 0xC3, 0x31, 0xE3, 0x30, 0x77, 0x30, 0x3E, 0x30, 0x1C, 0x30, // Code for char 2
|
||||
0x0B, 0x0C, 0x0C, 0x0E, 0x1C, 0x07, 0x38, 0xC3, 0x30, 0xC3, 0x30, 0xC3, 0x30, 0xC3, 0x30, 0xC3, 0x30, 0xE7, 0x39, 0x7E, 0x1F, 0x3C, 0x0E, // Code for char 3
|
||||
0x0B, 0xC0, 0x03, 0xE0, 0x03, 0x70, 0x03, 0x38, 0x03, 0x1C, 0x03, 0x0E, 0x03, 0x07, 0x03, 0xFF, 0x3F, 0xFF, 0x3F, 0x00, 0x03, 0x00, 0x03, // Code for char 4
|
||||
0x0B, 0x3F, 0x0C, 0x7F, 0x1C, 0x63, 0x38, 0x63, 0x30, 0x63, 0x30, 0x63, 0x30, 0x63, 0x30, 0x63, 0x30, 0xE3, 0x38, 0xC3, 0x1F, 0x83, 0x0F, // Code for char 5
|
||||
0x0B, 0xC0, 0x0F, 0xF0, 0x1F, 0xF8, 0x39, 0xDC, 0x30, 0xCE, 0x30, 0xC7, 0x30, 0xC3, 0x30, 0xC3, 0x30, 0xC3, 0x39, 0x80, 0x1F, 0x00, 0x0F, // Code for char 6
|
||||
0x0B, 0x03, 0x00, 0x03, 0x00, 0x03, 0x00, 0x03, 0x30, 0x03, 0x3C, 0x03, 0x0F, 0xC3, 0x03, 0xF3, 0x00, 0x3F, 0x00, 0x0F, 0x00, 0x03, 0x00, // Code for char 7
|
||||
0x0B, 0x00, 0x0F, 0xBC, 0x1F, 0xFE, 0x39, 0xE7, 0x30, 0xC3, 0x30, 0xC3, 0x30, 0xC3, 0x30, 0xE7, 0x30, 0xFE, 0x39, 0xBC, 0x1F, 0x00, 0x0F, // Code for char 8
|
||||
0x0B, 0x3C, 0x00, 0x7E, 0x00, 0xE7, 0x30, 0xC3, 0x30, 0xC3, 0x30, 0xC3, 0x38, 0xC3, 0x1C, 0xC3, 0x0E, 0xE7, 0x07, 0xFE, 0x03, 0xFC, 0x00, // Code for char 9
|
||||
0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x70, 0x1C, 0x70, 0x1C, 0x70, 0x1C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char :
|
||||
0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x70, 0x9C, 0x70, 0xFC, 0x70, 0x7C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char ;
|
||||
0x09, 0x00, 0x00, 0xC0, 0x00, 0xE0, 0x01, 0xF0, 0x03, 0x38, 0x07, 0x1C, 0x0E, 0x0E, 0x1C, 0x07, 0x38, 0x03, 0x30, 0x00, 0x00, 0x00, 0x00, // Code for char <
|
||||
0x0A, 0x00, 0x00, 0x60, 0x06, 0x60, 0x06, 0x60, 0x06, 0x60, 0x06, 0x60, 0x06, 0x60, 0x06, 0x60, 0x06, 0x60, 0x06, 0x60, 0x06, 0x00, 0x00, // Code for char =
|
||||
0x09, 0x00, 0x00, 0x03, 0x30, 0x07, 0x38, 0x0E, 0x1C, 0x1C, 0x0E, 0x38, 0x07, 0xF0, 0x03, 0xE0, 0x01, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char >
|
||||
0x0A, 0x1C, 0x00, 0x1E, 0x00, 0x07, 0x00, 0x03, 0x00, 0x83, 0x37, 0xC3, 0x37, 0xE3, 0x00, 0x77, 0x00, 0x3E, 0x00, 0x1C, 0x00, 0x00, 0x00, // Code for char ?
|
||||
0x0B, 0xF8, 0x0F, 0xFE, 0x1F, 0x07, 0x18, 0xF3, 0x33, 0xFB, 0x37, 0x1B, 0x36, 0xFB, 0x37, 0xFB, 0x37, 0x07, 0x36, 0xFE, 0x03, 0xF8, 0x01, // Code for char @
|
||||
0x0A, 0x00, 0x38, 0x00, 0x3F, 0xE0, 0x07, 0xFC, 0x06, 0x1F, 0x06, 0x1F, 0x06, 0xFC, 0x06, 0xE0, 0x07, 0x00, 0x3F, 0x00, 0x38, 0x00, 0x00, // Code for char A
|
||||
0x0A, 0xFF, 0x3F, 0xFF, 0x3F, 0xC3, 0x30, 0xC3, 0x30, 0xC3, 0x30, 0xC3, 0x30, 0xE7, 0x30, 0xFE, 0x39, 0xBC, 0x1F, 0x00, 0x0F, 0x00, 0x00, // Code for char B
|
||||
0x0A, 0xF0, 0x03, 0xFC, 0x0F, 0x0E, 0x1C, 0x07, 0x38, 0x03, 0x30, 0x03, 0x30, 0x03, 0x30, 0x07, 0x38, 0x0E, 0x1C, 0x0C, 0x0C, 0x00, 0x00, // Code for char C
|
||||
0x0A, 0xFF, 0x3F, 0xFF, 0x3F, 0x03, 0x30, 0x03, 0x30, 0x03, 0x30, 0x03, 0x30, 0x07, 0x38, 0x0E, 0x1C, 0xFC, 0x0F, 0xF0, 0x03, 0x00, 0x00, // Code for char D
|
||||
0x0A, 0xFF, 0x3F, 0xFF, 0x3F, 0xC3, 0x30, 0xC3, 0x30, 0xC3, 0x30, 0xC3, 0x30, 0xC3, 0x30, 0xC3, 0x30, 0x03, 0x30, 0x03, 0x30, 0x00, 0x00, // Code for char E
|
||||
0x0A, 0xFF, 0x3F, 0xFF, 0x3F, 0xC3, 0x00, 0xC3, 0x00, 0xC3, 0x00, 0xC3, 0x00, 0xC3, 0x00, 0xC3, 0x00, 0x03, 0x00, 0x03, 0x00, 0x00, 0x00, // Code for char F
|
||||
0x0A, 0xF0, 0x03, 0xFC, 0x0F, 0x0E, 0x1C, 0x07, 0x38, 0x03, 0x30, 0xC3, 0x30, 0xC3, 0x30, 0xC3, 0x30, 0xC7, 0x3F, 0xC6, 0x3F, 0x00, 0x00, // Code for char G
|
||||
0x0A, 0xFF, 0x3F, 0xFF, 0x3F, 0xC0, 0x00, 0xC0, 0x00, 0xC0, 0x00, 0xC0, 0x00, 0xC0, 0x00, 0xC0, 0x00, 0xFF, 0x3F, 0xFF, 0x3F, 0x00, 0x00, // Code for char H
|
||||
0x08, 0x00, 0x00, 0x00, 0x00, 0x03, 0x30, 0x03, 0x30, 0xFF, 0x3F, 0xFF, 0x3F, 0x03, 0x30, 0x03, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char I
|
||||
0x0A, 0x00, 0x0E, 0x00, 0x1E, 0x00, 0x38, 0x00, 0x30, 0x00, 0x30, 0x00, 0x30, 0x00, 0x30, 0x00, 0x38, 0xFF, 0x1F, 0xFF, 0x07, 0x00, 0x00, // Code for char J
|
||||
0x0A, 0xFF, 0x3F, 0xFF, 0x3F, 0xC0, 0x00, 0xE0, 0x01, 0xF0, 0x03, 0x38, 0x07, 0x1C, 0x0E, 0x0E, 0x1C, 0x07, 0x38, 0x03, 0x30, 0x00, 0x00, // Code for char K
|
||||
0x0A, 0xFF, 0x3F, 0xFF, 0x3F, 0x00, 0x30, 0x00, 0x30, 0x00, 0x30, 0x00, 0x30, 0x00, 0x30, 0x00, 0x30, 0x00, 0x30, 0x00, 0x30, 0x00, 0x00, // Code for char L
|
||||
0x0A, 0xFF, 0x3F, 0xFF, 0x3F, 0x1E, 0x00, 0x78, 0x00, 0xE0, 0x01, 0xE0, 0x01, 0x78, 0x00, 0x1E, 0x00, 0xFF, 0x3F, 0xFF, 0x3F, 0x00, 0x00, // Code for char M
|
||||
0x0A, 0xFF, 0x3F, 0xFF, 0x3F, 0x0E, 0x00, 0x38, 0x00, 0xF0, 0x00, 0xC0, 0x03, 0x00, 0x07, 0x00, 0x1C, 0xFF, 0x3F, 0xFF, 0x3F, 0x00, 0x00, // Code for char N
|
||||
0x0A, 0xF0, 0x03, 0xFC, 0x0F, 0x0E, 0x1C, 0x07, 0x38, 0x03, 0x30, 0x03, 0x30, 0x07, 0x38, 0x0E, 0x1C, 0xFC, 0x0F, 0xF0, 0x03, 0x00, 0x00, // Code for char O
|
||||
0x0A, 0xFF, 0x3F, 0xFF, 0x3F, 0x83, 0x01, 0x83, 0x01, 0x83, 0x01, 0x83, 0x01, 0x83, 0x01, 0xC7, 0x01, 0xFE, 0x00, 0x7C, 0x00, 0x00, 0x00, // Code for char P
|
||||
0x0A, 0xF0, 0x03, 0xFC, 0x0F, 0x0E, 0x1C, 0x07, 0x38, 0x03, 0x30, 0x03, 0x36, 0x07, 0x3E, 0x0E, 0x1C, 0xFC, 0x3F, 0xF0, 0x33, 0x00, 0x00, // Code for char Q
|
||||
0x0A, 0xFF, 0x3F, 0xFF, 0x3F, 0x83, 0x01, 0x83, 0x01, 0x83, 0x03, 0x83, 0x07, 0x83, 0x0F, 0xC7, 0x1D, 0xFE, 0x38, 0x7C, 0x30, 0x00, 0x00, // Code for char R
|
||||
0x0A, 0x3C, 0x0C, 0x7E, 0x1C, 0xE7, 0x38, 0xC3, 0x30, 0xC3, 0x30, 0xC3, 0x30, 0xC3, 0x30, 0xC7, 0x39, 0x8E, 0x1F, 0x0C, 0x0F, 0x00, 0x00, // Code for char S
|
||||
0x09, 0x00, 0x00, 0x03, 0x00, 0x03, 0x00, 0x03, 0x00, 0xFF, 0x3F, 0xFF, 0x3F, 0x03, 0x00, 0x03, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char T
|
||||
0x0A, 0xFF, 0x07, 0xFF, 0x1F, 0x00, 0x38, 0x00, 0x30, 0x00, 0x30, 0x00, 0x30, 0x00, 0x30, 0x00, 0x38, 0xFF, 0x1F, 0xFF, 0x07, 0x00, 0x00, // Code for char U
|
||||
0x0A, 0x07, 0x00, 0x3F, 0x00, 0xF8, 0x01, 0xC0, 0x0F, 0x00, 0x3E, 0x00, 0x3E, 0xC0, 0x0F, 0xF8, 0x01, 0x3F, 0x00, 0x07, 0x00, 0x00, 0x00, // Code for char V
|
||||
0x0A, 0xFF, 0x3F, 0xFF, 0x3F, 0x00, 0x1C, 0x00, 0x06, 0x80, 0x03, 0x80, 0x03, 0x00, 0x06, 0x00, 0x1C, 0xFF, 0x3F, 0xFF, 0x3F, 0x00, 0x00, // Code for char W
|
||||
0x0A, 0x03, 0x30, 0x0F, 0x3C, 0x1C, 0x0E, 0x30, 0x03, 0xE0, 0x01, 0xE0, 0x01, 0x30, 0x03, 0x1C, 0x0E, 0x0F, 0x3C, 0x03, 0x30, 0x00, 0x00, // Code for char X
|
||||
0x0A, 0x03, 0x00, 0x0F, 0x00, 0x3C, 0x00, 0xF0, 0x00, 0xC0, 0x3F, 0xC0, 0x3F, 0xF0, 0x00, 0x3C, 0x00, 0x0F, 0x00, 0x03, 0x00, 0x00, 0x00, // Code for char Y
|
||||
0x0A, 0x03, 0x30, 0x03, 0x3C, 0x03, 0x3E, 0x03, 0x33, 0xC3, 0x31, 0xE3, 0x30, 0x33, 0x30, 0x1F, 0x30, 0x0F, 0x30, 0x03, 0x30, 0x00, 0x00, // Code for char Z
|
||||
0x08, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x3F, 0xFF, 0x3F, 0x03, 0x30, 0x03, 0x30, 0x03, 0x30, 0x03, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char [
|
||||
0x0B, 0x0E, 0x00, 0x1C, 0x00, 0x38, 0x00, 0x70, 0x00, 0xE0, 0x00, 0xC0, 0x01, 0x80, 0x03, 0x00, 0x07, 0x00, 0x0E, 0x00, 0x1C, 0x00, 0x18, // Code for char BackSlash
|
||||
0x08, 0x00, 0x00, 0x00, 0x00, 0x03, 0x30, 0x03, 0x30, 0x03, 0x30, 0x03, 0x30, 0xFF, 0x3F, 0xFF, 0x3F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char ]
|
||||
0x0B, 0x60, 0x00, 0x70, 0x00, 0x38, 0x00, 0x1C, 0x00, 0x0E, 0x00, 0x07, 0x00, 0x0E, 0x00, 0x1C, 0x00, 0x38, 0x00, 0x70, 0x00, 0x60, 0x00, // Code for char ^
|
||||
0x0B, 0x00, 0xC0, 0x00, 0xC0, 0x00, 0xC0, 0x00, 0xC0, 0x00, 0xC0, 0x00, 0xC0, 0x00, 0xC0, 0x00, 0xC0, 0x00, 0xC0, 0x00, 0xC0, 0x00, 0xC0, // Code for char _
|
||||
0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3E, 0x00, 0x7E, 0x00, 0x4E, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char `
|
||||
0x0A, 0x00, 0x1C, 0x40, 0x3E, 0x60, 0x33, 0x60, 0x33, 0x60, 0x33, 0x60, 0x33, 0x60, 0x33, 0x60, 0x33, 0xE0, 0x3F, 0xC0, 0x3F, 0x00, 0x00, // Code for char a
|
||||
0x0A, 0xFF, 0x3F, 0xFF, 0x3F, 0xC0, 0x30, 0x60, 0x30, 0x60, 0x30, 0x60, 0x30, 0x60, 0x30, 0xE0, 0x38, 0xC0, 0x1F, 0x80, 0x0F, 0x00, 0x00, // Code for char b
|
||||
0x0A, 0x80, 0x0F, 0xC0, 0x1F, 0xE0, 0x38, 0x60, 0x30, 0x60, 0x30, 0x60, 0x30, 0x60, 0x30, 0x60, 0x30, 0xC0, 0x18, 0x80, 0x08, 0x00, 0x00, // Code for char c
|
||||
0x0A, 0x80, 0x0F, 0xC0, 0x1F, 0xE0, 0x38, 0x60, 0x30, 0x60, 0x30, 0x60, 0x30, 0xE0, 0x30, 0xC0, 0x30, 0xFF, 0x3F, 0xFF, 0x3F, 0x00, 0x00, // Code for char d
|
||||
0x0A, 0x80, 0x0F, 0xC0, 0x1F, 0xE0, 0x3B, 0x60, 0x33, 0x60, 0x33, 0x60, 0x33, 0x60, 0x33, 0x60, 0x33, 0xC0, 0x13, 0x80, 0x01, 0x00, 0x00, // Code for char e
|
||||
0x08, 0xC0, 0x00, 0xC0, 0x00, 0xFC, 0x3F, 0xFE, 0x3F, 0xC7, 0x00, 0xC3, 0x00, 0xC3, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char f
|
||||
0x0A, 0x80, 0x03, 0xC0, 0xC7, 0xE0, 0xCE, 0x60, 0xCC, 0x60, 0xCC, 0x60, 0xCC, 0x60, 0xCC, 0x60, 0xE6, 0xE0, 0x7F, 0xE0, 0x3F, 0x00, 0x00, // Code for char g
|
||||
0x09, 0xFF, 0x3F, 0xFF, 0x3F, 0xC0, 0x00, 0x60, 0x00, 0x60, 0x00, 0x60, 0x00, 0xE0, 0x00, 0xC0, 0x3F, 0x80, 0x3F, 0x00, 0x00, 0x00, 0x00, // Code for char h
|
||||
0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x60, 0x30, 0xEC, 0x3F, 0xEC, 0x3F, 0x00, 0x30, 0x00, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char i
|
||||
0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x60, 0x00, 0xE0, 0x00, 0xC0, 0x60, 0xC0, 0xEC, 0xFF, 0xEC, 0x7F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char j
|
||||
0x09, 0x00, 0x00, 0xFF, 0x3F, 0xFF, 0x3F, 0x00, 0x03, 0x80, 0x07, 0xC0, 0x0F, 0xE0, 0x1C, 0x60, 0x38, 0x00, 0x30, 0x00, 0x00, 0x00, 0x00, // Code for char k
|
||||
0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x03, 0x30, 0xFF, 0x3F, 0xFF, 0x3F, 0x00, 0x30, 0x00, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char l
|
||||
0x0A, 0xE0, 0x3F, 0xC0, 0x3F, 0xE0, 0x00, 0xE0, 0x00, 0xC0, 0x3F, 0xC0, 0x3F, 0xE0, 0x00, 0xE0, 0x00, 0xC0, 0x3F, 0x80, 0x3F, 0x00, 0x00, // Code for char m
|
||||
0x0A, 0x00, 0x00, 0xE0, 0x3F, 0xE0, 0x3F, 0x60, 0x00, 0x60, 0x00, 0x60, 0x00, 0x60, 0x00, 0xE0, 0x00, 0xC0, 0x3F, 0x80, 0x3F, 0x00, 0x00, // Code for char n
|
||||
0x0A, 0x80, 0x0F, 0xC0, 0x1F, 0xE0, 0x38, 0x60, 0x30, 0x60, 0x30, 0x60, 0x30, 0x60, 0x30, 0xE0, 0x38, 0xC0, 0x1F, 0x80, 0x0F, 0x00, 0x00, // Code for char o
|
||||
0x0A, 0xE0, 0xFF, 0xE0, 0xFF, 0x60, 0x0C, 0x60, 0x18, 0x60, 0x18, 0x60, 0x18, 0x60, 0x18, 0xE0, 0x1C, 0xC0, 0x0F, 0x80, 0x07, 0x00, 0x00, // Code for char p
|
||||
0x0A, 0x80, 0x07, 0xC0, 0x0F, 0xE0, 0x1C, 0x60, 0x18, 0x60, 0x18, 0x60, 0x18, 0x60, 0x18, 0x60, 0x0C, 0xE0, 0xFF, 0xE0, 0xFF, 0x00, 0x00, // Code for char q
|
||||
0x0A, 0x00, 0x00, 0xE0, 0x3F, 0xE0, 0x3F, 0xC0, 0x00, 0x60, 0x00, 0x60, 0x00, 0x60, 0x00, 0x60, 0x00, 0xE0, 0x00, 0xC0, 0x00, 0x00, 0x00, // Code for char r
|
||||
0x08, 0xC0, 0x11, 0xE0, 0x33, 0x60, 0x33, 0x60, 0x33, 0x60, 0x33, 0x60, 0x33, 0x60, 0x3F, 0x40, 0x1E, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char s
|
||||
0x08, 0x60, 0x00, 0x60, 0x00, 0xFE, 0x1F, 0xFE, 0x3F, 0x60, 0x30, 0x60, 0x30, 0x60, 0x30, 0x00, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char t
|
||||
0x0A, 0xE0, 0x0F, 0xE0, 0x1F, 0x00, 0x38, 0x00, 0x30, 0x00, 0x30, 0x00, 0x30, 0x00, 0x30, 0x00, 0x18, 0xE0, 0x3F, 0xE0, 0x3F, 0x00, 0x00, // Code for char u
|
||||
0x0A, 0x60, 0x00, 0xE0, 0x01, 0x80, 0x07, 0x00, 0x1E, 0x00, 0x38, 0x00, 0x38, 0x00, 0x1E, 0x80, 0x07, 0xE0, 0x01, 0x60, 0x00, 0x00, 0x00, // Code for char v
|
||||
0x0A, 0xE0, 0x07, 0xE0, 0x1F, 0x00, 0x38, 0x00, 0x1C, 0xE0, 0x0F, 0xE0, 0x0F, 0x00, 0x1C, 0x00, 0x38, 0xE0, 0x1F, 0xE0, 0x07, 0x00, 0x00, // Code for char w
|
||||
0x09, 0x60, 0x30, 0xE0, 0x38, 0xC0, 0x1D, 0x80, 0x0F, 0x00, 0x07, 0x80, 0x0F, 0xC0, 0x1D, 0xE0, 0x38, 0x60, 0x30, 0x00, 0x00, 0x00, 0x00, // Code for char x
|
||||
0x09, 0x00, 0x00, 0x60, 0x00, 0xE0, 0x81, 0x80, 0xE7, 0x00, 0x7E, 0x00, 0x1E, 0x80, 0x07, 0xE0, 0x01, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char y
|
||||
0x09, 0x60, 0x30, 0x60, 0x38, 0x60, 0x3C, 0x60, 0x36, 0x60, 0x33, 0xE0, 0x31, 0xE0, 0x30, 0x60, 0x30, 0x20, 0x30, 0x00, 0x00, 0x00, 0x00, // Code for char z
|
||||
0x09, 0x00, 0x00, 0x80, 0x00, 0xC0, 0x01, 0xFC, 0x1F, 0x7E, 0x3F, 0x07, 0x70, 0x03, 0x60, 0x03, 0x60, 0x03, 0x60, 0x00, 0x00, 0x00, 0x00, // Code for char {
|
||||
0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x3F, 0xFF, 0x3F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char |
|
||||
0x09, 0x00, 0x00, 0x03, 0x60, 0x03, 0x60, 0x03, 0x60, 0x07, 0x70, 0x7E, 0x3F, 0xFC, 0x1F, 0xC0, 0x01, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char }
|
||||
0x0A, 0x10, 0x00, 0x18, 0x00, 0x0C, 0x00, 0x04, 0x00, 0x0C, 0x00, 0x18, 0x00, 0x10, 0x00, 0x18, 0x00, 0x0C, 0x00, 0x04, 0x00, 0x00, 0x00, // Code for char ~
|
||||
0x0A, 0x00, 0x0F, 0x80, 0x0F, 0xC0, 0x0C, 0x60, 0x0C, 0x30, 0x0C, 0x30, 0x0C, 0x60, 0x0C, 0xC0, 0x0C, 0x80, 0x0F, 0x00, 0x0F, 0x00, 0x00 // Code for char
|
||||
};
|
||||
|
||||
|
||||
//Font Generated by MikroElektronika GLCD Font Creator 1.2.0.0
|
||||
//MikroElektronika 2011
|
||||
//http://www.mikroe.com
|
||||
|
||||
//GLCD FontName : Terminal12x16
|
||||
//GLCD FontSize : 12 x 16
|
||||
|
||||
fontdatatype Terminal12x16[] PROGMEM = {
|
||||
0x0C, 0x10, 0x20, 0x60,
|
||||
0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char
|
||||
0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7C, 0x00, 0xFF, 0x33, 0xFF, 0x33, 0xFF, 0x33, 0x7C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char !
|
||||
0x09, 0x00, 0x00, 0x00, 0x00, 0x3C, 0x00, 0x3C, 0x00, 0x3C, 0x00, 0x00, 0x00, 0x3C, 0x00, 0x3C, 0x00, 0x3C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char "
|
||||
0x0C, 0x00, 0x02, 0x10, 0x1E, 0x90, 0x1F, 0xF0, 0x1F, 0xFE, 0x03, 0x7E, 0x1E, 0x9E, 0x1F, 0xF0, 0x1F, 0xFE, 0x03, 0x7E, 0x02, 0x1E, 0x00, 0x10, 0x00, // Code for char #
|
||||
0x0A, 0x00, 0x00, 0x78, 0x04, 0xFC, 0x0C, 0xFC, 0x0C, 0xFF, 0x3F, 0xFF, 0x3F, 0xFF, 0x3F, 0xCC, 0x0F, 0xCC, 0x0F, 0x88, 0x07, 0x00, 0x00, 0x00, 0x00, // Code for char $
|
||||
0x0C, 0x00, 0x30, 0x38, 0x38, 0x38, 0x3C, 0x38, 0x1E, 0x38, 0x0F, 0x80, 0x07, 0xC0, 0x03, 0xE0, 0x39, 0xF0, 0x38, 0x78, 0x38, 0x3C, 0x38, 0x1C, 0x00, // Code for char %
|
||||
0x0B, 0x00, 0x00, 0x00, 0x1F, 0xB8, 0x3F, 0xFC, 0x3F, 0xFE, 0x31, 0xE6, 0x37, 0xFE, 0x3F, 0x3E, 0x1E, 0x1C, 0x3E, 0x00, 0x36, 0x00, 0x22, 0x00, 0x00, // Code for char &
|
||||
0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x27, 0x00, 0x3F, 0x00, 0x3F, 0x00, 0x1F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char '
|
||||
0x09, 0x00, 0x00, 0x00, 0x00, 0xF0, 0x03, 0xFC, 0x0F, 0xFE, 0x1F, 0xFF, 0x3F, 0x07, 0x38, 0x01, 0x20, 0x01, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char (
|
||||
0x09, 0x00, 0x00, 0x00, 0x00, 0x01, 0x20, 0x01, 0x20, 0x07, 0x38, 0xFF, 0x3F, 0xFE, 0x1F, 0xFC, 0x0F, 0xF0, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char )
|
||||
0x0A, 0x00, 0x00, 0x98, 0x0C, 0xB8, 0x0E, 0xF8, 0x0F, 0xF8, 0x0F, 0xF8, 0x0F, 0xF8, 0x0F, 0xF8, 0x0F, 0xB8, 0x0E, 0x98, 0x0C, 0x00, 0x00, 0x00, 0x00, // Code for char *
|
||||
0x0A, 0x00, 0x00, 0x80, 0x01, 0x80, 0x01, 0x80, 0x01, 0xF0, 0x0F, 0xF0, 0x0F, 0xF0, 0x0F, 0x80, 0x01, 0x80, 0x01, 0x80, 0x01, 0x00, 0x00, 0x00, 0x00, // Code for char +
|
||||
0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xB8, 0x00, 0xF8, 0x00, 0xF8, 0x00, 0x78, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char ,
|
||||
0x0A, 0x00, 0x00, 0x80, 0x01, 0x80, 0x01, 0x80, 0x01, 0x80, 0x01, 0x80, 0x01, 0x80, 0x01, 0x80, 0x01, 0x80, 0x01, 0x80, 0x01, 0x00, 0x00, 0x00, 0x00, // Code for char -
|
||||
0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x38, 0x00, 0x38, 0x00, 0x38, 0x00, 0x38, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char .
|
||||
0x0C, 0x00, 0x18, 0x00, 0x1C, 0x00, 0x1E, 0x00, 0x0F, 0x80, 0x07, 0xC0, 0x03, 0xE0, 0x01, 0xF0, 0x00, 0x78, 0x00, 0x3C, 0x00, 0x1E, 0x00, 0x0E, 0x00, // Code for char /
|
||||
0x0C, 0xF8, 0x07, 0xFE, 0x1F, 0xFE, 0x1F, 0x07, 0x3F, 0x83, 0x33, 0xC3, 0x31, 0xE3, 0x30, 0x73, 0x30, 0x3F, 0x38, 0xFE, 0x1F, 0xFE, 0x1F, 0xF8, 0x07, // Code for char 0
|
||||
0x0B, 0x00, 0x00, 0x00, 0x00, 0x0C, 0x30, 0x0C, 0x30, 0x0E, 0x30, 0xFF, 0x3F, 0xFF, 0x3F, 0xFF, 0x3F, 0x00, 0x30, 0x00, 0x30, 0x00, 0x30, 0x00, 0x00, // Code for char 1
|
||||
0x0C, 0x1C, 0x30, 0x1E, 0x38, 0x1F, 0x3C, 0x07, 0x3E, 0x03, 0x3F, 0x83, 0x37, 0xC3, 0x33, 0xE3, 0x31, 0xF7, 0x30, 0x7F, 0x30, 0x3E, 0x30, 0x1C, 0x30, // Code for char 2
|
||||
0x0C, 0x0C, 0x0C, 0x0E, 0x1C, 0x0F, 0x3C, 0xC7, 0x38, 0xC3, 0x30, 0xC3, 0x30, 0xC3, 0x30, 0xC3, 0x30, 0xE7, 0x39, 0xFF, 0x3F, 0x7E, 0x1F, 0x3C, 0x0E, // Code for char 3
|
||||
0x0C, 0xC0, 0x03, 0xE0, 0x03, 0xF0, 0x03, 0x78, 0x03, 0x3C, 0x03, 0x1E, 0x03, 0x0F, 0x03, 0xFF, 0x3F, 0xFF, 0x3F, 0xFF, 0x3F, 0x00, 0x03, 0x00, 0x03, // Code for char 4
|
||||
0x0C, 0x3F, 0x0C, 0x7F, 0x1C, 0x7F, 0x3C, 0x63, 0x38, 0x63, 0x30, 0x63, 0x30, 0x63, 0x30, 0x63, 0x30, 0xE3, 0x38, 0xE3, 0x3F, 0xC3, 0x1F, 0x83, 0x0F, // Code for char 5
|
||||
0x0C, 0xC0, 0x0F, 0xF0, 0x1F, 0xF8, 0x3F, 0xFC, 0x39, 0xDE, 0x30, 0xCF, 0x30, 0xC7, 0x30, 0xC3, 0x30, 0xC3, 0x39, 0xC3, 0x3F, 0x80, 0x1F, 0x00, 0x0F, // Code for char 6
|
||||
0x0C, 0x03, 0x00, 0x03, 0x00, 0x03, 0x00, 0x03, 0x30, 0x03, 0x3C, 0x03, 0x3F, 0xC3, 0x0F, 0xF3, 0x03, 0xFF, 0x00, 0x3F, 0x00, 0x0F, 0x00, 0x03, 0x00, // Code for char 7
|
||||
0x0C, 0x00, 0x0F, 0xBC, 0x1F, 0xFE, 0x3F, 0xFF, 0x39, 0xE7, 0x30, 0xC3, 0x30, 0xC3, 0x30, 0xE7, 0x30, 0xFF, 0x39, 0xFE, 0x3F, 0xBC, 0x1F, 0x00, 0x0F, // Code for char 8
|
||||
0x0C, 0x3C, 0x00, 0x7E, 0x00, 0xFF, 0x30, 0xE7, 0x30, 0xC3, 0x30, 0xC3, 0x38, 0xC3, 0x3C, 0xC3, 0x1E, 0xE7, 0x0F, 0xFF, 0x07, 0xFE, 0x03, 0xFC, 0x00, // Code for char 9
|
||||
0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x70, 0x1C, 0x70, 0x1C, 0x70, 0x1C, 0x70, 0x1C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char :
|
||||
0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x70, 0x9C, 0x70, 0xFC, 0x70, 0xFC, 0x70, 0x7C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char ;
|
||||
0x0A, 0x00, 0x00, 0xC0, 0x00, 0xE0, 0x01, 0xF0, 0x03, 0xF8, 0x07, 0x3C, 0x0F, 0x1E, 0x1E, 0x0F, 0x3C, 0x07, 0x38, 0x03, 0x30, 0x00, 0x00, 0x00, 0x00, // Code for char <
|
||||
0x0B, 0x00, 0x00, 0x60, 0x06, 0x60, 0x06, 0x60, 0x06, 0x60, 0x06, 0x60, 0x06, 0x60, 0x06, 0x60, 0x06, 0x60, 0x06, 0x60, 0x06, 0x60, 0x06, 0x00, 0x00, // Code for char =
|
||||
0x0A, 0x00, 0x00, 0x03, 0x30, 0x07, 0x38, 0x0F, 0x3C, 0x1E, 0x1E, 0x3C, 0x0F, 0xF8, 0x07, 0xF0, 0x03, 0xE0, 0x01, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char >
|
||||
0x0B, 0x1C, 0x00, 0x1E, 0x00, 0x1F, 0x00, 0x07, 0x00, 0x83, 0x37, 0xC3, 0x37, 0xE3, 0x37, 0xF7, 0x00, 0x7F, 0x00, 0x3E, 0x00, 0x1C, 0x00, 0x00, 0x00, // Code for char ?
|
||||
0x0C, 0xF8, 0x0F, 0xFE, 0x1F, 0xFF, 0x1F, 0xF7, 0x3B, 0xFB, 0x37, 0xFB, 0x37, 0xFB, 0x37, 0xFB, 0x37, 0xFF, 0x37, 0xFF, 0x37, 0xFE, 0x03, 0xF8, 0x01, // Code for char @
|
||||
0x0B, 0x00, 0x38, 0x00, 0x3F, 0xE0, 0x3F, 0xFC, 0x07, 0xFF, 0x06, 0x1F, 0x06, 0xFF, 0x06, 0xFC, 0x07, 0xE0, 0x3F, 0x00, 0x3F, 0x00, 0x38, 0x00, 0x00, // Code for char A
|
||||
0x0B, 0xFF, 0x3F, 0xFF, 0x3F, 0xFF, 0x3F, 0xC3, 0x30, 0xC3, 0x30, 0xC3, 0x30, 0xE7, 0x30, 0xFF, 0x39, 0xFE, 0x3F, 0xBC, 0x1F, 0x00, 0x0F, 0x00, 0x00, // Code for char B
|
||||
0x0B, 0xF0, 0x03, 0xFC, 0x0F, 0xFE, 0x1F, 0x0F, 0x3C, 0x07, 0x38, 0x03, 0x30, 0x03, 0x30, 0x07, 0x38, 0x0F, 0x3C, 0x0E, 0x1C, 0x0C, 0x0C, 0x00, 0x00, // Code for char C
|
||||
0x0B, 0xFF, 0x3F, 0xFF, 0x3F, 0xFF, 0x3F, 0x03, 0x30, 0x03, 0x30, 0x03, 0x30, 0x07, 0x38, 0x0F, 0x3C, 0xFE, 0x1F, 0xFC, 0x0F, 0xF0, 0x03, 0x00, 0x00, // Code for char D
|
||||
0x0B, 0xFF, 0x3F, 0xFF, 0x3F, 0xFF, 0x3F, 0xC3, 0x30, 0xC3, 0x30, 0xC3, 0x30, 0xC3, 0x30, 0xC3, 0x30, 0xC3, 0x30, 0x03, 0x30, 0x03, 0x30, 0x00, 0x00, // Code for char E
|
||||
0x0B, 0xFF, 0x3F, 0xFF, 0x3F, 0xFF, 0x3F, 0xC3, 0x00, 0xC3, 0x00, 0xC3, 0x00, 0xC3, 0x00, 0xC3, 0x00, 0xC3, 0x00, 0x03, 0x00, 0x03, 0x00, 0x00, 0x00, // Code for char F
|
||||
0x0B, 0xF0, 0x03, 0xFC, 0x0F, 0xFE, 0x1F, 0x0F, 0x3C, 0x07, 0x38, 0xC3, 0x30, 0xC3, 0x30, 0xC3, 0x30, 0xC7, 0x3F, 0xC7, 0x3F, 0xC6, 0x3F, 0x00, 0x00, // Code for char G
|
||||
0x0B, 0xFF, 0x3F, 0xFF, 0x3F, 0xFF, 0x3F, 0xC0, 0x00, 0xC0, 0x00, 0xC0, 0x00, 0xC0, 0x00, 0xC0, 0x00, 0xFF, 0x3F, 0xFF, 0x3F, 0xFF, 0x3F, 0x00, 0x00, // Code for char H
|
||||
0x09, 0x00, 0x00, 0x00, 0x00, 0x03, 0x30, 0x03, 0x30, 0xFF, 0x3F, 0xFF, 0x3F, 0xFF, 0x3F, 0x03, 0x30, 0x03, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char I
|
||||
0x0B, 0x00, 0x0E, 0x00, 0x1E, 0x00, 0x3E, 0x00, 0x38, 0x00, 0x30, 0x00, 0x30, 0x00, 0x30, 0x00, 0x38, 0xFF, 0x3F, 0xFF, 0x1F, 0xFF, 0x07, 0x00, 0x00, // Code for char J
|
||||
0x0B, 0xFF, 0x3F, 0xFF, 0x3F, 0xFF, 0x3F, 0xE0, 0x01, 0xF0, 0x03, 0xF8, 0x07, 0x3C, 0x0F, 0x1E, 0x1E, 0x0F, 0x3C, 0x07, 0x38, 0x03, 0x30, 0x00, 0x00, // Code for char K
|
||||
0x0B, 0xFF, 0x3F, 0xFF, 0x3F, 0xFF, 0x3F, 0x00, 0x30, 0x00, 0x30, 0x00, 0x30, 0x00, 0x30, 0x00, 0x30, 0x00, 0x30, 0x00, 0x30, 0x00, 0x30, 0x00, 0x00, // Code for char L
|
||||
0x0B, 0xFF, 0x3F, 0xFF, 0x3F, 0xFF, 0x3F, 0x7E, 0x00, 0xF8, 0x01, 0xE0, 0x01, 0xF8, 0x01, 0x7E, 0x00, 0xFF, 0x3F, 0xFF, 0x3F, 0xFF, 0x3F, 0x00, 0x00, // Code for char M
|
||||
0x0B, 0xFF, 0x3F, 0xFF, 0x3F, 0xFF, 0x3F, 0x3E, 0x00, 0xF8, 0x00, 0xF0, 0x03, 0xC0, 0x07, 0x00, 0x1F, 0xFF, 0x3F, 0xFF, 0x3F, 0xFF, 0x3F, 0x00, 0x00, // Code for char N
|
||||
0x0B, 0xF0, 0x03, 0xFC, 0x0F, 0xFE, 0x1F, 0x0F, 0x3C, 0x07, 0x38, 0x03, 0x30, 0x07, 0x38, 0x0F, 0x3C, 0xFE, 0x1F, 0xFC, 0x0F, 0xF0, 0x03, 0x00, 0x00, // Code for char O
|
||||
0x0B, 0xFF, 0x3F, 0xFF, 0x3F, 0xFF, 0x3F, 0x83, 0x01, 0x83, 0x01, 0x83, 0x01, 0x83, 0x01, 0xC7, 0x01, 0xFF, 0x01, 0xFE, 0x00, 0x7C, 0x00, 0x00, 0x00, // Code for char P
|
||||
0x0B, 0xF0, 0x03, 0xFC, 0x0F, 0xFE, 0x1F, 0x0F, 0x3C, 0x07, 0x38, 0x03, 0x36, 0x07, 0x3E, 0x0F, 0x3E, 0xFE, 0x3F, 0xFC, 0x3F, 0xF0, 0x33, 0x00, 0x00, // Code for char Q
|
||||
0x0B, 0xFF, 0x3F, 0xFF, 0x3F, 0xFF, 0x3F, 0x83, 0x01, 0x83, 0x03, 0x83, 0x07, 0x83, 0x0F, 0xC7, 0x1F, 0xFF, 0x3D, 0xFE, 0x38, 0x7C, 0x30, 0x00, 0x00, // Code for char R
|
||||
0x0B, 0x3C, 0x0C, 0x7E, 0x1C, 0xFF, 0x3C, 0xE7, 0x38, 0xC3, 0x30, 0xC3, 0x30, 0xC3, 0x30, 0xC7, 0x39, 0xCF, 0x3F, 0x8E, 0x1F, 0x0C, 0x0F, 0x00, 0x00, // Code for char S
|
||||
0x0A, 0x00, 0x00, 0x03, 0x00, 0x03, 0x00, 0x03, 0x00, 0xFF, 0x3F, 0xFF, 0x3F, 0xFF, 0x3F, 0x03, 0x00, 0x03, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char T
|
||||
0x0B, 0xFF, 0x07, 0xFF, 0x1F, 0xFF, 0x3F, 0x00, 0x38, 0x00, 0x30, 0x00, 0x30, 0x00, 0x30, 0x00, 0x38, 0xFF, 0x3F, 0xFF, 0x1F, 0xFF, 0x07, 0x00, 0x00, // Code for char U
|
||||
0x0B, 0x07, 0x00, 0x3F, 0x00, 0xFF, 0x01, 0xF8, 0x0F, 0xC0, 0x3F, 0x00, 0x3E, 0xC0, 0x3F, 0xF8, 0x0F, 0xFF, 0x01, 0x3F, 0x00, 0x07, 0x00, 0x00, 0x00, // Code for char V
|
||||
0x0B, 0xFF, 0x3F, 0xFF, 0x3F, 0xFF, 0x3F, 0x00, 0x1E, 0x80, 0x07, 0x80, 0x03, 0x80, 0x07, 0x00, 0x1E, 0xFF, 0x3F, 0xFF, 0x3F, 0xFF, 0x3F, 0x00, 0x00, // Code for char W
|
||||
0x0B, 0x03, 0x30, 0x0F, 0x3C, 0x1F, 0x3E, 0x3C, 0x0F, 0xF0, 0x03, 0xE0, 0x01, 0xF0, 0x03, 0x3C, 0x0F, 0x1F, 0x3E, 0x0F, 0x3C, 0x03, 0x30, 0x00, 0x00, // Code for char X
|
||||
0x0B, 0x03, 0x00, 0x0F, 0x00, 0x3F, 0x00, 0xFC, 0x00, 0xF0, 0x3F, 0xC0, 0x3F, 0xF0, 0x3F, 0xFC, 0x00, 0x3F, 0x00, 0x0F, 0x00, 0x03, 0x00, 0x00, 0x00, // Code for char Y
|
||||
0x0B, 0x03, 0x30, 0x03, 0x3C, 0x03, 0x3E, 0x03, 0x3F, 0xC3, 0x33, 0xE3, 0x31, 0xF3, 0x30, 0x3F, 0x30, 0x1F, 0x30, 0x0F, 0x30, 0x03, 0x30, 0x00, 0x00, // Code for char Z
|
||||
0x09, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x3F, 0xFF, 0x3F, 0xFF, 0x3F, 0x03, 0x30, 0x03, 0x30, 0x03, 0x30, 0x03, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char [
|
||||
0x0C, 0x0E, 0x00, 0x1E, 0x00, 0x3C, 0x00, 0x78, 0x00, 0xF0, 0x00, 0xE0, 0x01, 0xC0, 0x03, 0x80, 0x07, 0x00, 0x0F, 0x00, 0x1E, 0x00, 0x1C, 0x00, 0x18, // Code for char BackSlash
|
||||
0x09, 0x00, 0x00, 0x00, 0x00, 0x03, 0x30, 0x03, 0x30, 0x03, 0x30, 0x03, 0x30, 0xFF, 0x3F, 0xFF, 0x3F, 0xFF, 0x3F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char ]
|
||||
0x0C, 0x60, 0x00, 0x70, 0x00, 0x78, 0x00, 0x3C, 0x00, 0x1E, 0x00, 0x0F, 0x00, 0x0F, 0x00, 0x1E, 0x00, 0x3C, 0x00, 0x78, 0x00, 0x70, 0x00, 0x60, 0x00, // Code for char ^
|
||||
0x0C, 0x00, 0xC0, 0x00, 0xC0, 0x00, 0xC0, 0x00, 0xC0, 0x00, 0xC0, 0x00, 0xC0, 0x00, 0xC0, 0x00, 0xC0, 0x00, 0xC0, 0x00, 0xC0, 0x00, 0xC0, 0x00, 0xC0, // Code for char _
|
||||
0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3E, 0x00, 0x7E, 0x00, 0x7E, 0x00, 0x4E, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char `
|
||||
0x0B, 0x00, 0x1C, 0x40, 0x3E, 0x60, 0x3F, 0x60, 0x33, 0x60, 0x33, 0x60, 0x33, 0x60, 0x33, 0x60, 0x33, 0xE0, 0x3F, 0xE0, 0x3F, 0xC0, 0x3F, 0x00, 0x00, // Code for char a
|
||||
0x0B, 0xFF, 0x3F, 0xFF, 0x3F, 0xFF, 0x3F, 0xE0, 0x30, 0x60, 0x30, 0x60, 0x30, 0x60, 0x30, 0xE0, 0x38, 0xE0, 0x3F, 0xC0, 0x1F, 0x80, 0x0F, 0x00, 0x00, // Code for char b
|
||||
0x0B, 0x80, 0x0F, 0xC0, 0x1F, 0xE0, 0x3F, 0xE0, 0x38, 0x60, 0x30, 0x60, 0x30, 0x60, 0x30, 0x60, 0x30, 0xE0, 0x38, 0xC0, 0x18, 0x80, 0x08, 0x00, 0x00, // Code for char c
|
||||
0x0B, 0x80, 0x0F, 0xC0, 0x1F, 0xE0, 0x3F, 0xE0, 0x38, 0x60, 0x30, 0x60, 0x30, 0xE0, 0x30, 0xE0, 0x30, 0xFF, 0x3F, 0xFF, 0x3F, 0xFF, 0x3F, 0x00, 0x00, // Code for char d
|
||||
0x0B, 0x80, 0x0F, 0xC0, 0x1F, 0xE0, 0x3F, 0xE0, 0x3B, 0x60, 0x33, 0x60, 0x33, 0x60, 0x33, 0x60, 0x33, 0xE0, 0x33, 0xC0, 0x13, 0x80, 0x01, 0x00, 0x00, // Code for char e
|
||||
0x09, 0xC0, 0x00, 0xC0, 0x00, 0xFC, 0x3F, 0xFE, 0x3F, 0xFF, 0x3F, 0xC7, 0x00, 0xC3, 0x00, 0xC3, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char f
|
||||
0x0B, 0x80, 0x03, 0xC0, 0xC7, 0xE0, 0xCF, 0xE0, 0xCE, 0x60, 0xCC, 0x60, 0xCC, 0x60, 0xCC, 0x60, 0xEE, 0xE0, 0xFF, 0xE0, 0x7F, 0xE0, 0x3F, 0x00, 0x00, // Code for char g
|
||||
0x0A, 0xFF, 0x3F, 0xFF, 0x3F, 0xFF, 0x3F, 0xE0, 0x00, 0x60, 0x00, 0x60, 0x00, 0xE0, 0x00, 0xE0, 0x3F, 0xC0, 0x3F, 0x80, 0x3F, 0x00, 0x00, 0x00, 0x00, // Code for char h
|
||||
0x09, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x60, 0x30, 0xEC, 0x3F, 0xEC, 0x3F, 0xEC, 0x3F, 0x00, 0x30, 0x00, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char i
|
||||
0x09, 0x00, 0x00, 0x00, 0x00, 0x00, 0x60, 0x00, 0xE0, 0x00, 0xE0, 0x60, 0xC0, 0xEC, 0xFF, 0xEC, 0xFF, 0xEC, 0x7F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char j
|
||||
0x0A, 0x00, 0x00, 0xFF, 0x3F, 0xFF, 0x3F, 0xFF, 0x3F, 0x80, 0x07, 0xC0, 0x0F, 0xE0, 0x1F, 0xE0, 0x3C, 0x60, 0x38, 0x00, 0x30, 0x00, 0x00, 0x00, 0x00, // Code for char k
|
||||
0x09, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x03, 0x30, 0xFF, 0x3F, 0xFF, 0x3F, 0xFF, 0x3F, 0x00, 0x30, 0x00, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char l
|
||||
0x0B, 0xE0, 0x3F, 0xE0, 0x3F, 0xE0, 0x3F, 0xE0, 0x00, 0xE0, 0x3F, 0xC0, 0x3F, 0xE0, 0x3F, 0xE0, 0x00, 0xE0, 0x3F, 0xC0, 0x3F, 0x80, 0x3F, 0x00, 0x00, // Code for char m
|
||||
0x0B, 0x00, 0x00, 0xE0, 0x3F, 0xE0, 0x3F, 0xE0, 0x3F, 0x60, 0x00, 0x60, 0x00, 0x60, 0x00, 0xE0, 0x00, 0xE0, 0x3F, 0xC0, 0x3F, 0x80, 0x3F, 0x00, 0x00, // Code for char n
|
||||
0x0B, 0x80, 0x0F, 0xC0, 0x1F, 0xE0, 0x3F, 0xE0, 0x38, 0x60, 0x30, 0x60, 0x30, 0x60, 0x30, 0xE0, 0x38, 0xE0, 0x3F, 0xC0, 0x1F, 0x80, 0x0F, 0x00, 0x00, // Code for char o
|
||||
0x0B, 0xE0, 0xFF, 0xE0, 0xFF, 0xE0, 0xFF, 0x60, 0x1C, 0x60, 0x18, 0x60, 0x18, 0x60, 0x18, 0xE0, 0x1C, 0xE0, 0x1F, 0xC0, 0x0F, 0x80, 0x07, 0x00, 0x00, // Code for char p
|
||||
0x0B, 0x80, 0x07, 0xC0, 0x0F, 0xE0, 0x1F, 0xE0, 0x1C, 0x60, 0x18, 0x60, 0x18, 0x60, 0x18, 0x60, 0x1C, 0xE0, 0xFF, 0xE0, 0xFF, 0xE0, 0xFF, 0x00, 0x00, // Code for char q
|
||||
0x0B, 0x00, 0x00, 0xE0, 0x3F, 0xE0, 0x3F, 0xE0, 0x3F, 0xE0, 0x00, 0x60, 0x00, 0x60, 0x00, 0x60, 0x00, 0xE0, 0x00, 0xE0, 0x00, 0xC0, 0x00, 0x00, 0x00, // Code for char r
|
||||
0x09, 0xC0, 0x11, 0xE0, 0x33, 0xE0, 0x33, 0x60, 0x33, 0x60, 0x33, 0x60, 0x33, 0x60, 0x3F, 0x60, 0x3F, 0x40, 0x1E, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char s
|
||||
0x09, 0x60, 0x00, 0x60, 0x00, 0xFE, 0x1F, 0xFE, 0x3F, 0xFE, 0x3F, 0x60, 0x30, 0x60, 0x30, 0x60, 0x30, 0x00, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char t
|
||||
0x0B, 0xE0, 0x0F, 0xE0, 0x1F, 0xE0, 0x3F, 0x00, 0x38, 0x00, 0x30, 0x00, 0x30, 0x00, 0x30, 0x00, 0x38, 0xE0, 0x3F, 0xE0, 0x3F, 0xE0, 0x3F, 0x00, 0x00, // Code for char u
|
||||
0x0B, 0x60, 0x00, 0xE0, 0x01, 0xE0, 0x07, 0x80, 0x1F, 0x00, 0x3E, 0x00, 0x38, 0x00, 0x3E, 0x80, 0x1F, 0xE0, 0x07, 0xE0, 0x01, 0x60, 0x00, 0x00, 0x00, // Code for char v
|
||||
0x0B, 0xE0, 0x07, 0xE0, 0x1F, 0xE0, 0x3F, 0x00, 0x3C, 0xE0, 0x1F, 0xE0, 0x0F, 0xE0, 0x1F, 0x00, 0x3C, 0xE0, 0x3F, 0xE0, 0x1F, 0xE0, 0x07, 0x00, 0x00, // Code for char w
|
||||
0x0A, 0x60, 0x30, 0xE0, 0x38, 0xE0, 0x3D, 0xC0, 0x1F, 0x80, 0x0F, 0x80, 0x0F, 0xC0, 0x1F, 0xE0, 0x3D, 0xE0, 0x38, 0x60, 0x30, 0x00, 0x00, 0x00, 0x00, // Code for char x
|
||||
0x0A, 0x00, 0x00, 0x60, 0x00, 0xE0, 0x81, 0xE0, 0xE7, 0x80, 0xFF, 0x00, 0x7E, 0x80, 0x1F, 0xE0, 0x07, 0xE0, 0x01, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char y
|
||||
0x0A, 0x60, 0x30, 0x60, 0x38, 0x60, 0x3C, 0x60, 0x3E, 0x60, 0x37, 0xE0, 0x33, 0xE0, 0x31, 0xE0, 0x30, 0x60, 0x30, 0x20, 0x30, 0x00, 0x00, 0x00, 0x00, // Code for char z
|
||||
0x0A, 0x00, 0x00, 0x80, 0x00, 0xC0, 0x01, 0xFC, 0x1F, 0xFE, 0x3F, 0x7F, 0x7F, 0x07, 0x70, 0x03, 0x60, 0x03, 0x60, 0x03, 0x60, 0x00, 0x00, 0x00, 0x00, // Code for char {
|
||||
0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x3F, 0xFF, 0x3F, 0xFF, 0x3F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char |
|
||||
0x0A, 0x00, 0x00, 0x03, 0x60, 0x03, 0x60, 0x03, 0x60, 0x07, 0x70, 0x7F, 0x7F, 0xFE, 0x3F, 0xFC, 0x1F, 0xC0, 0x01, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char }
|
||||
0x0B, 0x10, 0x00, 0x18, 0x00, 0x1C, 0x00, 0x0C, 0x00, 0x0C, 0x00, 0x1C, 0x00, 0x18, 0x00, 0x18, 0x00, 0x1C, 0x00, 0x0C, 0x00, 0x04, 0x00, 0x00, 0x00, // Code for char ~
|
||||
0x0B, 0x00, 0x0F, 0x80, 0x0F, 0xC0, 0x0F, 0xE0, 0x0C, 0x70, 0x0C, 0x30, 0x0C, 0x70, 0x0C, 0xE0, 0x0C, 0xC0, 0x0F, 0x80, 0x0F, 0x00, 0x0F, 0x00, 0x00 // Code for char
|
||||
};
|
||||
|
||||
|
||||
//Font Generated by MikroElektronika GLCD Font Creator 1.2.0.0
|
||||
//MikroElektronika 2011
|
||||
//http://www.mikroe.com
|
||||
|
||||
//GLCD FontName : Trebuchet_MS16x21
|
||||
//GLCD FontSize : 16 x 21
|
||||
|
||||
fontdatatype Trebuchet_MS16x21[] PROGMEM = {
|
||||
0x10, 0x15, 0x2E, 0x0D,
|
||||
0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0C, 0x00, 0x00, 0x1E, 0x00, 0x00, 0x1E, 0x00, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char .
|
||||
0x0C, 0x00, 0x00, 0x10, 0x00, 0x00, 0x1E, 0x00, 0xC0, 0x1F, 0x00, 0xF0, 0x1F, 0x00, 0xFE, 0x0F, 0x80, 0xFF, 0x03, 0xF0, 0x7F, 0x00, 0xFE, 0x0F, 0x00, 0xFF, 0x03, 0x00, 0x7F, 0x00, 0x00, 0x0F, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char /
|
||||
0x10, 0x00, 0x00, 0x00, 0xC0, 0x7F, 0x00, 0xF0, 0xFF, 0x03, 0xFC, 0xFF, 0x07, 0xFE, 0xFF, 0x0F, 0x3E, 0x80, 0x0F, 0x0F, 0x00, 0x1E, 0x07, 0x00, 0x1C, 0x07, 0x00, 0x1C, 0x07, 0x00, 0x1C, 0x0F, 0x00, 0x1E, 0x1F, 0x80, 0x0F, 0xFE, 0xFF, 0x0F, 0xFC, 0xFF, 0x07, 0xF8, 0xFF, 0x01, 0xC0, 0x7F, 0x00, // Code for char 0
|
||||
0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF0, 0x00, 0x00, 0x78, 0x00, 0x00, 0x38, 0x00, 0x00, 0x3C, 0x00, 0x00, 0xFE, 0xFF, 0x1F, 0xFE, 0xFF, 0x1F, 0xFF, 0xFF, 0x1F, 0xFF, 0xFF, 0x1F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char 1
|
||||
0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0C, 0x00, 0x18, 0x1E, 0x00, 0x1C, 0x0E, 0x00, 0x1F, 0x0F, 0x80, 0x1F, 0x07, 0xC0, 0x1F, 0x07, 0xF0, 0x1F, 0x07, 0xF8, 0x1D, 0x07, 0xFE, 0x1C, 0x0F, 0x3F, 0x1C, 0xFE, 0x1F, 0x1C, 0xFE, 0x0F, 0x1C, 0xFC, 0x03, 0x1C, 0xF8, 0x00, 0x1C, 0x00, 0x00, 0x1C, // Code for char 2
|
||||
0x0F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x04, 0x00, 0x0E, 0x0E, 0x00, 0x0F, 0x0F, 0x00, 0x1E, 0x07, 0x00, 0x1C, 0x07, 0x07, 0x1C, 0x07, 0x07, 0x1C, 0x07, 0x07, 0x1C, 0x8F, 0x0F, 0x1E, 0xFF, 0x1F, 0x1E, 0xFE, 0xFD, 0x0F, 0xFC, 0xFD, 0x0F, 0x78, 0xF8, 0x07, 0x00, 0xF0, 0x01, 0x00, 0x00, 0x00, // Code for char 3
|
||||
0x10, 0x00, 0x00, 0x00, 0x00, 0xE0, 0x00, 0x00, 0xF0, 0x00, 0x00, 0xF8, 0x00, 0x00, 0xFE, 0x00, 0x00, 0xEF, 0x00, 0x80, 0xE7, 0x00, 0xC0, 0xE3, 0x00, 0xF0, 0xE0, 0x00, 0x78, 0xE0, 0x00, 0xFC, 0xFF, 0x1F, 0xFE, 0xFF, 0x1F, 0xFF, 0xFF, 0x1F, 0xFF, 0xFF, 0x1F, 0x00, 0xE0, 0x00, 0x00, 0xE0, 0x00, // Code for char 4
|
||||
0x0F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0xFF, 0x03, 0x0F, 0xFF, 0x07, 0x0E, 0xFF, 0x03, 0x1C, 0xFF, 0x01, 0x1C, 0xC7, 0x01, 0x1C, 0xC7, 0x01, 0x1C, 0xC7, 0x01, 0x1E, 0xC7, 0x03, 0x1F, 0xC7, 0xFF, 0x0F, 0x87, 0xFF, 0x0F, 0x07, 0xFF, 0x07, 0x00, 0xFC, 0x01, 0x00, 0x00, 0x00, // Code for char 5
|
||||
0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFE, 0x00, 0x80, 0xFF, 0x03, 0xE0, 0xFF, 0x07, 0xF0, 0xFF, 0x0F, 0xF8, 0x0F, 0x1E, 0x7C, 0x07, 0x1C, 0x3E, 0x07, 0x1C, 0x1E, 0x07, 0x1C, 0x0F, 0x07, 0x1C, 0x07, 0x0F, 0x1E, 0x02, 0xFE, 0x0F, 0x00, 0xFE, 0x0F, 0x00, 0xFC, 0x07, 0x00, 0xF0, 0x01, // Code for char 6
|
||||
0x10, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x07, 0x00, 0x00, 0x07, 0x00, 0x18, 0x07, 0x00, 0x1E, 0x07, 0xC0, 0x1F, 0x07, 0xF0, 0x1F, 0x07, 0xFC, 0x0F, 0x07, 0xFF, 0x01, 0xC7, 0x7F, 0x00, 0xF7, 0x0F, 0x00, 0xFF, 0x03, 0x00, 0xFF, 0x00, 0x00, 0x3F, 0x00, 0x00, 0x0F, 0x00, 0x00, 0x03, 0x00, 0x00, // Code for char 7
|
||||
0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xE0, 0x03, 0x78, 0xF8, 0x07, 0xFC, 0xFD, 0x0F, 0xFE, 0xFF, 0x0F, 0xFF, 0x1F, 0x1E, 0x8F, 0x0F, 0x1C, 0x07, 0x07, 0x1C, 0x07, 0x0F, 0x1C, 0x8F, 0x0F, 0x1C, 0xFF, 0x3F, 0x1E, 0xFE, 0xFD, 0x0F, 0xFE, 0xFD, 0x0F, 0x78, 0xF0, 0x07, 0x00, 0xE0, 0x03, // Code for char 8
|
||||
0x0F, 0x00, 0x00, 0x00, 0xF0, 0x01, 0x00, 0xFC, 0x07, 0x00, 0xFE, 0x0F, 0x00, 0xFE, 0x0F, 0x08, 0x0F, 0x1E, 0x1C, 0x07, 0x1C, 0x1E, 0x07, 0x1C, 0x0F, 0x07, 0x9C, 0x0F, 0x07, 0xDC, 0x07, 0x0F, 0xFE, 0x03, 0xFE, 0xFF, 0x01, 0xFC, 0xFF, 0x00, 0xF8, 0x3F, 0x00, 0xE0, 0x0F, 0x00, 0x00, 0x00, 0x00, // Code for char 9
|
||||
0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x01, 0x0C, 0xC0, 0x03, 0x1E, 0xC0, 0x03, 0x1E, 0x80, 0x01, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 // Code for char :
|
||||
};
|
||||
|
||||
|
||||
|
||||
Executable
+1711
File diff suppressed because it is too large
Load Diff
Executable
+165
@@ -0,0 +1,165 @@
|
||||
#ifndef Display_h
|
||||
#define Display_h
|
||||
#define FONT_LARGE 1
|
||||
#define FONT_SMALL 0
|
||||
|
||||
#include <SPI.h>
|
||||
//#include <TFT22_ILI9225.h>
|
||||
#include "gfxfont.h"
|
||||
#include <U8x8lib.h>
|
||||
#include <SPIFFS.h>
|
||||
|
||||
|
||||
#define WIDTH_AUTO 9999
|
||||
struct DispEntry {
|
||||
int16_t y;
|
||||
int16_t x;
|
||||
int16_t fmt, width;
|
||||
uint16_t fg,bg;
|
||||
void (*func)(DispEntry *de);
|
||||
const char *extra;
|
||||
};
|
||||
|
||||
#define GPSUSE_BASE 1
|
||||
#define GPSUSE_DIST 2
|
||||
#define GPSUSE_BEARING 4
|
||||
struct DispInfo {
|
||||
DispEntry *de;
|
||||
uint8_t *actions;
|
||||
int16_t *timeouts;
|
||||
const char *label;
|
||||
uint8_t usegps;
|
||||
};
|
||||
|
||||
struct StatInfo {
|
||||
uint8_t len;
|
||||
uint8_t size;
|
||||
};
|
||||
|
||||
// Now starting towards supporting different Display types / libraries
|
||||
class RawDisplay {
|
||||
public:
|
||||
virtual void begin() = 0;
|
||||
virtual void clear() = 0;
|
||||
virtual void setFont(uint8_t fontindex) = 0;
|
||||
virtual void getDispSize(uint8_t *height, uint8_t *width, uint8_t *lineskip, uint8_t *colskip) = 0;
|
||||
virtual void drawString(uint8_t x, uint8_t y, const char *s, int16_t width=WIDTH_AUTO, uint16_t fg=0xffff, uint16_t bg=0 ) = 0;
|
||||
virtual void drawTile(uint8_t x, uint8_t y, uint8_t cnt, uint8_t *tile_ptr) = 0;
|
||||
virtual void drawTriangle(uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, uint16_t x3, uint16_t y3, uint16_t color, bool fill) = 0;
|
||||
virtual void drawBitmap(uint16_t x1, uint16_t y1, const uint16_t* bitmap, int16_t w, int16_t h) = 0;
|
||||
virtual void welcome() = 0;
|
||||
virtual void drawIP(uint8_t x, uint8_t y, int16_t width=WIDTH_AUTO, uint16_t fg=0xffff, uint16_t bg=0 ) = 0;
|
||||
virtual void drawQS(uint8_t x, uint8_t y, uint8_t len, uint8_t size, uint8_t *stat, uint16_t fg=0xffff, uint16_t bg=0) = 0;
|
||||
};
|
||||
|
||||
class U8x8Display : public RawDisplay {
|
||||
private:
|
||||
U8X8 *u8x8 = NULL; // initialize later after reading config file
|
||||
int _type;
|
||||
const uint8_t **fontlist;
|
||||
int nfonts;
|
||||
|
||||
public:
|
||||
U8x8Display(int type = 0) { _type = type; }
|
||||
void begin();
|
||||
void clear();
|
||||
void setFont(uint8_t fontindex);
|
||||
void getDispSize(uint8_t *height, uint8_t *width, uint8_t *lineskip, uint8_t *colskip);
|
||||
void drawString(uint8_t x, uint8_t y, const char *s, int16_t width=WIDTH_AUTO, uint16_t fg=0xffff, uint16_t bg=0);
|
||||
void drawTile(uint8_t x, uint8_t y, uint8_t cnt, uint8_t *tile_ptr);
|
||||
void drawTriangle(uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, uint16_t x3, uint16_t y3, uint16_t color, bool fill);
|
||||
void drawBitmap(uint16_t x1, uint16_t y1, const uint16_t* bitmap, int16_t w, int16_t h);
|
||||
void welcome();
|
||||
void drawIP(uint8_t x, uint8_t y, int16_t width=WIDTH_AUTO, uint16_t fg=0xffff, uint16_t bg=0);
|
||||
void drawQS(uint8_t x, uint8_t y, uint8_t len, uint8_t size, uint8_t *stat, uint16_t fg=0xffff, uint16_t bg=0);
|
||||
};
|
||||
|
||||
class Display {
|
||||
private:
|
||||
void replaceLayouts(DispInfo *newlayout, int nnew);
|
||||
int allocDispInfo(int entries, DispInfo *d, char *label);
|
||||
void parseDispElement(char *text, DispEntry *de);
|
||||
int xscale=13, yscale=22;
|
||||
int fontsma=0, fontlar=1;
|
||||
uint16_t colfg, colbg;
|
||||
static void circ(int x, int y);
|
||||
static int countEntries(File f);
|
||||
void calcGPS();
|
||||
void calcVbat();
|
||||
void calcDurVol();
|
||||
boolean gpsValid;
|
||||
float gpsLat, gpsLon;
|
||||
int gpsAlt;
|
||||
int gpsDist; // -1: invalid
|
||||
int gpsCourse, gpsDir, gpsBear; // 0..360; -1: invalid
|
||||
boolean gpsCourseOld;
|
||||
static const int LINEBUFLEN{ 255 };
|
||||
static char lineBuf[LINEBUFLEN];
|
||||
static const char *trim(char *s) {
|
||||
char *ret = s;
|
||||
while(*ret && isspace(*ret)) { ret++; }
|
||||
int lastidx;
|
||||
while(1) {
|
||||
lastidx = strlen(ret)-1;
|
||||
if(lastidx>=0 && isspace(ret[lastidx]))
|
||||
ret[lastidx] = 0;
|
||||
else
|
||||
break;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
public:
|
||||
void initFromFile();
|
||||
|
||||
int layoutIdx;
|
||||
DispInfo *layout;
|
||||
|
||||
DispInfo *layouts;
|
||||
int nLayouts;
|
||||
static RawDisplay *rdis;
|
||||
|
||||
Display();
|
||||
void init();
|
||||
static char buf[17];
|
||||
static void drawLat(DispEntry *de);
|
||||
static void drawLon(DispEntry *de);
|
||||
static void drawAz(DispEntry *de);
|
||||
static void drawVBat(DispEntry *de);
|
||||
static void drawDurVol(DispEntry *de);
|
||||
static void drawAlt(DispEntry *de);
|
||||
static void drawHS(DispEntry *de);
|
||||
static void drawVS(DispEntry *de);
|
||||
static void drawID(DispEntry *de);
|
||||
static void drawRSSI(DispEntry *de);
|
||||
static void drawQS(DispEntry *de);
|
||||
static void drawType(DispEntry *de);
|
||||
static void drawFreq(DispEntry *de);
|
||||
static void drawAFC(DispEntry *de);
|
||||
static void drawIP(DispEntry *de);
|
||||
static void drawSite(DispEntry *de);
|
||||
static void drawTelemetry(DispEntry *de);
|
||||
static void drawKilltimer(DispEntry *de);
|
||||
static void drawGPS(DispEntry *de);
|
||||
static void drawText(DispEntry *de);
|
||||
static void drawBatt(DispEntry *de);
|
||||
static void drawString(DispEntry *de, const char *str);
|
||||
void clearIP();
|
||||
void setIP(const char *ip, bool AP);
|
||||
void updateDisplayPos();
|
||||
void updateDisplayPos2();
|
||||
void updateDisplayAz();
|
||||
void updateDisplayVBat();
|
||||
void updateDisplayID();
|
||||
void updateDisplayRSSI();
|
||||
void updateStat();
|
||||
void updateDisplayRXConfig();
|
||||
void updateDisplayIP();
|
||||
void updateDisplay();
|
||||
void updateDisplayVBatt();
|
||||
|
||||
void setLayout(int layout);
|
||||
};
|
||||
|
||||
extern Display disp;
|
||||
|
||||
#endif
|
||||
Executable
+529
@@ -0,0 +1,529 @@
|
||||
|
||||
/* M10 decoder functions */
|
||||
#include "M10.h"
|
||||
#include "SX1278FSK.h"
|
||||
#include "rsc.h"
|
||||
#include "Sonde.h"
|
||||
#include <SPIFFS.h>
|
||||
|
||||
// well...
|
||||
//#include "rs92gps.h"
|
||||
|
||||
#define M10_DEBUG 1
|
||||
|
||||
#if M10_DEBUG
|
||||
#define M10_DBG(x) x
|
||||
#else
|
||||
#define M10_DBG(x)
|
||||
#endif
|
||||
|
||||
|
||||
static byte data1[512];
|
||||
static byte *dataptr=data1;
|
||||
|
||||
static uint8_t rxbitc;
|
||||
static uint16_t rxbyte;
|
||||
static int rxp=0;
|
||||
static int haveNewFrame = 0;
|
||||
static int lastFrame = 0;
|
||||
static int headerDetected = 0;
|
||||
|
||||
int M10::setup(float frequency)
|
||||
{
|
||||
#if M10_DEBUG
|
||||
Serial.println("Setup sx1278 for M10 sonde");
|
||||
#endif
|
||||
//if(!initialized) {
|
||||
//Gencrctab();
|
||||
//initrsc();
|
||||
// not here for now.... get_eph("/brdc.19n");
|
||||
// initialized = true;
|
||||
//}
|
||||
|
||||
if(sx1278.ON()!=0) {
|
||||
M10_DBG(Serial.println("Setting SX1278 power on FAILED"));
|
||||
return 1;
|
||||
}
|
||||
if(sx1278.setFSK()!=0) {
|
||||
M10_DBG(Serial.println("Setting FSJ mode FAILED"));
|
||||
return 1;
|
||||
}
|
||||
if(sx1278.setBitrate(9600)!=0) {
|
||||
M10_DBG(Serial.println("Setting bitrate 9600bit/s FAILED"));
|
||||
return 1;
|
||||
}
|
||||
#if M10_DEBUG
|
||||
float br = sx1278.getBitrate();
|
||||
Serial.print("Exact bitrate is ");
|
||||
Serial.println(br);
|
||||
#endif
|
||||
if(sx1278.setAFCBandwidth(sonde.config.rs92.rxbw)!=0) {
|
||||
M10_DBG(Serial.printf("Setting AFC bandwidth %d Hz FAILED", sonde.config.rs92.rxbw));
|
||||
return 1;
|
||||
}
|
||||
if(sx1278.setRxBandwidth(sonde.config.rs92.rxbw)!=0) {
|
||||
M10_DBG(Serial.printf("Setting RX bandwidth to %d Hz FAILED", sonde.config.rs92.rxbw));
|
||||
return 1;
|
||||
}
|
||||
|
||||
// Enable auto-AFC, auto-AGC, RX Trigger by preamble
|
||||
if(sx1278.setRxConf(0x1E)!=0) {
|
||||
M10_DBG(Serial.println("Setting RX Config FAILED"));
|
||||
return 1;
|
||||
}
|
||||
// Set autostart_RX to 01, preamble 0, SYNC detect==on, syncsize=3 (==4 byte
|
||||
//char header[] = "0110.0101 0110.0110 1010.0101 1010.1010";
|
||||
|
||||
//const char *SYNC="\x10\xB6\xCA\x11\x22\x96\x12\xF8";
|
||||
//const char *SYNC="\x08\x6D\x53\x88\x44\x69\x48\x1F";
|
||||
// was 0x57
|
||||
//const char *SYNC="\x99\x9A";
|
||||
#if 1
|
||||
// version 1, working with continuous RX
|
||||
const char *SYNC="\x66\x65";
|
||||
if(sx1278.setSyncConf(0x70, 2, (const uint8_t *)SYNC)!=0) {
|
||||
M10_DBG(Serial.println("Setting SYNC Config FAILED"));
|
||||
return 1;
|
||||
}
|
||||
//if(sx1278.setPreambleDetect(0xA8)!=0) {
|
||||
if((sx1278.setPreambleDetect(0x9F)!=0)&&((sx1278.setPreambleDetect(0xAF)!=0))) {
|
||||
M10_DBG(Serial.println("Setting PreambleDetect FAILED"));
|
||||
return 1;
|
||||
}
|
||||
#endif
|
||||
#if 0
|
||||
// version 2, with per-packet rx start, untested
|
||||
// header is 2a 10 65, i.e. with lsb first
|
||||
// 0 0101 0100 1 0 0000 1000 1 0 1010 0110 1
|
||||
// 10 10011001 10011010 01 10 10101010 01101010 01 10 01100110 10010110 01
|
||||
// preamble 0x6A 0x66 0x6A
|
||||
// i.e. preamble detector on (0x80), preamble detector size 1 (0x00), preample chip errors??? (0x0A)
|
||||
// after 2a2a2a2a2a1065
|
||||
if(sx1278.setPreambleDetect(0xA8)!=0) {
|
||||
M10_DBG(Serial.println("Setting PreambleDetect FAILED"));
|
||||
return 1;
|
||||
}
|
||||
// sync config: ato restart (01), preamble polarity AA (0), sync on (1), resevered (0), syncsize 2+1 (010) => 0x52
|
||||
const char *SYNC="\x6A\x66\x69";
|
||||
if(sx1278.setSyncConf(0x52, 3, (const uint8_t *)SYNC)!=0) {
|
||||
M10_DBG(Serial.println("Setting SYNC Config FAILED"));
|
||||
return 1;
|
||||
}
|
||||
// payload length is ((240 - 7)*10 +6)/8 = 292
|
||||
#endif
|
||||
|
||||
// Packet config 1: fixed len, no mancecer, no crc, no address filter
|
||||
// Packet config 2: packet mode, no home ctrl, no beackn, msb(packetlen)=0)
|
||||
if(sx1278.setPacketConfig(0x08, 0x40)!=0) {
|
||||
M10_DBG(Serial.println("Setting Packet config FAILED"));
|
||||
return 1;
|
||||
}
|
||||
|
||||
Serial.print("M10: setting RX frequency to ");
|
||||
Serial.println(frequency);
|
||||
int res = sx1278.setFrequency(frequency);
|
||||
// enable RX
|
||||
sx1278.setPayloadLength(0); // infinite for now...
|
||||
//sx1278.setPayloadLength(292);
|
||||
sx1278.writeRegister(REG_OP_MODE, FSK_RX_MODE);
|
||||
|
||||
#if M10_DEBUG
|
||||
M10_DBG(Serial.println("Setting SX1278 config for M10 finished\n"); Serial.println());
|
||||
#endif
|
||||
return res;
|
||||
}
|
||||
|
||||
#if 0
|
||||
int M10::setFrequency(float frequency) {
|
||||
Serial.print("M10: setting RX frequency to ");
|
||||
Serial.println(frequency);
|
||||
int res = sx1278.setFrequency(frequency);
|
||||
// enable RX
|
||||
sx1278.setPayloadLength(0); // infinite for now...
|
||||
|
||||
sx1278.writeRegister(REG_OP_MODE, FSK_RX_MODE);
|
||||
return res;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if 0
|
||||
uint32_t M10::bits2val(const uint8_t *bits, int len) {
|
||||
uint32_t val = 0;
|
||||
for (int j = 0; j < len; j++) {
|
||||
val |= (bits[j] << (len-1-j));
|
||||
}
|
||||
return val;
|
||||
}
|
||||
#endif
|
||||
|
||||
M10::M10() {
|
||||
}
|
||||
|
||||
#define M10_FRAMELEN 101
|
||||
#define M10_CRCPOS 99
|
||||
|
||||
void M10::printRaw(uint8_t *data, int len)
|
||||
{
|
||||
char buf[3];
|
||||
int i;
|
||||
for(i=0; i<len; i++) {
|
||||
snprintf(buf, 3, "%02X ", data[i]);
|
||||
Serial.print(buf);
|
||||
}
|
||||
Serial.println();
|
||||
}
|
||||
|
||||
static int update_checkM10(int c, uint8_t b) {
|
||||
int c0, c1, t, t6, t7, s;
|
||||
c1 = c & 0xFF;
|
||||
// B
|
||||
b = (b >> 1) | ((b & 1) << 7);
|
||||
b ^= (b >> 2) & 0xFF;
|
||||
// A1
|
||||
t6 = ( c & 1) ^ ((c >> 2) & 1) ^ ((c >> 4) & 1);
|
||||
t7 = ((c >> 1) & 1) ^ ((c >> 3) & 1) ^ ((c >> 5) & 1);
|
||||
t = (c & 0x3F) | (t6 << 6) | (t7 << 7);
|
||||
// A2
|
||||
s = (c >> 7) & 0xFF;
|
||||
s ^= (s >> 2) & 0xFF;
|
||||
c0 = b ^ t ^ s;
|
||||
return ((c1 << 8) | c0) & 0xFFFF;
|
||||
}
|
||||
static bool checkM10crc(uint8_t *msg) {
|
||||
int i, cs, cs1;
|
||||
cs = 0;
|
||||
for (i = 0; i < M10_CRCPOS; i++) {
|
||||
cs = update_checkM10(cs, msg[i]);
|
||||
}
|
||||
cs = cs & 0xFFFF;
|
||||
cs1 = (msg[M10_CRCPOS] << 8) | msg[M10_CRCPOS+1];
|
||||
return (cs1 == cs);
|
||||
}
|
||||
|
||||
typedef uint32_t SET256[8];
|
||||
static SET256 sondeudp_VARSET = {0x03BBBBF0UL,0x80600000UL,0x06A001A0UL,
|
||||
0x0000001CUL,0x00000000UL,0x00000000UL,0x00000000UL,
|
||||
0x00000000UL};
|
||||
// VARSET=SET256{4..9,11..13,15..17,19..21,23..25,53..54,63,69,71,72,85,87,89,90,98..100};
|
||||
|
||||
static uint8_t fixcnt[M10_FRAMELEN];
|
||||
static uint8_t fixbytes[M10_FRAMELEN];
|
||||
|
||||
static int32_t getint32(uint8_t *data) {
|
||||
return (int32_t)( data[3]|(data[2]<<8)|(data[1]<<16)|(data[0]<<24) );
|
||||
}
|
||||
static int16_t getint16(uint8_t *data) {
|
||||
return (int16_t)(data[1]|((uint16_t)data[0]<<8));
|
||||
}
|
||||
|
||||
static char dez(uint8_t nr) {
|
||||
nr = nr%10;
|
||||
return '0'+nr;
|
||||
}
|
||||
static char hex(uint8_t nr) {
|
||||
nr = nr&0x0f;
|
||||
if(nr<10) return '0'+nr;
|
||||
else return 'A'+nr-10;
|
||||
}
|
||||
const static float DEGMUL = 1.0/0xB60B60;
|
||||
#define VMUL 0.005
|
||||
#ifndef PI
|
||||
#define PI (3.1415926535897932384626433832795)
|
||||
#endif
|
||||
#define RAD (PI/180)
|
||||
|
||||
|
||||
// ret: 1=frame ok; 2=frame with errors; 0=ignored frame (m10dop-alternativ)
|
||||
int M10::decodeframeM10(uint8_t *data) {
|
||||
int repairstep = 16;
|
||||
int repl = 0;
|
||||
bool crcok;
|
||||
// error correction, inspired by oe5dxl's sondeudp
|
||||
do {
|
||||
crcok = checkM10crc(data);
|
||||
if(crcok) break;
|
||||
repl = 0;
|
||||
for(int i=0; i<M10_CRCPOS; i++) {
|
||||
if( ((sondeudp_VARSET[i/32]&(1<<(i%32))) != 1) && (fixcnt[i]>=repairstep) ) {
|
||||
repl++;
|
||||
data[i] = fixbytes[i];
|
||||
}
|
||||
}
|
||||
repairstep >>= 1;
|
||||
} while(repairstep>0);
|
||||
if(crcok) {
|
||||
for(int i=0; i<M10_CRCPOS; i++) {
|
||||
if(fixbytes[i]==data[i] &&fixcnt[i]<255) fixcnt[i]++;
|
||||
else { fixcnt[i]=0; fixbytes[i]=data[i]; }
|
||||
}
|
||||
}
|
||||
Serial.println(crcok?"CRC OK":"CRC NOT OK");
|
||||
//M10 0x9F M10Plus 0xAF M20 0x20
|
||||
if((data[1]==0x9F && data[2]==0x20) || (data[1]==0xAF && data[2]==0x20)) {
|
||||
Serial.println("Decoding...");
|
||||
// Its a M10
|
||||
// getid...
|
||||
char ids[11];
|
||||
ids[0] = 'M';
|
||||
ids[1] = 'E';
|
||||
ids[2] = hex(data[95]/16);
|
||||
ids[3] = hex(data[95]);
|
||||
ids[4] = hex(data[93]);
|
||||
uint32_t id = data[96] + data[97]*256;
|
||||
ids[5] = hex(id/4096);
|
||||
ids[6] = hex(id/256);
|
||||
ids[7] = hex(id/16);
|
||||
ids[8] = hex(id);
|
||||
ids[9] = 0;
|
||||
strncpy(sonde.si()->id, ids, 10);
|
||||
ids[0] = hex(data[95]/16);
|
||||
ids[1] = dez((data[95]&0x0f)/10);
|
||||
ids[2] = dez((data[95]&0x0f));
|
||||
ids[3] = dez(data[93]);
|
||||
ids[4] = dez(id>>13);
|
||||
id &= 0x1fff;
|
||||
ids[5] = dez(id/1000);
|
||||
ids[6] = dez((id/100)%10);
|
||||
ids[7] = dez((id/10)%10);
|
||||
ids[8] = dez(id%10);
|
||||
strncpy(sonde.si()->ser, ids, 10);
|
||||
sonde.si()->validID = true;
|
||||
Serial.printf("ID is %s [%02x %02x %d]\n", ids, data[95], data[93], id);
|
||||
// ID printed on sonde is ...-.-abbbb, with a=id>>13, bbbb=id&0x1fff in decimal
|
||||
// position data
|
||||
sonde.si()->lat = getint32(data+14) * DEGMUL;
|
||||
sonde.si()->lon = getint32(data+18) * DEGMUL;
|
||||
sonde.si()->alt = getint32(data+22) * 0.001;
|
||||
float ve = getint16(data+4)*VMUL;
|
||||
float vn = getint16(data+6)*VMUL;
|
||||
sonde.si()->vs = getint16(data+8) * VMUL;
|
||||
sonde.si()->hs = sqrt(ve*ve+vn*vn);
|
||||
float dir = atan2(vn, ve)*(1.0/RAD);
|
||||
if(dir<0) dir+=360;
|
||||
sonde.si()->dir = dir;
|
||||
sonde.si()->validPos = 0x3f;
|
||||
|
||||
uint32_t gpstime = getint32(data+10);
|
||||
uint16_t gpsweek = getint16(data+32);
|
||||
// UTC is GPSTIME - 18s (24*60*60-18 = 86382)
|
||||
// one week = 7*24*60*60 = 604800 seconds
|
||||
// unix epoch starts jan 1st 1970 0:00
|
||||
// gps time starts jan 6, 1980 0:00. thats 315964800 epoch seconds.
|
||||
// subtracting 86400 yields 315878400UL
|
||||
sonde.si()->time = (gpstime/1000) + 86382 + gpsweek*604800 + 315878400UL;
|
||||
sonde.si()->validTime = true;
|
||||
} else {
|
||||
Serial.printf("data is %02x %02x %02x\n", data[0], data[1], data[2]);
|
||||
return 0;
|
||||
}
|
||||
return crcok?1:2;
|
||||
}
|
||||
|
||||
static uint32_t rxdata;
|
||||
static bool rxsearching=true;
|
||||
|
||||
// search for
|
||||
// //101001100110011010011010011001100110100110101010100110101001
|
||||
// //1010011001100110100110100110 0110.0110 1001.1010 1010.1001 1010.1001 => 0x669AA9A9
|
||||
void M10::processM10data(uint8_t dt)
|
||||
{
|
||||
for(int i=0; i<8; i++) {
|
||||
uint8_t d = (dt&0x80)?1:0;
|
||||
dt <<= 1;
|
||||
rxdata = (rxdata<<1) | d;
|
||||
//uint8_t value = ((rxdata>>1)^rxdata)&0x01;
|
||||
//if((rxbitc&1)==1) { rxbyte = (rxbyte>>1) + ((value)<<8); } // mancester decoded data
|
||||
//rxbyte = (rxbyte>>1) | (d<<8);
|
||||
if( (rxbitc&1)==0 ) {
|
||||
// "bit1"
|
||||
rxbyte = (rxbyte<<1) | d;
|
||||
} else {
|
||||
// "bit2" ==> 01 or 10 => 1, otherweise => 0
|
||||
rxbyte = rxbyte ^ d;
|
||||
}
|
||||
//
|
||||
if(rxsearching) {
|
||||
if( rxdata == 0xcccca64c || rxdata == 0x333359b3 ) {
|
||||
rxsearching = false;
|
||||
rxbitc = 0;
|
||||
rxp = 0;
|
||||
#if 1
|
||||
int rssi=sx1278.getRSSI();
|
||||
int fei=sx1278.getFEI();
|
||||
int afc=sx1278.getAFC();
|
||||
Serial.print("Test: RSSI="); Serial.print(rssi);
|
||||
Serial.print(" FEI="); Serial.print(fei);
|
||||
Serial.print(" AFC="); Serial.println(afc);
|
||||
sonde.si()->rssi = rssi;
|
||||
sonde.si()->afc = afc;
|
||||
#endif
|
||||
}
|
||||
} else {
|
||||
rxbitc = (rxbitc+1)%16; // 16;
|
||||
if(rxbitc == 0) { // got 8 data bit
|
||||
//Serial.printf("%03x ",rxbyte);
|
||||
dataptr[rxp++] = rxbyte&0xff; // (rxbyte>>1)&0xff;
|
||||
#if 0
|
||||
if(rxp==7 && dataptr[6] != 0x65) {
|
||||
Serial.printf("wrong start: %02x\n",dataptr[6]);
|
||||
rxsearching = true;
|
||||
}
|
||||
#endif
|
||||
if(rxp>=M10_FRAMELEN) {
|
||||
rxsearching = true;
|
||||
haveNewFrame = decodeframeM10(dataptr);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int M10::receive() {
|
||||
unsigned long t0 = millis();
|
||||
Serial.printf("M10::receive() start at %ld\n",t0);
|
||||
while( millis() - t0 < 1000 ) {
|
||||
uint8_t value = sx1278.readRegister(REG_IRQ_FLAGS2);
|
||||
if ( bitRead(value, 7) ) {
|
||||
Serial.println("FIFO full");
|
||||
}
|
||||
if ( bitRead(value, 4) ) {
|
||||
Serial.println("FIFO overflow");
|
||||
}
|
||||
if ( bitRead(value, 2) == 1 ) {
|
||||
Serial.println("FIFO: ready()");
|
||||
sx1278.clearIRQFlags();
|
||||
}
|
||||
if(bitRead(value, 6) == 0) { // while FIFO not empty
|
||||
byte data = sx1278.readRegister(REG_FIFO);
|
||||
//Serial.printf("%02x",data);
|
||||
processM10data(data);
|
||||
value = sx1278.readRegister(REG_IRQ_FLAGS2);
|
||||
} else {
|
||||
if(headerDetected) {
|
||||
t0 = millis(); // restart timer... don't time out if header detected...
|
||||
headerDetected = 0;
|
||||
}
|
||||
if(haveNewFrame) {
|
||||
Serial.printf("M10::receive(): new frame complete after %ldms\n", millis()-t0);
|
||||
printRaw(dataptr, M10_FRAMELEN);
|
||||
int retval = haveNewFrame==1 ? RX_OK: RX_ERROR;
|
||||
haveNewFrame = 0;
|
||||
return retval;
|
||||
}
|
||||
delay(2);
|
||||
}
|
||||
}
|
||||
Serial.printf("M10::receive() timed out\n");
|
||||
return RX_TIMEOUT; // TODO RX_OK;
|
||||
}
|
||||
|
||||
#define M10MAXLEN (240)
|
||||
int M10::waitRXcomplete() {
|
||||
// called after complete...
|
||||
#if 0
|
||||
Serial.printf("decoding frame %d\n", lastFrame);
|
||||
print_frame(lastFrame==1?data1:data2, 240);
|
||||
SondeInfo *si = sonde.sondeList+rxtask.receiveSonde;
|
||||
si->lat = gpx.lat;
|
||||
si->lon = gpx.lon;
|
||||
si->alt = gpx.alt;
|
||||
si->vs = gpx.vU;
|
||||
si->hs = gpx.vH;
|
||||
si->dir = gpx.vD;
|
||||
si->validPos = 0x3f;
|
||||
memcpy(si->id, gpx.id, 9);
|
||||
si->validID = true;
|
||||
|
||||
int res=0;
|
||||
uint32_t t0 = millis();
|
||||
while( rxtask.receiveResult == 0xFFFF && millis()-t0 < 2000) { delay(20); }
|
||||
|
||||
if( rxtask.receiveResult<0 || rxtask.receiveResult==RX_TIMEOUT) {
|
||||
res = RX_TIMEOUT;
|
||||
} else if ( rxtask.receiveResult==0) {
|
||||
res = RX_OK;
|
||||
} else {
|
||||
res = RX_ERROR;
|
||||
}
|
||||
rxtask.receiveResult = 0xFFFF;
|
||||
Serial.printf("M10::waitRXcomplete returning %d (%s)\n", res, RXstr[res]);
|
||||
return res;
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
#if 0
|
||||
int oldwaitRXcomplete() {
|
||||
Serial.println("M10: receive frame...\n");
|
||||
sx1278receiveData = true;
|
||||
delay(6000); // done in other task....
|
||||
//sx1278receiveData = false;
|
||||
#if 0
|
||||
//sx1278.setPayloadLength(518-8); // Expect 320-8 bytes or 518-8 bytes (8 byte header)
|
||||
//sx1278.setPayloadLength(0); // infinite for now...
|
||||
|
||||
////// test code for continuous reception
|
||||
// sx1278.receive(); /// active FSK RX mode -- already done above...
|
||||
uint8_t value = sx1278.readRegister(REG_IRQ_FLAGS2);
|
||||
unsigned long previous = millis();
|
||||
|
||||
byte ready=0;
|
||||
uint32_t wait = 8000;
|
||||
// while not yet done or FIFO not yet empty
|
||||
// bit 6: FIFO Empty
|
||||
// bit 2 payload ready
|
||||
int by=0;
|
||||
while( (!ready || bitRead(value,6)==0) && (millis() - previous < wait) )
|
||||
{
|
||||
if( bitRead(value, 7) ) { Serial.println("FIFO full"); }
|
||||
if( bitRead(value, 4) ) { Serial.println("FIFO overflow"); }
|
||||
if( bitRead(value,2)==1 ) ready=1;
|
||||
if( bitRead(value, 6) == 0 ) { // FIFO not empty
|
||||
byte data = sx1278.readRegister(REG_FIFO);
|
||||
process8N1data(data);
|
||||
by++;
|
||||
#if 0
|
||||
if(di==1) {
|
||||
int rssi=getRSSI();
|
||||
int fei=getFEI();
|
||||
int afc=getAFC();
|
||||
Serial.print("Test: RSSI="); Serial.println(rssi);
|
||||
Serial.print("Test: FEI="); Serial.println(fei);
|
||||
Serial.print("Test: AFC="); Serial.println(afc);
|
||||
sonde.si()->rssi = rssi;
|
||||
sonde.si()->afc = afc;
|
||||
}
|
||||
if(di>520) {
|
||||
// TODO
|
||||
Serial.println("TOO MUCH DATA");
|
||||
break;
|
||||
}
|
||||
previous = millis(); // reset timeout after receiving data
|
||||
#endif
|
||||
}
|
||||
value = sx1278.readRegister(REG_IRQ_FLAGS2);
|
||||
}
|
||||
Serial.printf("processed %d bytes before end/timeout\n", by);
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
/////
|
||||
#if 0
|
||||
int e = sx1278.receivePacketTimeout(1000, data+8);
|
||||
if(e) { Serial.println("TIMEOUT"); return RX_TIMEOUT; } //if timeout... return 1
|
||||
|
||||
printRaw(data, M10MAXLEN);
|
||||
//for(int i=0; i<M10MAXLEN; i++) { data[i] = reverse(data[i]); }
|
||||
//printRaw(data, MAXLEN);
|
||||
//for(int i=0; i<M10MAXLEN; i++) { data[i] = data[i] ^ scramble[i&0x3F]; }
|
||||
//printRaw(data, MAXLEN);
|
||||
//int res = decode41(data, M10MAXLEN);
|
||||
#endif
|
||||
int res=0;
|
||||
return res==0 ? RX_OK : RX_ERROR;
|
||||
}
|
||||
#endif
|
||||
|
||||
M10 m10 = M10();
|
||||
Executable
+96
@@ -0,0 +1,96 @@
|
||||
/*
|
||||
* M10.h
|
||||
* Functions for decoding Meteomodem M10 sondes with SX127x chips
|
||||
* Copyright (C) 2019 Hansi Reiser, dl9rdz
|
||||
*
|
||||
* SPDX-License-Identifier: GPL-2.0+
|
||||
*/
|
||||
|
||||
#ifndef M10_h
|
||||
#define M10_h
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdint.h>
|
||||
#include <Arduino.h>
|
||||
#ifndef inttypes_h
|
||||
#include <inttypes.h>
|
||||
#endif
|
||||
|
||||
#if 0
|
||||
struct CONTEXTR9 {
|
||||
char calibdata[512];
|
||||
uint32_t calibok;
|
||||
char mesok;
|
||||
char posok;
|
||||
char framesent;
|
||||
double lat;
|
||||
double lon;
|
||||
double heig;
|
||||
double speed;
|
||||
double dir;
|
||||
double climb;
|
||||
double lastlat;
|
||||
double laslong;
|
||||
double lastalt;
|
||||
double lastspeed;
|
||||
double lastdir;
|
||||
double lastclb;
|
||||
float hrmsc;
|
||||
float vrmsc;
|
||||
double hp;
|
||||
double hyg;
|
||||
double temp;
|
||||
double ozontemp;
|
||||
double ozon;
|
||||
uint32_t goodsats;
|
||||
uint32_t timems;
|
||||
uint32_t framenum;
|
||||
};
|
||||
#endif
|
||||
|
||||
/* Main class */
|
||||
class M10
|
||||
{
|
||||
private:
|
||||
void printRaw(uint8_t *data, int len);
|
||||
void processM10data(uint8_t data);
|
||||
int decodeframeM10(uint8_t *data);
|
||||
#if 0
|
||||
void stobyte92(uint8_t byte);
|
||||
void dogps(const uint8_t *sf, int sf_len,
|
||||
struct CONTEXTR9 * cont, uint32_t * timems,
|
||||
uint32_t * gpstime);
|
||||
uint32_t bits2val(const uint8_t *bits, int len);
|
||||
int bitsToBytes(uint8_t *bits, uint8_t *bytes, int len);
|
||||
int decode92(byte *data, int maxlen);
|
||||
|
||||
uint8_t hamming_conf[ 7*8]; // 7*8=56
|
||||
uint8_t hamming_dat1[13*8]; // 13*8=104
|
||||
uint8_t hamming_dat2[13*8];
|
||||
|
||||
uint8_t block_conf[ 7*4]; // 7*4=28
|
||||
uint8_t block_dat1[13*4]; // 13*4=52
|
||||
uint8_t block_dat2[13*4];
|
||||
|
||||
uint8_t H[4][8] = // extended Hamming(8,4) particy check matrix
|
||||
{{ 0, 1, 1, 1, 1, 0, 0, 0},
|
||||
{ 1, 0, 1, 1, 0, 1, 0, 0},
|
||||
{ 1, 1, 0, 1, 0, 0, 1, 0},
|
||||
{ 1, 1, 1, 0, 0, 0, 0, 1}};
|
||||
uint8_t He[8] = { 0x7, 0xB, 0xD, 0xE, 0x8, 0x4, 0x2, 0x1}; // Spalten von H:
|
||||
// 1-bit-error-Syndrome
|
||||
boolean initialized = false;
|
||||
#endif
|
||||
|
||||
public:
|
||||
M10();
|
||||
int setup(float frequency);
|
||||
int receive();
|
||||
int waitRXcomplete();
|
||||
|
||||
//int use_ecc = 1;
|
||||
};
|
||||
|
||||
extern M10 m10;
|
||||
|
||||
#endif
|
||||
Executable
+556
@@ -0,0 +1,556 @@
|
||||
|
||||
/* RS41 decoder functions */
|
||||
#include "RS41.h"
|
||||
#include "SX1278FSK.h"
|
||||
#include "rsc.h"
|
||||
#include "Sonde.h"
|
||||
|
||||
#define RS41_DEBUG 0
|
||||
|
||||
#if RS41_DEBUG
|
||||
#define RS41_DBG(x) x
|
||||
#else
|
||||
#define RS41_DBG(x)
|
||||
#endif
|
||||
|
||||
#define RS41MAXLEN (320)
|
||||
static byte data[800];
|
||||
static int dpos = 0;
|
||||
|
||||
static uint16_t CRCTAB[256];
|
||||
|
||||
#define X2C_DIVR(a, b) ((b) != 0.0f ? (a)/(b) : (a))
|
||||
#define X2C_DIVL(a, b) ((a)/(b))
|
||||
static uint32_t X2C_LSH(uint32_t a, int32_t length, int32_t n)
|
||||
{
|
||||
uint32_t m;
|
||||
|
||||
m = 0;
|
||||
m = (length == 32) ? 0xFFFFFFFFl : (1 << length) - 1;
|
||||
if (n > 0) {
|
||||
if (n >= (int32_t)length)
|
||||
return 0;
|
||||
return (a << n) & m;
|
||||
}
|
||||
|
||||
if (n <= (int32_t)-length)
|
||||
return 0;
|
||||
return (a >> -n) & m;
|
||||
}
|
||||
|
||||
static double atang2(double x, double y)
|
||||
{
|
||||
double w;
|
||||
if (fabs(x)>fabs(y)) {
|
||||
w = (double)atan((float)(X2C_DIVL(y,x)));
|
||||
if (x<0.0) {
|
||||
if (y>0.0) w = 3.1415926535898+w;
|
||||
else w = w-3.1415926535898;
|
||||
}
|
||||
}
|
||||
else if (y!=0.0) {
|
||||
w = (double)(1.5707963267949f-atan((float)(X2C_DIVL(x,
|
||||
y))));
|
||||
if (y<0.0) w = w-3.1415926535898;
|
||||
}
|
||||
else w = 0.0;
|
||||
return w;
|
||||
} /* end atang2() */
|
||||
|
||||
|
||||
static void Gencrctab(void)
|
||||
{
|
||||
uint16_t j;
|
||||
uint16_t i;
|
||||
uint16_t crc;
|
||||
for (i = 0U; i<=255U; i++) {
|
||||
crc = (uint16_t)(i*256U);
|
||||
for (j = 0U; j<=7U; j++) {
|
||||
if ((0x8000U & crc)) crc = X2C_LSH(crc,16,1)^0x1021U;
|
||||
else crc = X2C_LSH(crc,16,1);
|
||||
} /* end for */
|
||||
CRCTAB[i] = X2C_LSH(crc,16,-8)|X2C_LSH(crc,16,8);
|
||||
} /* end for */
|
||||
} /* end Gencrctab() */
|
||||
|
||||
int RS41::setup(float frequency)
|
||||
{
|
||||
#if RS41_DEBUG
|
||||
Serial.println("Setup sx1278 for RS41 sonde");
|
||||
#endif
|
||||
if(!initialized) {
|
||||
Gencrctab();
|
||||
initrsc();
|
||||
initialized = true;
|
||||
}
|
||||
|
||||
if(sx1278.ON()!=0) {
|
||||
RS41_DBG(Serial.println("Setting SX1278 power on FAILED"));
|
||||
return 1;
|
||||
}
|
||||
if(sx1278.setFSK()!=0) {
|
||||
RS41_DBG(Serial.println("Setting FSK mode FAILED"));
|
||||
return 1;
|
||||
}
|
||||
if(sx1278.setBitrate(4800)!=0) {
|
||||
RS41_DBG(Serial.println("Setting bitrate 4800bit/s FAILED"));
|
||||
return 1;
|
||||
}
|
||||
#if RS41_DEBUG
|
||||
float br = sx1278.getBitrate();
|
||||
Serial.print("Exact bitrate is ");
|
||||
Serial.println(br);
|
||||
#endif
|
||||
|
||||
if(sx1278.setAFCBandwidth(sonde.config.rs41.agcbw)!=0) {
|
||||
RS41_DBG(Serial.printf("Setting AFC bandwidth %d Hz FAILED", sonde.config.rs41.agcbw));
|
||||
return 1;
|
||||
}
|
||||
if(sx1278.setRxBandwidth(sonde.config.rs41.rxbw)!=0) {
|
||||
RS41_DBG(Serial.printf("Setting RX bandwidth to %d Hz FAILED", sonde.config.rs41.rxbw));
|
||||
return 1;
|
||||
}
|
||||
// Enable auto-AFC, auto-AGC, RX Trigger by preamble
|
||||
if(sx1278.setRxConf(0x1E)!=0) {
|
||||
RS41_DBG(Serial.println("Setting RX Config FAILED"));
|
||||
return 1;
|
||||
}
|
||||
// Set autostart_RX to 01, preamble 0, SYNC detect==on, syncsize=3 (==4 byte
|
||||
//char header[] = "0110.0101 0110.0110 1010.0101 1010.1010";
|
||||
|
||||
//const char *SYNC="\x10\xB6\xCA\x11\x22\x96\x12\xF8";
|
||||
const char *SYNC="\x08\x6D\x53\x88\x44\x69\x48\x1F";
|
||||
if(sx1278.setSyncConf(0x57, 8, (const uint8_t *)SYNC)!=0) {
|
||||
RS41_DBG(Serial.println("Setting SYNC Config FAILED"));
|
||||
return 1;
|
||||
}
|
||||
if(sx1278.setPreambleDetect(0xA8)!=0) {
|
||||
RS41_DBG(Serial.println("Setting PreambleDetect FAILED"));
|
||||
return 1;
|
||||
}
|
||||
|
||||
// Packet config 1: fixed len, no mancecer, no crc, no address filter
|
||||
// Packet config 2: packet mode, no home ctrl, no beackn, msb(packetlen)=0)
|
||||
if(sx1278.setPacketConfig(0x08, 0x40)!=0) {
|
||||
RS41_DBG(Serial.println("Setting Packet config FAILED"));
|
||||
return 1;
|
||||
}
|
||||
Serial.print("RS41: setting RX frequency to ");
|
||||
Serial.println(frequency);
|
||||
int retval = sx1278.setFrequency(frequency);
|
||||
dpos = 0;
|
||||
|
||||
#if RS41_DEBUG
|
||||
RS41_DBG(Serial.println("Setting SX1278 config for RS41 finished\n"); Serial.println());
|
||||
#endif
|
||||
sx1278.clearIRQFlags();
|
||||
|
||||
// the following is already done in receivePacketTimeout()
|
||||
// sx1278.setPayloadLength(RS41MAXLEN-8); // Expect 320-8 bytes or 518-8 bytes (8 byte header)
|
||||
// sx1278.writeRegister(REG_OP_MODE, FSK_RX_MODE);
|
||||
return retval;
|
||||
}
|
||||
|
||||
uint32_t RS41::bits2val(const uint8_t *bits, int len) {
|
||||
uint32_t val = 0;
|
||||
for (int j = 0; j < len; j++) {
|
||||
val |= (bits[j] << (len-1-j));
|
||||
}
|
||||
return val;
|
||||
}
|
||||
|
||||
RS41::RS41() {
|
||||
}
|
||||
|
||||
/* RS41 reed solomon decoder, from dxlAPRS
|
||||
*/
|
||||
static int32_t reedsolomon41(byte buf[], uint32_t buf_len, uint32_t len2)
|
||||
{
|
||||
uint32_t i;
|
||||
int32_t res1;
|
||||
/*tb1, */
|
||||
int32_t res;
|
||||
char b1[256];
|
||||
char b[256];
|
||||
uint32_t eraspos[24];
|
||||
uint32_t tmp;
|
||||
for (i = 0UL; i<=255UL; i++) {
|
||||
b[i] = 0;
|
||||
b1[i] = 0;
|
||||
} /* end for */
|
||||
tmp = len2;
|
||||
i = 0UL;
|
||||
if (i<=tmp) for (;; i++) {
|
||||
b[230UL-i] = buf[i*2UL+56UL];
|
||||
b1[230UL-i] = buf[i*2UL+57UL];
|
||||
if (i==tmp) break;
|
||||
} /* end for */
|
||||
for (i = 0UL; i<=23UL; i++) {
|
||||
b[254UL-i] = buf[i+8UL];
|
||||
b1[254UL-i] = buf[i+32UL];
|
||||
} /* end for */
|
||||
res = decodersc(b, eraspos, 0);
|
||||
res1 = decodersc(b1, eraspos, 0);
|
||||
if (res>0L && res<=12L) {
|
||||
tmp = len2;
|
||||
i = 0UL;
|
||||
if (i<=tmp) for (;; i++) {
|
||||
buf[i*2UL+56UL] = b[230UL-i];
|
||||
if (i==tmp) break;
|
||||
} /* end for */
|
||||
for (i = 0UL; i<=23UL; i++) {
|
||||
buf[i+8UL] = b[254UL-i];
|
||||
} /* end for */
|
||||
}
|
||||
if (res1>0L && res1<=12L) {
|
||||
tmp = len2;
|
||||
i = 0UL;
|
||||
if (i<=tmp) for (;; i++) {
|
||||
buf[i*2UL+57UL] = b1[230UL-i];
|
||||
if (i==tmp) break;
|
||||
} /* end for */
|
||||
for (i = 0UL; i<=23UL; i++) {
|
||||
buf[i+32UL] = b1[254UL-i];
|
||||
} /* end for */
|
||||
}
|
||||
if (res<0L || res1<0L) return -1L;
|
||||
else return res+res1;
|
||||
return 0;
|
||||
} /* end reedsolomon41() */
|
||||
|
||||
|
||||
|
||||
|
||||
static char crcrs(const byte frame[], uint32_t frame_len,
|
||||
int32_t from, int32_t to)
|
||||
{
|
||||
uint16_t crc;
|
||||
int32_t i;
|
||||
int32_t tmp;
|
||||
crc = 0xFFFFU;
|
||||
tmp = to-3L;
|
||||
i = from;
|
||||
if (i<=tmp) for (;; i++) {
|
||||
crc = X2C_LSH(crc,16,-8)^CRCTAB[(uint32_t)((crc^(uint16_t)(uint8_t)frame[i])&0xFFU)];
|
||||
if (i==tmp) break;
|
||||
} /* end for */
|
||||
return frame[to-1L]==(char)crc && frame[to-2L]==(char)X2C_LSH(crc,
|
||||
16,-8);
|
||||
} /* end crcrs() */
|
||||
|
||||
static int32_t getint32(const byte frame[], uint32_t frame_len,
|
||||
uint32_t p)
|
||||
{
|
||||
uint32_t n;
|
||||
uint32_t i;
|
||||
n = 0UL;
|
||||
for (i = 3UL;; i--) {
|
||||
n = n*256UL+(uint32_t)(uint8_t)frame[p+i];
|
||||
if (i==0UL) break;
|
||||
} /* end for */
|
||||
return (int32_t)n;
|
||||
} /* end getint32() */
|
||||
|
||||
|
||||
static uint32_t getcard16(const byte frame[], uint32_t frame_len,
|
||||
uint32_t p)
|
||||
{
|
||||
return (uint32_t)(uint8_t)frame[p]+256UL*(uint32_t)(uint8_t)
|
||||
frame[p+1UL];
|
||||
} /* end getcard16() */
|
||||
|
||||
|
||||
static int32_t getint16(const byte frame[], uint32_t frame_len,
|
||||
uint32_t p)
|
||||
{
|
||||
uint32_t n;
|
||||
n = (uint32_t)(uint8_t)frame[p]+256UL*(uint32_t)(uint8_t)
|
||||
frame[p+1UL];
|
||||
if (n>=32768UL) return (int32_t)(n-65536UL);
|
||||
return (int32_t)n;
|
||||
} /* end getint16() */
|
||||
|
||||
static void wgs84r(double x, double y, double z,
|
||||
double * lat, double * long0,
|
||||
double * heig)
|
||||
{
|
||||
double sl;
|
||||
double ct;
|
||||
double st;
|
||||
double t;
|
||||
double rh;
|
||||
double xh;
|
||||
double h;
|
||||
h = x*x+y*y;
|
||||
if (h>0.0) {
|
||||
rh = (double)sqrt((float)h);
|
||||
xh = x+rh;
|
||||
*long0 = atang2(xh, y)*2.0;
|
||||
if (*long0>3.1415926535898) *long0 = *long0-6.2831853071796;
|
||||
t = (double)atan((float)(X2C_DIVL(z*1.003364089821,
|
||||
rh)));
|
||||
st = (double)sin((float)t);
|
||||
ct = (double)cos((float)t);
|
||||
*lat = (double)atan((float)
|
||||
(X2C_DIVL(z+4.2841311513312E+4*st*st*st,
|
||||
rh-4.269767270718E+4*ct*ct*ct)));
|
||||
sl = (double)sin((float)*lat);
|
||||
*heig = X2C_DIVL(rh,(double)cos((float)*lat))-(double)(X2C_DIVR(6.378137E+6f,
|
||||
sqrt((float)(1.0-6.6943799901413E-3*sl*sl))));
|
||||
}
|
||||
else {
|
||||
*lat = 0.0;
|
||||
*long0 = 0.0;
|
||||
*heig = 0.0;
|
||||
}
|
||||
/* lat:=atan(z/(rh*(1.0 - E2))); */
|
||||
/* heig:=sqrt(h + z*z) - EARTHA; */
|
||||
} /* end wgs84r() */
|
||||
|
||||
// returns: 0=ok, -1=error
|
||||
static void posrs41(const byte b[], uint32_t b_len, uint32_t p)
|
||||
{
|
||||
double dir;
|
||||
double vu;
|
||||
double ve;
|
||||
double vn;
|
||||
double vz;
|
||||
double vy;
|
||||
double vx;
|
||||
double heig;
|
||||
double long0;
|
||||
double lat;
|
||||
double z;
|
||||
double y;
|
||||
double x;
|
||||
x = (double)getint32(b, b_len, p)*0.01;
|
||||
y = (double)getint32(b, b_len, p+4UL)*0.01;
|
||||
z = (double)getint32(b, b_len, p+8UL)*0.01;
|
||||
wgs84r(x, y, z, &lat, &long0, &heig);
|
||||
Serial.print(" ");
|
||||
sonde.si()->lat = (float)(X2C_DIVL(lat,1.7453292519943E-2));
|
||||
Serial.print(sonde.si()->lat);
|
||||
Serial.print(" ");
|
||||
sonde.si()->lon = (float)(X2C_DIVL(long0,1.7453292519943E-2));
|
||||
Serial.print(sonde.si()->lon);
|
||||
if (heig<1.E+5 && heig>(-1.E+5)) {
|
||||
Serial.print(" ");
|
||||
Serial.print((uint32_t)heig);
|
||||
Serial.print("m");
|
||||
}
|
||||
/*speed */
|
||||
vx = (double)getint16(b, b_len, p+12UL)*0.01;
|
||||
vy = (double)getint16(b, b_len, p+14UL)*0.01;
|
||||
vz = (double)getint16(b, b_len, p+16UL)*0.01;
|
||||
vn = (-(vx*(double)sin((float)lat)*(double)
|
||||
cos((float)long0))-vy*(double)
|
||||
sin((float)lat)*(double)sin((float)
|
||||
long0))+vz*(double)cos((float)lat);
|
||||
ve = -(vx*(double)sin((float)long0))+vy*(double)
|
||||
cos((float)long0);
|
||||
vu = vx*(double)cos((float)lat)*(double)
|
||||
cos((float)long0)+vy*(double)
|
||||
cos((float)lat)*(double)sin((float)
|
||||
long0)+vz*(double)sin((float)lat);
|
||||
dir = X2C_DIVL(atang2(vn, ve),1.7453292519943E-2);
|
||||
if (dir<0.0) dir = 360.0+dir;
|
||||
sonde.si()->dir = dir;
|
||||
Serial.print(" ");
|
||||
sonde.si()->hs = sqrt((float)(vn*vn+ve*ve))*3.6f;
|
||||
Serial.print(sonde.si()->hs);
|
||||
Serial.print("km/h ");
|
||||
Serial.print(dir);
|
||||
Serial.print("deg ");
|
||||
Serial.print((float)vu);
|
||||
sonde.si()->vs = vu;
|
||||
Serial.print("m/s ");
|
||||
uint8_t sats = getcard16(b, b_len, p+18UL)&255UL;
|
||||
Serial.print(sats);
|
||||
Serial.print("Sats");
|
||||
sonde.si()->sats = sats;
|
||||
sonde.si()->alt = heig;
|
||||
if( 0==(int)(lat*10000) && 0==(int)(long0*10000) ) {
|
||||
if(sonde.si()->validPos) {
|
||||
// we have an old position, so keep previous position and mark it as old
|
||||
sonde.si()->validPos |= 0x80;
|
||||
}
|
||||
}
|
||||
else
|
||||
sonde.si()->validPos = 0x7f;
|
||||
} /* end posrs41() */
|
||||
|
||||
|
||||
|
||||
// returns: 0: ok, -1: rs or crc error
|
||||
int RS41::decode41(byte *data, int maxlen)
|
||||
{
|
||||
char buf[128];
|
||||
int crcok = 0;
|
||||
|
||||
int32_t corr = reedsolomon41(data, 560, 131); // try short frame first
|
||||
if(corr<0) {
|
||||
corr = reedsolomon41(data, 560, 230); // try long frame
|
||||
}
|
||||
#if 0
|
||||
Serial.print("RS result:");
|
||||
Serial.print(corr);
|
||||
Serial.println();
|
||||
#endif
|
||||
int p = 57; // 8 byte header, 48 byte RS
|
||||
while(p<maxlen) { /* why 555? */
|
||||
uint8_t typ = data[p++];
|
||||
uint32_t len = data[p++]+2UL;
|
||||
if(p+len>maxlen) break;
|
||||
|
||||
#if 0
|
||||
// DEBUG OUTPUT
|
||||
Serial.print("@");
|
||||
Serial.print(p-2);
|
||||
Serial.print(": ID:");
|
||||
Serial.print(typ, HEX);
|
||||
Serial.print(", len=");
|
||||
Serial.print(len);
|
||||
Serial.print(": ");
|
||||
for(int i=0; i<len-1; i++) {
|
||||
char buf[3];
|
||||
snprintf(buf, 4, "%02X|", data[p+i]);
|
||||
Serial.print(buf);
|
||||
}
|
||||
#endif
|
||||
// check CRC
|
||||
if(!crcrs(data, 560, p, p+len)) {
|
||||
Serial.println("###CRC ERROR###");
|
||||
} else {
|
||||
crcok = 1;
|
||||
switch(typ) {
|
||||
case 'y': // name
|
||||
{
|
||||
Serial.print("#");
|
||||
uint16_t fnr = data[p]+(data[p+1]<<8);
|
||||
Serial.print(fnr);
|
||||
sonde.si()->frame = fnr;
|
||||
Serial.print("; RS41 ID ");
|
||||
snprintf(buf, 10, "%.8s ", data+p+2);
|
||||
Serial.print(buf);
|
||||
sonde.si()->type=STYPE_RS41;
|
||||
strncpy(sonde.si()->id, (const char *)(data+p+2), 8);
|
||||
sonde.si()->id[8]=0;
|
||||
strncpy(sonde.si()->ser, (const char *)(data+p+2), 8);
|
||||
sonde.si()->ser[8]=0;
|
||||
sonde.si()->validID=true;
|
||||
int calnr = data[p+23];
|
||||
// not sure about this
|
||||
if(calnr==0x31) {
|
||||
uint16_t bt = data[p+30] + 256*data[p+31];
|
||||
sonde.si()->burstKT = bt;
|
||||
}
|
||||
// this should be right...
|
||||
if(calnr==0x02) {
|
||||
uint16_t kt = data[p+31] + 256*data[p+32];
|
||||
sonde.si()->launchKT = kt;
|
||||
}
|
||||
// and this seems fine as well...
|
||||
if(calnr==0x32) {
|
||||
uint16_t cntdown = data[p+24] + (data[p+25]<<8);
|
||||
uint16_t min = cntdown - (cntdown/3600)*3600;
|
||||
Serial.printf("Countdown value: %d\n [%2d:%02d:%02d]", cntdown, cntdown/3600, min/60, min-(min/60)*60);
|
||||
sonde.si()->countKT = cntdown;
|
||||
sonde.si()->crefKT = fnr;
|
||||
}
|
||||
}
|
||||
// TODO: some more data
|
||||
break;
|
||||
case '|': // date
|
||||
{
|
||||
uint32_t gpstime = getint32(data, 560, p+2);
|
||||
uint16_t gpsweek = getint16(data, 560, p);
|
||||
// UTC is GPSTIME - 18s (24*60*60-18 = 86382)
|
||||
// one week = 7*24*60*60 = 604800 seconds
|
||||
// unix epoch starts jan 1st 1970 0:00
|
||||
// gps time starts jan 6, 1980 0:00. thats 315964800 epoch seconds.
|
||||
// subtracting 86400 yields 315878400UL
|
||||
sonde.si()->time = (gpstime/1000) + 86382 + gpsweek*604800 + 315878400UL;
|
||||
sonde.si()->validTime = true;
|
||||
}
|
||||
break;
|
||||
case '{': // pos
|
||||
posrs41(data+p, len, 0);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}}
|
||||
p += len;
|
||||
Serial.println();
|
||||
}
|
||||
return crcok ? 0 : -1;
|
||||
}
|
||||
void RS41::printRaw(uint8_t *data, int len)
|
||||
{
|
||||
char buf[3];
|
||||
int i;
|
||||
for(i=0; i<len; i++) {
|
||||
snprintf(buf, 3, "%02X", data[i]);
|
||||
Serial.print(buf);
|
||||
}
|
||||
Serial.println();
|
||||
}
|
||||
|
||||
void RS41::bitsToBytes(uint8_t *bits, uint8_t *bytes, int len)
|
||||
{
|
||||
int i;
|
||||
for(i=0; i<len*4; i++) {
|
||||
bytes[i/8] = (bytes[i/8]<<1) | (bits[i]?1:0);
|
||||
}
|
||||
bytes[(i-1)/8] &= 0x0F;
|
||||
}
|
||||
|
||||
static unsigned char lookup[16] = {
|
||||
0x0, 0x8, 0x4, 0xc, 0x2, 0xa, 0x6, 0xe,
|
||||
0x1, 0x9, 0x5, 0xd, 0x3, 0xb, 0x7, 0xf, };
|
||||
|
||||
static uint8_t reverse(uint8_t n) {
|
||||
return (lookup[n&0x0f] << 4) | lookup[n>>4];
|
||||
}
|
||||
|
||||
|
||||
static uint8_t scramble[64] = {150U,131U,62U,81U,177U,73U,8U,152U,50U,5U,89U,
|
||||
14U,249U,68U,198U,38U,33U,96U,194U,234U,121U,93U,109U,161U,
|
||||
84U,105U,71U,12U,220U,232U,92U,241U,247U,118U,130U,127U,7U,
|
||||
153U,162U,44U,147U,124U,48U,99U,245U,16U,46U,97U,208U,188U,
|
||||
180U,182U,6U,170U,244U,35U,120U,110U,59U,174U,191U,123U,76U,
|
||||
193U};
|
||||
|
||||
|
||||
int RS41::receive() {
|
||||
sx1278.setPayloadLength(RS41MAXLEN-8);
|
||||
int e = sx1278.receivePacketTimeout(1000, data+8);
|
||||
if(e) { Serial.println("TIMEOUT"); return RX_TIMEOUT; }
|
||||
|
||||
for(int i=0; i<RS41MAXLEN; i++) { data[i] = reverse(data[i]); }
|
||||
for(int i=0; i<RS41MAXLEN; i++) { data[i] = data[i] ^ scramble[i&0x3F]; }
|
||||
return decode41(data, RS41MAXLEN);
|
||||
}
|
||||
|
||||
int RS41::waitRXcomplete() {
|
||||
// Currently not used. can be used for additinoal post-processing
|
||||
// (required for RS92 to avoid FIFO overrun in rx task)
|
||||
#if 0
|
||||
int res;
|
||||
uint32_t t0 = millis();
|
||||
while(rxtask.receiveResult<0 && millis()-t0 < 3000) { delay(50); }
|
||||
|
||||
if(rxtask.receiveResult<0 || rxtask.receiveResult==RX_TIMEOUT) {
|
||||
res = RX_TIMEOUT;
|
||||
} else if (rxtask.receiveResult==0) {
|
||||
res = RX_OK;
|
||||
} else {
|
||||
res = RX_ERROR;
|
||||
}
|
||||
rxtask.receiveResult = -1;
|
||||
Serial.printf("waitRXcomplete returning %d\n", res);
|
||||
return res;
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
RS41 rs41 = RS41();
|
||||
Executable
+67
@@ -0,0 +1,67 @@
|
||||
/*
|
||||
* RS41.h
|
||||
* Functions for decoding RS41 sondes with SX127x chips
|
||||
* Copyright (C) 2019 Hansi Reiser, dl9rdz
|
||||
*
|
||||
* SPDX-License-Identifier: GPL-2.0+
|
||||
*/
|
||||
|
||||
#ifndef RS41_h
|
||||
#define RS41_h
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdint.h>
|
||||
#include <Arduino.h>
|
||||
#ifndef inttypes_h
|
||||
#include <inttypes.h>
|
||||
#endif
|
||||
|
||||
/* Main class */
|
||||
class RS41
|
||||
{
|
||||
private:
|
||||
uint32_t bits2val(const uint8_t *bits, int len);
|
||||
void printRaw(uint8_t *data, int len);
|
||||
void bitsToBytes(uint8_t *bits, uint8_t *bytes, int len);
|
||||
int decode41(byte *data, int maxlen);
|
||||
|
||||
#define B 8
|
||||
#define S 4
|
||||
uint8_t hamming_conf[ 7*B]; // 7*8=56
|
||||
uint8_t hamming_dat1[13*B]; // 13*8=104
|
||||
uint8_t hamming_dat2[13*B];
|
||||
|
||||
uint8_t block_conf[ 7*S]; // 7*4=28
|
||||
uint8_t block_dat1[13*S]; // 13*4=52
|
||||
uint8_t block_dat2[13*S];
|
||||
|
||||
uint8_t H[4][8] = // extended Hamming(8,4) particy check matrix
|
||||
{{ 0, 1, 1, 1, 1, 0, 0, 0},
|
||||
{ 1, 0, 1, 1, 0, 1, 0, 0},
|
||||
{ 1, 1, 0, 1, 0, 0, 1, 0},
|
||||
{ 1, 1, 1, 0, 0, 0, 0, 1}};
|
||||
uint8_t He[8] = { 0x7, 0xB, 0xD, 0xE, 0x8, 0x4, 0x2, 0x1}; // Spalten von H:
|
||||
// 1-bit-error-Syndrome
|
||||
boolean initialized = false;
|
||||
|
||||
public:
|
||||
RS41();
|
||||
// New interface:
|
||||
// setup() is called when channel is activated (sets mode and frequency and activates receiver)
|
||||
int setup(float frequency);
|
||||
// processRXbyte is called by background task for each received byte
|
||||
// should be fast enough to not cause sx127x fifo buffer overflow
|
||||
// void processRXbyte(uint8_t data);
|
||||
// is called approx. 1x per second, may do some post-processing of received data
|
||||
// and update information in sonde data structure
|
||||
// returns infomration about sucess/error (for timers and for quality bar in display)
|
||||
int receive();
|
||||
int waitRXcomplete();
|
||||
//int receiveFrame();
|
||||
|
||||
int use_ecc = 1;
|
||||
};
|
||||
|
||||
extern RS41 rs41;
|
||||
|
||||
#endif
|
||||
Executable
+727
@@ -0,0 +1,727 @@
|
||||
|
||||
/* RS92 decoder functions */
|
||||
#include "RS92.h"
|
||||
#include "SX1278FSK.h"
|
||||
#include "rsc.h"
|
||||
#include "Sonde.h"
|
||||
#include <SPIFFS.h>
|
||||
|
||||
// well...
|
||||
#include "rs92gps.h"
|
||||
|
||||
#define RS92_DEBUG 1
|
||||
|
||||
#if RS92_DEBUG
|
||||
#define RS92_DBG(x) x
|
||||
#else
|
||||
#define RS92_DBG(x)
|
||||
#endif
|
||||
|
||||
//static uint16_t CRCTAB[256];
|
||||
uint16_t *CRCTAB = NULL;
|
||||
|
||||
#define X2C_DIVR(a, b) ((b) != 0.0f ? (a)/(b) : (a))
|
||||
#define X2C_DIVL(a, b) ((a)/(b))
|
||||
static uint32_t X2C_LSH(uint32_t a, int32_t length, int32_t n)
|
||||
{
|
||||
uint32_t m;
|
||||
|
||||
m = 0;
|
||||
m = (length == 32) ? 0xFFFFFFFFl : (1 << length) - 1;
|
||||
if (n > 0) {
|
||||
if (n >= (int32_t)length)
|
||||
return 0;
|
||||
return (a << n) & m;
|
||||
}
|
||||
|
||||
if (n <= (int32_t)-length)
|
||||
return 0;
|
||||
return (a >> -n) & m;
|
||||
}
|
||||
|
||||
#if 0
|
||||
static double atang2(double x, double y)
|
||||
{
|
||||
double w;
|
||||
if (fabs(x)>fabs(y)) {
|
||||
w = (double)atan((float)(X2C_DIVL(y,x)));
|
||||
if (x<0.0) {
|
||||
if (y>0.0) w = 3.1415926535898+w;
|
||||
else w = w-3.1415926535898;
|
||||
}
|
||||
}
|
||||
else if (y!=0.0) {
|
||||
w = (double)(1.5707963267949f-atan((float)(X2C_DIVL(x,
|
||||
y))));
|
||||
if (y<0.0) w = w-3.1415926535898;
|
||||
}
|
||||
else w = 0.0;
|
||||
return w;
|
||||
} /* end atang2() */
|
||||
#endif
|
||||
|
||||
static void Gencrctab(void)
|
||||
{
|
||||
uint16_t j;
|
||||
uint16_t i;
|
||||
uint16_t crc;
|
||||
if(!CRCTAB) { CRCTAB=(uint16_t *)malloc(256*sizeof(uint16_t)); }
|
||||
for (i = 0U; i<=255U; i++) {
|
||||
crc = (uint16_t)(i*256U);
|
||||
for (j = 0U; j<=7U; j++) {
|
||||
if ((0x8000U & crc)) crc = X2C_LSH(crc,16,1)^0x1021U;
|
||||
else crc = X2C_LSH(crc,16,1);
|
||||
} /* end for */
|
||||
CRCTAB[i] = X2C_LSH(crc,16,-8)|X2C_LSH(crc,16,8);
|
||||
} /* end for */
|
||||
} /* end Gencrctab() */
|
||||
|
||||
|
||||
static byte data1[512]={0x2A, 0x2A, 0x2A, 0x2A, 0x2A, 0x10};
|
||||
static byte data2[512]={0x2A, 0x2A, 0x2A, 0x2A, 0x2A, 0x10};
|
||||
static byte *dataptr=data1;
|
||||
|
||||
static uint8_t rxbitc;
|
||||
static int32_t asynst[10]={0};
|
||||
static uint16_t rxbyte;
|
||||
int rxp=0;
|
||||
|
||||
static int haveNewFrame = 0;
|
||||
static int lastFrame = 0;
|
||||
static int headerDetected = 0;
|
||||
|
||||
int RS92::setup(float frequency)
|
||||
{
|
||||
#if RS92_DEBUG
|
||||
Serial.println("Setup sx1278 for RS92 sonde");
|
||||
#endif
|
||||
if(!initialized) {
|
||||
Gencrctab();
|
||||
initrsc();
|
||||
// not here for now.... get_eph("/brdc.19n");
|
||||
initialized = true;
|
||||
}
|
||||
|
||||
if(sx1278.ON()!=0) {
|
||||
RS92_DBG(Serial.println("Setting SX1278 power on FAILED"));
|
||||
return 1;
|
||||
}
|
||||
if(sx1278.setFSK()!=0) {
|
||||
RS92_DBG(Serial.println("Setting FSJ mode FAILED"));
|
||||
return 1;
|
||||
}
|
||||
if(sx1278.setBitrate(4800)!=0) {
|
||||
RS92_DBG(Serial.println("Setting bitrate 4800bit/s FAILED"));
|
||||
return 1;
|
||||
}
|
||||
#if RS92_DEBUG
|
||||
float br = sx1278.getBitrate();
|
||||
Serial.print("Exact bitrate is ");
|
||||
Serial.println(br);
|
||||
#endif
|
||||
if(sx1278.setAFCBandwidth(sonde.config.rs92.rxbw)!=0) {
|
||||
RS92_DBG(Serial.printf("Setting AFC bandwidth %d Hz FAILED", sonde.config.rs92.rxbw));
|
||||
return 1;
|
||||
}
|
||||
if(sx1278.setRxBandwidth(sonde.config.rs92.rxbw)!=0) {
|
||||
RS92_DBG(Serial.printf("Setting RX bandwidth to %d Hz FAILED", sonde.config.rs92.rxbw));
|
||||
return 1;
|
||||
}
|
||||
|
||||
// Enable auto-AFC, auto-AGC, RX Trigger by preamble
|
||||
if(sx1278.setRxConf(0x1E)!=0) {
|
||||
RS92_DBG(Serial.println("Setting RX Config FAILED"));
|
||||
return 1;
|
||||
}
|
||||
// Set autostart_RX to 01, preamble 0, SYNC detect==on, syncsize=3 (==4 byte
|
||||
//char header[] = "0110.0101 0110.0110 1010.0101 1010.1010";
|
||||
|
||||
//const char *SYNC="\x10\xB6\xCA\x11\x22\x96\x12\xF8";
|
||||
//const char *SYNC="\x08\x6D\x53\x88\x44\x69\x48\x1F";
|
||||
// was 0x57
|
||||
//const char *SYNC="\x99\x9A";
|
||||
#if 1
|
||||
// version 1, working with continuous RX
|
||||
const char *SYNC="\x66\x65";
|
||||
if(sx1278.setSyncConf(0x70, 2, (const uint8_t *)SYNC)!=0) {
|
||||
RS92_DBG(Serial.println("Setting SYNC Config FAILED"));
|
||||
return 1;
|
||||
}
|
||||
if(sx1278.setPreambleDetect(0xA8)!=0) {
|
||||
RS92_DBG(Serial.println("Setting PreambleDetect FAILED"));
|
||||
return 1;
|
||||
}
|
||||
#endif
|
||||
#if 0
|
||||
// version 2, with per-packet rx start, untested
|
||||
// header is 2a 10 65, i.e. with lsb first
|
||||
// 0 0101 0100 1 0 0000 1000 1 0 1010 0110 1
|
||||
// 10 10011001 10011010 01 10 10101010 01101010 01 10 01100110 10010110 01
|
||||
// preamble 0x6A 0x66 0x6A
|
||||
// i.e. preamble detector on (0x80), preamble detector size 1 (0x00), preample chip errors??? (0x0A)
|
||||
// after 2a2a2a2a2a1065
|
||||
if(sx1278.setPreambleDetect(0xA8)!=0) {
|
||||
RS92_DBG(Serial.println("Setting PreambleDetect FAILED"));
|
||||
return 1;
|
||||
}
|
||||
// sync config: ato restart (01), preamble polarity AA (0), sync on (1), resevered (0), syncsize 2+1 (010) => 0x52
|
||||
const char *SYNC="\x6A\x66\x69";
|
||||
if(sx1278.setSyncConf(0x52, 3, (const uint8_t *)SYNC)!=0) {
|
||||
RS92_DBG(Serial.println("Setting SYNC Config FAILED"));
|
||||
return 1;
|
||||
}
|
||||
// payload length is ((240 - 7)*10 +6)/8 = 292
|
||||
#endif
|
||||
|
||||
// Packet config 1: fixed len, no mancecer, no crc, no address filter
|
||||
// Packet config 2: packet mode, no home ctrl, no beackn, msb(packetlen)=0)
|
||||
if(sx1278.setPacketConfig(0x08, 0x40)!=0) {
|
||||
RS92_DBG(Serial.println("Setting Packet config FAILED"));
|
||||
return 1;
|
||||
}
|
||||
|
||||
Serial.print("RS92: setting RX frequency to ");
|
||||
Serial.println(frequency);
|
||||
int res = sx1278.setFrequency(frequency);
|
||||
sx1278.clearIRQFlags();
|
||||
|
||||
// enable RX
|
||||
sx1278.setPayloadLength(0); // infinite for now...
|
||||
//sx1278.setPayloadLength(292);
|
||||
sx1278.writeRegister(REG_OP_MODE, FSK_RX_MODE);
|
||||
|
||||
#if RS92_DEBUG
|
||||
RS92_DBG(Serial.println("Setting SX1278 config for RS92 finished\n"); Serial.println());
|
||||
#endif
|
||||
return res;
|
||||
}
|
||||
|
||||
#if 0
|
||||
int RS92::setFrequency(float frequency) {
|
||||
Serial.print("RS92: setting RX frequency to ");
|
||||
Serial.println(frequency);
|
||||
int res = sx1278.setFrequency(frequency);
|
||||
// enable RX
|
||||
sx1278.setPayloadLength(0); // infinite for now...
|
||||
|
||||
sx1278.writeRegister(REG_OP_MODE, FSK_RX_MODE);
|
||||
return res;
|
||||
}
|
||||
#endif
|
||||
|
||||
uint32_t RS92::bits2val(const uint8_t *bits, int len) {
|
||||
uint32_t val = 0;
|
||||
for (int j = 0; j < len; j++) {
|
||||
val |= (bits[j] << (len-1-j));
|
||||
}
|
||||
return val;
|
||||
}
|
||||
|
||||
RS92::RS92() {
|
||||
}
|
||||
|
||||
/* RS92 reed solomon decoder, from dxlAPRS
|
||||
*/
|
||||
|
||||
|
||||
#if 0
|
||||
static char crcrs(const byte frame[], uint32_t frame_len,
|
||||
int32_t from, int32_t to)
|
||||
{
|
||||
uint16_t crc;
|
||||
int32_t i;
|
||||
int32_t tmp;
|
||||
crc = 0xFFFFU;
|
||||
tmp = to-3L;
|
||||
i = from;
|
||||
if (i<=tmp) for (;; i++) {
|
||||
crc = X2C_LSH(crc,16,-8)^CRCTAB[(uint32_t)((crc^(uint16_t)(uint8_t)frame[i])&0xFFU)];
|
||||
if (i==tmp) break;
|
||||
} /* end for */
|
||||
return frame[to-1L]==(char)crc && frame[to-2L]==(char)X2C_LSH(crc,
|
||||
16,-8);
|
||||
} /* end crcrs() */
|
||||
|
||||
static int32_t getint32(const byte frame[], uint32_t frame_len,
|
||||
uint32_t p)
|
||||
{
|
||||
uint32_t n;
|
||||
uint32_t i;
|
||||
n = 0UL;
|
||||
for (i = 3UL;; i--) {
|
||||
n = n*256UL+(uint32_t)(uint8_t)frame[p+i];
|
||||
if (i==0UL) break;
|
||||
} /* end for */
|
||||
return (int32_t)n;
|
||||
} /* end getint32() */
|
||||
|
||||
|
||||
static uint32_t getcard16(const byte frame[], uint32_t frame_len,
|
||||
uint32_t p)
|
||||
{
|
||||
return (uint32_t)(uint8_t)frame[p]+256UL*(uint32_t)(uint8_t)
|
||||
frame[p+1UL];
|
||||
} /* end getcard16() */
|
||||
|
||||
|
||||
static int32_t getint16(const byte frame[], uint32_t frame_len,
|
||||
uint32_t p)
|
||||
{
|
||||
uint32_t n;
|
||||
n = (uint32_t)(uint8_t)frame[p]+256UL*(uint32_t)(uint8_t)
|
||||
frame[p+1UL];
|
||||
if (n>=32768UL) return (int32_t)(n-65536UL);
|
||||
return (int32_t)n;
|
||||
} /* end getint16() */
|
||||
|
||||
static void wgs84r(double x, double y, double z,
|
||||
double * lat, double * long0,
|
||||
double * heig)
|
||||
{
|
||||
double sl;
|
||||
double ct;
|
||||
double st;
|
||||
double t;
|
||||
double rh;
|
||||
double xh;
|
||||
double h;
|
||||
h = x*x+y*y;
|
||||
if (h>0.0) {
|
||||
rh = (double)sqrt((float)h);
|
||||
xh = x+rh;
|
||||
*long0 = atang2(xh, y)*2.0;
|
||||
if (*long0>3.1415926535898) *long0 = *long0-6.2831853071796;
|
||||
t = (double)atan((float)(X2C_DIVL(z*1.003364089821,
|
||||
rh)));
|
||||
st = (double)sin((float)t);
|
||||
ct = (double)cos((float)t);
|
||||
*lat = (double)atan((float)
|
||||
(X2C_DIVL(z+4.2841311513312E+4*st*st*st,
|
||||
rh-4.269767270718E+4*ct*ct*ct)));
|
||||
sl = (double)sin((float)*lat);
|
||||
*heig = X2C_DIVL(rh,(double)cos((float)*lat))-(double)(X2C_DIVR(6.378137E+6f,
|
||||
sqrt((float)(1.0-6.6943799901413E-3*sl*sl))));
|
||||
}
|
||||
else {
|
||||
*lat = 0.0;
|
||||
*long0 = 0.0;
|
||||
*heig = 0.0;
|
||||
}
|
||||
/* lat:=atan(z/(rh*(1.0 - E2))); */
|
||||
/* heig:=sqrt(h + z*z) - EARTHA; */
|
||||
} /* end wgs84r() */
|
||||
#endif
|
||||
|
||||
|
||||
static int32_t reedsolomon92(uint8_t *buf, uint32_t buf_len)
|
||||
{
|
||||
uint32_t i;
|
||||
int32_t res;
|
||||
uint8_t b[256];
|
||||
uint32_t eraspos[24];
|
||||
for (i = 0UL; i<=255UL; i++) {
|
||||
b[i] = 0;
|
||||
} /* end for */
|
||||
for (i = 0UL; i<=209UL; i++) {
|
||||
b[230UL-i] = buf[i+6UL];
|
||||
} /* end for */
|
||||
for (i = 0UL; i<=23UL; i++) {
|
||||
b[254UL-i] = buf[i+216UL];
|
||||
} /* end for */
|
||||
res = decodersc((char *)b, eraspos, 0L);
|
||||
if (res>0L && res<=12L) {
|
||||
for (i = 0UL; i<=209UL; i++) {
|
||||
buf[i+6UL] = b[230UL-i];
|
||||
} /* end for */
|
||||
for (i = 0UL; i<=23UL; i++) {
|
||||
buf[i+216UL] = b[254UL-i];
|
||||
} /* end for */
|
||||
}
|
||||
return res;
|
||||
} /* end reedsolomon92() */
|
||||
|
||||
void printRaw(uint8_t *data, int len)
|
||||
{
|
||||
char buf[3];
|
||||
int i;
|
||||
for(i=0; i<len; i++) {
|
||||
snprintf(buf, 3, "%02X", data[i]);
|
||||
Serial.print(buf);
|
||||
}
|
||||
Serial.println();
|
||||
}
|
||||
|
||||
void RS92::decodeframe92(uint8_t *data)
|
||||
{
|
||||
//uint32_t gpstime;
|
||||
//uint32_t flen;
|
||||
//uint32_t j;
|
||||
int32_t corr;
|
||||
corr = reedsolomon92(data, 301ul);
|
||||
//int calok;
|
||||
//int mesok;
|
||||
//uint32_t calibok;
|
||||
lastFrame = (dataptr==data1)?1:2;
|
||||
Serial.printf("rs corr is %d --- data:%p data1:%p data2:%p lastframe=%d\n", corr, data, data1, data2, lastFrame);
|
||||
dataptr = (dataptr==data1)?data2:data1;
|
||||
//print_frame(data, 240);
|
||||
#if 0
|
||||
/* from sondemod*/
|
||||
int p=6;
|
||||
while(1) {
|
||||
uint8_t typ = data[p];
|
||||
if(typ==0xff) break;
|
||||
++p;
|
||||
int len = ((uint32_t)data[p])*2 + 2;
|
||||
Serial.printf("type %c: len=%d\n", typ, len);
|
||||
//printRaw(data+p, len+2);
|
||||
if(len>240) {
|
||||
Serial.print("RS92 frame too long: ");
|
||||
Serial.println(len);
|
||||
break;
|
||||
}
|
||||
++p;
|
||||
j=0;
|
||||
uint16_t crc = 0xFFFF;
|
||||
while(j<len) {
|
||||
if(j < len-2) {
|
||||
for(int ic = 0; ic<=7; ic++) {
|
||||
if (((0x8000&crc)!=0) != ( ((1<<(7-ic))&data[p])!=0 )) {
|
||||
crc <<= 1;
|
||||
crc ^= 0x1021;
|
||||
} else {
|
||||
crc <<= 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
++p;
|
||||
++j;
|
||||
if(p>240) {
|
||||
Serial.println("eof");
|
||||
return;
|
||||
}
|
||||
}
|
||||
if ( (((uint8_t)(crc&0xff)) != data[p-2]) || (((uint8_t)(crc>>8)) != data[p-1])) {
|
||||
Serial.printf("************ crc error: expected %04x\n",crc);
|
||||
continue;
|
||||
}
|
||||
switch(typ) {
|
||||
case 'e':
|
||||
Serial.println("cal ");
|
||||
//docalib(sf, 256, objname, 9, &contextr9, &mhz, &frameno);
|
||||
// ...
|
||||
break;
|
||||
case 'i':
|
||||
if(calok && calibok==0xffffffff) {
|
||||
//domes(sf, 256, &hp, &hyg, &temp)
|
||||
mesok = 1;
|
||||
}
|
||||
break;
|
||||
case 'g':
|
||||
Serial.println("gps ");
|
||||
if(1||calok) {
|
||||
//dogps(data+p-len, 256, &contextr9, &contextr9.timems, &gpstime);
|
||||
}
|
||||
break;
|
||||
case 'h':
|
||||
Serial.println("data "); break;
|
||||
if(data[p+2]!=3) Serial.println("aux ");
|
||||
// ..
|
||||
break;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
} /* end decodeframe92() */
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void RS92::printRaw(uint8_t *data, int len)
|
||||
{
|
||||
char buf[3];
|
||||
int i;
|
||||
for(i=0; i<len; i++) {
|
||||
snprintf(buf, 3, "%02X", data[i]);
|
||||
Serial.print(buf);
|
||||
}
|
||||
Serial.println();
|
||||
}
|
||||
|
||||
#if 0
|
||||
// I guess this is old copy&paste stuff from RS41??
|
||||
int RS92::bitsToBytes(uint8_t *bits, uint8_t *bytes, int len)
|
||||
{
|
||||
int i;
|
||||
for(i=0; i<len*4; i++) {
|
||||
bytes[i/8] = (bytes[i/8]<<1) | (bits[i]?1:0);
|
||||
}
|
||||
bytes[(i-1)/8] &= 0x0F;
|
||||
}
|
||||
|
||||
static unsigned char lookup[16] = {
|
||||
0x0, 0x8, 0x4, 0xc, 0x2, 0xa, 0x6, 0xe,
|
||||
0x1, 0x9, 0x5, 0xd, 0x3, 0xb, 0x7, 0xf, };
|
||||
|
||||
static uint8_t reverse(uint8_t n) {
|
||||
return (lookup[n&0x0f] << 4) | lookup[n>>4];
|
||||
}
|
||||
|
||||
|
||||
static uint8_t scramble[64] = {150U,131U,62U,81U,177U,73U,8U,152U,50U,5U,89U,
|
||||
14U,249U,68U,198U,38U,33U,96U,194U,234U,121U,93U,109U,161U,
|
||||
84U,105U,71U,12U,220U,232U,92U,241U,247U,118U,130U,127U,7U,
|
||||
153U,162U,44U,147U,124U,48U,99U,245U,16U,46U,97U,208U,188U,
|
||||
180U,182U,6U,170U,244U,35U,120U,110U,59U,174U,191U,123U,76U,
|
||||
193U};
|
||||
#endif
|
||||
|
||||
|
||||
void RS92::stobyte92(uint8_t b)
|
||||
{
|
||||
dataptr[rxp] = b;
|
||||
if(rxp>=5 || b=='*') rxp++; else rxp=0;
|
||||
if(rxp==6) { // header detected
|
||||
headerDetected = 1;
|
||||
}
|
||||
if(rxp>=240) { // frame complete... (240 byte)
|
||||
rxp=0;
|
||||
//printRaw(data, 240);
|
||||
decodeframe92(dataptr);
|
||||
haveNewFrame = 1;
|
||||
}
|
||||
} /* end stobyte92() */
|
||||
|
||||
|
||||
uint32_t rxdata;
|
||||
bool rxsearching=true;
|
||||
|
||||
// search for
|
||||
// 101001100110011010011010011001100110100110101010100110101001
|
||||
// 1010011001100110100110100110 0110.0110 1001.1010 1010.1001 1010.1001 => 0x669AA9A9
|
||||
void RS92::process8N1data(uint8_t dt)
|
||||
{
|
||||
for(int i=0; i<8; i++) {
|
||||
uint8_t d = (dt&0x80)?1:0;
|
||||
rxdata = (rxdata<<1) | d;
|
||||
if((rxbitc&1)==1) { rxbyte = (rxbyte>>1) + (d<<9); } // mancester decoded data
|
||||
dt <<= 1;
|
||||
//
|
||||
if(rxsearching) {
|
||||
if(rxdata == 0x669AA9A9) {
|
||||
rxsearching = false;
|
||||
rxbitc = 0;
|
||||
rxp = 6;
|
||||
int rssi=sx1278.getRSSI();
|
||||
int fei=sx1278.getFEI();
|
||||
int afc=sx1278.getAFC();
|
||||
Serial.print("Test: RSSI="); Serial.print(rssi);
|
||||
Serial.print(" FEI="); Serial.print(fei);
|
||||
Serial.print(" AFC="); Serial.println(afc);
|
||||
sonde.si()->rssi = rssi;
|
||||
sonde.si()->afc = afc;
|
||||
}
|
||||
} else {
|
||||
rxbitc = (rxbitc+1)%20;
|
||||
if(rxbitc == 0) { // got startbit, 8 data bit, stop bit
|
||||
//Serial.printf("%03x ",rxbyte);
|
||||
dataptr[rxp++] = (rxbyte>>1)&0xff;
|
||||
if(rxp==7 && dataptr[6] != 0x65) {
|
||||
Serial.printf("wrong start: %02x\n",dataptr[6]);
|
||||
rxsearching = true;
|
||||
}
|
||||
if(rxp>=240) {
|
||||
rxsearching = true;
|
||||
decodeframe92(dataptr);
|
||||
haveNewFrame = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void process8N1dataOrig(uint8_t data)
|
||||
{
|
||||
// data contains 8 bits (after mancester encoding; 4 real bit), big endian
|
||||
for(int i=0; i<4; i++) {
|
||||
uint8_t d = (data&0x80)?1:0;
|
||||
data = data << 2;
|
||||
rxbyte = (rxbyte>>1) + (d<<8);
|
||||
int maxk = 0;
|
||||
int max0 = 0;
|
||||
for(int k = 0; k< 10; k++) {
|
||||
int n = asynst[k] - asynst[(k+1)%10];
|
||||
if(abs(n)>abs(max0)) {
|
||||
max0 = n;
|
||||
maxk = k;
|
||||
}
|
||||
}
|
||||
//Serial.printf("<%d,%d,%d>",max0,maxk,rxbitc);
|
||||
if(rxbitc == maxk) {
|
||||
if(max0<0) { rxbyte = rxbyte ^ 0xFF; }
|
||||
/////TODO stobyte92( rxbyte&0xff );
|
||||
}
|
||||
//Serial.printf("%d:",asynst[rxbitc]);
|
||||
if(d) {
|
||||
asynst[rxbitc] += (32767-asynst[rxbitc])/16;
|
||||
} else {
|
||||
asynst[rxbitc] -= (32767+asynst[rxbitc])/16;
|
||||
}
|
||||
//Serial.printf("%d ",asynst[rxbitc]);
|
||||
rxbitc = (rxbitc+1) % 10;
|
||||
}
|
||||
}
|
||||
|
||||
int RS92::receive() {
|
||||
unsigned long t0 = millis();
|
||||
Serial.printf("RS92::receive() start at %ld\n",t0);
|
||||
while( millis() - t0 < 1000 ) {
|
||||
uint8_t value = sx1278.readRegister(REG_IRQ_FLAGS2);
|
||||
if ( bitRead(value, 7) ) {
|
||||
Serial.println("FIFO full");
|
||||
}
|
||||
if ( bitRead(value, 4) ) {
|
||||
Serial.println("FIFO overflow");
|
||||
}
|
||||
if ( bitRead(value, 2) == 1 ) {
|
||||
Serial.println("FIFO: ready()");
|
||||
sx1278.clearIRQFlags();
|
||||
}
|
||||
if(bitRead(value, 6) == 0) { // while FIFO not empty
|
||||
byte data = sx1278.readRegister(REG_FIFO);
|
||||
//Serial.printf("%02x",data);
|
||||
process8N1data(data);
|
||||
value = sx1278.readRegister(REG_IRQ_FLAGS2);
|
||||
} else {
|
||||
if(headerDetected) {
|
||||
t0 = millis(); // restart timer... don't time out if header detected...
|
||||
headerDetected = 0;
|
||||
}
|
||||
if(haveNewFrame) {
|
||||
Serial.printf("RS92::receive(): new frame complete after %ldms\n", millis()-t0);
|
||||
haveNewFrame = 0;
|
||||
return RX_OK;
|
||||
}
|
||||
delay(2);
|
||||
}
|
||||
}
|
||||
Serial.printf("RS92::receive() timed out\n");
|
||||
return RX_TIMEOUT; // TODO RX_OK;
|
||||
}
|
||||
|
||||
#define RS92MAXLEN (240)
|
||||
int RS92::waitRXcomplete() {
|
||||
// called after complete...
|
||||
Serial.printf("decoding frame %d\n", lastFrame);
|
||||
print_frame(lastFrame==1?data1:data2, 240);
|
||||
|
||||
SondeInfo *si = sonde.sondeList+rxtask.receiveSonde;
|
||||
si->lat = gpx.lat;
|
||||
si->lon = gpx.lon;
|
||||
si->alt = gpx.alt;
|
||||
si->vs = gpx.vU;
|
||||
si->hs = gpx.vH;
|
||||
si->dir = gpx.vD;
|
||||
si->validPos = 0x3f;
|
||||
memcpy(si->id, gpx.id, 9);
|
||||
memcpy(si->ser, gpx.id, 9);
|
||||
si->validID = true;
|
||||
si->frame = gpx.frnr;
|
||||
si->sats = gpx.k;
|
||||
si->time = (gpx.gpssec/1000) + 86382 + gpx.week*604800 + 315878400UL;
|
||||
si->validTime = true;
|
||||
|
||||
#if 0
|
||||
int res=0;
|
||||
uint32_t t0 = millis();
|
||||
while( rxtask.receiveResult == 0xFFFF && millis()-t0 < 2000) { delay(20); }
|
||||
|
||||
if( rxtask.receiveResult<0 || rxtask.receiveResult==RX_TIMEOUT) {
|
||||
res = RX_TIMEOUT;
|
||||
} else if ( rxtask.receiveResult==0) {
|
||||
res = RX_OK;
|
||||
} else {
|
||||
res = RX_ERROR;
|
||||
}
|
||||
rxtask.receiveResult = 0xFFFF;
|
||||
Serial.printf("RS92::waitRXcomplete returning %d (%s)\n", res, RXstr[res]);
|
||||
return res;
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
#if 0
|
||||
int oldwaitRXcomplete() {
|
||||
Serial.println("RS92: receive frame...\n");
|
||||
sx1278receiveData = true;
|
||||
delay(6000); // done in other task....
|
||||
//sx1278receiveData = false;
|
||||
#if 0
|
||||
//sx1278.setPayloadLength(518-8); // Expect 320-8 bytes or 518-8 bytes (8 byte header)
|
||||
//sx1278.setPayloadLength(0); // infinite for now...
|
||||
|
||||
////// test code for continuous reception
|
||||
// sx1278.receive(); /// active FSK RX mode -- already done above...
|
||||
uint8_t value = sx1278.readRegister(REG_IRQ_FLAGS2);
|
||||
unsigned long previous = millis();
|
||||
|
||||
byte ready=0;
|
||||
uint32_t wait = 8000;
|
||||
// while not yet done or FIFO not yet empty
|
||||
// bit 6: FIFO Empty
|
||||
// bit 2 payload ready
|
||||
int by=0;
|
||||
while( (!ready || bitRead(value,6)==0) && (millis() - previous < wait) )
|
||||
{
|
||||
if( bitRead(value, 7) ) { Serial.println("FIFO full"); }
|
||||
if( bitRead(value, 4) ) { Serial.println("FIFO overflow"); }
|
||||
if( bitRead(value,2)==1 ) ready=1;
|
||||
if( bitRead(value, 6) == 0 ) { // FIFO not empty
|
||||
byte data = sx1278.readRegister(REG_FIFO);
|
||||
process8N1data(data);
|
||||
by++;
|
||||
#if 0
|
||||
if(di==1) {
|
||||
int rssi=getRSSI();
|
||||
int fei=getFEI();
|
||||
int afc=getAFC();
|
||||
Serial.print("Test: RSSI="); Serial.println(rssi);
|
||||
Serial.print("Test: FEI="); Serial.println(fei);
|
||||
Serial.print("Test: AFC="); Serial.println(afc);
|
||||
sonde.si()->rssi = rssi;
|
||||
sonde.si()->afc = afc;
|
||||
}
|
||||
if(di>520) {
|
||||
// TODO
|
||||
Serial.println("TOO MUCH DATA");
|
||||
break;
|
||||
}
|
||||
previous = millis(); // reset timeout after receiving data
|
||||
#endif
|
||||
}
|
||||
value = sx1278.readRegister(REG_IRQ_FLAGS2);
|
||||
}
|
||||
Serial.printf("processed %d bytes before end/timeout\n", by);
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
/////
|
||||
#if 0
|
||||
int e = sx1278.receivePacketTimeout(1000, data+8);
|
||||
if(e) { Serial.println("TIMEOUT"); return RX_TIMEOUT; } //if timeout... return 1
|
||||
|
||||
printRaw(data, RS92MAXLEN);
|
||||
//for(int i=0; i<RS92MAXLEN; i++) { data[i] = reverse(data[i]); }
|
||||
//printRaw(data, MAXLEN);
|
||||
//for(int i=0; i<RS92MAXLEN; i++) { data[i] = data[i] ^ scramble[i&0x3F]; }
|
||||
//printRaw(data, MAXLEN);
|
||||
//int res = decode41(data, RS92MAXLEN);
|
||||
#endif
|
||||
int res=0;
|
||||
return res==0 ? RX_OK : RX_ERROR;
|
||||
}
|
||||
#endif
|
||||
|
||||
RS92 rs92 = RS92();
|
||||
Executable
+96
@@ -0,0 +1,96 @@
|
||||
/*
|
||||
* RS92.h
|
||||
* Functions for decoding RS92 sondes with SX127x chips
|
||||
* Copyright (C) 2019 Hansi Reiser, dl9rdz
|
||||
*
|
||||
* SPDX-License-Identifier: GPL-2.0+
|
||||
*/
|
||||
|
||||
#ifndef RS92_h
|
||||
#define RS92_h
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdint.h>
|
||||
#include <Arduino.h>
|
||||
#ifndef inttypes_h
|
||||
#include <inttypes.h>
|
||||
#endif
|
||||
|
||||
|
||||
struct CONTEXTR9 {
|
||||
char calibdata[512];
|
||||
uint32_t calibok;
|
||||
char mesok;
|
||||
char posok;
|
||||
char framesent;
|
||||
double lat;
|
||||
double lon;
|
||||
double heig;
|
||||
double speed;
|
||||
double dir;
|
||||
double climb;
|
||||
double lastlat;
|
||||
double laslong;
|
||||
double lastalt;
|
||||
double lastspeed;
|
||||
double lastdir;
|
||||
double lastclb;
|
||||
float hrmsc;
|
||||
float vrmsc;
|
||||
double hp;
|
||||
double hyg;
|
||||
double temp;
|
||||
double ozontemp;
|
||||
double ozon;
|
||||
uint32_t goodsats;
|
||||
uint32_t timems;
|
||||
uint32_t framenum;
|
||||
};
|
||||
|
||||
|
||||
/* Main class */
|
||||
class RS92
|
||||
{
|
||||
private:
|
||||
void process8N1data(uint8_t data);
|
||||
void stobyte92(uint8_t byte);
|
||||
void decodeframe92(uint8_t *data);
|
||||
#if 0
|
||||
void dogps(const uint8_t *sf, int sf_len,
|
||||
struct CONTEXTR9 * cont, uint32_t * timems,
|
||||
uint32_t * gpstime);
|
||||
#endif
|
||||
uint32_t bits2val(const uint8_t *bits, int len);
|
||||
void printRaw(uint8_t *data, int len);
|
||||
int bitsToBytes(uint8_t *bits, uint8_t *bytes, int len);
|
||||
int decode92(byte *data, int maxlen);
|
||||
|
||||
uint8_t hamming_conf[ 7*8]; // 7*8=56
|
||||
uint8_t hamming_dat1[13*8]; // 13*8=104
|
||||
uint8_t hamming_dat2[13*8];
|
||||
|
||||
uint8_t block_conf[ 7*4]; // 7*4=28
|
||||
uint8_t block_dat1[13*4]; // 13*4=52
|
||||
uint8_t block_dat2[13*4];
|
||||
|
||||
uint8_t H[4][8] = // extended Hamming(8,4) particy check matrix
|
||||
{{ 0, 1, 1, 1, 1, 0, 0, 0},
|
||||
{ 1, 0, 1, 1, 0, 1, 0, 0},
|
||||
{ 1, 1, 0, 1, 0, 0, 1, 0},
|
||||
{ 1, 1, 1, 0, 0, 0, 0, 1}};
|
||||
uint8_t He[8] = { 0x7, 0xB, 0xD, 0xE, 0x8, 0x4, 0x2, 0x1}; // Spalten von H:
|
||||
// 1-bit-error-Syndrome
|
||||
boolean initialized = false;
|
||||
|
||||
public:
|
||||
RS92();
|
||||
int setup(float frequency);
|
||||
int receive();
|
||||
int waitRXcomplete();
|
||||
|
||||
int use_ecc = 1;
|
||||
};
|
||||
|
||||
extern RS92 rs92;
|
||||
|
||||
#endif
|
||||
Executable
+113
@@ -0,0 +1,113 @@
|
||||
#include "Scanner.h"
|
||||
#include <SX1278FSK.h>
|
||||
#include <U8x8lib.h>
|
||||
|
||||
#include "Sonde.h"
|
||||
#include "Display.h"
|
||||
|
||||
#define CHANBW 10
|
||||
#define PIXSAMPL (50/CHANBW)
|
||||
#define SMOOTH 3
|
||||
//#define STARTF 401000000
|
||||
#define NCHAN ((int)(6000/CHANBW))
|
||||
|
||||
double STARTF = (sonde.config.startfreq * 1000000);
|
||||
//int CHANBW = (sonde.config.channelbw);
|
||||
//int NCHAN = ((int)(6000/CHANBW));
|
||||
//int PIXSAMPL = (50/CHANBW);
|
||||
|
||||
int scanresult[NCHAN];
|
||||
int scandisp[NCHAN/PIXSAMPL];
|
||||
|
||||
#define PLOT_N 128
|
||||
#define TICK1 (128/6)
|
||||
#define TICK2 (TICK1/4)
|
||||
//#define PLOT_MIN -250
|
||||
#define PLOT_MIN (sonde.config.noisefloor*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};
|
||||
void Scanner::fillTiles(uint8_t *row, int value) {
|
||||
for(int y=0; y<8; y++) {
|
||||
int nbits = value - 8*(7-y);
|
||||
if(nbits<0) { row[8*y]=0; continue; }
|
||||
if(nbits>=8) { row[8*y]=255; continue; }
|
||||
row[8*y] = tilepatterns[nbits];
|
||||
}
|
||||
}
|
||||
/*
|
||||
* There are 16*8 columns to plot, NPLOT must be lower than that
|
||||
* currently, we use 128 * 50kHz channels
|
||||
* There are 8*8 values to plot; MIN is bottom end,
|
||||
*/
|
||||
uint8_t tiles[16] = { 0x0f,0x0f,0x0f,0x0f,0xf0,0xf0,0xf0,0xf0, 1, 3, 7, 15, 31, 63, 127, 255};
|
||||
void Scanner::plotResult()
|
||||
{
|
||||
uint8_t row[8*8];
|
||||
for(int i=0; i<PLOT_N; i+=8) {
|
||||
for(int j=0; j<8; j++) {
|
||||
fillTiles(row+j, PLOT_SCALE(scandisp[i+j]));
|
||||
if( ((i+j)%TICK1)==0) { row[j] |= 0x07; }
|
||||
if( ((i+j)%TICK2)==0) { row[j] |= 0x01; }
|
||||
}
|
||||
for(int y=0; y<8; y++) {
|
||||
if(sonde.config.marker && y==1) {
|
||||
// don't overwrite MHz marker text
|
||||
if(i<3*8 || (i>=7*8&&i<10*8) || i>=13*8) continue;
|
||||
}
|
||||
disp.rdis->drawTile(i/8, y, 1, row+8*y);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Scanner::scan()
|
||||
{
|
||||
// Configure
|
||||
sx1278.writeRegister(REG_PLL_HOP, 0x80); // FastHopOn
|
||||
sx1278.setRxBandwidth(CHANBW*1000);
|
||||
sx1278.writeRegister(REG_RSSI_CONFIG, SMOOTH&0x07);
|
||||
sx1278.setFrequency(STARTF);
|
||||
sx1278.writeRegister(REG_OP_MODE, FSK_RX_MODE);
|
||||
delay(20);
|
||||
|
||||
unsigned long start = millis();
|
||||
uint32_t lastfrf=-1;
|
||||
for(int iter=0; iter<2; iter++) { // two interations, to catch all RS41 transmissions
|
||||
for(int i=0; i<NCHAN; i++) {
|
||||
float freq = STARTF + 1000.0*i*CHANBW;
|
||||
uint32_t frf = freq * 1.0 * (1<<19) / SX127X_CRYSTAL_FREQ;
|
||||
if( (lastfrf>>16)!=(frf>>16) ) {
|
||||
sx1278.writeRegister(REG_FRF_MSB, (frf&0xff0000)>>16);
|
||||
}
|
||||
if( ((lastfrf&0x00ff00)>>8) != ((frf&0x00ff00)>>8) ) {
|
||||
sx1278.writeRegister(REG_FRF_MID, (frf&0x00ff00)>>8);
|
||||
}
|
||||
sx1278.writeRegister(REG_FRF_LSB, (frf&0x0000ff));
|
||||
lastfrf = frf;
|
||||
// Wait TS_HOP (20us) + TS_RSSI ( 2^(SMOOTH+1) / 4 / CHANBW us)
|
||||
int wait = 20 + 1000*(1<<(SMOOTH+1))/4/CHANBW;
|
||||
delayMicroseconds(wait+5);
|
||||
int rssi = -(int)sx1278.readRegister(REG_RSSI_VALUE_FSK);
|
||||
if(iter==0) { scanresult[i] = rssi; } else {
|
||||
if(rssi>scanresult[i]) scanresult[i]=rssi;
|
||||
}
|
||||
}
|
||||
}
|
||||
unsigned long duration = millis()-start;
|
||||
Serial.print("Scan time: ");
|
||||
Serial.println(duration);
|
||||
for(int i=0; i<NCHAN; i+=PIXSAMPL) {
|
||||
scandisp[i/PIXSAMPL]=scanresult[i];
|
||||
for(int j=1; j<PIXSAMPL; j++) { scandisp[i/PIXSAMPL]+=scanresult[i+j]; }
|
||||
//for(int j=1; j<PIXSAMPL; j++) { if(scanresult[i+j]>scandisp[i/PIXSAMPL]) scandisp[i/PIXSAMPL] = scanresult[i+j]; }
|
||||
Serial.print(scanresult[i]); Serial.print(", ");
|
||||
}
|
||||
Serial.println("\n");
|
||||
for(int i=0; i<NCHAN/PIXSAMPL; i++) {
|
||||
scandisp[i]/=PIXSAMPL;
|
||||
Serial.print(scandisp[i]); Serial.print(", ");
|
||||
}
|
||||
Serial.println("\n");
|
||||
}
|
||||
|
||||
Scanner scanner = Scanner();
|
||||
Executable
+24
@@ -0,0 +1,24 @@
|
||||
|
||||
|
||||
#ifndef _SCANNER_H
|
||||
#define _SCANNER_H
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdint.h>
|
||||
#include <Arduino.h>
|
||||
#ifndef inttypes_h
|
||||
#include <inttypes.h>
|
||||
#endif
|
||||
|
||||
class Scanner
|
||||
{
|
||||
private:
|
||||
void fillTiles(uint8_t *row, int value);
|
||||
|
||||
public:
|
||||
void plotResult();
|
||||
void scan(void);
|
||||
};
|
||||
|
||||
extern Scanner scanner;
|
||||
#endif
|
||||
Executable
+688
@@ -0,0 +1,688 @@
|
||||
#include <U8x8lib.h>
|
||||
#include <U8g2lib.h>
|
||||
|
||||
#include "Sonde.h"
|
||||
#include "RS41.h"
|
||||
#include "RS92.h"
|
||||
#include "DFM.h"
|
||||
#include "M10.h"
|
||||
#include "SX1278FSK.h"
|
||||
#include "Display.h"
|
||||
#include <Wire.h>
|
||||
|
||||
extern SX1278FSK sx1278;
|
||||
|
||||
RXTask rxtask = { -1, -1, -1, 0xFFFF, 0 };
|
||||
|
||||
const char *evstring[]={"NONE", "KEY1S", "KEY1D", "KEY1M", "KEY1L", "KEY2S", "KEY2D", "KEY2M", "KEY2L",
|
||||
"VIEWTO", "RXTO", "NORXTO", "(max)"};
|
||||
|
||||
const char *RXstr[]={"RX_OK", "RX_TIMEOUT", "RX_ERROR", "RX_UNKNOWN"};
|
||||
|
||||
int fingerprintValue[]={ 17, 31, 64, 4, 55, 48, 23, 128+23, -1 };
|
||||
const char *fingerprintText[]={
|
||||
"TTGO T-Beam (new version 1.0), I2C not working after powerup, assuming 0.9\" OLED@21,22",
|
||||
"TTGO LORA32 v2.1_1.6 (0.9\" OLED@21,22)",
|
||||
"TTGO LORA v1.0 (0.9\" OLED@4,15)",
|
||||
"Heltec v1/v2 (0.9\"OLED@4,15)",
|
||||
"TTGO T-Beam (old version), 0.9\" OLED@21,22",
|
||||
"TTGO T-Beam (old version), SPI TFT@4,21,22",
|
||||
"TTGO T-Beam (new version 1.0), 0.9\" OLED@21,22",
|
||||
"TTGO T-Beam (new version 1.0), SPI TFT@4,13,14",
|
||||
};
|
||||
|
||||
int getKeyPressEvent(); /* in RX_FSK.ino */
|
||||
|
||||
/* Task model:
|
||||
* There is a background task for all SX1278 interaction.
|
||||
* - On startup and on each mode/frequency change (requested by setting requestNextSonde
|
||||
* to an sonde index >=0) it calls Sonde::setup(), which will call the new decoder's
|
||||
* setup function. Setup will update the value currentSonde.
|
||||
* - Periodically it calls Sonde::receive(), which calls the current decoder's receive()
|
||||
* function. It should return control to the SX1278 main loop at least once per second.
|
||||
* It will also set the internal variable receiveResult. The decoder's receive function
|
||||
* must make sure that there are no FIFI overflows in the SX1278.
|
||||
* - the Arduino main loop will call the waitRXcomplete function, which should return as
|
||||
* soon as there is some new data to display, or no later than after 1s, returning the
|
||||
* value of receiveResult (or timeout, if receiveResult was not set within 1s). It
|
||||
* should also return immediately if there is some keyboard input.
|
||||
*/
|
||||
int initlevels[40];
|
||||
|
||||
Sonde::Sonde() {
|
||||
for (int i = 0; i < 39; i++) {
|
||||
initlevels[i] = gpio_get_level((gpio_num_t)i);
|
||||
}
|
||||
}
|
||||
|
||||
void Sonde::defaultConfig() {
|
||||
fingerprint = initlevels[4];
|
||||
fingerprint = (fingerprint<<1) | initlevels[12];
|
||||
fingerprint = (fingerprint<<1) | initlevels[16];
|
||||
fingerprint = (fingerprint<<1) | initlevels[17];
|
||||
fingerprint = (fingerprint<<1) | initlevels[21];
|
||||
fingerprint = (fingerprint<<1) | initlevels[22];
|
||||
fingerprint = (fingerprint<<1) | initlevels[23];
|
||||
Serial.printf("Board fingerprint is %d\n", fingerprint);
|
||||
|
||||
sondeList = (SondeInfo *)malloc((MAXSONDE+1)*sizeof(SondeInfo));
|
||||
memset(sondeList, 0, (MAXSONDE+1)*sizeof(SondeInfo));
|
||||
config.touch_thresh = 70;
|
||||
config.led_pout = -1;
|
||||
config.power_pout = -1;
|
||||
config.spectrum=10;
|
||||
// Try autodetecting board type
|
||||
// Seems like on startup, GPIO4 is 1 on v1 boards, 0 on v2.1 boards?
|
||||
config.gpsOn=0;
|
||||
config.gps_rxd = -1;
|
||||
config.gps_txd = -1;
|
||||
strcpy(config.gps_lat,"43.591");
|
||||
strcpy(config.gps_lon,"7.100");
|
||||
config.gps_alt=123;
|
||||
config.gps_Lat=0;
|
||||
config.gps_Lon=0;
|
||||
config.gps_Alt=0;
|
||||
config.oled_rst = 16;
|
||||
config.disptype = 0;
|
||||
config.oled_orient = 1;
|
||||
config.button2_axp = 0;
|
||||
config.norx_timeout = 20;
|
||||
if(initlevels[16]==0) {
|
||||
config.oled_sda = 4;
|
||||
config.oled_scl = 15;
|
||||
config.button_pin = 0;
|
||||
config.button2_pin = T4 + 128; // T4 == GPIO13
|
||||
config.power_pout = 21; // for Heltec v2
|
||||
config.led_pout = 2;
|
||||
Serial.println("Autoconfig: looks like TTGO v1 / Heltec v1/V2 board");
|
||||
} else {
|
||||
config.oled_sda = 21;
|
||||
config.oled_scl = 22;
|
||||
if(initlevels[17]==0) { // T-Beam
|
||||
if(initlevels[12]==0) { // T-Beam v1.0
|
||||
Serial.println("Autoconfig: looks like T-Beam 1.0 board");
|
||||
config.button_pin = 38;
|
||||
config.button2_pin = 15 + 128; //T4 + 128; // T4 = GPIO13
|
||||
// Maybe in future use as default only PWR as button2?
|
||||
//config.button2_pin = 255;
|
||||
config.button2_axp = 1;
|
||||
config.gps_rxd = 34;
|
||||
// Check for I2C-Display@21,22
|
||||
#define SSD1306_ADDRESS 0x3c
|
||||
Wire.begin(21, 22);
|
||||
Wire.beginTransmission(SSD1306_ADDRESS);
|
||||
byte err = Wire.endTransmission();
|
||||
delay(100); // otherwise its too fast?!
|
||||
Wire.beginTransmission(SSD1306_ADDRESS);
|
||||
err = Wire.endTransmission();
|
||||
if(err!=0 && fingerprint!=17) { // hmm. 17 after powerup with oled commected and no i2c answer!?!?
|
||||
fingerprint |= 128;
|
||||
Serial.println("no I2C display found, assuming large TFT display\n");
|
||||
// CS=0, RST=14, RS=2, SDA=4, CLK=13
|
||||
Serial.println("... with large TFT display\n");
|
||||
config.disptype = 1;
|
||||
config.oled_sda = 4;
|
||||
config.oled_scl = 13;
|
||||
config.oled_rst = 14;
|
||||
config.spectrum = -1; // no spectrum for now on large display
|
||||
} else {
|
||||
// OLED display, pins 21,22 ok...
|
||||
config.disptype = 0;
|
||||
Serial.println("... with small OLED display\n");
|
||||
}
|
||||
} else {
|
||||
Serial.println("Autoconfig: looks like T-Beam v0.7 board");
|
||||
config.button_pin = 39;
|
||||
config.button2_pin = T4 + 128; // T4 == GPIO13
|
||||
config.gps_rxd = 12;
|
||||
// Check if we possibly have a large display
|
||||
if(initlevels[21]==0) {
|
||||
Serial.println("Autoconfig: looks like T-Beam v0.7 board with large TFT display");
|
||||
config.disptype = 1;
|
||||
config.oled_sda = 4;
|
||||
config.oled_scl = 21;
|
||||
config.oled_rst = 22;
|
||||
config.spectrum = -1; // no spectrum for now on large display
|
||||
}
|
||||
}
|
||||
} else {
|
||||
config.button_pin = 2 + 128; // GPIO2 / T2
|
||||
config.button2_pin = 14 + 128; // GPIO14 / T6
|
||||
config.led_pout = 25;
|
||||
}
|
||||
}
|
||||
//
|
||||
config.noisefloor = -125;
|
||||
config.gainLNA=0;
|
||||
strcpy(config.call,"NOCALL");
|
||||
strcpy(config.passcode, "---");
|
||||
strcpy(config.mdnsname, "radiosonde");
|
||||
strcpy(config.vbatmax,"1.84");
|
||||
strcpy(config.vbatmin,"1.64");
|
||||
config.telemetryOn=0;
|
||||
config.buzzerOn=0;
|
||||
config.buzzerFreq=700;
|
||||
config.buzzerPort=12;
|
||||
config.dbsmetre=0;
|
||||
config.degdec=0;
|
||||
config.maxsonde=15;
|
||||
config.debug=0;
|
||||
config.wifi=1;
|
||||
config.wifiap=1;
|
||||
config.display[0]=0;
|
||||
config.display[1]=1;
|
||||
config.display[2]=-1;
|
||||
config.startfreq=400;
|
||||
config.channelbw=10;
|
||||
config.marker=0;
|
||||
config.showafc=0;
|
||||
config.freqofs=0;
|
||||
config.rs41.agcbw=12500;
|
||||
config.rs41.rxbw=6300;
|
||||
config.rs92.rxbw=12500;
|
||||
config.rs92.alt2d=480;
|
||||
config.dfm.agcbw=20800;
|
||||
config.dfm.rxbw=10400;
|
||||
config.udpfeed.active = 1;
|
||||
config.udpfeed.type = 0;
|
||||
strcpy(config.udpfeed.host, "fra1od.fr.to");
|
||||
strcpy(config.udpfeed.symbol, "/O");
|
||||
config.udpfeed.port = 14580;
|
||||
config.udpfeed.highrate = 1;
|
||||
config.udpfeed.idformat = ID_DFMGRAW;
|
||||
config.tcpfeed.active = 0;
|
||||
config.tcpfeed.type = 1;
|
||||
strcpy(config.tcpfeed.host, "radiosondy.info");
|
||||
strcpy(config.tcpfeed.symbol, "/O");
|
||||
config.tcpfeed.port = 14580;
|
||||
config.tcpfeed.highrate = 10;
|
||||
config.tcpfeed.idformat = ID_DFMDXL;
|
||||
config.kisstnc.active = 0;
|
||||
}
|
||||
|
||||
void Sonde::setConfig(const char *cfg) {
|
||||
while(*cfg==' '||*cfg=='\t') cfg++;
|
||||
if(*cfg=='#') return;
|
||||
char *s = strchr(cfg,'=');
|
||||
if(!s) return;
|
||||
char *val = s+1;
|
||||
*s=0; s--;
|
||||
while(s>cfg && (*s==' '||*s=='\t')) { *s=0; s--; }
|
||||
Serial.printf("configuration option '%s'=%s \n", cfg, val);
|
||||
if(strcmp(cfg,"noisefloor")==0) {
|
||||
config.noisefloor = atoi(val);
|
||||
if(config.noisefloor==0) config.noisefloor=-130;
|
||||
} else if(strcmp(cfg,"gainLNA")==0) {
|
||||
config.gainLNA = atoi(val);
|
||||
} else if(strcmp(cfg,"call")==0) {
|
||||
strncpy(config.call, val, 9);
|
||||
config.call[9]=0;
|
||||
} 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,"button2_pin")==0) {
|
||||
config.button2_pin = atoi(val);
|
||||
} else if(strcmp(cfg,"button2_axp")==0) {
|
||||
config.button2_axp = atoi(val);
|
||||
} else if(strcmp(cfg,"touch_thresh")==0) {
|
||||
config.touch_thresh = atoi(val);
|
||||
} else if(strcmp(cfg,"led_pout")==0) {
|
||||
config.led_pout = atoi(val);
|
||||
} else if(strcmp(cfg,"power_pout")==0) {
|
||||
config.power_pout = atoi(val);
|
||||
} else if(strcmp(cfg,"disptype")==0) {
|
||||
config.disptype = atoi(val);
|
||||
} else if(strcmp(cfg,"oled_sda")==0) {
|
||||
config.oled_sda = atoi(val);
|
||||
} else if(strcmp(cfg,"oled_scl")==0) {
|
||||
config.oled_scl = atoi(val);
|
||||
} else if(strcmp(cfg,"oled_rst")==0) {
|
||||
config.oled_rst = atoi(val);
|
||||
} else if(strcmp(cfg,"oled_orient")==0) {
|
||||
config.oled_orient = atoi(val);
|
||||
} else if(strcmp(cfg,"gpsOn")==0) {
|
||||
config.gpsOn = atoi(val);
|
||||
} else if(strcmp(cfg,"gps_rxd")==0) {
|
||||
config.gps_rxd = atoi(val);
|
||||
} else if(strcmp(cfg,"gps_txd")==0) {
|
||||
config.gps_txd = atoi(val);
|
||||
} else if(strcmp(cfg,"gps_lat")==0) {
|
||||
strncpy(config.gps_lat, val, 8);
|
||||
} else if(strcmp(cfg,"gps_lon")==0) {
|
||||
strncpy(config.gps_lon, val, 8);
|
||||
} else if(strcmp(cfg,"gps_alt")==0) {
|
||||
config.gps_alt = atoi(val);
|
||||
} else if(strcmp(cfg,"maxsonde")==0) {
|
||||
config.maxsonde = atoi(val);
|
||||
if(config.maxsonde>MAXSONDE) config.maxsonde=MAXSONDE;
|
||||
} else if(strcmp(cfg,"debug")==0) {
|
||||
config.debug = atoi(val);
|
||||
} else if(strcmp(cfg,"wifi")==0) {
|
||||
config.wifi = atoi(val);
|
||||
} else if(strcmp(cfg,"wifiap")==0) {
|
||||
config.wifiap = atoi(val);
|
||||
} else if(strcmp(cfg,"mdnsname")==0) {
|
||||
strncpy(config.mdnsname, val, 14);
|
||||
} else if(strcmp(cfg,"vbatmax")==0) {
|
||||
strncpy(config.vbatmax,val,5);
|
||||
} else if(strcmp(cfg,"vbatmin")==0) {
|
||||
strncpy(config.vbatmin,val,5);
|
||||
} else if(strcmp(cfg,"telemetryOn")==0) {
|
||||
config.telemetryOn=atoi(val);
|
||||
} else if(strcmp(cfg,"buzzerOn")==0) {
|
||||
config.buzzerOn=atoi(val);
|
||||
} else if(strcmp(cfg,"buzzerPort")==0) {
|
||||
config.buzzerPort=atoi(val);
|
||||
} else if(strcmp(cfg,"buzzerFreq")==0) {
|
||||
config.buzzerFreq=atoi(val);
|
||||
} else if(strcmp(cfg,"dbsmetre")==0) {
|
||||
config.dbsmetre=atoi(val);
|
||||
} else if(strcmp(cfg,"degdec")==0) {
|
||||
config.degdec=atoi(val);
|
||||
} else if(strcmp(cfg,"display")==0) {
|
||||
int i = 0;
|
||||
char *ptr;
|
||||
while(val) {
|
||||
ptr = strchr(val,',');
|
||||
if(ptr) *ptr = 0;
|
||||
config.display[i++] = atoi(val);
|
||||
val = ptr?ptr+1:NULL;
|
||||
Serial.printf("appending value %d next is %s\n", config.display[i-1], val?val:"");
|
||||
}
|
||||
config.display[i] = -1;
|
||||
} else if (strcmp(cfg, "norx_timeout")==0) {
|
||||
config.norx_timeout = atoi(val);
|
||||
} else if(strcmp(cfg,"startfreq")==0) {
|
||||
config.startfreq = atoi(val);
|
||||
} else if(strcmp(cfg,"channelbw")==0) {
|
||||
config.channelbw = atoi(val);
|
||||
} else if(strcmp(cfg,"spectrum")==0) {
|
||||
config.spectrum = atoi(val);
|
||||
} else if(strcmp(cfg,"marker")==0) {
|
||||
config.marker = atoi(val);
|
||||
} else if(strcmp(cfg,"showafc")==0) {
|
||||
config.showafc = atoi(val);
|
||||
} else if(strcmp(cfg,"freqofs")==0) {
|
||||
config.freqofs = atoi(val);
|
||||
} else if(strcmp(cfg,"rs41.agcbw")==0) {
|
||||
config.rs41.agcbw = atoi(val);
|
||||
} else if(strcmp(cfg,"rs41.rxbw")==0) {
|
||||
config.rs41.rxbw = atoi(val);
|
||||
} else if(strcmp(cfg,"dfm.agcbw")==0) {
|
||||
config.dfm.agcbw = atoi(val);
|
||||
} else if(strcmp(cfg,"dfm.rxbw")==0) {
|
||||
config.dfm.rxbw = atoi(val);
|
||||
} else if(strcmp(cfg,"rs92.alt2d")==0) {
|
||||
config.rs92.alt2d= atoi(val);
|
||||
} else if(strcmp(cfg,"kisstnc.active")==0) {
|
||||
config.kisstnc.active = atoi(val);
|
||||
} else if(strcmp(cfg,"kisstnc.idformat")==0) {
|
||||
config.kisstnc.idformat = atoi(val);
|
||||
} else if(strcmp(cfg,"rs92.rxbw")==0) {
|
||||
config.rs92.rxbw = atoi(val);
|
||||
} else if(strcmp(cfg,"axudp.active")==0) {
|
||||
config.udpfeed.active = atoi(val)>0;
|
||||
} else if(strcmp(cfg,"axudp.host")==0) {
|
||||
strncpy(config.udpfeed.host, val, 63);
|
||||
} else if(strcmp(cfg,"axudp.port")==0) {
|
||||
config.udpfeed.port = atoi(val);
|
||||
} else if(strcmp(cfg,"axudp.symbol")==0) {
|
||||
strncpy(config.udpfeed.symbol, val, 3);
|
||||
} else if(strcmp(cfg,"axudp.highrate")==0) {
|
||||
config.udpfeed.highrate = atoi(val);
|
||||
} else if(strcmp(cfg,"axudp.idformat")==0) {
|
||||
config.udpfeed.idformat = atoi(val);
|
||||
} else if(strcmp(cfg,"tcp.active")==0) {
|
||||
config.tcpfeed.active = atoi(val)>0;
|
||||
} else if(strcmp(cfg,"tcp.host")==0) {
|
||||
strncpy(config.tcpfeed.host, val, 63);
|
||||
} else if(strcmp(cfg,"tcp.port")==0) {
|
||||
config.tcpfeed.port = atoi(val);
|
||||
} else if(strcmp(cfg,"tcp.symbol")==0) {
|
||||
strncpy(config.tcpfeed.symbol, val, 3);
|
||||
} else if(strcmp(cfg,"tcp.highrate")==0) {
|
||||
config.tcpfeed.highrate = atoi(val);
|
||||
} else if(strcmp(cfg,"tcp.idformat")==0) {
|
||||
config.tcpfeed.idformat = atoi(val);
|
||||
} else {
|
||||
Serial.printf("Invalid config option '%s'=%s \n", cfg, val);
|
||||
}
|
||||
}
|
||||
|
||||
void Sonde::setIP(String ip, bool AP) {
|
||||
ipaddr = ip;
|
||||
isAP = AP;
|
||||
}
|
||||
|
||||
void Sonde::clearSonde() {
|
||||
nSonde = 0;
|
||||
}
|
||||
void Sonde::addSonde(float frequency, SondeType type, int active, char *launchsite) {
|
||||
if(nSonde>=config.maxsonde) {
|
||||
Serial.println("Cannot add another sonde, MAXSONDE reached");
|
||||
return;
|
||||
}
|
||||
Serial.printf("Adding %f - %d - %d - %s\n", frequency, type, active, launchsite);
|
||||
sondeList[nSonde].type = type;
|
||||
sondeList[nSonde].freq = frequency;
|
||||
sondeList[nSonde].active = active;
|
||||
strncpy(sondeList[nSonde].launchsite, launchsite, 17);
|
||||
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++;
|
||||
}
|
||||
|
||||
// called by updateState (only)
|
||||
void Sonde::nextConfig() {
|
||||
currentSonde++;
|
||||
if(currentSonde>=nSonde) {
|
||||
currentSonde=0;
|
||||
}
|
||||
// Skip non-active entries (but don't loop forever if there are no active ones)
|
||||
for(int i=0; i<config.maxsonde; i++) {
|
||||
if(!sondeList[currentSonde].active) {
|
||||
currentSonde++;
|
||||
if(currentSonde>=nSonde) currentSonde=0;
|
||||
}
|
||||
}
|
||||
}
|
||||
void Sonde::nextRxSonde() {
|
||||
rxtask.currentSonde++;
|
||||
if(rxtask.currentSonde>=nSonde) {
|
||||
rxtask.currentSonde=0;
|
||||
}
|
||||
for(int i=0; i<config.maxsonde; i++) {
|
||||
if(!sondeList[rxtask.currentSonde].active) {
|
||||
rxtask.currentSonde++;
|
||||
if(rxtask.currentSonde>=nSonde) rxtask.currentSonde=0;
|
||||
}
|
||||
}
|
||||
Serial.printf("nextRxSonde: %d\n", rxtask.currentSonde);
|
||||
}
|
||||
void Sonde::nextRxFreq(int addkhz) {
|
||||
// last entry is for the variable frequency
|
||||
rxtask.currentSonde = nSonde - 1;
|
||||
sondeList[rxtask.currentSonde].active = 1;
|
||||
sondeList[rxtask.currentSonde].freq += addkhz*0.001;
|
||||
if(sondeList[rxtask.currentSonde].freq>406)
|
||||
sondeList[rxtask.currentSonde].freq = 400;
|
||||
Serial.printf("nextRxFreq: %d\n", rxtask.currentSonde);
|
||||
}
|
||||
SondeInfo *Sonde::si() {
|
||||
return &sondeList[currentSonde];
|
||||
}
|
||||
|
||||
void Sonde::setup() {
|
||||
if(rxtask.currentSonde<0 || rxtask.currentSonde>=config.maxsonde) {
|
||||
Serial.print("Invalid rxtask.currentSonde: ");
|
||||
Serial.println(rxtask.currentSonde);
|
||||
rxtask.currentSonde = 0;
|
||||
}
|
||||
|
||||
// update receiver config
|
||||
Serial.print("\nSonde::setup() on sonde index ");
|
||||
Serial.println(rxtask.currentSonde);
|
||||
switch(sondeList[rxtask.currentSonde].type) {
|
||||
case STYPE_RS41:
|
||||
rs41.setup(sondeList[rxtask.currentSonde].freq * 1000000);
|
||||
break;
|
||||
case STYPE_DFM06:
|
||||
case STYPE_DFM09:
|
||||
dfm.setup( sondeList[rxtask.currentSonde].freq * 1000000, sondeList[rxtask.currentSonde].type==STYPE_DFM06?0:1 );
|
||||
break;
|
||||
case STYPE_RS92:
|
||||
rs92.setup( sondeList[rxtask.currentSonde].freq * 1000000);
|
||||
break;
|
||||
case STYPE_M10:
|
||||
m10.setup( sondeList[rxtask.currentSonde].freq * 1000000);
|
||||
break;
|
||||
}
|
||||
// debug
|
||||
float afcbw = sx1278.getAFCBandwidth();
|
||||
float rxbw = sx1278.getRxBandwidth();
|
||||
Serial.printf("AFC BW: %f RX BW: %f\n", afcbw, rxbw);
|
||||
}
|
||||
|
||||
extern void flashLed(int ms);
|
||||
extern void buzzerLed(int temps);
|
||||
void Sonde::receive() {
|
||||
uint16_t res = 0;
|
||||
SondeInfo *si = &sondeList[rxtask.currentSonde];
|
||||
switch(si->type) {
|
||||
case STYPE_RS41:
|
||||
res = rs41.receive();
|
||||
break;
|
||||
case STYPE_RS92:
|
||||
res = rs92.receive();
|
||||
break;
|
||||
case STYPE_M10:
|
||||
res = m10.receive();
|
||||
break;
|
||||
case STYPE_DFM06:
|
||||
case STYPE_DFM09:
|
||||
res = dfm.receive();
|
||||
break;
|
||||
}
|
||||
|
||||
// state information for RX_TIMER / NORX_TIMER events
|
||||
if(res==0) { // RX OK
|
||||
flashLed(700);
|
||||
if(sonde.config.buzzerOn==1) {
|
||||
buzzerLed(500);
|
||||
}
|
||||
if(si->lastState != 1) {
|
||||
si->rxStart = millis();
|
||||
si->lastState = 1;
|
||||
}
|
||||
} else { // RX not ok
|
||||
if(res==RX_ERROR) {
|
||||
flashLed(100);
|
||||
}
|
||||
Serial.printf("RX result %d, laststate was %d\n", res, si->lastState);
|
||||
if(si->lastState != 0) {
|
||||
si->norxStart = millis();
|
||||
si->lastState = 0;
|
||||
}
|
||||
}
|
||||
// Serial.printf("debug: res was %d, now lastState is %d\n", res, si->lastState);
|
||||
|
||||
|
||||
// we should handle timer events here, because after returning from receive,
|
||||
// we'll directly enter setup
|
||||
rxtask.receiveSonde = rxtask.currentSonde; // pass info about decoded sonde to main loop
|
||||
|
||||
int event = getKeyPressEvent();
|
||||
if (!event) event = timeoutEvent(si);
|
||||
int action = (event==EVT_NONE) ? ACT_NONE : disp.layout->actions[event];
|
||||
Serial.printf("event %x: action is %x\n", event, action);
|
||||
// If action is to move to a different sonde index, we do update things here, set activate
|
||||
// to force the sx1278 task to call sonde.setup(), and pass information about sonde to
|
||||
// main loop (display update...)
|
||||
if(action == ACT_NEXTSONDE || action==ACT_PREVSONDE || (action>64&&action<128) ) {
|
||||
// handled here...
|
||||
if(action==ACT_NEXTSONDE||action==ACT_PREVSONDE)
|
||||
nextRxSonde();
|
||||
else
|
||||
nextRxFreq( action-64 );
|
||||
action = ACT_SONDE(rxtask.currentSonde);
|
||||
if(rxtask.activate==-1) {
|
||||
// race condition here. maybe better use mutex. TODO
|
||||
rxtask.activate = action;
|
||||
}
|
||||
}
|
||||
res = (action<<8) | (res&0xff);
|
||||
Serial.printf("receive Result is %04x\n", res);
|
||||
// let waitRXcomplete resume...
|
||||
rxtask.receiveResult = res;
|
||||
|
||||
}
|
||||
|
||||
// return (action<<8) | (rxresult)
|
||||
uint16_t Sonde::waitRXcomplete() {
|
||||
uint16_t res=0;
|
||||
uint32_t t0 = millis();
|
||||
rxloop:
|
||||
while( rxtask.receiveResult==0xFFFF && millis()-t0 < 3000) { delay(50); }
|
||||
if( rxtask.receiveResult == RX_UPDATERSSI ) {
|
||||
rxtask.receiveResult = 0xFFFF;
|
||||
Serial.print("RSSI update: ");
|
||||
disp.updateDisplayRSSI();
|
||||
goto rxloop;
|
||||
}
|
||||
|
||||
if( rxtask.receiveResult==0xFFFF) {
|
||||
Serial.println("TIMEOUT in waitRXcomplete. Should never happen!\n");
|
||||
res = RX_TIMEOUT;
|
||||
} else {
|
||||
res = rxtask.receiveResult;
|
||||
}
|
||||
rxtask.receiveResult = 0xFFFF;
|
||||
/// TODO: THis has caused an exception when swithcing back to spectrumm...
|
||||
Serial.printf("waitRXcomplete returning %04x (%s)\n", res, (res&0xff)<4?RXstr[res&0xff]:"");
|
||||
// currently used only by RS92
|
||||
switch(sondeList[rxtask.receiveSonde].type) {
|
||||
case STYPE_RS41:
|
||||
rs41.waitRXcomplete();
|
||||
break;
|
||||
case STYPE_RS92:
|
||||
rs92.waitRXcomplete();
|
||||
break;
|
||||
case STYPE_M10:
|
||||
m10.waitRXcomplete();
|
||||
break;
|
||||
case STYPE_DFM06:
|
||||
case STYPE_DFM09:
|
||||
dfm.waitRXcomplete();
|
||||
break;
|
||||
}
|
||||
memmove(sonde.si()->rxStat+1, sonde.si()->rxStat, 17);
|
||||
sonde.si()->rxStat[0] = res;
|
||||
return res;
|
||||
}
|
||||
|
||||
uint8_t Sonde::timeoutEvent(SondeInfo *si) {
|
||||
uint32_t now = millis();
|
||||
#if 1
|
||||
Serial.printf("Timeout check: %d - %d vs %d; %d - %d vs %d; %d - %d vs %d\n",
|
||||
now, si->viewStart, disp.layout->timeouts[0],
|
||||
now, si->rxStart, disp.layout->timeouts[1],
|
||||
now, si->norxStart, disp.layout->timeouts[2]);
|
||||
#endif
|
||||
Serial.printf("lastState is %d\n", si->lastState);
|
||||
if(disp.layout->timeouts[0]>=0 && now - si->viewStart >= disp.layout->timeouts[0]) {
|
||||
Serial.println("View timer expired");
|
||||
return EVT_VIEWTO;
|
||||
}
|
||||
if(si->lastState==1 && disp.layout->timeouts[1]>=0 && now - si->rxStart >= disp.layout->timeouts[1]) {
|
||||
Serial.println("RX timer expired");
|
||||
return EVT_RXTO;
|
||||
}
|
||||
if(si->lastState==0 && disp.layout->timeouts[2]>=0 && now - si->norxStart >= disp.layout->timeouts[2]) {
|
||||
Serial.println("NORX timer expired");
|
||||
return EVT_NORXTO;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
uint8_t Sonde::updateState(uint8_t event) {
|
||||
Serial.printf("Sonde::updateState for event %d\n", event);
|
||||
// No change
|
||||
if(event==ACT_NONE) return 0xFF;
|
||||
|
||||
// In all cases (new display mode, new sonde) we reset the mode change timers
|
||||
sonde.sondeList[sonde.currentSonde].viewStart = millis();
|
||||
sonde.sondeList[sonde.currentSonde].lastState = -1;
|
||||
|
||||
// Moving to a different display mode
|
||||
if (event==ACT_DISPLAY_SPECTRUM || event==ACT_DISPLAY_WIFI) {
|
||||
// main loop will call setMode() and disable sx1278 background task
|
||||
return event;
|
||||
}
|
||||
int n = event;
|
||||
if(event==ACT_DISPLAY_DEFAULT) {
|
||||
n = config.display[1];
|
||||
} else if(event==ACT_DISPLAY_SCANNER) {
|
||||
n= config.display[0];
|
||||
} else if(event==ACT_DISPLAY_NEXT) {
|
||||
int i;
|
||||
for(i=0; config.display[i]!=-1; i++) {
|
||||
if(config.display[i] == disp.layoutIdx) break;
|
||||
}
|
||||
if(config.display[i]==-1 || config.display[i+1]==-1) {
|
||||
//unknown index, or end of list => loop to start
|
||||
n = config.display[1];
|
||||
} else {
|
||||
n = config.display[i+1];
|
||||
}
|
||||
}
|
||||
if(n>=0 && n<ACT_MAXDISPLAY) {
|
||||
if(n>=disp.nLayouts) {
|
||||
Serial.println("WARNNG: next layout out of range");
|
||||
n = config.display[1];
|
||||
}
|
||||
Serial.printf("Setting display mode %d\n", n);
|
||||
disp.setLayout(n);
|
||||
sonde.clearDisplay();
|
||||
return 0xFF;
|
||||
}
|
||||
|
||||
// Moving to a different value for currentSonde
|
||||
// TODO: THis should be done in sx1278 task, not in main loop!!!!!
|
||||
if(event==ACT_NEXTSONDE) {
|
||||
sonde.nextConfig();
|
||||
Serial.printf("advancing to next sonde %d\n", sonde.currentSonde);
|
||||
return event;
|
||||
}
|
||||
if (event==ACT_PREVSONDE) {
|
||||
// TODO
|
||||
Serial.printf("previous not supported, advancing to next sonde\n");
|
||||
sonde.nextConfig();
|
||||
return ACT_NEXTSONDE;
|
||||
}
|
||||
if(event&0x80) {
|
||||
sonde.currentSonde = (event&0x7F);
|
||||
return ACT_NEXTSONDE;
|
||||
}
|
||||
return 0xFF;
|
||||
}
|
||||
|
||||
void Sonde::updateDisplayPos() {
|
||||
disp.updateDisplayPos();
|
||||
}
|
||||
|
||||
void Sonde::updateDisplayPos2() {
|
||||
disp.updateDisplayPos2();
|
||||
}
|
||||
|
||||
void Sonde::updateDisplayID() {
|
||||
disp.updateDisplayID();
|
||||
}
|
||||
|
||||
void Sonde::updateDisplayRSSI() {
|
||||
disp.updateDisplayRSSI();
|
||||
}
|
||||
|
||||
void Sonde::updateStat() {
|
||||
disp.updateStat();
|
||||
}
|
||||
|
||||
void Sonde::updateDisplayRXConfig() {
|
||||
disp.updateDisplayRXConfig();
|
||||
}
|
||||
|
||||
void Sonde::updateDisplayIP() {
|
||||
disp.updateDisplayIP();
|
||||
}
|
||||
|
||||
void Sonde::updateDisplay()
|
||||
{
|
||||
int t = millis();
|
||||
disp.updateDisplay();
|
||||
Serial.printf("updateDisplay took %d ms\n", (int)(millis()-t));
|
||||
}
|
||||
|
||||
void Sonde::clearDisplay() {
|
||||
disp.rdis->clear();
|
||||
}
|
||||
|
||||
Sonde sonde = Sonde();
|
||||
Executable
+271
@@ -0,0 +1,271 @@
|
||||
|
||||
#ifndef Sonde_h
|
||||
#define Sonde_h
|
||||
|
||||
// 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, RX_UNKNOWN, RX_NOPOS };
|
||||
#define RX_UPDATERSSI 0xFFFE
|
||||
|
||||
// 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[];
|
||||
extern const char *RXstr[];
|
||||
#define EVENTNAME(s) evstring[s]
|
||||
|
||||
//int8_t actions[EVT_MAX];
|
||||
#define ACT_NONE 255
|
||||
#define ACT_DISPLAY(n) (n)
|
||||
#define ACT_MAXDISPLAY 50
|
||||
#define ACT_DISPLAY_SCANNER 0
|
||||
#define ACT_DISPLAY_NEXT 64
|
||||
#define ACT_DISPLAY_DEFAULT 63
|
||||
#define ACT_DISPLAY_SPECTRUM 62
|
||||
#define ACT_DISPLAY_WIFI 61
|
||||
#define ACT_NEXTSONDE 65
|
||||
#define ACT_PREVSONDE 66
|
||||
#define ACT_ADDFREQ(n) ((n)+64)
|
||||
#define ACT_SONDE(n) ((n)+128)
|
||||
|
||||
// 0000nnnn => goto display nnnn
|
||||
// 01000000 => goto sonde -1
|
||||
// 01000001 => goto sonde +1
|
||||
|
||||
#define NSondeTypes 5
|
||||
enum SondeType { STYPE_DFM06, STYPE_DFM09, STYPE_RS41, STYPE_RS92, STYPE_M10 };
|
||||
extern const char *sondeTypeStr[NSondeTypes];
|
||||
|
||||
typedef struct st_sondeinfo {
|
||||
// receiver configuration
|
||||
bool active;
|
||||
SondeType type;
|
||||
float freq;
|
||||
// decoded ID
|
||||
char id[10];
|
||||
char ser[12];
|
||||
bool validID;
|
||||
char launchsite[18];
|
||||
// decoded position
|
||||
float lat; // latitude
|
||||
float lon; // longitude
|
||||
float az; // azimut
|
||||
float vbat; // vbat %
|
||||
int durvolheure; // duree vol heure
|
||||
int durvolminute; // duree vol minute
|
||||
int durvolseconde; // duree vol seconde
|
||||
float alt; // altitude
|
||||
float vs; // vertical speed
|
||||
float hs; // horizontal speed
|
||||
float dir; // 0..360
|
||||
uint8_t sats; // number of sats
|
||||
uint8_t validPos; // bit pattern for validity of above 7 fields; 0x80: position is old
|
||||
// decoded GPS time
|
||||
uint32_t time;
|
||||
uint16_t sec;
|
||||
uint32_t frame;
|
||||
bool validTime;
|
||||
// RSSI from receiver
|
||||
int rssi; // signal strength
|
||||
int32_t afc; // afc correction value
|
||||
// statistics
|
||||
uint8_t rxStat[20];
|
||||
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
|
||||
// shut down timers, currently only for RS41; -1=disabled
|
||||
int16_t launchKT, burstKT, countKT;
|
||||
uint16_t crefKT; // frame number in which countKT was last sent
|
||||
} SondeInfo;
|
||||
// rxStat: 3=undef[empty] 1=timeout[.] 2=errro[E] 0=ok[|] 4=no valid position[°]
|
||||
|
||||
// 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 to sonde reception for sonde <value) in RXTask.
|
||||
// Will be reset to -1 by RXTask
|
||||
int activate;
|
||||
// Variables set by RXTask, corresponding to mode ST_DECODER (if active) or something else,
|
||||
// and currently received sonde
|
||||
int mainState;
|
||||
int currentSonde;
|
||||
// Variable set by RXTask to communicate status to Arduino task
|
||||
// via waitRXcomplete function
|
||||
uint16_t receiveResult;
|
||||
uint16_t receiveSonde; // sonde inde corresponding to receiveResult
|
||||
// status variabe set by decoder to indicate something is broken
|
||||
// int fifoOverflow;
|
||||
} RXTask;
|
||||
|
||||
extern RXTask rxtask;
|
||||
|
||||
struct st_rs41config {
|
||||
int agcbw;
|
||||
int rxbw;
|
||||
};
|
||||
struct st_rs92config {
|
||||
int rxbw;
|
||||
int alt2d;
|
||||
};
|
||||
struct st_dfmconfig {
|
||||
int agcbw;
|
||||
int rxbw;
|
||||
};
|
||||
|
||||
|
||||
enum IDTYPE { ID_DFMDXL, ID_DFMGRAW, ID_DFMAUTO };
|
||||
|
||||
struct st_feedinfo {
|
||||
bool active;
|
||||
int type; // 0:UDP(axudp), 1:TCP(aprs.fi)
|
||||
char host[64];
|
||||
int port;
|
||||
char symbol[3];
|
||||
int lowrate;
|
||||
int highrate;
|
||||
int lowlimit;
|
||||
int idformat; // 0: dxl 1: real 2: auto
|
||||
};
|
||||
|
||||
// maybe extend for external Bluetooth interface?
|
||||
// internal bluetooth consumes too much memory
|
||||
struct st_kisstnc {
|
||||
bool active;
|
||||
int idformat;
|
||||
};
|
||||
|
||||
|
||||
typedef struct st_rdzconfig {
|
||||
// hardware configuration
|
||||
int button_pin; // PIN port number menu button (+128 for touch mode)
|
||||
int button2_pin; // PIN port number menu button (+128 for touch mode)
|
||||
int button2_axp; // Use AXP192 power button as button2
|
||||
int touch_thresh; // Threshold value (0..100) for touch input button
|
||||
int led_pout; // POUT port number of LED (used as serial monitor)
|
||||
int power_pout; // Power control pin (for Heltec v2)
|
||||
int disptype; // 0=OLED; 1=ILI9225
|
||||
int oled_sda; // OLED data pin
|
||||
int oled_scl; // OLED clock pin
|
||||
int oled_rst; // OLED reset pin
|
||||
int oled_orient; // OLED orientation (default: 1)
|
||||
int gpsOn; // GPS Active On=1/Off=0
|
||||
int gps_rxd; // GPS module RXD pin. We expect 9600 baud NMEA data.
|
||||
int gps_txd; // GPS module TXD pin
|
||||
char gps_lat[20]; // QTH no gps latitude
|
||||
char gps_lon[20]; // QTH no gps longitude
|
||||
int gps_alt; // QTH no gps altitude
|
||||
float gps_Lat,gps_Lon, gps_Alt; // QTH gps OM lat, lon, alt
|
||||
// software configuration
|
||||
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
|
||||
int8_t display[30]; // list of display mode (0:scanner, 1:default, 2,... additional modes)
|
||||
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 -1=disable; 0=forever
|
||||
int marker; // show freq marker in spectrum 0=disable
|
||||
int maxsonde; // number of max sonde in scan (range=1-99)
|
||||
int norx_timeout; // Time after which rx mode switches to scan mode (without rx signal)
|
||||
int noisefloor; // for spectrum display
|
||||
int gainLNA;
|
||||
char mdnsname[15]; // mDNS-Name, defaults to radiosonde
|
||||
char vbatmax[5]; // Vbat maxi when bat charged
|
||||
char vbatmin[5]; // Vbat minimum discharged
|
||||
int telemetryOn; // Active Save information telemetry
|
||||
int buzzerPort; // Buzzer port
|
||||
int buzzerFreq; // Buzzer Frequency
|
||||
int buzzerOn; // Buzzer On
|
||||
int dbsmetre; // Db or Smetre display
|
||||
int degdec; // Degres or Decimal 0=decimal 1=degres
|
||||
// receiver configuration
|
||||
int showafc; // show afc value in rx screen
|
||||
int freqofs; // frequency offset (tuner config = rx frequency + freqofs) in Hz
|
||||
struct st_rs41config rs41; // configuration options specific for RS41 receiver
|
||||
struct st_rs92config rs92;
|
||||
struct st_dfmconfig dfm;
|
||||
// data feed configuration
|
||||
// for now, one feed for each type is enough, but might get extended to more?
|
||||
char call[10]; // APRS callsign
|
||||
char passcode[9]; // APRS passcode
|
||||
struct st_feedinfo udpfeed; // target for AXUDP messages
|
||||
struct st_feedinfo tcpfeed; // target for APRS-IS TCP connections
|
||||
struct st_kisstnc kisstnc; // target for KISS TNC (via TCP, mainly for APRSdroid)
|
||||
} RDZConfig;
|
||||
|
||||
|
||||
#define MAXSONDE 99
|
||||
|
||||
extern int fingerprintValue[];
|
||||
extern const char *fingerprintText[];
|
||||
|
||||
class Sonde
|
||||
{
|
||||
private:
|
||||
public:
|
||||
RDZConfig config;
|
||||
int fingerprint = 0;
|
||||
int currentSonde = 0;
|
||||
int nSonde;
|
||||
String ipaddr;
|
||||
bool isAP;
|
||||
// moved to heap, saving space in .bss
|
||||
//SondeInfo sondeList[MAXSONDE+1];
|
||||
SondeInfo *sondeList;
|
||||
|
||||
Sonde();
|
||||
void defaultConfig();
|
||||
void setConfig(const char *str);
|
||||
|
||||
void clearSonde();
|
||||
void addSonde(float frequency, SondeType type, int active, char *launchsite);
|
||||
void nextConfig();
|
||||
void nextRxSonde();
|
||||
void nextRxFreq(int addkhz);
|
||||
|
||||
/* new interface */
|
||||
void setup();
|
||||
void receive();
|
||||
uint16_t waitRXcomplete();
|
||||
/* old and temp interface */
|
||||
#if 0
|
||||
void processRXbyte(uint8_t data);
|
||||
int receiveFrame();
|
||||
#endif
|
||||
|
||||
SondeInfo *si();
|
||||
|
||||
uint8_t timeoutEvent(SondeInfo *si);
|
||||
uint8_t updateState(uint8_t event);
|
||||
|
||||
void updateDisplayPos();
|
||||
void updateDisplayPos2();
|
||||
void updateDisplayID();
|
||||
void updateDisplayRSSI();
|
||||
void updateDisplayRXConfig();
|
||||
void updateStat();
|
||||
void updateDisplayIP();
|
||||
void updateDisplay();
|
||||
void clearDisplay();
|
||||
|
||||
void setIP(String ip, bool isAP);
|
||||
};
|
||||
|
||||
extern Sonde sonde;
|
||||
|
||||
#endif
|
||||
|
||||
Executable
+1412
File diff suppressed because it is too large
Load Diff
Executable
+468
@@ -0,0 +1,468 @@
|
||||
// SPDX-License-Identifier: GPL-3.0
|
||||
// original source: https://github.com/Nkawu/TFT22_ILI9225
|
||||
|
||||
#ifndef TFT22_ILI9225_h
|
||||
#define TFT22_ILI9225_h
|
||||
|
||||
#ifdef __STM32F1__
|
||||
#define ARDUINO_STM32_FEATHER
|
||||
#define PROGMEM
|
||||
// if 'SPI_CHANNEL' is not defined, 'SPI' is used, only valid for STM32F1
|
||||
//#define SPI_CHANNEL SPI_2
|
||||
#endif
|
||||
|
||||
#define USE_STRING_CLASS
|
||||
|
||||
#ifdef USE_STRING_CLASS
|
||||
#define STRING String
|
||||
#else
|
||||
#define STRING const char *
|
||||
#endif
|
||||
|
||||
#if ARDUINO >= 100
|
||||
#include "Arduino.h"
|
||||
#else
|
||||
#include "WProgram.h"
|
||||
#endif
|
||||
#include <SPI.h>
|
||||
#include "gfxfont.h"
|
||||
|
||||
#if defined(ARDUINO_STM32_FEATHER) || defined(ARDUINO_ARCH_STM32) || defined(ARDUINO_ARCH_STM32F1) || defined(STM32F1)
|
||||
typedef volatile uint32 RwReg;
|
||||
#endif
|
||||
#if defined(ARDUINO_FEATHER52)
|
||||
typedef volatile uint32_t RwReg;
|
||||
#endif
|
||||
|
||||
/* ILI9225 screen size */
|
||||
#define ILI9225_LCD_WIDTH 176
|
||||
#define ILI9225_LCD_HEIGHT 220
|
||||
|
||||
/* ILI9225 LCD Registers */
|
||||
#define ILI9225_DRIVER_OUTPUT_CTRL (0x01u) // Driver Output Control
|
||||
#define ILI9225_LCD_AC_DRIVING_CTRL (0x02u) // LCD AC Driving Control
|
||||
#define ILI9225_ENTRY_MODE (0x03u) // Entry Mode
|
||||
#define ILI9225_DISP_CTRL1 (0x07u) // Display Control 1
|
||||
#define ILI9225_BLANK_PERIOD_CTRL1 (0x08u) // Blank Period Control
|
||||
#define ILI9225_FRAME_CYCLE_CTRL (0x0Bu) // Frame Cycle Control
|
||||
#define ILI9225_INTERFACE_CTRL (0x0Cu) // Interface Control
|
||||
#define ILI9225_OSC_CTRL (0x0Fu) // Osc Control
|
||||
#define ILI9225_POWER_CTRL1 (0x10u) // Power Control 1
|
||||
#define ILI9225_POWER_CTRL2 (0x11u) // Power Control 2
|
||||
#define ILI9225_POWER_CTRL3 (0x12u) // Power Control 3
|
||||
#define ILI9225_POWER_CTRL4 (0x13u) // Power Control 4
|
||||
#define ILI9225_POWER_CTRL5 (0x14u) // Power Control 5
|
||||
#define ILI9225_VCI_RECYCLING (0x15u) // VCI Recycling
|
||||
#define ILI9225_RAM_ADDR_SET1 (0x20u) // Horizontal GRAM Address Set
|
||||
#define ILI9225_RAM_ADDR_SET2 (0x21u) // Vertical GRAM Address Set
|
||||
#define ILI9225_GRAM_DATA_REG (0x22u) // GRAM Data Register
|
||||
#define ILI9225_GATE_SCAN_CTRL (0x30u) // Gate Scan Control Register
|
||||
#define ILI9225_VERTICAL_SCROLL_CTRL1 (0x31u) // Vertical Scroll Control 1 Register
|
||||
#define ILI9225_VERTICAL_SCROLL_CTRL2 (0x32u) // Vertical Scroll Control 2 Register
|
||||
#define ILI9225_VERTICAL_SCROLL_CTRL3 (0x33u) // Vertical Scroll Control 3 Register
|
||||
#define ILI9225_PARTIAL_DRIVING_POS1 (0x34u) // Partial Driving Position 1 Register
|
||||
#define ILI9225_PARTIAL_DRIVING_POS2 (0x35u) // Partial Driving Position 2 Register
|
||||
#define ILI9225_HORIZONTAL_WINDOW_ADDR1 (0x36u) // Horizontal Address Start Position
|
||||
#define ILI9225_HORIZONTAL_WINDOW_ADDR2 (0x37u) // Horizontal Address End Position
|
||||
#define ILI9225_VERTICAL_WINDOW_ADDR1 (0x38u) // Vertical Address Start Position
|
||||
#define ILI9225_VERTICAL_WINDOW_ADDR2 (0x39u) // Vertical Address End Position
|
||||
#define ILI9225_GAMMA_CTRL1 (0x50u) // Gamma Control 1
|
||||
#define ILI9225_GAMMA_CTRL2 (0x51u) // Gamma Control 2
|
||||
#define ILI9225_GAMMA_CTRL3 (0x52u) // Gamma Control 3
|
||||
#define ILI9225_GAMMA_CTRL4 (0x53u) // Gamma Control 4
|
||||
#define ILI9225_GAMMA_CTRL5 (0x54u) // Gamma Control 5
|
||||
#define ILI9225_GAMMA_CTRL6 (0x55u) // Gamma Control 6
|
||||
#define ILI9225_GAMMA_CTRL7 (0x56u) // Gamma Control 7
|
||||
#define ILI9225_GAMMA_CTRL8 (0x57u) // Gamma Control 8
|
||||
#define ILI9225_GAMMA_CTRL9 (0x58u) // Gamma Control 9
|
||||
#define ILI9225_GAMMA_CTRL10 (0x59u) // Gamma Control 10
|
||||
|
||||
#define ILI9225C_INVOFF 0x20
|
||||
#define ILI9225C_INVON 0x21
|
||||
|
||||
// autoincrement modes (register ILI9225_ENTRY_MODE, bit 5..3 )
|
||||
enum autoIncMode_t { R2L_BottomUp, BottomUp_R2L, L2R_BottomUp, BottomUp_L2R, R2L_TopDown, TopDown_R2L, L2R_TopDown, TopDown_L2R };
|
||||
|
||||
/* RGB 16-bit color table definition (RG565) */
|
||||
#define COLOR_BLACK 0x0000 /* 0, 0, 0 */
|
||||
#define COLOR_WHITE 0xFFFF /* 255, 255, 255 */
|
||||
#define COLOR_BLUE 0x001F /* 0, 0, 255 */
|
||||
#define COLOR_GREEN 0x07E0 /* 0, 255, 0 */
|
||||
#define COLOR_RED 0xF800 /* 255, 0, 0 */
|
||||
#define COLOR_NAVY 0x000F /* 0, 0, 128 */
|
||||
#define COLOR_DARKBLUE 0x0011 /* 0, 0, 139 */
|
||||
#define COLOR_DARKGREEN 0x03E0 /* 0, 128, 0 */
|
||||
#define COLOR_DARKCYAN 0x03EF /* 0, 128, 128 */
|
||||
#define COLOR_CYAN 0x07FF /* 0, 255, 255 */
|
||||
#define COLOR_TURQUOISE 0x471A /* 64, 224, 208 */
|
||||
#define COLOR_INDIGO 0x4810 /* 75, 0, 130 */
|
||||
#define COLOR_DARKRED 0x8000 /* 128, 0, 0 */
|
||||
#define COLOR_OLIVE 0x7BE0 /* 128, 128, 0 */
|
||||
#define COLOR_GRAY 0x8410 /* 128, 128, 128 */
|
||||
#define COLOR_GREY 0x8410 /* 128, 128, 128 */
|
||||
#define COLOR_SKYBLUE 0x867D /* 135, 206, 235 */
|
||||
#define COLOR_BLUEVIOLET 0x895C /* 138, 43, 226 */
|
||||
#define COLOR_LIGHTGREEN 0x9772 /* 144, 238, 144 */
|
||||
#define COLOR_DARKVIOLET 0x901A /* 148, 0, 211 */
|
||||
#define COLOR_YELLOWGREEN 0x9E66 /* 154, 205, 50 */
|
||||
#define COLOR_BROWN 0xA145 /* 165, 42, 42 */
|
||||
#define COLOR_DARKGRAY 0x7BEF /* 128, 128, 128 */
|
||||
#define COLOR_DARKGREY 0x7BEF /* 128, 128, 128 */
|
||||
#define COLOR_SIENNA 0xA285 /* 160, 82, 45 */
|
||||
#define COLOR_LIGHTBLUE 0xAEDC /* 172, 216, 230 */
|
||||
#define COLOR_GREENYELLOW 0xAFE5 /* 173, 255, 47 */
|
||||
#define COLOR_SILVER 0xC618 /* 192, 192, 192 */
|
||||
#define COLOR_LIGHTGRAY 0xC618 /* 192, 192, 192 */
|
||||
#define COLOR_LIGHTGREY 0xC618 /* 192, 192, 192 */
|
||||
#define COLOR_LIGHTCYAN 0xE7FF /* 224, 255, 255 */
|
||||
#define COLOR_VIOLET 0xEC1D /* 238, 130, 238 */
|
||||
#define COLOR_AZUR 0xF7FF /* 240, 255, 255 */
|
||||
#define COLOR_BEIGE 0xF7BB /* 245, 245, 220 */
|
||||
#define COLOR_MAGENTA 0xF81F /* 255, 0, 255 */
|
||||
#define COLOR_TOMATO 0xFB08 /* 255, 99, 71 */
|
||||
#define COLOR_GOLD 0xFEA0 /* 255, 215, 0 */
|
||||
#define COLOR_ORANGE 0xFD20 /* 255, 165, 0 */
|
||||
#define COLOR_SNOW 0xFFDF /* 255, 250, 250 */
|
||||
#define COLOR_YELLOW 0xFFE0 /* 255, 255, 0 */
|
||||
|
||||
|
||||
/* Font defines */
|
||||
#define FONT_HEADER_SIZE 4 // 1: pixel width of 1 font character, 2: pixel height,
|
||||
#define readFontByte(x) pgm_read_byte(&cfont.font[x])
|
||||
|
||||
extern uint8_t Terminal6x8[];
|
||||
extern uint8_t Terminal11x16[];
|
||||
extern uint8_t Terminal12x16[];
|
||||
extern uint8_t Trebuchet_MS16x21[];
|
||||
|
||||
struct _currentFont
|
||||
{
|
||||
uint8_t* font;
|
||||
uint8_t width;
|
||||
uint8_t height;
|
||||
uint8_t offset;
|
||||
uint8_t numchars;
|
||||
uint8_t nbrows;
|
||||
bool monoSp;
|
||||
};
|
||||
#define MONOSPACE 1
|
||||
|
||||
#if defined (ARDUINO_STM32_FEATHER)
|
||||
#undef USE_FAST_PINIO
|
||||
#elif defined (__AVR__) || defined(TEENSYDUINO) || defined(ESP8266) || defined(__arm__)
|
||||
#define USE_FAST_PINIO
|
||||
#endif
|
||||
|
||||
/// Main and core class
|
||||
class TFT22_ILI9225 {
|
||||
|
||||
public:
|
||||
|
||||
TFT22_ILI9225(int8_t RST, int8_t RS, int8_t CS, int8_t SDI, int8_t CLK, int8_t LED);
|
||||
TFT22_ILI9225(int8_t RST, int8_t RS, int8_t CS, int8_t LED);
|
||||
TFT22_ILI9225(int8_t RST, int8_t RS, int8_t CS, int8_t SDI, int8_t CLK, int8_t LED, uint8_t brightness);
|
||||
TFT22_ILI9225(int8_t RST, int8_t RS, int8_t CS, int8_t LED, uint8_t brightness);
|
||||
|
||||
/// Initialization
|
||||
#ifndef ESP32
|
||||
void begin(void);
|
||||
#else
|
||||
void begin(SPIClass &spi=SPI);
|
||||
#endif
|
||||
|
||||
/// Clear the screen
|
||||
void clear(void);
|
||||
|
||||
/// Invert screen
|
||||
/// @param flag true to invert, false for normal screen
|
||||
void invert(boolean flag);
|
||||
|
||||
/// Switch backlight on or off
|
||||
/// @param flag true=on, false=off
|
||||
void setBacklight(boolean flag);
|
||||
|
||||
/// Set backlight brightness
|
||||
/// @param brightness sets backlight brightness 0-255
|
||||
void setBacklightBrightness(uint8_t brightness);
|
||||
|
||||
/// Switch display on or off
|
||||
/// @param flag true=on, false=off
|
||||
void setDisplay(boolean flag);
|
||||
|
||||
/// Set orientation
|
||||
/// @param orientation orientation, 0=portrait, 1=right rotated landscape, 2=reverse portrait, 3=left rotated landscape
|
||||
void setOrientation(uint8_t orientation);
|
||||
|
||||
/// Get orientation
|
||||
/// @return orientation orientation, 0=portrait, 1=right rotated landscape, 2=reverse portrait, 3=left rotated landscape
|
||||
uint8_t getOrientation(void);
|
||||
|
||||
/// Font size, x-axis
|
||||
/// @return horizontal size of current font, in pixels
|
||||
// uint8_t fontX(void);
|
||||
|
||||
/// Font size, y-axis
|
||||
/// @return vertical size of current font, in pixels
|
||||
// uint8_t fontY(void);
|
||||
|
||||
/// Screen size, x-axis
|
||||
/// @return horizontal size of the screen, in pixels
|
||||
/// @note 240 means 240 pixels and thus 0..239 coordinates (decimal)
|
||||
uint16_t maxX(void);
|
||||
|
||||
/// Screen size, y-axis
|
||||
/// @return vertical size of the screen, in pixels
|
||||
/// @note 220 means 220 pixels and thus 0..219 coordinates (decimal)
|
||||
uint16_t maxY(void);
|
||||
|
||||
/// Draw circle
|
||||
/// @param x0 center, point coordinate, x-axis
|
||||
/// @param y0 center, point coordinate, y-axis
|
||||
/// @param radius radius
|
||||
/// @param color 16-bit color
|
||||
void drawCircle(uint16_t x0, uint16_t y0, uint16_t radius, uint16_t color);
|
||||
|
||||
/// Draw solid circle
|
||||
/// @param x0 center, point coordinate, x-axis
|
||||
/// @param y0 center, point coordinate, y-axis
|
||||
/// @param radius radius
|
||||
/// @param color 16-bit color
|
||||
void fillCircle(uint8_t x0, uint8_t y0, uint8_t radius, uint16_t color);
|
||||
|
||||
/// Set background color
|
||||
/// @param color background color, default=black
|
||||
void setBackgroundColor(uint16_t color = COLOR_BLACK);
|
||||
|
||||
/// Draw line, rectangle coordinates
|
||||
/// @param x1 start point coordinate, x-axis
|
||||
/// @param y1 start point coordinate, y-axis
|
||||
/// @param x2 end point coordinate, x-axis
|
||||
/// @param y2 end point coordinate, y-axis
|
||||
/// @param color 16-bit color
|
||||
void drawLine(uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, uint16_t color);
|
||||
|
||||
/// Draw rectangle, rectangle coordinates
|
||||
/// @param x1 top left coordinate, x-axis
|
||||
/// @param y1 top left coordinate, y-axis
|
||||
/// @param x2 bottom right coordinate, x-axis
|
||||
/// @param y2 bottom right coordinate, y-axis
|
||||
/// @param color 16-bit color
|
||||
void drawRectangle(uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, uint16_t color);
|
||||
|
||||
/// Draw solid rectangle, rectangle coordinates
|
||||
/// @param x1 top left coordinate, x-axis
|
||||
/// @param y1 top left coordinate, y-axis
|
||||
/// @param x2 bottom right coordinate, x-axis
|
||||
/// @param y2 bottom right coordinate, y-axis
|
||||
/// @param color 16-bit color
|
||||
void fillRectangle(uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, uint16_t color);
|
||||
|
||||
/// Draw pixel
|
||||
/// @param x1 point coordinate, x-axis
|
||||
/// @param y1 point coordinate, y-axis
|
||||
/// @param color 16-bit color
|
||||
void drawPixel(uint16_t x1, uint16_t y1, uint16_t color);
|
||||
|
||||
/// Draw ASCII Text (pixel coordinates)
|
||||
/// @param x point coordinate, x-axis
|
||||
/// @param y point coordinate, y-axis
|
||||
/// @param s text string
|
||||
/// @param color 16-bit color, default=white
|
||||
/// @return x-position behind text
|
||||
uint16_t drawText(uint16_t x, uint16_t y, STRING s, uint16_t color = COLOR_WHITE);
|
||||
|
||||
/// width of an ASCII Text (pixel )
|
||||
/// @param s text string
|
||||
uint16_t getTextWidth( STRING s ) ;
|
||||
|
||||
/// Calculate 16-bit color from 8-bit Red-Green-Blue components
|
||||
/// @param red red component, 0x00..0xff
|
||||
/// @param green green component, 0x00..0xff
|
||||
/// @param blue blue component, 0x00..0xff
|
||||
/// @return 16-bit color
|
||||
uint16_t setColor(uint8_t red, uint8_t green, uint8_t blue);
|
||||
|
||||
/// Calculate 8-bit Red-Green-Blue components from 16-bit color
|
||||
/// @param rgb 16-bit color
|
||||
/// @param red red component, 0x00..0xff
|
||||
/// @param green green component, 0x00..0xff
|
||||
/// @param blue blue component, 0x00..0xff
|
||||
void splitColor(uint16_t rgb, uint8_t &red, uint8_t &green, uint8_t &blue);
|
||||
|
||||
/// Draw triangle, triangle coordinates
|
||||
/// @param x1 corner 1 coordinate, x-axis
|
||||
/// @param y1 corner 1 coordinate, y-axis
|
||||
/// @param x2 corner 2 coordinate, x-axis
|
||||
/// @param y2 corner 2 coordinate, y-axis
|
||||
/// @param x3 corner 3 coordinate, x-axis
|
||||
/// @param y3 corner 3 coordinate, y-axis
|
||||
/// @param color 16-bit color
|
||||
void drawTriangle(uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, uint16_t x3, uint16_t y3, uint16_t color);
|
||||
|
||||
/// Draw solid triangle, triangle coordinates
|
||||
/// @param x1 corner 1 coordinate, x-axis
|
||||
/// @param y1 corner 1 coordinate, y-axis
|
||||
/// @param x2 corner 2 coordinate, x-axis
|
||||
/// @param y2 corner 2 coordinate, y-axis
|
||||
/// @param x3 corner 3 coordinate, x-axis
|
||||
/// @param y3 corner 3 coordinate, y-axis
|
||||
/// @param color 16-bit color
|
||||
void fillTriangle(uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, uint16_t x3, uint16_t y3, uint16_t color);
|
||||
|
||||
/// Set current font
|
||||
/// @param font Font name
|
||||
void setFont(uint8_t* font, bool monoSp=false ); // default = proportional
|
||||
|
||||
/// Get current font
|
||||
_currentFont getFont();
|
||||
|
||||
/// Draw single character (pixel coordinates)
|
||||
/// @param x point coordinate, x-axis
|
||||
/// @param y point coordinate, y-axis
|
||||
/// @param ch ASCII character
|
||||
/// @param color 16-bit color, default=white
|
||||
/// @return width of character in display pixels
|
||||
uint16_t drawChar(uint16_t x, uint16_t y, uint16_t ch, uint16_t color = COLOR_WHITE);
|
||||
|
||||
/// width of an ASCII character (pixel )
|
||||
/// @param ch ASCII character
|
||||
uint16_t getCharWidth( uint16_t ch ) ;
|
||||
|
||||
/// Draw bitmap
|
||||
/// @param x point coordinate, x-axis
|
||||
/// @param y point coordinate, y-axis
|
||||
/// @param bitmap
|
||||
/// @param w width
|
||||
/// @param h height
|
||||
/// @param color 16-bit color, default=white
|
||||
/// @param bg 16-bit color, background
|
||||
void drawBitmap(int16_t x, int16_t y, const uint8_t *bitmap, int16_t w, int16_t h, uint16_t color);
|
||||
void drawBitmap(int16_t x, int16_t y, const uint8_t *bitmap, int16_t w, int16_t h, uint16_t color, uint16_t bg);
|
||||
void drawBitmap(int16_t x, int16_t y, uint8_t *bitmap, int16_t w, int16_t h, uint16_t color);
|
||||
void drawBitmap(int16_t x, int16_t y, uint8_t *bitmap, int16_t w, int16_t h, uint16_t color, uint16_t bg);
|
||||
|
||||
void drawXBitmap(int16_t x, int16_t y, const uint8_t *bitmap, int16_t w, int16_t h, uint16_t color);
|
||||
void drawXBitmap(int16_t x, int16_t y, const uint8_t *bitmap, int16_t w, int16_t h, uint16_t color, uint16_t bg);
|
||||
|
||||
/// Draw bitmap
|
||||
/// @param x point coordinate, x-axis
|
||||
/// @param y point coordinate, y-axis
|
||||
/// @param bitmap, 2D 16bit color bitmap
|
||||
/// @param w width
|
||||
/// @param h height
|
||||
void drawBitmap(uint16_t x, uint16_t y, const uint16_t** bitmap, int16_t w, int16_t h);
|
||||
void drawBitmap(uint16_t x, uint16_t y, uint16_t** bitmap, int16_t w, int16_t h);
|
||||
|
||||
/// Draw bitmap
|
||||
/// @param x point coordinate, x-axis
|
||||
/// @param y point coordinate, y-axis
|
||||
/// @param bitmap, 1D 16bit color bitmap
|
||||
/// @param w width
|
||||
/// @param h height
|
||||
void drawBitmap(uint16_t x, uint16_t y, const uint16_t* bitmap, int16_t w, int16_t h);
|
||||
void drawBitmap(uint16_t x, uint16_t y, uint16_t* bitmap, int16_t w, int16_t h);
|
||||
|
||||
/// Set current GFX font
|
||||
/// @param f GFX font name defined in include file
|
||||
void setGFXFont(const GFXfont *f = NULL);
|
||||
|
||||
/// Draw a string with the current GFX font
|
||||
/// @param x point coordinate, x-axis
|
||||
/// @param y point coordinate, y-axis
|
||||
/// @param s string to print
|
||||
/// @param color 16-bit color
|
||||
void drawGFXText(int16_t x, int16_t y, STRING s, uint16_t color);
|
||||
|
||||
/// Get the width & height of a text string with the current GFX font
|
||||
/// @param str string to analyze
|
||||
/// @param x point coordinate, x-axis
|
||||
/// @param y point coordinate, y-axis
|
||||
/// @param w width in pixels of string
|
||||
/// @param h height in pixels of string
|
||||
void getGFXTextExtent(STRING str, int16_t x, int16_t y, int16_t *w, int16_t *h);
|
||||
|
||||
/// Draw a single character with the current GFX font
|
||||
/// @param x point coordinate, x-axis
|
||||
/// @param y point coordinate, y-axis
|
||||
/// @param c character to draw
|
||||
/// @param color 16-bit color
|
||||
/// @return width of character in display pixels
|
||||
uint16_t drawGFXChar(int16_t x, int16_t y, unsigned char c, uint16_t color);
|
||||
|
||||
uint16_t drawGFXcharBM(int16_t x, int16_t y, unsigned char c, uint16_t color, uint16_t *bm, int bmwd);
|
||||
|
||||
void getGFXCharExtent(uint8_t c, int16_t *gw, int16_t *gh, int16_t *xa);
|
||||
|
||||
private:
|
||||
|
||||
void _spiWrite(uint8_t v);
|
||||
void _spiWrite16(uint16_t v);
|
||||
void _spiWriteCommand(uint8_t c);
|
||||
void _spiWriteData(uint8_t d);
|
||||
|
||||
void _swap(uint16_t &a, uint16_t &b);
|
||||
void _setWindow(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1);
|
||||
void _setWindow(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1, autoIncMode_t mode);
|
||||
void _resetWindow();
|
||||
void _drawBitmap(int16_t x, int16_t y, const uint8_t *bitmap, int16_t w, int16_t h,
|
||||
uint16_t color, uint16_t bg, bool transparent, bool progmem, bool Xbit );
|
||||
void _orientCoordinates(uint16_t &x1, uint16_t &y1);
|
||||
void _writeRegister(uint16_t reg, uint16_t data);
|
||||
void _writeData(uint8_t HI, uint8_t LO);
|
||||
void _writeData16(uint16_t HILO);
|
||||
void _writeCommand(uint8_t HI, uint8_t LO);
|
||||
void _writeCommand16(uint16_t HILO);
|
||||
uint16_t _maxX, _maxY, _bgColor;
|
||||
|
||||
#if defined (__AVR__) || defined(TEENSYDUINO)
|
||||
int8_t _rst, _rs, _cs, _sdi, _clk, _led;
|
||||
#ifdef USE_FAST_PINIO
|
||||
volatile uint8_t *mosiport, *clkport, *dcport, *rsport, *csport;
|
||||
uint8_t mosipinmask, clkpinmask, cspinmask, dcpinmask;
|
||||
#endif
|
||||
#elif defined (__arm__)
|
||||
int32_t _rst, _rs, _cs, _sdi, _clk, _led;
|
||||
#ifdef USE_FAST_PINIO
|
||||
volatile RwReg *mosiport, *clkport, *dcport, *rsport, *csport;
|
||||
uint32_t mosipinmask, clkpinmask, cspinmask, dcpinmask;
|
||||
#endif
|
||||
#elif defined (ESP8266) || defined (ESP32)
|
||||
int8_t _rst, _rs, _cs, _sdi, _clk, _led;
|
||||
#ifdef USE_FAST_PINIO
|
||||
volatile uint32_t *mosiport, *clkport, *dcport, *rsport, *csport;
|
||||
uint32_t mosipinmask, clkpinmask, cspinmask, dcpinmask;
|
||||
#endif
|
||||
#else
|
||||
int8_t _rst, _rs, _cs, _sdi, _clk, _led;
|
||||
#endif
|
||||
|
||||
uint8_t _orientation, _brightness;
|
||||
|
||||
// correspondig modes if orientation changed:
|
||||
const autoIncMode_t modeTab [3][8] = {
|
||||
// { R2L_BottomUp, BottomUp_R2L, L2R_BottomUp, BottomUp_L2R, R2L_TopDown, TopDown_R2L, L2R_TopDown, TopDown_L2R }//
|
||||
/* 90° */ { BottomUp_L2R, L2R_BottomUp, TopDown_L2R, L2R_TopDown, BottomUp_R2L, R2L_BottomUp, TopDown_R2L, R2L_TopDown },
|
||||
/*180° */ { L2R_TopDown , TopDown_L2R, R2L_TopDown, TopDown_R2L, L2R_BottomUp, BottomUp_L2R, R2L_BottomUp, BottomUp_R2L},
|
||||
/*270° */ { TopDown_R2L , R2L_TopDown, BottomUp_R2L, R2L_BottomUp, TopDown_L2R, L2R_TopDown, BottomUp_L2R, L2R_BottomUp}
|
||||
};
|
||||
|
||||
|
||||
bool hwSPI, blState;
|
||||
|
||||
_currentFont cfont;
|
||||
|
||||
#ifdef ESP32
|
||||
SPIClass _spi;
|
||||
#endif
|
||||
|
||||
protected:
|
||||
|
||||
uint32_t writeFunctionLevel;
|
||||
void startWrite(void);
|
||||
void endWrite(void);
|
||||
|
||||
|
||||
GFXfont *gfxFont;
|
||||
};
|
||||
|
||||
#endif
|
||||
Executable
+350
@@ -0,0 +1,350 @@
|
||||
/* Copyright (C) Hansi Reiser, dl9rdz
|
||||
*
|
||||
* partially based on dxlAPRS toolchain
|
||||
*
|
||||
* Copyright (C) Christian Rabler <oe5dxl@oevsv.at>
|
||||
*
|
||||
* SPDX-License-Identifier: GPL-2.0+
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <WString.h>
|
||||
#include <stdlib.h>
|
||||
//#include <arpa/inet.h>
|
||||
//#include <sys/socket.h>
|
||||
#include <math.h>
|
||||
#include <unistd.h>
|
||||
#include <inttypes.h>
|
||||
#include "aprs.h"
|
||||
|
||||
#if 0
|
||||
int openudp(const char *ip, int port, struct sockaddr_in *si) {
|
||||
int fd;
|
||||
if((fd=socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP))==-1) return -1;
|
||||
memset((char *)&si, 0, sizeof(si));
|
||||
si->sin_family = AF_INET;
|
||||
si->sin_port = htons(port);
|
||||
if(inet_aton(ip, &(si->sin_addr))==0) {
|
||||
return -1;
|
||||
}
|
||||
return fd;
|
||||
}
|
||||
|
||||
int sendudp(int fd, struct sockaddr_in *si, char *frame, int framelen)
|
||||
{
|
||||
if(sendto(fd, frame, framelen, 0, (struct sockaddr *)si, sizeof(struct sockaddr_in))==-1) {
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
void aprsstr_append(char *b, const char *data)
|
||||
{
|
||||
int blen=strlen(b);
|
||||
int len=strlen(data);
|
||||
if(blen+len>APRS_MAXLEN) len=APRS_MAXLEN-blen;
|
||||
strncat(b, data, len);
|
||||
}
|
||||
|
||||
uint32_t realcard(float x) {
|
||||
if(x<0) return 0;
|
||||
else return (uint32_t)x;
|
||||
}
|
||||
|
||||
|
||||
/* CRC for AXUDP frames */
|
||||
|
||||
#define APRSCRC_POLY 0x8408
|
||||
static uint8_t CRCL[256];
|
||||
static uint8_t CRCH[256];
|
||||
|
||||
void aprs_gencrctab(void)
|
||||
{
|
||||
uint32_t c;
|
||||
uint32_t crc;
|
||||
uint32_t i;
|
||||
for (c = 0UL; c<=255UL; c++) {
|
||||
crc = 255UL-c;
|
||||
for (i = 0UL; i<=7UL; i++) {
|
||||
if ((crc&1)) crc = (uint32_t)((uint32_t)(crc>>1)^APRSCRC_POLY);
|
||||
else crc = crc>>1;
|
||||
} /* end for */
|
||||
CRCL[c] = (uint8_t)crc;
|
||||
CRCH[c] = (uint8_t)(255UL-(crc>>8));
|
||||
} /* end for */
|
||||
} /* end Gencrctab() */
|
||||
|
||||
static void aprsstr_appcrc(char frame[], uint32_t frame_len, int32_t size)
|
||||
{
|
||||
uint8_t h;
|
||||
uint8_t l;
|
||||
uint8_t b;
|
||||
int32_t i;
|
||||
int32_t tmp;
|
||||
l = 0U;
|
||||
h = 0U;
|
||||
tmp = size-1L;
|
||||
i = 0L;
|
||||
if (i<=tmp) for (;; i++) {
|
||||
b = (uint8_t)((uint8_t)(uint8_t)frame[i]^l);
|
||||
l = CRCL[b]^h;
|
||||
h = CRCH[b];
|
||||
if (i==tmp) break;
|
||||
} /* end for */
|
||||
frame[size] = (char)l;
|
||||
frame[size+1L] = (char)h;
|
||||
} /* end aprsstr_appcrc() */
|
||||
|
||||
|
||||
static int mkaprscall(int32_t * p, char raw[],
|
||||
uint32_t * i, const char mon[],
|
||||
char sep1, char sep2, char sep3,
|
||||
uint32_t sbase)
|
||||
{
|
||||
uint32_t s;
|
||||
uint32_t l;
|
||||
l = 0UL;
|
||||
while ((((mon[*i] && mon[*i]!=sep1) && mon[*i]!=sep2) && mon[*i]!=sep3)
|
||||
&& mon[*i]!='-') {
|
||||
s = (uint32_t)(uint8_t)mon[*i]*2UL&255UL;
|
||||
if (s<=64UL) return 0;
|
||||
raw[*p] = (char)s;
|
||||
++*p;
|
||||
++*i;
|
||||
++l;
|
||||
if (l>=7UL) return 0;
|
||||
}
|
||||
while (l<6UL) {
|
||||
raw[*p] = '@';
|
||||
++*p;
|
||||
++l;
|
||||
}
|
||||
s = 0UL;
|
||||
if (mon[*i]=='-') {
|
||||
++*i;
|
||||
while ((uint8_t)mon[*i]>='0' && (uint8_t)mon[*i]<='9') {
|
||||
s = (s*10UL+(uint32_t)(uint8_t)mon[*i])-48UL;
|
||||
++*i;
|
||||
}
|
||||
if (s>15UL) return 0;
|
||||
}
|
||||
raw[*p] = (char)((s+sbase)*2UL);
|
||||
++*p;
|
||||
return 1;
|
||||
} /* end call() */
|
||||
|
||||
|
||||
|
||||
// returns raw len, 0 in case of error
|
||||
extern int aprsstr_mon2raw(const char *mon, char raw[], int raw_len)
|
||||
{
|
||||
uint32_t r;
|
||||
uint32_t n;
|
||||
uint32_t i;
|
||||
uint32_t tmp;
|
||||
int p = 7L;
|
||||
i = 0UL;
|
||||
fprintf(stderr,"mon2raw for %s\n", mon);
|
||||
if (!mkaprscall(&p, raw, &i, mon, '>', 0, 0, 48UL)) {
|
||||
return 0;
|
||||
}
|
||||
p = 0L;
|
||||
if (mon[i]!='>') return 0;
|
||||
/* ">" */
|
||||
++i;
|
||||
if (!mkaprscall(&p, raw, &i, mon, ':', ',', 0, 112UL)) {
|
||||
return 0;
|
||||
}
|
||||
p = 14L;
|
||||
n = 0UL;
|
||||
while (mon[i]==',') {
|
||||
++i;
|
||||
if (!mkaprscall(&p, raw, &i, mon, ':', ',', '*', 48UL)) {
|
||||
return 0;
|
||||
}
|
||||
++n;
|
||||
if (n>8UL) {
|
||||
return 0;
|
||||
}
|
||||
if (mon[i]=='*') {
|
||||
/* "*" has repeatet sign */
|
||||
++i;
|
||||
r = (uint32_t)p;
|
||||
if (r>=21UL) for (tmp = (uint32_t)(r-21UL)/7UL;;) {
|
||||
raw[r-1UL] = (char)((uint32_t)(uint8_t)raw[r-1UL]+128UL);
|
||||
/* set "has repeated" flags */
|
||||
if (!tmp) break;
|
||||
--tmp;
|
||||
r -= 7UL;
|
||||
} /* end for */
|
||||
}
|
||||
}
|
||||
if (p==0L || mon[i]!=':') {
|
||||
return 0;
|
||||
}
|
||||
raw[p-1L] = (char)((uint32_t)(uint8_t)raw[p-1L]+1UL);
|
||||
/* end address field mark */
|
||||
raw[p] = '\003';
|
||||
++p;
|
||||
raw[p] = '\360';
|
||||
++p;
|
||||
++i;
|
||||
n = 256UL;
|
||||
while (mon[i]) {
|
||||
/* copy info part */
|
||||
if (p>=(int32_t)(raw_len-1)-2L || n==0UL) {
|
||||
return 0;
|
||||
}
|
||||
raw[p] = mon[i];
|
||||
++p;
|
||||
++i;
|
||||
--n;
|
||||
}
|
||||
aprsstr_appcrc(raw, raw_len, p);
|
||||
fprintf(stderr,"results in %s\n",raw);
|
||||
return p+2;
|
||||
} /* end mon2raw() */
|
||||
|
||||
extern int aprsstr_mon2kiss(const char *mon, char raw[], int raw_len)
|
||||
{
|
||||
char tmp[201];
|
||||
int len = aprsstr_mon2raw(mon, tmp, 201);
|
||||
if(len==0) return 0;
|
||||
int idx=0;
|
||||
raw[idx++] = '\xC0';
|
||||
for(int i=0; i<len-2; i++) { // -2: discard CRC, not used in KISS
|
||||
if(tmp[i]=='\xC0') {
|
||||
raw[idx++] = '\xDB';
|
||||
raw[idx++] = '\xDC';
|
||||
} else if (tmp[i]=='\xDB') {
|
||||
raw[idx++] = '\xDB';
|
||||
raw[idx++] = '\xDD';
|
||||
} else {
|
||||
raw[idx++] = tmp[i];
|
||||
}
|
||||
if(idx>=raw_len)
|
||||
return 0;
|
||||
}
|
||||
return idx;
|
||||
}
|
||||
|
||||
#define FEET (1.0/0.3048)
|
||||
#define KNOTS (1.851984)
|
||||
|
||||
#define X2C_max_longcard 0xFFFFFFFFUL
|
||||
static uint32_t X2C_TRUNCC(double x, uint32_t min0, uint32_t max0)
|
||||
{
|
||||
uint32_t i;
|
||||
|
||||
if (x < (double)min0)
|
||||
i = (uint32_t)min0;
|
||||
if (x > (double)max0)
|
||||
i = (uint32_t)max0;
|
||||
|
||||
i = (uint32_t)x;
|
||||
if ((double)i > x)
|
||||
--i;
|
||||
return i;
|
||||
}
|
||||
|
||||
|
||||
static uint32_t truncc(double r)
|
||||
{
|
||||
if (r<=0.0) return 0UL;
|
||||
else if (r>=2.E+9) return 2000000000UL;
|
||||
else return (uint32_t)X2C_TRUNCC(r,0UL,X2C_max_longcard);
|
||||
return 0;
|
||||
} /* end truncc() */
|
||||
|
||||
|
||||
|
||||
static uint32_t dao91(double x)
|
||||
/* radix91(xx/1.1) of dddmm.mmxx */
|
||||
{
|
||||
double a;
|
||||
a = fabs(x);
|
||||
return ((truncc((a-(double)(float)truncc(a))*6.E+5)%100UL)
|
||||
*20UL+11UL)/22UL;
|
||||
} /* end dao91() */
|
||||
|
||||
|
||||
char b[201];
|
||||
char raw[201];
|
||||
|
||||
char *aprs_senddata(SondeInfo *s, const char *usercall, const char *sym) {
|
||||
// float lat, float lon, float alt, float speed, float dir, float climb, const char *type, const char *objname, const char *usercall, const char *sym, const char *comm)
|
||||
*b=0;
|
||||
aprsstr_append(b, usercall);
|
||||
aprsstr_append(b, ">");
|
||||
const char *destcall="APZRDZ";
|
||||
aprsstr_append(b, destcall);
|
||||
// uncompressed
|
||||
aprsstr_append(b, ":;");
|
||||
char tmp[10];
|
||||
snprintf(tmp,10,"%s ",s->id);
|
||||
aprsstr_append(b, tmp);
|
||||
aprsstr_append(b, "*");
|
||||
// time
|
||||
int i = strlen(b);
|
||||
int sec = s->time % 86400;
|
||||
snprintf(b+i, APRS_MAXLEN-1, "%02d%02d%02dz", sec/(60*60), (sec%(60*60))/60, sec%60);
|
||||
i = strlen(b);
|
||||
//aprsstr_append_data(time, ds);
|
||||
int lati = abs((int)s->lat);
|
||||
int latm = (fabs(s->lat)-lati)*6000;
|
||||
snprintf(b+i, APRS_MAXLEN-i, "%02d%02d.%02d%c%c", lati, latm/100, latm%100, s->lat<0?'S':'N', sym[0]);
|
||||
i = strlen(b);
|
||||
int loni = abs((int)s->lon);
|
||||
int lonm = (fabs(s->lon)-loni)*6000;
|
||||
snprintf(b+i, APRS_MAXLEN-i, "%03d%02d.%02d%c%c", loni, lonm/100, lonm%100, s->lon<0?'W':'E', sym[1]);
|
||||
if(s->hs>0.5) {
|
||||
i=strlen(b);
|
||||
snprintf(b+i, APRS_MAXLEN-i, "%03d/%03d", realcard(s->dir+1.5), realcard(s->hs*1.0/KNOTS+0.5));
|
||||
}
|
||||
if(s->alt>0.5) {
|
||||
i=strlen(b);
|
||||
snprintf(b+i, APRS_MAXLEN-i, "/A=%06d", realcard(s->alt*FEET+0.5));
|
||||
}
|
||||
int dao=1;
|
||||
if(dao) {
|
||||
i=strlen(b);
|
||||
snprintf(b+i, APRS_MAXLEN-i, "!w%c%c!", 33+dao91(s->lat), 33+dao91(s->lon));
|
||||
}
|
||||
strcat(b, "&");
|
||||
char comm[100];
|
||||
snprintf(comm, 100, "Clb=%.1fm/s %.3fMHz Type=%s", s->vs, s->freq, sondeTypeStr[s->type]);
|
||||
strcat(b, comm);
|
||||
if(s->type==STYPE_M10||s->type==STYPE_DFM06||s->type==STYPE_DFM09) {
|
||||
snprintf(comm, 100, " ser=%s", s->ser);
|
||||
strcat(b, comm);
|
||||
}
|
||||
return b;
|
||||
}
|
||||
|
||||
|
||||
#if 0
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
Gencrctab();
|
||||
|
||||
struct sockaddr_in si;
|
||||
int fd = openudp("127.0.0.1",9002,&si);
|
||||
if(fd<0) { fprintf(stderr,"open failed\n"); return 1; }
|
||||
|
||||
float lat=48, lon=10;
|
||||
while(1) {
|
||||
const char *str = aprs_senddata(lat, lon, 543, 5, 180, 1.5, "RS41", "TE0ST", "TE1ST", "EO");
|
||||
int rawlen = aprsstr_mon2raw(str, raw, APRS_MAXLEN);
|
||||
sendudp(fd, raw, rawlen);
|
||||
|
||||
str = "OE3XKC>APMI06,qAR,OE3XLR:;ER-341109*111111z4803.61NE01532.39E0145.650MHz R15k OE3XPA";
|
||||
rawlen = aprsstr_mon2raw(str, raw, APRS_MAXLEN);
|
||||
sendudp(fd, &si, raw, rawlen);
|
||||
lat += 0.002; lon += 0.01;
|
||||
sleep(5);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
Executable
+14
@@ -0,0 +1,14 @@
|
||||
|
||||
#ifndef _aprs_h
|
||||
#define _aprs_h
|
||||
#include "Sonde.h"
|
||||
|
||||
|
||||
#define APRS_MAXLEN 201
|
||||
void aprs_gencrctab(void);
|
||||
int aprsstr_mon2raw(const char *mon, char raw[], int raw_len);
|
||||
int aprsstr_mon2kiss(const char *mon, char raw[], int raw_len);
|
||||
char *aprs_senddata(SondeInfo *s, const char *usercall, const char *sym);
|
||||
|
||||
|
||||
#endif
|
||||
Executable
+68
@@ -0,0 +1,68 @@
|
||||
Heltec board v1 => fingerprint 0000100 => 4
|
||||
(sda,scl: 4,15) (same as LORA v1.0)
|
||||
0:1 1:0 2:0 3:1 4:0 5:1 6:0 7:1 8:0 9:1 10:1 11:1 12:0 13:0 14:1 15:0 16:0 17:0 18:0 19:0 20:0 21:1 22:0 23:0 24:0 25:0 26:0 27:0 28:0 29:0 30:0 31:0 32:0 33:0 34:0 35:0 36:0 37:0 38:0
|
||||
|
||||
Heltec board v2
|
||||
(sda,scl: 4,15) (similar to v1.0, but GPIO21 switches 3V3) => fingerprint 4
|
||||
0:1 1:0 2:0 3:1 4:0 5:1 6:0 7:1 8:0 9:1 10:1 11:1 12:0 13:0 14:1 15:0 16:0 17:0 18:0 19:0 20:0 21:1 22:0 23:0 24:0 25:0 26:0 27:0 28:0 29:0 30:0 31:0 32:0 33:0 34:0 35:0 36:0 37:0 38:0
|
||||
0:1 1:1 2:0 3:1 4:0 5:1 6:0 7:1 8:0 9:1 10:1 11:1 12:0 13:0 14:1 15:0 16:0 17:0 18:0 19:0 20:0 21:1 22:0 23:0 24:0 25:0 26:0 27:0 28:0 29:0 30:0 31:0 32:0 33:0 34:0 35:0 36:0 37:0 38:0 (before setup
|
||||
|
||||
TTGO LORA32 v2.1_1.6 (button1: touch gpio 2 => 130; button2: touch gpio14 => 142) fingerprint 0011111 => 31
|
||||
(sda,scl: 21,22)
|
||||
0:1 1:0 2:0 3:1 4:0 5:1 6:0 7:1 8:0 9:1 10:1 11:1 12:0 13:0 14:1 15:1 16:1 17:1 18:0 19:0 20:0 21:1 22:1 23:1 24:0 25:0 26:0 27:0 28:0 29:0 30:0 31:0 32:0 33:0 34:0 35:0 36:0 37:0 38:0
|
||||
0:4 1:4 2:0 3:4 4:0 5:4 6:0 7:4 8:0 9:4 10:4 11:4 12:0 13:0 14:4 15:4 16:4 17:4 18:0 19:0 20:0 21:4 22:4 23:4 24:0 25:0 26:0 27:0 28:0 29:0 30:0 31:0 32:0 33:0 34:0 35:0 36:0 37:0 38:0 (in Sonde())
|
||||
|
||||
TTGO LORA v1.0 => fingerprint 1000000 => 64
|
||||
(sda,scl: 4,15) (button1: 0) (button2: touch gpio13 = 141)
|
||||
0:1 1:0 2:0 3:1 4:1 5:1 6:0 7:1 8:0 9:1 10:1 11:1 12:0 13:0 14:1 15:1 16:0 17:0 18:0 19:0 20:0 21:0 22:0 23:0 24:0 25:0 26:0 27:0 28:0 29:0 30:0 31:0 32:0 33:0 34:0 35:0 36:0 37:0 38:0
|
||||
0:4 1:4 2:0 3:4 4:4 5:4 6:0 7:4 8:0 9:4 10:4 11:4 12:0 13:0 14:4 15:4 16:0 17:0 18:0 19:0 20:0 21:0 22:0 23:0 24:0 25:0 26:0 27:0 28:0 29:0 30:0 31:0 32:0 33:0 34:0 35:0 36:0 37:0 38:0 (in Sonde())
|
||||
|
||||
TTGO T-Beam => fingerprint 0110111 => 55
|
||||
(sda,scl: 21,22) (button1: 39) (button2: touch gpio13 = 141) (gps rx: 12)
|
||||
0:1 1:0 2:0 3:1 4:0 5:1 6:0 7:1 8:0 9:1 10:1 11:1 12:1 13:0 14:1 15:1 16:1 17:0 18:0 19:0 20:0 21:1 22:1 23:1 24:0 25:0 26:0 27:0 28:0 29:0 30:0 31:0 32:0 33:0 34:0 35:0 36:0 37:0 38:0
|
||||
0:4 1:4 2:0 3:4 4:0 5:4 6:0 7:4 8:0 9:4 10:4 11:4 12:4 13:0 14:4 15:4 16:4 17:0 18:0 19:0 20:0 21:4 22:4 23:4 24:0 25:0 26:0 27:0 28:0 29:0 30:0 31:0 32:0 33:0 34:0 35:0 36:0 37:0 38:0 (before setup)
|
||||
|
||||
TTGO T-Beam with extern 2" ILI9225 Display => fingerprint 0110000 => 48
|
||||
0:1 1:0 2:0 3:1 4:0 5:1 6:0 7:1 8:0 9:1 10:1 11:1 12:1 13:0 14:1 15:1 16:1 17:0 18:0 19:0 20:0 21:0 22:0 23:1 24:0 25:0 26:0 27:0 28:0 29:0 30:0 31:0 32:0 33:0 34:0 35:0 36:0 37:0 38:0
|
||||
0:4 1:4 2:0 3:4 4:0 5:4 6:0 7:4 8:0 9:4 10:4 11:4 12:4 13:0 14:4 15:4 16:4 17:0 18:0 19:0 20:0 21:0 22:0 23:4 24:0 25:0 26:0 27:0 28:0 29:0 30:0 31:0 32:0 33:0 34:0 35:0 36:0 37:0 38:0 (before setup)
|
||||
|
||||
TTGO T-Beam 1.0 with OLED display => fingerprint 0010111 => 23
|
||||
0:1 1:0 2:0 3:1 4:0 5:1 6:0 7:1 8:0 9:1 10:1 11:1 12:0 13:0 14:1 15:1 16:1 17:0 18:0 19:0 20:0 21:1 22:1 23:1 24:0 25:0 26:0 27:0 28:0 29:0 30:0 31:0 32:0 33:0 34:0 35:0 36:0 37:0 38:0
|
||||
0:4 1:4 2:0 3:4 4:0 5:4 6:0 7:4 8:0 9:4 10:4 11:4 12:0 13:0 14:4 15:4 16:4 17:0 18:0 19:0 20:0 21:4 22:4 23:4 24:0 25:0 26:0 27:0 28:0 29:0 30:0 31:0 32:0 33:0 34:0 35:0 36:0 37:0 38:0 (before setup)
|
||||
|
||||
1
|
||||
|
||||
Fingerprint GPIOs: 4, 12, 16, 17, 21, 22, 23,
|
||||
|
||||
Current autodetect strategy:
|
||||
RST always set to 16
|
||||
|
||||
GPIO16=0 (GPio22,23 would also work):
|
||||
==Heltec or TTGO LORA v1.0==
|
||||
SDA,SCL set to (4,15)
|
||||
Button 1 set to GPIO 0
|
||||
Button 2 set to Touch in GPIO 13 (141)
|
||||
|
||||
|
||||
otherwise
|
||||
==LORA32 v2.1 or T-Beam==
|
||||
GPIO17=0:
|
||||
== T-BEAM =
|
||||
GPIO12==0: v1 (or check PMU via I2C?)
|
||||
GPS RX set to 34
|
||||
Button 1 set to GPIO28
|
||||
BUtton 2 set to Touch GPIO13
|
||||
else:
|
||||
GPS RX set to 12
|
||||
Button 1 set to GPIO39
|
||||
Button 2 set to Touch GPIO13 (141)
|
||||
GPIO21=0:
|
||||
large display connected (use ILI9225 contig: SDA4 CLK21 RS2 RST22 CS0)
|
||||
else:
|
||||
small display connected, set SDA,SCL to (21,22)
|
||||
otherweise:
|
||||
SDA,SCL set to (21,22)
|
||||
GPS disabled
|
||||
Button 1 set to Touch GPIO2 (130)
|
||||
Button 2 set to Touch GPIO14 (142)
|
||||
|
||||
Executable
+124
@@ -0,0 +1,124 @@
|
||||
#include "FS.h"
|
||||
#include <SPIFFS.h>
|
||||
#include <WiFi.h>
|
||||
//Write data web
|
||||
|
||||
//Fonction
|
||||
void writedataweb(){
|
||||
|
||||
|
||||
String updateHost = "xavier.debert.free.fr";
|
||||
String updateDataWeb = "/RS/dataweb/index.html.txt";
|
||||
String *updateData = &updateDataWeb;
|
||||
String dispHost = updateHost.substring(0, 14);
|
||||
//disp.rdis->drawString(2, 0, dispHost.c_str());
|
||||
|
||||
Serial.println("Connecting to: " + updateHost);
|
||||
// Connect to Update host
|
||||
if (client.connect(updateHost.c_str(), updatePort)) {
|
||||
// Connection succeeded, fecthing the bin
|
||||
Serial.println("Fetching index.html: " + String(*updateData));
|
||||
|
||||
|
||||
// Get the contents of the bin file
|
||||
client.print(String("GET ") + *updateData + " HTTP/1.1\r\n" +
|
||||
"Host: " + updateHost + "\r\n" +
|
||||
"Cache-Control: no-cache\r\n" +
|
||||
"Connection: close\r\n\r\n");
|
||||
|
||||
// Check what is being sent
|
||||
// Serial.print(String("GET ") + bin + " HTTP/1.1\r\n" +
|
||||
// "Host: " + host + "\r\n" +
|
||||
// "Cache-Control: no-cache\r\n" +
|
||||
// "Connection: close\r\n\r\n");
|
||||
|
||||
unsigned long timeout = millis();
|
||||
while (client.available() == 0) {
|
||||
if (millis() - timeout > 5000) {
|
||||
Serial.println("Client Timeout !");
|
||||
client.stop();
|
||||
return;
|
||||
}
|
||||
}
|
||||
// Once the response is available,
|
||||
// check stuff
|
||||
|
||||
/*
|
||||
Response Structure
|
||||
HTTP/1.1 200 OK
|
||||
x-amz-id-2: NVKxnU1aIQMmpGKhSwpCBh8y2JPbak18QLIfE+OiUDOos+7UftZKjtCFqrwsGOZRN5Zee0jpTd0=
|
||||
x-amz-request-id: 2D56B47560B764EC
|
||||
Date: Wed, 14 Jun 2017 03:33:59 GMT
|
||||
Last-Modified: Fri, 02 Jun 2017 14:50:11 GMT
|
||||
ETag: "d2afebbaaebc38cd669ce36727152af9"
|
||||
Accept-Ranges: bytes
|
||||
Content-Type: application/octet-stream
|
||||
Content-Length: 357280
|
||||
Server: AmazonS3
|
||||
|
||||
{{BIN FILE CONTENTS}}
|
||||
|
||||
*/
|
||||
while (client.available()) {
|
||||
// read line till /n
|
||||
String line = client.readStringUntil('\n');
|
||||
// remove space, to check if the line is end of headers
|
||||
line.trim();
|
||||
|
||||
// if the the line is empty,
|
||||
// this is end of headers
|
||||
// break the while and feed the
|
||||
// remaining `client` to the
|
||||
// Update.writeStream();
|
||||
if (!line.length()) {
|
||||
//headers ended
|
||||
break; // and get the OTA started
|
||||
}
|
||||
|
||||
// Check if the HTTP Response is 200
|
||||
// else break and Exit Update
|
||||
if (line.startsWith("HTTP/1.1")) {
|
||||
if (line.indexOf("200") < 0) {
|
||||
Serial.println("Got a non 200 status code from server. error.");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// extract headers here
|
||||
// Start with content length
|
||||
if (line.startsWith("Content-Length: ")) {
|
||||
contentLength = atoi((getHeaderValue(line, "Content-Length: ")).c_str());
|
||||
Serial.println("Got " + String(contentLength) + " bytes from server");
|
||||
}
|
||||
|
||||
// Next, the content type
|
||||
if (line.startsWith("Content-Type: ")) {
|
||||
String contentType = getHeaderValue(line, "Content-Type: ");
|
||||
Serial.println("Got " + contentType + " payload.");
|
||||
if (contentType == "application/text") {
|
||||
isValidContentType = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// Connect to updateHost failed
|
||||
// May be try?
|
||||
// Probably a choppy network?
|
||||
Serial.println("Connection to " + String(updateHost) + " failed. Please check your setup");
|
||||
// retry??
|
||||
// execOTA();
|
||||
}
|
||||
|
||||
/*
|
||||
Serial.printf("\nDataWeb On\n");
|
||||
//open file for appending new blank line to EOF.
|
||||
File f = SPIFFS.open("/data.html", "w");
|
||||
|
||||
f.println("<html><body>TEST de DATAWeb1</body></html>");
|
||||
|
||||
f.close();
|
||||
*/
|
||||
}
|
||||
|
||||
|
||||
|
||||
Executable
+226
@@ -0,0 +1,226 @@
|
||||
#include "time.h"
|
||||
#include "geteph.h"
|
||||
#include <SPIFFS.h>
|
||||
#include <WiFi.h>
|
||||
#include <rom/miniz.h>
|
||||
#include <inttypes.h>
|
||||
#include <WiFi.h>
|
||||
#include "Display.h"
|
||||
|
||||
|
||||
extern WiFiClient client;
|
||||
|
||||
static const char *ftpserver = "www.ngs.noaa.gov";
|
||||
char outbuf[128];
|
||||
|
||||
uint8_t getreply() {
|
||||
String s = client.readStringUntil('\n');
|
||||
Serial.println(s);
|
||||
const char *str = s.c_str();
|
||||
if(strlen(str)<4) return 255; // something unusual...
|
||||
if(str[3]=='-') { // multi-line resonse...
|
||||
String s2;
|
||||
const char *str2;
|
||||
do {
|
||||
s2 = client.readStringUntil('\n');
|
||||
Serial.println(s2);
|
||||
str2 = s2.c_str();
|
||||
if(strlen(str2)<4) return 255; // something is wrong
|
||||
} while( str[0]!=str2[0] || str[1]!=str2[1] || str[2]!=str2[2] || str2[3]!=' ' );
|
||||
}
|
||||
return str[0];
|
||||
}
|
||||
|
||||
void writeFully(File &file, uint8_t *buf, size_t len)
|
||||
{
|
||||
size_t olen;
|
||||
|
||||
while(len) {
|
||||
olen = file.write(buf, len);
|
||||
Serial.printf("written: %d of %d\n", olen, len);
|
||||
len -= olen;
|
||||
buf += olen;
|
||||
}
|
||||
}
|
||||
|
||||
void geteph() {
|
||||
// Set current time via network...
|
||||
struct tm tinfo;
|
||||
configTime(0, 0, "pool.ntp.org");
|
||||
bool ok = getLocalTime(&tinfo, 2000); // wait max 2 seconds to get current time via ntp
|
||||
if(!ok) {
|
||||
Serial.println("Failed to get current date/time");
|
||||
return;
|
||||
}
|
||||
|
||||
// Check time of last update
|
||||
int year = tinfo.tm_year + 1900;
|
||||
int day = tinfo.tm_yday + 1;
|
||||
Serial.printf("year %d, day %d\n", year, day);
|
||||
char nowstr[20];
|
||||
snprintf(nowstr, 20, "%04d%03d%02d", year, day, tinfo.tm_hour);
|
||||
File status = SPIFFS.open("/brdc.time", "r");
|
||||
if(status) {
|
||||
String ts = status.readStringUntil('\n');
|
||||
const char *tsstr = ts.c_str();
|
||||
if(tsstr && strlen(tsstr)>=9) {
|
||||
if(strcmp(nowstr, ts.c_str())<=0) {
|
||||
Serial.println("local brdc is up to date\n");
|
||||
return;
|
||||
}
|
||||
}
|
||||
Serial.printf("now: %s, existing: %s => updating\n", nowstr, tsstr);
|
||||
}
|
||||
status.close();
|
||||
disp.rdis->clear();
|
||||
disp.rdis->setFont(FONT_SMALL);
|
||||
disp.rdis->drawString(0, 0, "FTP ngs.noaa.gov");
|
||||
// fetch rinex from server
|
||||
File fh = SPIFFS.open("/brdc.gz","w");
|
||||
if(!fh) {
|
||||
Serial.println("cannot open file\n");
|
||||
return;
|
||||
}
|
||||
char buf[252];
|
||||
snprintf(buf, 128, "/cors/rinex/%04d/%03d/brdc%03d0.%02dn.gz", year, day, day, year-2000);
|
||||
Serial.println("running geteph\n");
|
||||
disp.rdis->drawString(0, 1, buf+21);
|
||||
|
||||
if(!client.connect(ftpserver, 21)) {
|
||||
Serial.println("FTP connection to www.ngs.noaa.gov failed");
|
||||
return;
|
||||
}
|
||||
#if 0
|
||||
while(!client.available()) delay(1);
|
||||
while(client.available()) {
|
||||
String s = client.readStringUntil('\n');
|
||||
Serial.println(s);
|
||||
}
|
||||
#endif
|
||||
if(getreply()>='4') { Serial.println("connected failed"); return; }
|
||||
client.print("USER anonymous\r\n");
|
||||
if(getreply()>='4') { Serial.println("USER failed"); return; }
|
||||
client.print("PASS anonymous\r\n");
|
||||
if(getreply()>='4') { Serial.println("PASS failed"); return; }
|
||||
client.print("TYPE I\r\n");
|
||||
if(getreply()>='4') { Serial.println("TYPE I failed"); return; }
|
||||
client.print("PASV\r\n");
|
||||
String s = client.readStringUntil('\n');
|
||||
Serial.println(s);
|
||||
if(s.c_str()[0]>='4') { Serial.println("PASV failed"); return; }
|
||||
int array_pasv[6];
|
||||
char *tStr = strtok((char *)s.c_str(), "(,");
|
||||
for(int i=0; i<6; i++) {
|
||||
tStr = strtok(NULL, "(,");
|
||||
if(tStr==NULL) {
|
||||
Serial.println("strange response to PASV");
|
||||
return;
|
||||
}
|
||||
array_pasv[i] = atoi(tStr);
|
||||
Serial.println(array_pasv[i]);
|
||||
}
|
||||
uint16_t port = (array_pasv[4]<<8) | (array_pasv[5]&0xff);
|
||||
WiFiClient dclient;
|
||||
Serial.printf("connecting to %s:%d\n", ftpserver,port);
|
||||
dclient.connect(ftpserver, port);
|
||||
if(!dclient) {
|
||||
Serial.println("data connection failed");
|
||||
return;
|
||||
}
|
||||
client.print("RETR ");
|
||||
Serial.printf("fetching %s with FTP...\n", buf);
|
||||
client.println(buf);
|
||||
s = client.readStringUntil('\n');
|
||||
Serial.println(s);
|
||||
if(s.c_str()[0]>='4') { Serial.println("RETR failed"); return; }
|
||||
int len=0;
|
||||
while(dclient.connected()) {
|
||||
while(dclient.available()) {
|
||||
char c = dclient.read();
|
||||
fh.write(c);
|
||||
len++;
|
||||
}
|
||||
}
|
||||
Serial.printf("fetched %d bytes\n", len);
|
||||
fh.close();
|
||||
snprintf(buf, 16, "Fetched %d B ",len);
|
||||
buf[16]=0;
|
||||
disp.rdis->drawString(0,2,buf);
|
||||
|
||||
disp.rdis->drawString(0,4,"Decompressing...");
|
||||
// decompression
|
||||
tinfl_decompressor *decomp = (tinfl_decompressor *)malloc(sizeof(tinfl_decompressor));
|
||||
tinfl_init(decomp);
|
||||
File file = SPIFFS.open("/brdc.gz","r");
|
||||
if(!file) {
|
||||
Serial.println("cannot open file\n");
|
||||
return;
|
||||
}
|
||||
File ofile = SPIFFS.open("/brdc", "w");
|
||||
if(!ofile) {
|
||||
Serial.println("cannot open file /brdc for writing");
|
||||
return;
|
||||
}
|
||||
file.readBytes(buf, 10); // skip gzip header
|
||||
char flags = buf[3];
|
||||
if(flags&0x07) {
|
||||
Serial.println("Unsupported flags in gzip header, may or may not cause a problem");
|
||||
}
|
||||
if(flags&0x08) { // skip file name extra header
|
||||
do {
|
||||
int res=file.readBytes(buf, 1);
|
||||
if(res!=1) return;
|
||||
} while(*buf);
|
||||
}
|
||||
if(flags&0x10) { // skip file name extra header
|
||||
do {
|
||||
int res=file.readBytes(buf, 1);
|
||||
if(res!=1) return;
|
||||
} while(*buf);
|
||||
}
|
||||
int opos = 0;
|
||||
int total = 0;
|
||||
Serial.println("Decompressing ephemeris data...\n");
|
||||
char *obuf =(char *)malloc(32768);
|
||||
char *ibuf =(char *)malloc(8192);
|
||||
while(file.available()) {
|
||||
size_t len = file.readBytes(ibuf, 8192);
|
||||
size_t inofs = 0;
|
||||
size_t inlen = len;
|
||||
while(inofs<len) {
|
||||
size_t outlen=32768-opos;
|
||||
int res = tinfl_decompress(decomp, (const mz_uint8 *)ibuf+inofs, &inlen, (uint8_t *)obuf, (mz_uint8 *)obuf+opos, &outlen, TINFL_FLAG_HAS_MORE_INPUT);
|
||||
if(res<0) break;
|
||||
if(outlen==0) break;
|
||||
Serial.printf("... (res=%d) decompressed %d into %d bytes\n", res, inlen, outlen);
|
||||
inofs += inlen;
|
||||
inlen = len - inofs;
|
||||
//size_t retv = ofile.write((uint8_t *)(obuf+opos), outlen);
|
||||
//Serial.printf("write %d bytes\n", retv);
|
||||
writeFully(ofile, (uint8_t *)(obuf+opos), outlen);
|
||||
//Serial.write((uint8_t *)(obuf+opos), outlen);
|
||||
total += outlen;
|
||||
opos += outlen;
|
||||
if(res==0) break; // done indication
|
||||
if(opos>=32768) {
|
||||
Serial.printf("... decompressed %d bytes\n", total);
|
||||
opos=0;
|
||||
}
|
||||
}
|
||||
}
|
||||
// maybe todo: check crc?!?
|
||||
Serial.printf("done extracing content (total length: %d)\n", total);
|
||||
status = SPIFFS.open("/brdc.time","w");
|
||||
status.println(nowstr);
|
||||
status.close();
|
||||
snprintf(buf, 16, "Done: %d B ",total);
|
||||
buf[16]=0;
|
||||
disp.rdis->drawString(0,5,buf);
|
||||
delay(1000);
|
||||
|
||||
free(obuf);
|
||||
free(ibuf);
|
||||
free(decomp);
|
||||
file.close();
|
||||
ofile.close();
|
||||
}
|
||||
Executable
+3
@@ -0,0 +1,3 @@
|
||||
|
||||
void geteph();
|
||||
|
||||
Executable
+26
@@ -0,0 +1,26 @@
|
||||
// SPDX-License-Identifier: GPL-3.0
|
||||
// original source: https://github.com/Nkawu/TFT_22_ILI9225
|
||||
|
||||
// Font structures like Adafruit_GFX (1.1 and later).
|
||||
// Example fonts are included in 'fonts' directory.
|
||||
// To use a font in your Arduino sketch, #include the corresponding .h
|
||||
// file and pass address of GFXfont struct to setFont().
|
||||
|
||||
#ifndef _GFFFONT_H_
|
||||
#define _GFFFONT_H_
|
||||
|
||||
typedef struct { // Data stored PER GLYPH
|
||||
uint16_t bitmapOffset; // Pointer into GFXfont->bitmap
|
||||
uint8_t width, height; // Bitmap dimensions in pixels
|
||||
uint8_t xAdvance; // Distance to advance cursor (x axis)
|
||||
int8_t xOffset, yOffset; // Dist from cursor pos to UL corner
|
||||
} GFXglyph;
|
||||
|
||||
typedef struct { // Data stored for FONT AS A WHOLE:
|
||||
uint8_t *bitmap; // Glyph bitmaps, concatenated
|
||||
GFXglyph *glyph; // Glyph array
|
||||
uint8_t first, last; // ASCII extents
|
||||
uint8_t yAdvance; // Newline distance (y axis)
|
||||
} GFXfont;
|
||||
|
||||
#endif // _GFFFONT_H_
|
||||
Executable
+1866
File diff suppressed because it is too large
Load Diff
Executable
+148
@@ -0,0 +1,148 @@
|
||||
|
||||
|
||||
typedef struct {
|
||||
uint16_t prn;
|
||||
uint16_t week;
|
||||
uint32_t toa;
|
||||
char epoch[20];
|
||||
double toe;
|
||||
double toc;
|
||||
double e;
|
||||
double delta_n;
|
||||
double delta_i;
|
||||
double i0;
|
||||
double OmegaDot;
|
||||
double sqrta;
|
||||
double Omega0;
|
||||
double w;
|
||||
double M0;
|
||||
double tgd;
|
||||
double idot;
|
||||
double cuc;
|
||||
double cus;
|
||||
double crc;
|
||||
double crs;
|
||||
double cic;
|
||||
double cis;
|
||||
double af0;
|
||||
double af1;
|
||||
double af2;
|
||||
int gpsweek;
|
||||
uint16_t svn;
|
||||
uint8_t ura;
|
||||
uint8_t health;
|
||||
uint8_t conf;
|
||||
} EPHEM_t;
|
||||
|
||||
|
||||
typedef struct {
|
||||
uint32_t t;
|
||||
double pseudorange;
|
||||
double pseudorate;
|
||||
double clock_corr;
|
||||
double clock_drift;
|
||||
double X;
|
||||
double Y;
|
||||
double Z;
|
||||
double vX;
|
||||
double vY;
|
||||
double vZ;
|
||||
int ephhr;
|
||||
double PR;
|
||||
double ephtime;
|
||||
int prn;
|
||||
} SAT_t;
|
||||
|
||||
|
||||
typedef struct {double X; double Y; double Z;} LOC_t;
|
||||
|
||||
typedef struct {double X; double Y; double Z;
|
||||
double vX; double vY; double vZ;} VEL_t;
|
||||
|
||||
|
||||
double dist(double X1, double Y1, double Z1, double X2, double Y2, double Z2);
|
||||
|
||||
void GPS_SatelliteClockCorrection(
|
||||
const unsigned short transmission_gpsweek, // GPS week when signal was transmit (0-1024+) [weeks]
|
||||
const double transmission_gpstow, // GPS time of week when signal was transmit [s]
|
||||
const unsigned short ephem_week, // ephemeris: GPS week (0-1024+) [weeks]
|
||||
const double toe, // ephemeris: time of week [s]
|
||||
const double toc, // ephemeris: clock reference time of week [s]
|
||||
const double af0, // ephemeris: polynomial clock correction coefficient [s],
|
||||
const double af1, // ephemeris: polynomial clock correction coefficient [s/s],
|
||||
const double af2, // ephemeris: polynomial clock correction coefficient [s/s^2]
|
||||
const double ecc, // ephemeris: eccentricity of satellite orbit []
|
||||
const double sqrta, // ephemeris: square root of the semi-major axis of orbit [m^(1/2)]
|
||||
const double delta_n, // ephemeris: mean motion difference from computed value [rad]
|
||||
const double m0, // ephemeris: mean anomaly at reference time [rad]
|
||||
const double tgd, // ephemeris: group delay differential between L1 and L2 [s]
|
||||
double* clock_correction );
|
||||
|
||||
void GPS_SatellitePosition_Ephem(
|
||||
const unsigned short gpsweek, // gps week of signal transmission (0-1024+) [week]
|
||||
const double gpstow, // time of week of signal transmission (gpstow-psr/c) [s]
|
||||
EPHEM_t ephem,
|
||||
double* clock_correction, // clock correction for this satellite for this epoch [m]
|
||||
double* satX, // satellite X position WGS84 ECEF [m]
|
||||
double* satY, // satellite Y position WGS84 ECEF [m]
|
||||
double* satZ // satellite Z position WGS84 ECEF [m]
|
||||
);
|
||||
|
||||
void GPS_SatelliteClockDriftCorrection(
|
||||
const unsigned short transmission_gpsweek, // GPS week when signal was transmit (0-1024+) [weeks]
|
||||
const double transmission_gpstow, // GPS time of week when signal was transmit [s]
|
||||
const unsigned short ephem_week, // ephemeris: GPS week (0-1024+) [weeks]
|
||||
const double toe, // ephemeris: time of week [s]
|
||||
const double toc, // ephemeris: clock reference time of week [s]
|
||||
const double af0, // ephemeris: polynomial clock correction coefficient [s],
|
||||
const double af1, // ephemeris: polynomial clock correction coefficient [s/s],
|
||||
const double af2, // ephemeris: polynomial clock correction coefficient [s/s^2]
|
||||
const double ecc, // ephemeris: eccentricity of satellite orbit []
|
||||
const double sqrta, // ephemeris: square root of the semi-major axis of orbit [m^(1/2)]
|
||||
const double delta_n, // ephemeris: mean motion difference from computed value [rad]
|
||||
const double m0, // ephemeris: mean anomaly at reference time [rad]
|
||||
const double tgd, // ephemeris: group delay differential between L1 and L2 [s]
|
||||
double* clock_correction, // ephemeris: satellite clock correction [m]
|
||||
double* clock_drift ) ;
|
||||
|
||||
void GPS_SatellitePositionVelocity_Ephem(
|
||||
const unsigned short gpsweek, // gps week of signal transmission (0-1024+) [week]
|
||||
const double gpstow, // time of week of signal transmission (gpstow-psr/c) [s]
|
||||
EPHEM_t ephem,
|
||||
double* clock_correction, // clock correction for this satellite for this epoch [m]
|
||||
double* clock_drift, // clock correction for this satellite for this epoch [m]
|
||||
double* satX, // satellite X position WGS84 ECEF [m]
|
||||
double* satY, // satellite Y position WGS84 ECEF [m]
|
||||
double* satZ, // satellite Z position WGS84 ECEF [m]
|
||||
double* satvX, // satellite X velocity WGS84 ECEF [m]
|
||||
double* satvY, // satellite Y velocity WGS84 ECEF [m]
|
||||
double* satvZ // satellite Z velocity WGS84 ECEF [m]
|
||||
);
|
||||
|
||||
|
||||
int NAV_ClosedFormSolution_FromPseudorange(
|
||||
SAT_t sats[4], // input: satellite position and pseudorange
|
||||
double* latitude, // output: ellipsoid latitude [rad]
|
||||
double* longitude, // ellipsoid longitude [rad]
|
||||
double* height, // ellipsoid height [m]
|
||||
double* rx_clock_bias, // receiver clock bias [m]
|
||||
double pos_ecef[3] );
|
||||
|
||||
int calc_DOPn(int n, SAT_t satss[], double pos_ecef[3], double DOP[4]);
|
||||
|
||||
int NAV_LinP(int N, SAT_t satv[], double pos_ecef[3], double dt,
|
||||
double dpos_ecef[3], double *cc);
|
||||
void ecef2elli(double X, double Y, double Z, double *lat, double *lon, double *alt);
|
||||
|
||||
int NAV_LinP(int N, SAT_t satv[], double pos_ecef[3], double dt,
|
||||
double dpos_ecef[3], double *cc);
|
||||
|
||||
int NAV_LinV(int N, SAT_t satv[], double pos_ecef[3],
|
||||
double vel_ecef[3], double dt,
|
||||
double dvel_ecef[3], double *cc);
|
||||
|
||||
int NAV_bancroft1(int N, SAT_t sats[], double pos_ecef[3], double *cc);
|
||||
|
||||
EPHEM_t *read_RNXpephs(const char *file);
|
||||
|
||||
|
||||
Executable
+1735
File diff suppressed because it is too large
Load Diff
Executable
+22
@@ -0,0 +1,22 @@
|
||||
|
||||
typedef struct {
|
||||
int frnr;
|
||||
char id[11];
|
||||
int week; int gpssec;
|
||||
int jahr; int monat; int tag;
|
||||
int wday;
|
||||
int std; int min; float sek;
|
||||
double lat; double lon; double alt;
|
||||
double vH; double vD; double vU;
|
||||
int k;
|
||||
int sats[4];
|
||||
double dop;
|
||||
int freq;
|
||||
unsigned short aux[4];
|
||||
double diter;
|
||||
} gpx_t;
|
||||
|
||||
extern gpx_t gpx;
|
||||
|
||||
void print_frame(uint8_t *data, int len);
|
||||
void get_eph(const char *file);
|
||||
Executable
+32
@@ -0,0 +1,32 @@
|
||||
/*
|
||||
* dxlAPRS toolchain
|
||||
*
|
||||
* Copyright (C) Christian Rabler <oe5dxl@oevsv.at>
|
||||
*
|
||||
* SPDX-License-Identifier: GPL-2.0+
|
||||
*/
|
||||
|
||||
#ifndef inttypes_h
|
||||
#include <inttypes.h>
|
||||
#endif
|
||||
|
||||
#define N 255
|
||||
#define R 24
|
||||
#define K (N-R)
|
||||
|
||||
void *init_rs_char(int symsize,int gfpoly,int fcr,int prim,int nroots,int pad);
|
||||
int decode_rs_char(void *arg,
|
||||
unsigned char *data, int *eras_pos, int no_eras);
|
||||
|
||||
void *rs;
|
||||
|
||||
void initrsc()
|
||||
{
|
||||
rs = init_rs_char( 8, 0x11d, 0, 1, R, 0);
|
||||
}
|
||||
|
||||
|
||||
int decodersc(char *data, uint32_t *eras_pos, uint32_t no_eras)
|
||||
{
|
||||
return decode_rs_char(rs, (unsigned char *)data, (int *)eras_pos, no_eras);
|
||||
}
|
||||
Executable
+17
@@ -0,0 +1,17 @@
|
||||
/*
|
||||
* dxlAPRS toolchain
|
||||
*
|
||||
* Copyright (C) Christian Rabler <oe5dxl@oevsv.at>
|
||||
*
|
||||
* SPDX-License-Identifier: GPL-2.0+
|
||||
*/
|
||||
#ifndef rsc_H_
|
||||
#define rsc_H_
|
||||
|
||||
|
||||
long decodersc(char [], uint32_t [], uint32_t);
|
||||
|
||||
void initrsc(void);
|
||||
|
||||
|
||||
#endif /* rsc_H_ */
|
||||
Executable
+436
@@ -0,0 +1,436 @@
|
||||
/*
|
||||
* Copyright 2016 Hannes Schmelzer, OE5HPM
|
||||
* doing several cleanups and architecture changes, no functional change yet
|
||||
*
|
||||
* General purpose Reed-Solomon decoder for 8-bit symbols or less
|
||||
* Copyright 2003 Phil Karn, KA9Q
|
||||
* May be used under the terms of the GNU Lesser General Public License (LGPL)
|
||||
*
|
||||
* The guts of the Reed-Solomon decoder, meant to be #included
|
||||
* into a function body with the following typedefs, macros and variables supplied
|
||||
* according to the code parameters:
|
||||
|
||||
* data_t - a typedef for the data symbol
|
||||
* data_t data[] - array of rs->nn data and parity symbols to be corrected in place
|
||||
* retval - an integer lvalue into which the decoder's return code is written
|
||||
* NROOTS - the number of roots in the RS code generator polynomial,
|
||||
* which is the same as the number of parity symbols in a block.
|
||||
Integer variable or literal.
|
||||
* rs->nn - the total number of symbols in a RS block. Integer variable or literal.
|
||||
* rs->pad - the number of pad symbols in a block. Integer variable or literal.
|
||||
* rs->alpha_to - The address of an array of rs->nn elements to convert Galois field
|
||||
* elements in index (log) form to polynomial form. Read only.
|
||||
* rs->index_of - The address of an array of rs->nn elements to convert Galois field
|
||||
* elements in polynomial form to index (log) form. Read only.
|
||||
* MODNN - a function to reduce its argument modulo rs->nn. May be inline or a macro.
|
||||
* rs->fcr - An integer literal or variable specifying the first consecutive root of the
|
||||
* Reed-Solomon generator polynomial. Integer variable or literal.
|
||||
* rs->prim - The primitive root of the generator poly. Integer variable or literal.
|
||||
* DEBUG - If set to 1 or more, do various internal consistency checking. Leave this
|
||||
* undefined for production code
|
||||
|
||||
* The memset(), memmove(), and memcpy() functions are used. The appropriate header
|
||||
* file declaring these functions (usually <string.h>) must be included by the calling
|
||||
* program.
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
struct rs {
|
||||
unsigned int magic; /* struct magic */
|
||||
int mm; /* Bits per symbol */
|
||||
int nn; /* Symbols per block (= (1<<mm)-1) */
|
||||
unsigned char *alpha_to; /* log lookup table */
|
||||
unsigned char *index_of; /* Antilog lookup table */
|
||||
unsigned char *genpoly; /* Generator polynomial */
|
||||
int nroots; /*
|
||||
* Number of generator
|
||||
* roots = number of parity symbols
|
||||
*/
|
||||
int fcr; /* First consecutive root, index form */
|
||||
int prim; /* Primitive element, index form */
|
||||
int iprim; /* prim-th root of 1, index form */
|
||||
int pad; /* Padding bytes in shortened block */
|
||||
};
|
||||
|
||||
static inline int modnn(struct rs *rs,int x)
|
||||
{
|
||||
while (x >= rs->nn) {
|
||||
x -= rs->nn;
|
||||
x = (x >> rs->mm) + (x & rs->nn);
|
||||
}
|
||||
return x;
|
||||
}
|
||||
|
||||
#define MODNN(x) modnn(rs, x)
|
||||
#define MIN(a,b) ((a) < (b) ? (a) : (b))
|
||||
#define MAGIC 0xABCD6722
|
||||
|
||||
void free_rs_char(void *arg)
|
||||
{
|
||||
struct rs *rs = (struct rs *)arg;
|
||||
|
||||
if (rs == NULL)
|
||||
return;
|
||||
if (rs->magic != MAGIC)
|
||||
return;
|
||||
|
||||
if (rs->alpha_to != NULL)
|
||||
free(rs->alpha_to);
|
||||
if (rs->index_of != NULL)
|
||||
free(rs->index_of);
|
||||
if (rs->genpoly != NULL)
|
||||
free(rs->genpoly);
|
||||
free(rs);
|
||||
}
|
||||
|
||||
/* Initialize a Reed-Solomon codec
|
||||
* symsize = symbol size, bits
|
||||
* gfpoly = Field generator polynomial coefficients
|
||||
* fcr = first root of RS code generator polynomial, index form
|
||||
* prim = primitive element to generate polynomial roots
|
||||
* nroots = RS code generator polynomial degree (number of roots)
|
||||
* pad = padding bytes at front of shortened block
|
||||
*/
|
||||
void *init_rs_char(int symsize, int gfpoly, int fcr, int prim,
|
||||
int nroots, int pad)
|
||||
{
|
||||
struct rs *rs;
|
||||
|
||||
int i, j, sr,root,iprim;
|
||||
|
||||
/* Check parameter ranges */
|
||||
if (symsize < 0 || symsize > 8*sizeof(unsigned char))
|
||||
return NULL;
|
||||
if (fcr < 0 || fcr >= (1<<symsize))
|
||||
return NULL;
|
||||
if (prim <= 0 || prim >= (1<<symsize))
|
||||
return NULL;
|
||||
if (nroots < 0 || nroots >= (1<<symsize))
|
||||
return NULL;
|
||||
if (pad < 0 || pad >= ((1<<symsize) -1 - nroots))
|
||||
return NULL;
|
||||
|
||||
rs = (struct rs*)malloc(sizeof(*rs));
|
||||
if (rs == NULL) {
|
||||
printf("%s: cannot allocate memory!\n", __func__);
|
||||
return NULL;
|
||||
}
|
||||
memset(rs, 0, sizeof(*rs));
|
||||
rs->magic = MAGIC;
|
||||
|
||||
rs->mm = symsize;
|
||||
rs->nn = (1<<symsize)-1;
|
||||
rs->pad = pad;
|
||||
|
||||
rs->alpha_to = (unsigned char *)malloc(sizeof(unsigned char)*(rs->nn+1));
|
||||
if (rs->alpha_to == NULL) {
|
||||
free(rs);
|
||||
return NULL;
|
||||
}
|
||||
rs->index_of = (unsigned char *)malloc(sizeof(unsigned char)*(rs->nn+1));
|
||||
if (rs->index_of == NULL) {
|
||||
free(rs->alpha_to);
|
||||
free(rs);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* Generate Galois field lookup tables */
|
||||
rs->index_of[0] = rs->nn; /* log(zero) = -inf */
|
||||
rs->alpha_to[rs->nn] = 0; /* alpha**-inf = 0 */
|
||||
sr = 1;
|
||||
for (i = 0; i < rs->nn; i++) {
|
||||
rs->index_of[sr] = i;
|
||||
rs->alpha_to[i] = sr;
|
||||
sr <<= 1;
|
||||
if (sr & (1<<symsize))
|
||||
sr ^= gfpoly;
|
||||
sr &= rs->nn;
|
||||
}
|
||||
if (sr != 1) {
|
||||
/* field generator polynomial is not primitive! */
|
||||
free(rs->alpha_to);
|
||||
free(rs->index_of);
|
||||
free(rs);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* Form RS code generator polynomial from its roots */
|
||||
rs->genpoly = (unsigned char *)malloc(sizeof(unsigned char)*(nroots+1));
|
||||
if(rs->genpoly == NULL) {
|
||||
free(rs->alpha_to);
|
||||
free(rs->index_of);
|
||||
free(rs);
|
||||
return NULL;
|
||||
}
|
||||
rs->fcr = fcr;
|
||||
rs->prim = prim;
|
||||
rs->nroots = nroots;
|
||||
|
||||
/* Find prim-th root of 1, used in decoding */
|
||||
for (iprim = 1; (iprim % prim) != 0; iprim += rs->nn)
|
||||
;
|
||||
rs->iprim = iprim / prim;
|
||||
|
||||
rs->genpoly[0] = 1;
|
||||
for (i = 0, root = fcr*prim; i < nroots; i++, root += prim) {
|
||||
rs->genpoly[i+1] = 1;
|
||||
|
||||
/* Multiply rs->genpoly[] by @**(root + x) */
|
||||
for (j = i; j > 0; j--) {
|
||||
if (rs->genpoly[j] != 0)
|
||||
rs->genpoly[j] = rs->genpoly[j-1] ^ rs->alpha_to[modnn(rs,rs->index_of[rs->genpoly[j]] + root)];
|
||||
else
|
||||
rs->genpoly[j] = rs->genpoly[j-1];
|
||||
}
|
||||
/* rs->genpoly[0] can never be zero */
|
||||
rs->genpoly[0] = rs->alpha_to[modnn(rs,rs->index_of[rs->genpoly[0]] + root)];
|
||||
}
|
||||
/* convert rs->genpoly[] to index form for quicker encoding */
|
||||
for (i = 0; i <= nroots; i++)
|
||||
rs->genpoly[i] = rs->index_of[rs->genpoly[i]];
|
||||
|
||||
return rs;
|
||||
}
|
||||
|
||||
int decode_rs_char(void *arg,
|
||||
unsigned char *data, int *eras_pos, int no_eras)
|
||||
{
|
||||
struct rs *rs = (struct rs *)arg;
|
||||
|
||||
if (rs == NULL)
|
||||
return -1;
|
||||
if (rs->magic != MAGIC)
|
||||
return -1;
|
||||
|
||||
int retval;
|
||||
int deg_lambda, el, deg_omega;
|
||||
int i, j, r,k;
|
||||
|
||||
unsigned char u,q,tmp,num1,num2,den,discr_r;
|
||||
unsigned char lambda[rs->nroots+1], s[rs->nroots]; /* Err+Eras Locator poly
|
||||
* and syndrome poly */
|
||||
unsigned char b[rs->nroots+1], t[rs->nroots+1], omega[rs->nroots+1];
|
||||
unsigned char root[rs->nroots], reg[rs->nroots+1], loc[rs->nroots];
|
||||
int syn_error, count;
|
||||
|
||||
/* form the syndromes; i.e., evaluate data(x) at roots of g(x) */
|
||||
for (i = 0; i < rs->nroots; i++)
|
||||
s[i] = data[0];
|
||||
|
||||
for (j = 1; j < rs->nn-rs->pad; j++) {
|
||||
for(i=0;i<rs->nroots;i++) {
|
||||
if(s[i] == 0) {
|
||||
s[i] = data[j];
|
||||
} else {
|
||||
s[i] = data[j] ^ rs->alpha_to[MODNN(rs->index_of[s[i]] + (rs->fcr+i)*rs->prim)];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Convert syndromes to index form, checking for nonzero condition */
|
||||
syn_error = 0;
|
||||
for (i = 0; i < rs->nroots; i++) {
|
||||
syn_error |= s[i];
|
||||
s[i] = rs->index_of[s[i]];
|
||||
}
|
||||
|
||||
if (!syn_error) {
|
||||
/* if syndrome is zero, data[] is a codeword and there are no
|
||||
* errors to correct. So return data[] unmodified
|
||||
*/
|
||||
count = 0;
|
||||
goto finish;
|
||||
}
|
||||
memset(&lambda[1], 0, rs->nroots*sizeof(lambda[0]));
|
||||
lambda[0] = 1;
|
||||
|
||||
if (no_eras > 0) {
|
||||
/* Init lambda to be the erasure locator polynomial */
|
||||
lambda[1] = rs->alpha_to[MODNN(rs->prim*(rs->nn-1-eras_pos[0]))];
|
||||
for (i = 1; i < no_eras; i++) {
|
||||
u = MODNN(rs->prim*(rs->nn-1-eras_pos[i]));
|
||||
for (j = i+1; j > 0; j--) {
|
||||
tmp = rs->index_of[lambda[j - 1]];
|
||||
if(tmp != rs->nn)
|
||||
lambda[j] ^= rs->alpha_to[MODNN(u + tmp)];
|
||||
}
|
||||
}
|
||||
|
||||
#if DEBUG >= 1
|
||||
/* Test code that verifies the erasure locator polynomial just constructed
|
||||
Needed only for decoder debugging. */
|
||||
|
||||
/* find roots of the erasure location polynomial */
|
||||
for(i=1;i<=no_eras;i++)
|
||||
reg[i] = rs->index_of[lambda[i]];
|
||||
|
||||
count = 0;
|
||||
for (i = 1,k=rs->iprim-1; i <= rs->nn; i++,k = MODNN(k+rs->iprim)) {
|
||||
q = 1;
|
||||
for (j = 1; j <= no_eras; j++)
|
||||
if (reg[j] != rs->nn) {
|
||||
reg[j] = MODNN(reg[j] + j);
|
||||
q ^= rs->alpha_to[reg[j]];
|
||||
}
|
||||
if (q != 0)
|
||||
continue;
|
||||
/* store root and error location number indices */
|
||||
root[count] = i;
|
||||
loc[count] = k;
|
||||
count++;
|
||||
}
|
||||
if (count != no_eras) {
|
||||
printf("count = %d no_eras = %d\n lambda(x) is WRONG\n",count,no_eras);
|
||||
count = -1;
|
||||
goto finish;
|
||||
}
|
||||
#if DEBUG >= 2
|
||||
printf("\n Erasure positions as determined by roots of Eras Loc Poly:\n");
|
||||
for (i = 0; i < count; i++)
|
||||
printf("%d ", loc[i]);
|
||||
printf("\n");
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
for (i = 0; i < rs->nroots+1; i++)
|
||||
b[i] = rs->index_of[lambda[i]];
|
||||
|
||||
/*
|
||||
* Begin Berlekamp-Massey algorithm to determine error+erasure
|
||||
* locator polynomial
|
||||
*/
|
||||
r = no_eras;
|
||||
el = no_eras;
|
||||
while (++r <= rs->nroots) { /* r is the step number */
|
||||
/* Compute discrepancy at the r-th step in poly-form */
|
||||
discr_r = 0;
|
||||
for (i = 0; i < r; i++) {
|
||||
if ((lambda[i] != 0) && (s[r-i-1] != rs->nn)) {
|
||||
discr_r ^= rs->alpha_to[MODNN(rs->index_of[lambda[i]] + s[r-i-1])];
|
||||
}
|
||||
}
|
||||
discr_r = rs->index_of[discr_r]; /* Index form */
|
||||
if (discr_r == rs->nn) {
|
||||
/* 2 lines below: B(x) <-- x*B(x) */
|
||||
memmove(&b[1],b,rs->nroots*sizeof(b[0]));
|
||||
b[0] = rs->nn;
|
||||
} else {
|
||||
/* 7 lines below: T(x) <-- lambda(x) - discr_r*x*b(x) */
|
||||
t[0] = lambda[0];
|
||||
for (i = 0 ; i < rs->nroots; i++) {
|
||||
if(b[i] != rs->nn)
|
||||
t[i+1] = lambda[i+1] ^ rs->alpha_to[MODNN(discr_r + b[i])];
|
||||
else
|
||||
t[i+1] = lambda[i+1];
|
||||
}
|
||||
if (2 * el <= r + no_eras - 1) {
|
||||
el = r + no_eras - el;
|
||||
/*
|
||||
* 2 lines below: B(x) <-- inv(discr_r) *
|
||||
* lambda(x)
|
||||
*/
|
||||
for (i = 0; i <= rs->nroots; i++)
|
||||
b[i] = (lambda[i] == 0) ? rs->nn : MODNN(rs->index_of[lambda[i]] - discr_r + rs->nn);
|
||||
} else {
|
||||
/* 2 lines below: B(x) <-- x*B(x) */
|
||||
memmove(&b[1],b,rs->nroots*sizeof(b[0]));
|
||||
b[0] = rs->nn;
|
||||
}
|
||||
memcpy(lambda,t,(rs->nroots+1)*sizeof(t[0]));
|
||||
}
|
||||
}
|
||||
|
||||
/* Convert lambda to index form and compute deg(lambda(x)) */
|
||||
deg_lambda = 0;
|
||||
for (i = 0;i < rs->nroots+1; i++){
|
||||
lambda[i] = rs->index_of[lambda[i]];
|
||||
if(lambda[i] != rs->nn)
|
||||
deg_lambda = i;
|
||||
}
|
||||
/* Find roots of the error+erasure locator polynomial by Chien search */
|
||||
memcpy(®[1], &lambda[1], rs->nroots*sizeof(reg[0]));
|
||||
count = 0; /* Number of roots of lambda(x) */
|
||||
for (i = 1,k=rs->iprim-1; i <= rs->nn; i++,k = MODNN(k+rs->iprim)) {
|
||||
q = 1; /* lambda[0] is always 0 */
|
||||
for (j = deg_lambda; j > 0; j--) {
|
||||
if (reg[j] != rs->nn) {
|
||||
reg[j] = MODNN(reg[j] + j);
|
||||
q ^= rs->alpha_to[reg[j]];
|
||||
}
|
||||
}
|
||||
if (q != 0)
|
||||
continue; /* Not a root */
|
||||
/* store root (index-form) and error location number */
|
||||
#if DEBUG>=2
|
||||
printf("count %d root %d loc %d\n",count,i,k);
|
||||
#endif
|
||||
root[count] = i;
|
||||
loc[count] = k;
|
||||
/* If we've already found max possible roots,
|
||||
* abort the search to save time
|
||||
*/
|
||||
if(++count == deg_lambda)
|
||||
break;
|
||||
}
|
||||
if (deg_lambda != count) {
|
||||
/*
|
||||
* deg(lambda) unequal to number of roots => uncorrectable
|
||||
* error detected
|
||||
*/
|
||||
count = -1;
|
||||
goto finish;
|
||||
}
|
||||
/*
|
||||
* Compute err+eras evaluator poly omega(x) = s(x)*lambda(x) (modulo
|
||||
* x**rs->nroots). in index form. Also find deg(omega).
|
||||
*/
|
||||
deg_omega = deg_lambda-1;
|
||||
for (i = 0; i <= deg_omega;i++) {
|
||||
tmp = 0;
|
||||
for (j = i; j >= 0; j--) {
|
||||
if ((s[i - j] != rs->nn) && (lambda[j] != rs->nn))
|
||||
tmp ^= rs->alpha_to[MODNN(s[i - j] + lambda[j])];
|
||||
}
|
||||
omega[i] = rs->index_of[tmp];
|
||||
}
|
||||
/*
|
||||
* Compute error values in poly-form. num1 = omega(inv(X(l))), num2 =
|
||||
* inv(X(l))**(rs->fcr-1) and den = lambda_pr(inv(X(l))) all in poly-form
|
||||
*/
|
||||
for (j = count-1; j >=0; j--) {
|
||||
num1 = 0;
|
||||
for (i = deg_omega; i >= 0; i--) {
|
||||
if (omega[i] != rs->nn)
|
||||
num1 ^= rs->alpha_to[MODNN(omega[i] + i * root[j])];
|
||||
}
|
||||
num2 = rs->alpha_to[MODNN(root[j] * (rs->fcr - 1) + rs->nn)];
|
||||
den = 0;
|
||||
|
||||
/* lambda[i+1] for i even is the formal derivative lambda_pr of lambda[i] */
|
||||
for (i = MIN(deg_lambda, rs->nroots-1) & ~1; i >= 0; i -=2) {
|
||||
if(lambda[i+1] != rs->nn)
|
||||
den ^= rs->alpha_to[MODNN(lambda[i+1] + i * root[j])];
|
||||
}
|
||||
#if DEBUG >= 1
|
||||
if (den == 0) {
|
||||
printf("\n ERROR: denominator = 0\n");
|
||||
count = -1;
|
||||
goto finish;
|
||||
}
|
||||
#endif
|
||||
/* Apply error to data */
|
||||
if (num1 != 0 && loc[j] >= rs->pad) {
|
||||
data[loc[j]-rs->pad] ^= rs->alpha_to[MODNN(rs->index_of[num1] + rs->index_of[num2] + rs->nn - rs->index_of[den])];
|
||||
}
|
||||
}
|
||||
finish:
|
||||
if(eras_pos != NULL) {
|
||||
for (i = 0; i < count; i++)
|
||||
eras_pos[i] = loc[i];
|
||||
}
|
||||
retval = count;
|
||||
|
||||
return retval;
|
||||
}
|
||||
Executable
+36
@@ -0,0 +1,36 @@
|
||||
#include <FS.h>
|
||||
#include <SPIFFS.h>
|
||||
#include <SD_MMC.h> // (or SD_MMC.h)
|
||||
|
||||
|
||||
void transfert_sd() {
|
||||
|
||||
if (!SD_MMC.begin()) {
|
||||
Serial.println("Carte SD introuvable");
|
||||
|
||||
}
|
||||
else{
|
||||
Serial.println("Carte SD détectée");
|
||||
sonde.clearDisplay();
|
||||
disp.rdis->drawString(0, 2, "Carte SD On");
|
||||
disp.rdis->drawString(0, 4, "Transfert Data");
|
||||
File sourceFile = SPIFFS.open("/data.csv", "r");
|
||||
File destFile = SD_MMC.open("/data.csv","w");
|
||||
|
||||
static uint8_t tanpon[512];
|
||||
while( sourceFile.read( tanpon, 512) ) {
|
||||
destFile.write( tanpon, 512 );
|
||||
}
|
||||
destFile.close();
|
||||
sourceFile.close();
|
||||
delay(1000);
|
||||
//sonde.updateDisplay();
|
||||
sonde.clearDisplay();
|
||||
disp.rdis->drawString(0, 2, "Sortir SD");
|
||||
disp.rdis->drawString(0, 4, "Reboot 5s");
|
||||
delay(5000);
|
||||
ESP.restart();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user