sforkowany z mirror/meshtastic-firmware
don't deepsleep if we have USB power
rodzic
c18306076a
commit
556ad310fc
|
@ -38,11 +38,11 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
|
||||
// Select which T-Beam board is being used. Only uncomment one. Note: these options now come from platformio standard build file flags
|
||||
//#ifdef ARDUINO_T_Beam
|
||||
//#define T_BEAM_V10 // AKA Rev1 (second board released)
|
||||
#define T_BEAM_V10 // AKA Rev1 (second board released)
|
||||
//#endif
|
||||
|
||||
//#ifdef ARDUINO_HELTEC_WIFI_LORA_32_V2
|
||||
#define HELTEC_LORA32
|
||||
//#define HELTEC_LORA32
|
||||
//#endif
|
||||
|
||||
// If we are using the JTAG port for debugging, some pins must be left free for that (and things like GPS have to be disabled)
|
||||
|
@ -62,7 +62,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
|
||||
// If not defined, we will wait for lock forever
|
||||
|
||||
#define MINWAKE_MSECS (30 * 60 * 1000) // stay awake a long time (30 mins) for debugging
|
||||
#define MINWAKE_MSECS (30 * 1000) // stay awake a long time (30 mins) for debugging
|
||||
// #define MINWAKE_MSECS (30 * 1000) // Wait after every boot for GPS lock (may need longer than 5s because we turned the gps off during deep sleep)
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
@ -122,6 +122,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
#define DIO0_GPIO 26
|
||||
#define DIO1_GPIO 33 // Note: not really used on this board
|
||||
#define DIO2_GPIO 32 // Note: not really used on this board
|
||||
|
||||
// Leave undefined to disable our PMU IRQ handler
|
||||
#define PMU_IRQ 35
|
||||
|
||||
#elif defined(HELTEC_LORA32)
|
||||
|
|
30
src/main.ino
30
src/main.ino
|
@ -37,8 +37,9 @@
|
|||
#include "axp20x.h"
|
||||
AXP20X_Class axp;
|
||||
bool pmu_irq = false;
|
||||
String baChStatus = "No charging";
|
||||
#endif
|
||||
bool isCharging = false;
|
||||
|
||||
|
||||
bool ssd1306_found = false;
|
||||
bool axp192_found = false;
|
||||
|
@ -268,6 +269,7 @@ void axp192Init()
|
|||
|
||||
axp.debugCharging();
|
||||
|
||||
#ifdef PMU_IRQ
|
||||
pinMode(PMU_IRQ, INPUT_PULLUP);
|
||||
attachInterrupt(PMU_IRQ, [] {
|
||||
pmu_irq = true;
|
||||
|
@ -277,11 +279,9 @@ void axp192Init()
|
|||
axp.adc1Enable(AXP202_BATT_CUR_ADC1, 1);
|
||||
axp.enableIRQ(AXP202_VBUS_REMOVED_IRQ | AXP202_VBUS_CONNECT_IRQ | AXP202_BATT_REMOVED_IRQ | AXP202_BATT_CONNECT_IRQ, 1);
|
||||
axp.clearIRQ();
|
||||
#endif
|
||||
|
||||
if (axp.isChargeing())
|
||||
{
|
||||
baChStatus = "Charging";
|
||||
}
|
||||
isCharging = axp.isChargeing();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -412,26 +412,21 @@ void loop()
|
|||
// blink the axp led
|
||||
axp.setChgLEDMode(ledon ? AXP20X_LED_LOW_LEVEL : AXP20X_LED_OFF);
|
||||
|
||||
#ifdef PMU_IRQ
|
||||
if (pmu_irq)
|
||||
{
|
||||
pmu_irq = false;
|
||||
axp.readIRQ();
|
||||
if (axp.isChargingIRQ())
|
||||
{
|
||||
baChStatus = "Charging";
|
||||
}
|
||||
else
|
||||
{
|
||||
baChStatus = "No Charging";
|
||||
}
|
||||
isCharging = axp.isChargingIRQ();
|
||||
|
||||
if (axp.isVbusRemoveIRQ())
|
||||
{
|
||||
baChStatus = "No Charging";
|
||||
}
|
||||
isCharging = false;
|
||||
|
||||
// This is not a GPIO actually connected on the tbeam board
|
||||
// digitalWrite(2, !digitalRead(2));
|
||||
axp.clearIRQ();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -465,7 +460,8 @@ void loop()
|
|||
#endif
|
||||
|
||||
#ifdef MINWAKE_MSECS
|
||||
if (millis() > MINWAKE_MSECS)
|
||||
// Don't deepsleep if we have USB power
|
||||
if (millis() > MINWAKE_MSECS && !isCharging)
|
||||
{
|
||||
sleep();
|
||||
}
|
||||
|
|
|
@ -29,8 +29,8 @@ typedef enum _ChannelSettings_ModemConfig {
|
|||
|
||||
typedef enum _DeviceState_Version {
|
||||
DeviceState_Version_Unset = 0,
|
||||
DeviceState_Version_Minimum = 5,
|
||||
DeviceState_Version_Current = 5
|
||||
DeviceState_Version_Minimum = 6,
|
||||
DeviceState_Version_Current = 6
|
||||
} DeviceState_Version;
|
||||
|
||||
/* Struct definitions */
|
||||
|
|
Ładowanie…
Reference in New Issue