Skip to content

Commit 13cd849

Browse files
committed
add power off to nano g2
1 parent 3f5c772 commit 13cd849

File tree

1 file changed

+35
-31
lines changed

1 file changed

+35
-31
lines changed

variants/nano_g2_ultra/nano-g2.h

Lines changed: 35 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,40 @@
11
#pragma once
22

3-
#include <MeshCore.h>
3+
#include "variant.h"
4+
45
#include <Arduino.h>
6+
#include <MeshCore.h>
57

68
// LoRa radio module pins
7-
#define P_LORA_DIO_1 (32 + 10)
8-
#define P_LORA_NSS (32 + 13)
9-
#define P_LORA_RESET (32 + 15)
10-
#define P_LORA_BUSY (32 + 11)
11-
#define P_LORA_SCLK (0 + 12)
12-
#define P_LORA_MISO (32 + 9)
13-
#define P_LORA_MOSI (0 + 11)
9+
#define P_LORA_DIO_1 (32 + 10)
10+
#define P_LORA_NSS (32 + 13)
11+
#define P_LORA_RESET (32 + 15)
12+
#define P_LORA_BUSY (32 + 11)
13+
#define P_LORA_SCLK (0 + 12)
14+
#define P_LORA_MISO (32 + 9)
15+
#define P_LORA_MOSI (0 + 11)
1416

1517
#define SX126X_DIO2_AS_RF_SWITCH true
1618
#define SX126X_DIO3_TCXO_VOLTAGE 1.8
17-
#define SX126X_POWER_EN 37
19+
#define SX126X_POWER_EN 37
1820

1921
// buttons
20-
#define PIN_BUTTON1 (32 + 6)
21-
#define BUTTON_PIN PIN_BUTTON1
22-
#define PIN_USER_BTN BUTTON_PIN
22+
#define PIN_BUTTON1 (32 + 6)
23+
#define BUTTON_PIN PIN_BUTTON1
24+
#define PIN_USER_BTN BUTTON_PIN
2325

2426
// GPS
25-
#define GPS_EN PIN_GPS_STANDBY
27+
#define GPS_EN PIN_GPS_STANDBY
2628
// built-ins
27-
#define VBAT_MV_PER_LSB (0.73242188F) // 3.0V ADC range and 12-bit ADC resolution = 3000mV/4096
29+
#define VBAT_MV_PER_LSB (0.73242188F) // 3.0V ADC range and 12-bit ADC resolution = 3000mV/4096
2830

29-
#define VBAT_DIVIDER (0.5F) // 150K + 150K voltage divider on VBAT, actually 100K + 100K
30-
#define VBAT_DIVIDER_COMP (2.0F) // Compensation factor for the VBAT divider
31+
#define VBAT_DIVIDER (0.5F) // 150K + 150K voltage divider on VBAT, actually 100K + 100K
32+
#define VBAT_DIVIDER_COMP (2.0F) // Compensation factor for the VBAT divider
3133

32-
#define PIN_VBAT_READ (0 + 2)
33-
#define REAL_VBAT_MV_PER_LSB (VBAT_DIVIDER_COMP * VBAT_MV_PER_LSB)
34+
#define PIN_VBAT_READ (0 + 2)
35+
#define REAL_VBAT_MV_PER_LSB (VBAT_DIVIDER_COMP * VBAT_MV_PER_LSB)
3436

35-
class NanoG2Ultra : public mesh::MainBoard
36-
{
37+
class NanoG2Ultra : public mesh::MainBoard {
3738
protected:
3839
uint8_t startup_reason;
3940

@@ -42,18 +43,21 @@ class NanoG2Ultra : public mesh::MainBoard
4243
uint16_t getBattMilliVolts() override;
4344
bool startOTAUpdate(const char *id, char reply[]) override;
4445

45-
uint8_t getStartupReason() const override
46-
{
47-
return startup_reason;
48-
}
46+
uint8_t getStartupReason() const override { return startup_reason; }
4947

50-
const char *getManufacturerName() const override
51-
{
52-
return "Nano G2 Ultra";
53-
}
48+
const char *getManufacturerName() const override { return "Nano G2 Ultra"; }
49+
50+
void reboot() override { NVIC_SystemReset(); }
51+
52+
void powerOff() override {
53+
// put GPS chip to sleep
54+
digitalWrite(PIN_GPS_STANDBY, LOW);
55+
// unset buzzer to prevent notification circuit activating on hibernate
56+
#undef PIN_BUZZER
57+
58+
nrf_gpio_cfg_sense_input(digitalPinToInterrupt(PIN_USER_BTN), NRF_GPIO_PIN_NOPULL,
59+
NRF_GPIO_PIN_SENSE_LOW);
5460

55-
void reboot() override
56-
{
57-
NVIC_SystemReset();
61+
sd_power_system_off();
5862
}
5963
};

0 commit comments

Comments
 (0)