version info in version.h, some code formatting (arduino style)
This commit is contained in:
parent
b68ffee8b0
commit
8da577a313
|
|
@ -10,6 +10,7 @@
|
||||||
#include <Sonde.h>
|
#include <Sonde.h>
|
||||||
#include <Scanner.h>
|
#include <Scanner.h>
|
||||||
#include <aprs.h>
|
#include <aprs.h>
|
||||||
|
#include "version.h"
|
||||||
|
|
||||||
// UNCOMMENT one of the constructor lines below
|
// UNCOMMENT one of the constructor lines below
|
||||||
U8X8_SSD1306_128X64_NONAME_SW_I2C *u8x8 = NULL; // initialize later after reading config file
|
U8X8_SSD1306_128X64_NONAME_SW_I2C *u8x8 = NULL; // initialize later after reading config file
|
||||||
|
|
@ -142,7 +143,7 @@ const char *handleQRGPost(AsyncWebServerRequest *request) {
|
||||||
Serial.println(request->getParam(i)->name().c_str());
|
Serial.println(request->getParam(i)->name().c_str());
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
for(int i=1; i<=sonde.config.maxsonde; i++) {
|
for (int i = 1; i <= sonde.config.maxsonde; i++) {
|
||||||
snprintf(label, 10, "A%d", i);
|
snprintf(label, 10, "A%d", i);
|
||||||
AsyncWebParameter *active = request->getParam(label, true);
|
AsyncWebParameter *active = request->getParam(label, true);
|
||||||
snprintf(label, 10, "F%d", i);
|
snprintf(label, 10, "F%d", i);
|
||||||
|
|
@ -523,9 +524,11 @@ void setup()
|
||||||
u8x8->clear();
|
u8x8->clear();
|
||||||
|
|
||||||
u8x8->setFont(u8x8_font_7x14_1x2_r);
|
u8x8->setFont(u8x8_font_7x14_1x2_r);
|
||||||
u8x8->drawString(1, 1, "RDZ_TTGO_SONDE");
|
u8x8->drawString(8 - strlen(version_name) / 2, 1, version_name);
|
||||||
u8x8->drawString(2, 3, "devel20190426");
|
u8x8->drawString(8 - strlen(version_id) / 2, 3, version_id);
|
||||||
u8x8->drawString(1, 5, "Mods by DL2MF");
|
u8x8->setFont(u8x8_font_chroma48medium8_r);
|
||||||
|
u8x8->drawString(0, 5, "by Hansi, DL9RDZ");
|
||||||
|
u8x8->drawString(1, 6, "Mods by DL2MF");
|
||||||
delay(3000);
|
delay(3000);
|
||||||
|
|
||||||
sonde.clearDisplay();
|
sonde.clearDisplay();
|
||||||
|
|
@ -705,7 +708,12 @@ void loopScanner() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int specTimer = 0;
|
||||||
|
|
||||||
void loopSpectrum() {
|
void loopSpectrum() {
|
||||||
|
int marker = 0;
|
||||||
|
char buf[5];
|
||||||
|
|
||||||
switch (getKeyPress()) {
|
switch (getKeyPress()) {
|
||||||
case KP_SHORT: /* move selection of peak, TODO */
|
case KP_SHORT: /* move selection of peak, TODO */
|
||||||
sonde.nextConfig(); // TODO: Should be set specific frequency
|
sonde.nextConfig(); // TODO: Should be set specific frequency
|
||||||
|
|
@ -718,25 +726,9 @@ void loopSpectrum() {
|
||||||
case KP_DOUBLE: /* ignore */ break;
|
case KP_DOUBLE: /* ignore */ break;
|
||||||
default: break;
|
default: break;
|
||||||
}
|
}
|
||||||
|
|
||||||
scanner.scan();
|
scanner.scan();
|
||||||
scanner.plotResult();
|
scanner.plotResult();
|
||||||
}
|
|
||||||
|
|
||||||
void startSpectrumDisplay() {
|
|
||||||
int marker=0;
|
|
||||||
char buf[5];
|
|
||||||
|
|
||||||
sonde.clearDisplay();
|
|
||||||
u8x8->setFont(u8x8_font_chroma48medium8_r);
|
|
||||||
u8x8->drawString(0, 0, "Spectrum Scan...");
|
|
||||||
delay(500);
|
|
||||||
|
|
||||||
enterMode(ST_SPECTRUM);
|
|
||||||
|
|
||||||
for (int i = 0; i < sonde.config.spectrum; i++) {
|
|
||||||
scanner.scan();
|
|
||||||
scanner.plotResult();
|
|
||||||
|
|
||||||
if (sonde.config.marker != 0) {
|
if (sonde.config.marker != 0) {
|
||||||
itoa((sonde.config.startfreq), buf, 10);
|
itoa((sonde.config.startfreq), buf, 10);
|
||||||
u8x8->drawString(0, 1, buf);
|
u8x8->drawString(0, 1, buf);
|
||||||
|
|
@ -744,19 +736,30 @@ void startSpectrumDisplay() {
|
||||||
itoa((sonde.config.startfreq + 6), buf, 10);
|
itoa((sonde.config.startfreq + 6), buf, 10);
|
||||||
u8x8->drawString(13, 1, buf);
|
u8x8->drawString(13, 1, buf);
|
||||||
}
|
}
|
||||||
|
if (specTimer > 0) {
|
||||||
if (sonde.config.timer != 0) {
|
itoa(specTimer, buf, 10);
|
||||||
itoa((sonde.config.spectrum - i), buf, 10);
|
|
||||||
if (sonde.config.marker != 0) {
|
if (sonde.config.marker != 0) {
|
||||||
marker = 1;
|
marker = 1;
|
||||||
}
|
}
|
||||||
u8x8->drawString(0, 1+marker, buf);
|
u8x8->drawString(0, 1 + marker, buf);
|
||||||
u8x8->drawString(2, 1+marker, "Sec.");
|
u8x8->drawString(2, 1 + marker, "Sec.");
|
||||||
|
specTimer--;
|
||||||
|
if (specTimer <= 0) {
|
||||||
|
enterMode(ST_SCANNER);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
delay(1000);
|
delay(1000);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void startSpectrumDisplay() {
|
||||||
|
sonde.clearDisplay();
|
||||||
|
u8x8->setFont(u8x8_font_chroma48medium8_r);
|
||||||
|
u8x8->drawString(0, 0, "Spectrum Scan...");
|
||||||
|
delay(500);
|
||||||
|
specTimer = sonde.config.spectrum;
|
||||||
|
enterMode(ST_SPECTRUM);
|
||||||
|
}
|
||||||
|
|
||||||
String translateEncryptionType(wifi_auth_mode_t encryptionType) {
|
String translateEncryptionType(wifi_auth_mode_t encryptionType) {
|
||||||
switch (encryptionType) {
|
switch (encryptionType) {
|
||||||
case (WIFI_AUTH_OPEN):
|
case (WIFI_AUTH_OPEN):
|
||||||
|
|
@ -775,7 +778,7 @@ String translateEncryptionType(wifi_auth_mode_t encryptionType) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void enableNetwork(bool enable) {
|
void enableNetwork(bool enable) {
|
||||||
if(enable) {
|
if (enable) {
|
||||||
SetupAsyncServer();
|
SetupAsyncServer();
|
||||||
udp.begin(WiFi.localIP(), LOCALUDPPORT);
|
udp.begin(WiFi.localIP(), LOCALUDPPORT);
|
||||||
connected = true;
|
connected = true;
|
||||||
|
|
@ -812,7 +815,7 @@ void WiFiEvent(WiFiEvent_t event)
|
||||||
break;
|
break;
|
||||||
case SYSTEM_EVENT_STA_DISCONNECTED:
|
case SYSTEM_EVENT_STA_DISCONNECTED:
|
||||||
Serial.println("Disconnected from WiFi access point");
|
Serial.println("Disconnected from WiFi access point");
|
||||||
if(wifi_state==WIFI_CONNECT){
|
if (wifi_state == WIFI_CONNECT) {
|
||||||
// If we get a disconnect event while waiting for connection (as I do sometimes with my FritzBox),
|
// If we get a disconnect event while waiting for connection (as I do sometimes with my FritzBox),
|
||||||
// just start from scratch with WiFi scan
|
// just start from scratch with WiFi scan
|
||||||
wifi_state = WIFI_DISABLED;
|
wifi_state = WIFI_DISABLED;
|
||||||
|
|
@ -979,7 +982,7 @@ void startAP() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void initialMode() {
|
void initialMode() {
|
||||||
if(sonde.config.spectrum != 0) { // enable Spectrum in config.txt: spectrum=number_of_seconds
|
if (sonde.config.spectrum != 0) { // enable Spectrum in config.txt: spectrum=number_of_seconds
|
||||||
enterMode(ST_SPECTRUM);
|
enterMode(ST_SPECTRUM);
|
||||||
} else {
|
} else {
|
||||||
enterMode(ST_SCANNER);
|
enterMode(ST_SCANNER);
|
||||||
|
|
@ -1020,7 +1023,7 @@ void loopWifiScan() {
|
||||||
|
|
||||||
WiFi.disconnect(true);
|
WiFi.disconnect(true);
|
||||||
WiFi.mode(WIFI_STA);
|
WiFi.mode(WIFI_STA);
|
||||||
int index=-1;
|
int index = -1;
|
||||||
int n = WiFi.scanNetworks();
|
int n = WiFi.scanNetworks();
|
||||||
for (int i = 0; i < n; i++) {
|
for (int i = 0; i < n; i++) {
|
||||||
Serial.print("Network name: ");
|
Serial.print("Network name: ");
|
||||||
|
|
@ -1037,17 +1040,19 @@ void loopWifiScan() {
|
||||||
Serial.println("-----------------------");
|
Serial.println("-----------------------");
|
||||||
const char *id = WiFi.SSID(i).c_str();
|
const char *id = WiFi.SSID(i).c_str();
|
||||||
int curidx = fetchWifiIndex(id);
|
int curidx = fetchWifiIndex(id);
|
||||||
if(curidx>=0 && index==-1) { index = curidx; }
|
if (curidx >= 0 && index == -1) {
|
||||||
|
index = curidx;
|
||||||
}
|
}
|
||||||
if(index>=0) { // some network was found
|
}
|
||||||
|
if (index >= 0) { // some network was found
|
||||||
Serial.print("Connecting to: "); Serial.println(fetchWifiSSID(index));
|
Serial.print("Connecting to: "); Serial.println(fetchWifiSSID(index));
|
||||||
u8x8->drawString(0, 6, "Conn:");
|
u8x8->drawString(0, 6, "Conn:");
|
||||||
u8x8->drawString(6, 6, fetchWifiSSID(index));
|
u8x8->drawString(6, 6, fetchWifiSSID(index));
|
||||||
WiFi.begin(fetchWifiSSID(index), fetchWifiPw(index));
|
WiFi.begin(fetchWifiSSID(index), fetchWifiPw(index));
|
||||||
while (WiFi.status() != WL_CONNECTED && cnt<20) {
|
while (WiFi.status() != WL_CONNECTED && cnt < 20) {
|
||||||
delay(500);
|
delay(500);
|
||||||
Serial.print(".");
|
Serial.print(".");
|
||||||
if(cnt==5) {
|
if (cnt == 5) {
|
||||||
// my FritzBox needs this for reconnecting
|
// my FritzBox needs this for reconnecting
|
||||||
WiFi.disconnect(true);
|
WiFi.disconnect(true);
|
||||||
delay(500);
|
delay(500);
|
||||||
|
|
@ -1058,7 +1063,7 @@ void loopWifiScan() {
|
||||||
cnt++;
|
cnt++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(index<0 || cnt>=15) { // no network found, or connect not successful
|
if (index < 0 || cnt >= 15) { // no network found, or connect not successful
|
||||||
WiFi.disconnect(true);
|
WiFi.disconnect(true);
|
||||||
delay(1000);
|
delay(1000);
|
||||||
startAP();
|
startAP();
|
||||||
|
|
@ -1082,9 +1087,11 @@ void loopWifiScan() {
|
||||||
initialMode();
|
initialMode();
|
||||||
|
|
||||||
if (sonde.config.spectrum != 0) { // enable Spectrum in config.txt: spectrum=number_of_seconds
|
if (sonde.config.spectrum != 0) { // enable Spectrum in config.txt: spectrum=number_of_seconds
|
||||||
startSpectrumDisplay();
|
//startSpectrumDisplay();
|
||||||
}
|
enterMode(ST_SPECTRUM);
|
||||||
|
} else {
|
||||||
enterMode(ST_SCANNER);
|
enterMode(ST_SCANNER);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void loop() {
|
void loop() {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue