mirror of
https://github.com/MarekZegare4/MeshCore-Solo.git
synced 2026-11-01 10:21:59 +00:00
Merge pull request #53 from sim1988son/main
Simpson: Enter long-press on the keypad, GPS skyview; the last position kept while GPS duty-cycling sleeps. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
#include <helpers/ui/DisplayDriver.h>
|
||||
#include <helpers/ui/UIScreen.h>
|
||||
#include <Arduino.h>
|
||||
#include <math.h>
|
||||
#include "icons.h"
|
||||
#include "InfoKit.h"
|
||||
#include "PopupMenu.h"
|
||||
@@ -167,8 +168,9 @@ private:
|
||||
#endif
|
||||
if (!loc) { row(d, f, rsv, "Receiver", "none"); return; }
|
||||
const bool fix = loc->isValid();
|
||||
const bool sleeping = sensors.isGpsDutySleeping();
|
||||
if (f.place(lh + 5)) { // the fix as a chip, satellites used / in view
|
||||
const char* st = !on ? "OFF" : !fix ? "NO FIX" : (g && g->fix_mode == 2) ? "2D FIX" : "3D FIX";
|
||||
const char* st = !on ? "OFF" : sleeping ? "SLEEP" : !fix ? "NO FIX" : (g && g->fix_mode == 2) ? "2D FIX" : "3D FIX";
|
||||
info::chip(d, 1, f.at, st, on && fix);
|
||||
#ifdef STATUS_HAS_SKY
|
||||
if (g) snprintf(a, sizeof(a), "%d/%d sats", skyview::usedCount(*g), g->count);
|
||||
@@ -177,15 +179,17 @@ private:
|
||||
snprintf(a, sizeof(a), "%ld sats", loc->satellitesCount());
|
||||
d.drawTextRightAlign(d.width() - rsv - 2, f.at + 1, a);
|
||||
}
|
||||
const long lat = loc->getLatitude(), lon = loc->getLongitude();
|
||||
const long lat = fix ? loc->getLatitude() : lround(sensors.node_lat * 1000000.0);
|
||||
const long lon = fix ? loc->getLongitude() : lround(sensors.node_lon * 1000000.0);
|
||||
// The driver reports 999 deg before a first fix (0,0 in the simulator).
|
||||
const bool known = labs(lat) <= 90000000L && (lat || lon);
|
||||
if (known) snprintf(a, sizeof(a), "%.5f\xc2\xb0%c", labs(lat) / 1e6, lat < 0 ? 'S' : 'N'); else strcpy(a, "-");
|
||||
row(d, f, rsv, fix ? "Lat" : "Lat (last)", a);
|
||||
if (known) snprintf(a, sizeof(a), "%.5f\xc2\xb0%c", labs(lon) / 1e6, lon < 0 ? 'W' : 'E'); else strcpy(a, "-");
|
||||
row(d, f, rsv, fix ? "Lon" : "Lon (last)", a);
|
||||
if (fix) {
|
||||
telemetry::altText(loc->getAltitude() / 1000.0f, imperial(), L1_INFO, a, sizeof(a));
|
||||
if (fix || (sensors.node_lat != 0.0 || sensors.node_lon != 0.0)) {
|
||||
const double altitude = fix ? loc->getAltitude() / 1000.0 : sensors.node_altitude;
|
||||
telemetry::altText(altitude, imperial(), L1_INFO, a, sizeof(a));
|
||||
row(d, f, rsv, "Altitude", a);
|
||||
}
|
||||
if (g && fix) {
|
||||
|
||||
@@ -1097,6 +1097,12 @@ void UITask::pollSimpsonKeypad() {
|
||||
}
|
||||
|
||||
void UITask::handleSimpsonKeypadKey(uint8_t key) {
|
||||
if (key == SIMPSON_KEY_ENTER_LONG) {
|
||||
if (_locked && !_unlock_kb) return;
|
||||
enqueueKey(handleLongPress(KEY_ENTER));
|
||||
return;
|
||||
}
|
||||
|
||||
if (checkDisplayOn(KEY_ENTER) == 0 || (_locked && !_unlock_kb)) return;
|
||||
|
||||
const uint32_t auto_off = autoOffMillis();
|
||||
@@ -1128,7 +1134,7 @@ void UITask::handleSimpsonKeypadKey(uint8_t key) {
|
||||
enqueueKey(KEY_RIGHT);
|
||||
break;
|
||||
case SIMPSON_KEY_ENTER:
|
||||
enqueueKey(_unlock_kb ? KEY_KB_ENTER : KEY_ENTER);
|
||||
enqueueKey((_unlock_kb || _kb.isVisible()) ? KEY_KB_ENTER : KEY_ENTER);
|
||||
break;
|
||||
case SIMPSON_KEY_BLUETOOTH:
|
||||
if (!_unlock_kb) gotoBluetoothHomePage();
|
||||
|
||||
@@ -13,10 +13,12 @@ build_flags = ${Simpson.build_flags}
|
||||
-D MAX_GROUP_CHANNELS=40
|
||||
-D BLE_PIN_CODE=123456
|
||||
-D DUAL_SERIAL=1
|
||||
-D MESHCORE_VERSION='"2.0.1"'
|
||||
-D OFFLINE_QUEUE_SIZE=128
|
||||
-D DISPLAY_CLASS=SH1106Display
|
||||
-D FIRMWARE_SOLO_BUILD=1
|
||||
-D UI_SENSORS_PAGE=1
|
||||
-D GPS_SKYVIEW
|
||||
-Os
|
||||
build_src_filter = ${Simpson.build_src_filter}
|
||||
+<helpers/nrf52/SerialBLEInterface.cpp>
|
||||
|
||||
@@ -950,6 +950,11 @@ void EnvironmentSensorManager::gpsDutyCycleLoop() {
|
||||
// awake -- back to sleep once we have a fix, or once we've waited long
|
||||
// enough that one isn't coming this cycle
|
||||
if (_location->isValid() || (int32_t)(now - _gps_duty_phase_until) >= 0) {
|
||||
if (_location->isValid()) {
|
||||
node_lat = ((double)_location->getLatitude()) / 1000000.0;
|
||||
node_lon = ((double)_location->getLongitude()) / 1000000.0;
|
||||
node_altitude = ((double)_location->getAltitude()) / 1000.0;
|
||||
}
|
||||
stop_gps();
|
||||
_gps_duty_phase_until = now + gps_duty_sleep_sec * 1000UL;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
#include "SimpsonKeypad.h"
|
||||
|
||||
static const uint32_t SIMPSON_LONG_PRESS_MS = 1200;
|
||||
|
||||
#include <Wire.h>
|
||||
|
||||
namespace {
|
||||
@@ -55,12 +57,32 @@ uint8_t SimpsonKeypad::poll() {
|
||||
uint8_t key = _keypad.getChar();
|
||||
if (key == I2C_KEYPAD_THRESHOLD) return SIMPSON_KEY_NONE;
|
||||
if (key == SIMPSON_KEY_NONE) {
|
||||
if (_last_key == SIMPSON_KEY_ENTER && !_enter_long_sent) {
|
||||
_last_key = SIMPSON_KEY_NONE;
|
||||
_enter_pressed_at = 0;
|
||||
return SIMPSON_KEY_ENTER;
|
||||
}
|
||||
_last_key = SIMPSON_KEY_NONE;
|
||||
_enter_pressed_at = 0;
|
||||
_enter_long_sent = false;
|
||||
return SIMPSON_KEY_NONE;
|
||||
}
|
||||
if (key == SIMPSON_KEY_ENTER && _last_key == SIMPSON_KEY_ENTER) {
|
||||
if (!_enter_long_sent && millis() - _enter_pressed_at >= SIMPSON_LONG_PRESS_MS) {
|
||||
_enter_long_sent = true;
|
||||
return SIMPSON_KEY_ENTER_LONG;
|
||||
}
|
||||
return SIMPSON_KEY_NONE;
|
||||
}
|
||||
if (key == _last_key) return SIMPSON_KEY_NONE;
|
||||
_last_key = key;
|
||||
|
||||
if (key == SIMPSON_KEY_ENTER) {
|
||||
_enter_pressed_at = millis();
|
||||
_enter_long_sent = false;
|
||||
return SIMPSON_KEY_NONE;
|
||||
}
|
||||
|
||||
if (key == SIMPSON_KEY_FN) {
|
||||
_mode = static_cast<SimpsonKeypadMode>((_mode + 1) % 4);
|
||||
loadModeMap();
|
||||
|
||||
@@ -30,13 +30,16 @@ enum SimpsonKeypadKey : uint8_t {
|
||||
SIMPSON_KEY_FN,
|
||||
SIMPSON_KEY_GPS,
|
||||
SIMPSON_KEY_BACKSPACE,
|
||||
SIMPSON_KEY_MODE_CHANGED
|
||||
SIMPSON_KEY_MODE_CHANGED,
|
||||
SIMPSON_KEY_ENTER_LONG
|
||||
};
|
||||
|
||||
class SimpsonKeypad {
|
||||
I2CKeyPad _keypad;
|
||||
SimpsonKeypadMode _mode = SIMPSON_KEYPAD_CONTROL;
|
||||
uint8_t _last_key = SIMPSON_KEY_NONE;
|
||||
uint32_t _enter_pressed_at = 0;
|
||||
bool _enter_long_sent = false;
|
||||
bool _ready = false;
|
||||
|
||||
void loadModeMap();
|
||||
|
||||
@@ -11,6 +11,7 @@ build_flags = ${Promicro.build_flags}
|
||||
-D ADC_MULTIPLIER=1.71
|
||||
-D SIMPSON_KEYPAD_ADDR=0x20
|
||||
-D DISPLAY_ROTATION=2
|
||||
-D ENV_INCLUDE_GPS=1
|
||||
-D ENV_SKIP_GPS_DETECT
|
||||
build_src_filter = ${nrf52_base.build_src_filter}
|
||||
+<helpers/sensors>
|
||||
|
||||
Reference in New Issue
Block a user