reduced count, created sample set with two rotations: up and sideways
This commit is contained in:
parent
fa212c80e6
commit
3c6db4f5ff
1 changed files with 81 additions and 21 deletions
|
|
@ -61,7 +61,7 @@ static constexpr uint8_t kMagCandidateCount = 3;
|
||||||
static constexpr uint8_t kMagCandidates[kMagCandidateCount] = {0x1C, 0x3C, 0x0D};
|
static constexpr uint8_t kMagCandidates[kMagCandidateCount] = {0x1C, 0x3C, 0x0D};
|
||||||
static constexpr float kDeclinationDeg = MAG_DECLINATION_DEG;
|
static constexpr float kDeclinationDeg = MAG_DECLINATION_DEG;
|
||||||
static constexpr float kDegPerRad = 57.29577951308232f;
|
static constexpr float kDegPerRad = 57.29577951308232f;
|
||||||
static constexpr char kApPassword[] = "microreticulum";
|
|
||||||
|
|
||||||
struct ClockDateTime {
|
struct ClockDateTime {
|
||||||
uint16_t year = 0;
|
uint16_t year = 0;
|
||||||
|
|
@ -385,16 +385,18 @@ void handleWebDownload() {
|
||||||
file.close();
|
file.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
void startWebServer() {
|
void startWebServerOLD() {
|
||||||
snprintf(g_apSsid, sizeof(g_apSsid), "Compass-%s", kBoardId);
|
// GPSQA-CY is a carry-over from previous exercises, but we can keep the SSID for continuity.
|
||||||
|
//The unique board ID is in the suffix, and the IP address is fixed based on LOG_AP_IP_OCTET.
|
||||||
|
snprintf(g_apSsid, sizeof(g_apSsid), "GPSQA-%s", kBoardId);
|
||||||
WiFi.mode(WIFI_AP);
|
WiFi.mode(WIFI_AP);
|
||||||
WiFi.setSleep(false);
|
WiFi.setSleep(false);
|
||||||
const IPAddress ip(192, 168, LOG_AP_IP_OCTET, 1);
|
const IPAddress ip(192, 168, LOG_AP_IP_OCTET, 1);
|
||||||
const IPAddress gw(192, 168, LOG_AP_IP_OCTET, 1);
|
const IPAddress gw(192, 168, LOG_AP_IP_OCTET, 1);
|
||||||
const IPAddress nm(255, 255, 255, 0);
|
const IPAddress nm(255, 255, 255, 0);
|
||||||
WiFi.softAPConfig(ip, gw, nm);
|
WiFi.softAPConfig(ip, gw, nm);
|
||||||
|
// no password required.
|
||||||
if (!WiFi.softAP(g_apSsid, kApPassword)) {
|
if (!WiFi.softAP(g_apSsid)) {
|
||||||
Serial.println("wifi_ap=failed");
|
Serial.println("wifi_ap=failed");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
@ -409,6 +411,52 @@ void startWebServer() {
|
||||||
Serial.printf("wifi_ap_url=http://192.168.%u.1/\n", (unsigned)LOG_AP_IP_OCTET);
|
Serial.printf("wifi_ap_url=http://192.168.%u.1/\n", (unsigned)LOG_AP_IP_OCTET);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void startWebServer() {
|
||||||
|
// GPSQA-CY is a carry-over from previous exercises, but we can keep the SSID for continuity.
|
||||||
|
//The unique board ID is in the suffix, and the IP address is fixed based on LOG_AP_IP_OCTET.
|
||||||
|
snprintf(g_apSsid, sizeof(g_apSsid), "GPSQA-%s", kBoardId);
|
||||||
|
WiFi.mode(WIFI_AP);
|
||||||
|
WiFi.setSleep(false);
|
||||||
|
|
||||||
|
const IPAddress ip(192, 168, LOG_AP_IP_OCTET, 1);
|
||||||
|
const IPAddress gw(192, 168, LOG_AP_IP_OCTET, 1);
|
||||||
|
const IPAddress nm(255, 255, 255, 0);
|
||||||
|
|
||||||
|
const bool cfgOk = WiFi.softAPConfig(ip, gw, nm);
|
||||||
|
Serial.printf("wifi_ap_config=%s\n", cfgOk ? "ok" : "failed");
|
||||||
|
// no password required.
|
||||||
|
if (!WiFi.softAP(g_apSsid)) {
|
||||||
|
Serial.println("wifi_ap=failed");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Serial.println("wifi_ap=started");
|
||||||
|
Serial.printf("wifi_ap_ssid=%s\n", g_apSsid);
|
||||||
|
Serial.printf("wifi_ap_ip=%s\n", WiFi.softAPIP().toString().c_str());
|
||||||
|
Serial.printf("wifi_station_count=%d\n", WiFi.softAPgetStationNum());
|
||||||
|
|
||||||
|
g_server.on("/", HTTP_GET, []() {
|
||||||
|
Serial.println("http_hit=/");
|
||||||
|
handleWebIndex();
|
||||||
|
});
|
||||||
|
g_server.on("/files", HTTP_GET, []() {
|
||||||
|
Serial.println("http_hit=/files");
|
||||||
|
handleWebFiles();
|
||||||
|
});
|
||||||
|
g_server.on("/download", HTTP_GET, []() {
|
||||||
|
Serial.println("http_hit=/download");
|
||||||
|
handleWebDownload();
|
||||||
|
});
|
||||||
|
|
||||||
|
g_server.onNotFound([]() {
|
||||||
|
Serial.printf("http_404 uri=%s\n", g_server.uri().c_str());
|
||||||
|
g_server.send(404, "text/plain", "not found\n");
|
||||||
|
});
|
||||||
|
|
||||||
|
g_server.begin();
|
||||||
|
g_webReady = true;
|
||||||
|
}
|
||||||
|
|
||||||
bool probeI2cAddr(TwoWire& wire, uint8_t addr) {
|
bool probeI2cAddr(TwoWire& wire, uint8_t addr) {
|
||||||
wire.beginTransmission(addr);
|
wire.beginTransmission(addr);
|
||||||
return wire.endTransmission() == 0;
|
return wire.endTransmission() == 0;
|
||||||
|
|
@ -721,6 +769,14 @@ void appSetup() {
|
||||||
g_lastHeartbeatMs = millis();
|
g_lastHeartbeatMs = millis();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// We want to capture a reasonable amount of data for calibration and testing,
|
||||||
|
// bu we also want to avoid creating huge logs or overwhelming the display.
|
||||||
|
// 600 samples at 200ms intervals is 2 minutes of data, which should be enough
|
||||||
|
// for calibration and testing.
|
||||||
|
// Adjust the sample_limit as needed based on your specific requirements and constraints.
|
||||||
|
|
||||||
|
uint32_t sample_limit = 600;
|
||||||
|
uint32_t sample_count = 0;
|
||||||
void appLoop() {
|
void appLoop() {
|
||||||
if (g_webReady) {
|
if (g_webReady) {
|
||||||
g_server.handleClient();
|
g_server.handleClient();
|
||||||
|
|
@ -730,28 +786,32 @@ void appLoop() {
|
||||||
g_sdMounted = g_sd.isMounted();
|
g_sdMounted = g_sd.isMounted();
|
||||||
|
|
||||||
const uint32_t now = millis();
|
const uint32_t now = millis();
|
||||||
if ((uint32_t)(now - g_lastSampleMs) >= kSampleIntervalMs) {
|
if (sample_count <= sample_limit) {
|
||||||
g_lastSampleMs = now;
|
if ((uint32_t)(now - g_lastSampleMs) >= kSampleIntervalMs) {
|
||||||
MagSample sample{};
|
g_lastSampleMs = now;
|
||||||
if (captureSample(sample)) {
|
MagSample sample{};
|
||||||
g_lastSample = sample;
|
if (captureSample(sample)) {
|
||||||
printSampleToSerial(sample);
|
sample_count++;
|
||||||
appendSampleToLog(sample);
|
g_lastSample = sample;
|
||||||
|
printSampleToSerial(sample);
|
||||||
|
appendSampleToLog(sample);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if ((uint32_t)(now - g_lastDisplayMs) >= kDisplayIntervalMs) {
|
if ((uint32_t)(now - g_lastDisplayMs) >= kDisplayIntervalMs) {
|
||||||
g_lastDisplayMs = now;
|
g_lastDisplayMs = now;
|
||||||
drawLiveUi();
|
drawLiveUi();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((uint32_t)(now - g_lastHeartbeatMs) >= 5000) {
|
if ((uint32_t)(now - g_lastHeartbeatMs) >= 5000) {
|
||||||
g_lastHeartbeatMs = now;
|
g_lastHeartbeatMs = now;
|
||||||
Serial.printf("alive seq=%lu log=%s web=%s sd=%s\n",
|
Serial.printf("alive seq=%lu log=%s web=%s sd=%s sta=%d\n",
|
||||||
(unsigned long)g_lastSample.seq,
|
(unsigned long)g_lastSample.seq,
|
||||||
g_logOpen ? "open" : "closed",
|
g_logOpen ? "open" : "closed",
|
||||||
g_webReady ? "up" : "down",
|
g_webReady ? "up" : "down",
|
||||||
g_sdMounted ? "mounted" : "absent");
|
g_sdMounted ? "mounted" : "absent",
|
||||||
|
WiFi.softAPgetStationNum());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue