hkicko/CubeCell-GPS-Helium-Mapper

screenOffMode = true But Screen Still Stays on

dagnum opened this issue · 1 comments

1. Thank you!
First, I would like to say wow you are amazing. Thank you for all of your work.

2. Goal
Low power as possible. The device will not be easily available to Re-charge.

Basically, report and go back to sleep asap. Disable the screen and LEDs etc.

3. Problem

The screen does not turn off. Its always on "Joined" or "GPS Searching" Screen. I will likely remove it but would be nice to make the feature work.

Any low power suggestions you have would be greatly appreciated.

My Settings:

#include "LoRaWan_APP.h"
#include "Arduino.h"
#include "GPS_Air530Z.h" // Enable this for board version 1.1
#include "HT_SSD1306Wire.h"

extern SSD1306Wire display; // Defined in LoRaWan_APP.cpp
extern uint8_t isDispayOn; // Defined in LoRaWan_APP.cpp
#ifdef GPS_Air530_H
Air530Class GPS;
#endif
#ifdef GPS_Air530Z_H
Air530ZClass GPS;
#endif

// Commend out/uncomment this line to disable/enable the auto sleep/wake up by vibration sensor feature
//#define VIBR_SENSOR GPIO5 // Change the pin where the sensor is connected if different
// Comment out/uncomment this line to disable/enable the functionality where the vibration sensor wakes the device from "deep" sleep (VIBR_SENSOR must be enabled)
//#define VIBR_WAKE_FROM_SLEEP
// If put to sleeep from the menu, this will disable the wake up by vibration and only allow it to work when auto sleep was activated in some way (like stopped for too long)
//#define MENU_SLEEP_DISABLE_VIBR_WAKEUP
// Enable this to activate the auto sleep on no vibration function for the cases when the device is left stationary indoors and GPS generates fake movement so it can't go to sleep
//#define VIBR_AUTOSLEEP_TIMEOUT 300000

#define GPS_READ_RATE 1000 // How often to read GPS (in ms)
#define MIN_DIST 25 // Minimum distance in meters from the last sent location before we can send again. A hex is about 340m, divide by this value to get the pings per hex.
#define MAX_GPS_WAIT 60000 // Max time to wait for GPS before going to sleep (in ms)
#define AUTO_SLEEP_TIMER 10000 // If no movement for this amount of time (in ms), the device will go to sleep. Comment out if you don't want this feature.
#define MENU_IDLE_TIMEOUT 30000 // Auto exit the menu if no button pressed in this amount of ms
#define VBAT_CORRECTION 1.004 // Edit this for calibrating your battery voltage
//#define CAYENNELPP_FORMAT

/*
set LoraWan_RGB to Active,the RGB active in loraWan
RGB red means sending;
RGB purple means joined done;
RGB blue means RxWindow1;
RGB yellow means RxWindow2;
RGB green means received done;
*/

/* OTAA para*/

uint8_t devEui[] = { xxx }; //REMOVED FOR SECURITY
uint8_t appEui[] = { xxx }; //REMOVED FOR SECURITY
uint8_t appKey[] = {xxx }; //REMOVED FOR SECURITY

/* ABP para*/
uint8_t nwkSKey[] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
uint8_t appSKey[] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
uint32_t devAddr = ( uint32_t )0x00000000;

#if defined( REGION_EU868 )
/LoraWan channelsmask, default channels 0-7/
uint16_t userChannelsMask[6] = { 0x00FF,0x0000,0x0000,0x0000,0x0000,0x0000 };
int8_t dataRates[6] = {0, 1, 2, 3, 4, 5};
#else
uint16_t userChannelsMask[6] = { 0xFF00,0x0000,0x0000,0x0000,0x0000,0x0000 };
int8_t dataRates[4] = {0, 1, 2, 3};
#endif

/LoraWan region, select in arduino IDE tools/
LoRaMacRegion_t loraWanRegion = ACTIVE_REGION;

/LoraWan Class, Class A and Class C are supported/
DeviceClass_t loraWanClass = LORAWAN_CLASS;

/the application data transmission duty cycle. value in [ms]./
/* Start with non-zero value, for the first transmission with previously stored JOIN,

  • but it will be changed later depending on the mode */
    uint32_t appTxDutyCycle = 1000;

/OTAA or ABP/
bool overTheAirActivation = LORAWAN_NETMODE;

/ADR enable/
bool loraWanAdr = LORAWAN_ADR;

/* set LORAWAN_Net_Reserve ON, the node could save the network info to flash, when node reset not need to join again */
bool keepNet = LORAWAN_NET_RESERVE;

/* Indicates if the node is sending confirmed or unconfirmed messages */
bool isTxConfirmed = LORAWAN_UPLINKMODE;

#define APP_PORT_DEFAULT 2
#define APP_PORT_LASTLOC 3

/* Application port */
uint8_t appPort = APP_PORT_DEFAULT;

bool sleepMode = true;
bool loopingInSend = false;
bool menuMode = false;
bool screenOffMode = true; // Enable normal operation with the screen off - for more battery saving
uint32_t lastScreenPrint = 0;
uint32_t joinStart = 0;
uint32_t gpsSearchStart = 0;
uint32_t lastSend = 0;
int currentMenu = 0;
bool displayBatPct = false; // Change here if you want to see the battery as percent vs voltage (not recommended because it is inacurate unless you go edit some min and max voltage values in the base libraries with values specific to your battery)
bool sleepActivatedFromMenu = false;
bool gpsTimerSet = false;
#ifdef VIBR_AUTOSLEEP_TIMEOUT
uint32_t lastVibrEvent = 0;
#endif

bool trackerMode = true;
bool sendLastLoc = false;
bool lastLocSet = false;
uint32_t last_lat = 0;
uint32_t last_lon = 0;
double last_send_lat = 0;
double last_send_lon = 0;
uint32_t min_dist_moved = MIN_DIST;
uint32_t dist_moved = UINT32_MAX;
bool nonstopMode = false;
bool gps_debug = false;
uint8_t currentDRidx = 1;
bool mustStartGPS = false;
bool mustCycleGPS = false;

I made some changes to allow screen off operation from the start.