From 5e556958628d62c41bec40de27fc8050c1be5645 Mon Sep 17 00:00:00 2001 From: geeksville Date: Wed, 18 Mar 2020 14:51:54 -0700 Subject: [PATCH 1/6] fix build warning --- src/MeshService.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/MeshService.cpp b/src/MeshService.cpp index 51c942d2bc..ec6003cc8e 100644 --- a/src/MeshService.cpp +++ b/src/MeshService.cpp @@ -328,8 +328,9 @@ void MeshService::onGPSChanged() // Update our local node info with our position (even if we don't decide to update anyone else) MeshPacket *p = allocForSending(); p->payload.which_variant = SubPacket_position_tag; - Position &pos = p->payload.variant.position; + #if 0 + Position &pos = p->payload.variant.position; if (gps.altitude.isValid()) pos.altitude = gps.altitude.meters(); pos.latitude = gps.location.lat(); From 0d94458c4e92e7cd1297561672a29c14582bf6f1 Mon Sep 17 00:00:00 2001 From: geeksville Date: Wed, 18 Mar 2020 14:59:30 -0700 Subject: [PATCH 2/6] bump preferences # --- src/NodeDB.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/NodeDB.cpp b/src/NodeDB.cpp index 6915ee0ac7..bee714a0f6 100644 --- a/src/NodeDB.cpp +++ b/src/NodeDB.cpp @@ -26,7 +26,7 @@ DeviceState versions used to be defined in the .proto file but really only this #define here. */ -#define DEVICESTATE_CUR_VER 2 +#define DEVICESTATE_CUR_VER 6 #define DEVICESTATE_MIN_VER DEVICESTATE_CUR_VER #define FS SPIFFS @@ -159,6 +159,7 @@ void NodeDB::loadFromDisk() DEBUG_MSG("Warn: devicestate is old, discarding\n"); else { + DEBUG_MSG("Loaded saved preferences version %d\n", scratch.version); devicestate = scratch; } From 53765298e1c5c2f455ac95aeb344e711cfb5a515 Mon Sep 17 00:00:00 2001 From: geeksville Date: Wed, 18 Mar 2020 15:00:17 -0700 Subject: [PATCH 3/6] add a real BOOT state, to avoid glitch from redrawing bootscreen twice also its the right thing to do ;-) --- src/PowerFSM.cpp | 13 ++++++++++--- src/PowerFSM.h | 4 ++-- src/main.cpp | 13 ++++++++----- src/screen.cpp | 18 +++++++++++++++--- src/screen.h | 3 +++ 5 files changed, 38 insertions(+), 13 deletions(-) diff --git a/src/PowerFSM.cpp b/src/PowerFSM.cpp index 7080bb4ada..0115008fc8 100644 --- a/src/PowerFSM.cpp +++ b/src/PowerFSM.cpp @@ -25,7 +25,7 @@ static void sdsEnter() static void lsEnter() { - DEBUG_MSG("lsEnter begin\n"); + DEBUG_MSG("lsEnter begin, ls_secs=%u\n", radioConfig.preferences.ls_secs); screen.setOn(false); while (!service.radio.rf95.canSleep()) @@ -124,16 +124,23 @@ static void screenPress() screen.onPress(); } + +static void bootEnter() { +} + State stateSDS(sdsEnter, NULL, NULL, "SDS"); State stateLS(lsEnter, lsIdle, lsExit, "LS"); State stateNB(nbEnter, NULL, NULL, "NB"); State stateDARK(darkEnter, NULL, NULL, "DARK"); +State stateBOOT(bootEnter , NULL, NULL, "BOOT"); State stateON(onEnter, NULL, NULL, "ON"); -Fsm powerFSM(&stateDARK); +Fsm powerFSM(&stateBOOT); void PowerFSM_setup() { - powerFSM.add_transition(&stateDARK, &stateON, EVENT_BOOT, NULL, "Boot"); + powerFSM.add_timed_transition(&stateBOOT, &stateON, 3 * 1000, NULL, + "boot timeout"); + powerFSM.add_transition(&stateLS, &stateDARK, EVENT_WAKE_TIMER, wakeForPing, "Wake timer"); // Note we don't really use this transition, because when we wake from light sleep we _always_ transition to NB and then it diff --git a/src/PowerFSM.h b/src/PowerFSM.h index f8a013dd21..c1bb7a87f0 100644 --- a/src/PowerFSM.h +++ b/src/PowerFSM.h @@ -4,12 +4,12 @@ // See sw-design.md for documentation -#define EVENT_PRESS 1 +#define EVENT_PRESS 1 #define EVENT_WAKE_TIMER 2 #define EVENT_RECEIVED_PACKET 3 #define EVENT_PACKET_FOR_PHONE 4 #define EVENT_RECEIVED_TEXT_MSG 5 -#define EVENT_BOOT 6 +// #define EVENT_BOOT 6 // now done with a timed transition #define EVENT_BLUETOOTH_PAIR 7 #define EVENT_NODEDB_UPDATED 8 // NodeDB has a big enough change that we think you should turn on the screen #define EVENT_CONTACT_FROM_PHONE 9 // the phone just talked to us over bluetooth diff --git a/src/main.cpp b/src/main.cpp index 28785228b4..5d4a35784b 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -243,18 +243,21 @@ void setup() if (ssd1306_found) screen.setup(); - // Init GPS - gps.setup(); + screen.showBootscreen(); + // Now that the screen is on, show our bootscreen screen_print("Started...\n"); + // Init GPS + gps.setup(); + service.init(); + // This must be _after_ service.init because we need our preferences loaded from flash to have proper timeout values + PowerFSM_setup(); // we will transition to ON in a couple of seconds, FIXME, only do this for cold boots, not waking from SDS + // setBluetoothEnable(false); we now don't start bluetooth until we enter the proper state setCPUFast(false); // 80MHz is fine for our slow peripherals - - PowerFSM_setup(); - powerFSM.trigger(EVENT_BOOT); // transition to ON, FIXME, only do this for cold boots, not waking from SDS } void initBluetooth() diff --git a/src/screen.cpp b/src/screen.cpp index 977ef2d83e..915b17dae3 100644 --- a/src/screen.cpp +++ b/src/screen.cpp @@ -57,7 +57,7 @@ Screen screen; static bool showingBluetooth; /// If set to true (possibly from an ISR), we should turn on the screen the next time our idle loop runs. -static bool showingBootScreen = true; // start by showing the bootscreen +static bool showingBootScreen = false; // start by showing the bootscreen bool Screen::isOn() { return screenOn; } @@ -584,7 +584,7 @@ void Screen::setup() // Scroll buffer dispdev.setLogBuffer(3, 32); - setOn(true); // update our screenOn bool + setOn(false); // start with the screen off #ifdef BICOLOR_DISPLAY dispdev.flipScreenVertically(); // looks better without this on lora32 @@ -593,10 +593,22 @@ void Screen::setup() // dispdev.setFont(Custom_ArialMT_Plain_10); ui.disableAutoTransition(); // we now require presses - ui.update(); // force an immediate draw of the bootscreen, because on some ssd1306 clones, the first draw command is discarded #endif } +void Screen::showBootscreen() { + if(!disp) + return; + + showingBootScreen = true; + setOn(true); + + // Add frames - we subtract one from the framecount so there won't be a visual glitch when we take the boot screen out of the sequence. + ui.setFrames(bootFrames, bootFrameCount); + + ui.update(); // force an immediate draw of the bootscreen, because on some ssd1306 clones, the first draw command is discarded +} + #define TRANSITION_FRAMERATE 30 // fps #define IDLE_FRAMERATE 10 // in fps diff --git a/src/screen.h b/src/screen.h index 9637f92844..1e4431da5b 100644 --- a/src/screen.h +++ b/src/screen.h @@ -38,6 +38,9 @@ class Screen : public PeriodicTask /// Rebuilt our list of screens void setFrames(); + + /// Show our logo (and turn the screen on) + void showBootscreen(); private: }; From c8b95f769181bcac36957909fd18e6061f235c7c Mon Sep 17 00:00:00 2001 From: geeksville Date: Wed, 18 Mar 2020 18:34:22 -0700 Subject: [PATCH 4/6] oops - I broke compass display with my gps changes and didn't notice till testing with two gps equipped devices. fixed. --- src/GPS.cpp | 6 ++++-- src/MeshService.cpp | 15 ++++++++------- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/src/GPS.cpp b/src/GPS.cpp index 52feaf651e..e120b73f12 100644 --- a/src/GPS.cpp +++ b/src/GPS.cpp @@ -146,7 +146,9 @@ void GPS::doTask() ublox.checkUblox(); // See if new data is available. Process bytes as they come in. // If we don't have a fix (a quick check), don't try waiting for a solution) - fixtype = ublox.getFixType(); + // Hmmm my fix type reading returns zeros for fix, which doesn't seem correct, because it is still sptting out positions + // turn off for now + // fixtype = ublox.getFixType(); DEBUG_MSG("fix type %d\n", fixtype); } @@ -154,7 +156,7 @@ void GPS::doTask() // DEBUG_MSG("lat %d\n", ublox.getLatitude()); // any fix that has time - if ((fixtype >= 2 && fixtype <= 5) && !timeSetFromGPS && ublox.getT()) { + if (!timeSetFromGPS && ublox.getT()) { struct timeval tv; /* Convert to unix time diff --git a/src/MeshService.cpp b/src/MeshService.cpp index ec6003cc8e..40af6ccdb2 100644 --- a/src/MeshService.cpp +++ b/src/MeshService.cpp @@ -329,14 +329,15 @@ void MeshService::onGPSChanged() MeshPacket *p = allocForSending(); p->payload.which_variant = SubPacket_position_tag; -#if 0 Position &pos = p->payload.variant.position; - if (gps.altitude.isValid()) - pos.altitude = gps.altitude.meters(); - pos.latitude = gps.location.lat(); - pos.longitude = gps.location.lng(); - pos.time = gps.getValidTime(); -#endif + // !zero or !zero lat/long means valid + if(gps.latitude != 0 || gps.longitude != 0) { + if (gps.altitude != 0) + pos.altitude = gps.altitude; + pos.latitude = gps.latitude; + pos.longitude = gps.longitude; + pos.time = gps.getValidTime(); + } // We limit our GPS broadcasts to a max rate static uint32_t lastGpsSend; From 2161ce21df6727d3e7baf1592911e8c9a94c8dc6 Mon Sep 17 00:00:00 2001 From: geeksville Date: Wed, 18 Mar 2020 18:51:18 -0700 Subject: [PATCH 5/6] the firmware version xml file should not be checked in, it is used directly by the android build and derived from version.sh --- release/latest/.gitignore | 1 + release/latest/curfirmwareversion.xml | 9 --------- 2 files changed, 1 insertion(+), 9 deletions(-) create mode 100644 release/latest/.gitignore delete mode 100644 release/latest/curfirmwareversion.xml diff --git a/release/latest/.gitignore b/release/latest/.gitignore new file mode 100644 index 0000000000..fff4166679 --- /dev/null +++ b/release/latest/.gitignore @@ -0,0 +1 @@ +curfirmwareversion.xml diff --git a/release/latest/curfirmwareversion.xml b/release/latest/curfirmwareversion.xml deleted file mode 100644 index 71a400aa7e..0000000000 --- a/release/latest/curfirmwareversion.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - 0.1.7 - From f6f9dfa46390af5ca3092768f0ad9cdc2a5579ef Mon Sep 17 00:00:00 2001 From: geeksville Date: Wed, 18 Mar 2020 18:53:55 -0700 Subject: [PATCH 6/6] 0.1.8 --- bin/version.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/version.sh b/bin/version.sh index a6ab5bbb45..f20179194a 100644 --- a/bin/version.sh +++ b/bin/version.sh @@ -1,3 +1,3 @@ -export VERSION=0.1.7 \ No newline at end of file +export VERSION=0.1.8 \ No newline at end of file