Explorar o código

fixed build errors and typos/inconsistencies

Rastislav Vysoky hai 6 meses
pai
achega
3a7ccc085d

+ 18 - 4
variants/thinknode_m3/ThinknodeM3Board.cpp

@@ -1,14 +1,28 @@
 #include <Arduino.h>
-#include "ThinknodeM3Board.h"
+#include "ThinkNodeM3Board.h"
 #include <Wire.h>
 
 #include <bluefruit.h>
 
-void ThinknodeM3Board::begin() {
-  Nrf52BoardDCDC::begin();
+void ThinkNodeM3Board::begin() {
+  NRF52Board::begin();
   btn_prev_state = HIGH;
 
   Wire.begin();
 
   delay(10);   // give sx1262 some time to power up
-}
+}
+
+uint16_t ThinkNodeM3Board::getBattMilliVolts() {
+  int adcvalue = 0;
+
+  analogReference(AR_INTERNAL_2_4);
+  analogReadResolution(ADC_RESOLUTION);
+  delay(10);
+
+  // ADC range is 0..2400mV and resolution is 12-bit (0..4095)
+  adcvalue = analogRead(PIN_VBAT_READ);
+  // Convert the raw value to compensated mv, taking the resistor-
+  // divider into account (providing the actual LIPO voltage)
+  return (uint16_t)((float)adcvalue * ADC_FACTOR);
+}

+ 19 - 23
variants/thinknode_m3/ThinknodeM3Board.h

@@ -6,38 +6,26 @@
 
 #define ADC_FACTOR ((1000.0*ADC_MULTIPLIER*AREF_VOLTAGE)/ADC_MAX)
 
-class ThinknodeM3Board : public Nrf52BoardDCDC {
+class ThinkNodeM3Board : public NRF52BoardDCDC {
 protected:
+#if NRF52_POWER_MANAGEMENT
+  void initiateShutdown(uint8_t reason) override;
+#endif
   uint8_t btn_prev_state;
 
 public:
+  ThinkNodeM3Board() : NRF52Board("THINKNODE_M3_OTA") {}
   void begin();
-
-  uint16_t getBattMilliVolts() override {
-    int adcvalue = 0;
-
-    analogReference(AR_INTERNAL_2_4);
-    analogReadResolution(ADC_RESOLUTION);
-    delay(10);
-
-    // ADC range is 0..2400mV and resolution is 12-bit (0..4095)
-    adcvalue = analogRead(PIN_VBAT_READ);
-    // Convert the raw value to compensated mv, taking the resistor-
-    // divider into account (providing the actual LIPO voltage)
-    return (uint16_t)((float)adcvalue * ADC_FACTOR);
-  }
+  uint16_t getBattMilliVolts() override;
 
 #if defined(P_LORA_TX_LED)
-#if !defined(P_LORA_TX_LED_ON)
-#define P_LORA_TX_LED_ON HIGH
-#endif
   void onBeforeTransmit() override {
-    digitalWrite(P_LORA_TX_LED, P_LORA_TX_LED_ON);   // turn TX LED on
+    digitalWrite(P_LORA_TX_LED, HIGH);   // turn TX LED on
   }
   void onAfterTransmit() override {
-    digitalWrite(P_LORA_TX_LED, !P_LORA_TX_LED_ON);   // turn TX LED off
+    digitalWrite(P_LORA_TX_LED, LOW);   // turn TX LED off
   }
-  #endif
+#endif
 
   const char* getManufacturerName() const override {
     return "Elecrow ThinkNode M3";
@@ -54,5 +42,13 @@ public:
     return 0;
   }
 
-  void powerOff() override { sd_power_system_off(); }
-};
+  void powerOff() override {
+    // turn off all leds, sd_power_system_off will not do this for us
+    #ifdef P_LORA_TX_LED
+    digitalWrite(P_LORA_TX_LED, LOW);
+    #endif
+
+    // power off board
+    sd_power_system_off();
+  }
+};

+ 8 - 8
variants/thinknode_m3/target.cpp

@@ -2,7 +2,7 @@
 #include "target.h"
 #include <helpers/sensors/MicroNMEALocationProvider.h>
 
-ThinknodeM3Board board;
+ThinkNodeM3Board board;
 
 RADIO_CLASS radio = new Module(P_LORA_NSS, P_LORA_DIO_1, P_LORA_RESET, P_LORA_BUSY, SPI);
 
@@ -30,26 +30,26 @@ static const uint32_t rfswitch_dios[Module::RFSWITCH_MAX_PINS] = {
   RADIOLIB_LR11X0_DIO5,
   RADIOLIB_LR11X0_DIO6,
   RADIOLIB_NC,
-  RADIOLIB_NC, 
+  RADIOLIB_NC,
   RADIOLIB_NC
 };
 
 static const Module::RfSwitchMode_t rfswitch_table[] = {
-  // mode                 DIO5  DIO6 
-  { LR11x0::MODE_STBY,   {LOW , LOW  }},  
+  // mode                 DIO5  DIO6
+  { LR11x0::MODE_STBY,   {LOW , LOW  }},
   { LR11x0::MODE_RX,     {HIGH, LOW  }},
   { LR11x0::MODE_TX,     {HIGH, HIGH }},
   { LR11x0::MODE_TX_HP,  {LOW , HIGH }},
-  { LR11x0::MODE_TX_HF,  {LOW , LOW  }}, 
+  { LR11x0::MODE_TX_HF,  {LOW , LOW  }},
   { LR11x0::MODE_GNSS,   {LOW , LOW  }},
-  { LR11x0::MODE_WIFI,   {LOW , LOW  }},  
+  { LR11x0::MODE_WIFI,   {LOW , LOW  }},
   END_OF_MODE_TABLE,
 };
 #endif
 
 bool radio_init() {
   rtc_clock.begin(Wire);
-  
+
 #ifdef LR11X0_DIO3_TCXO_VOLTAGE
   float tcxo = LR11X0_DIO3_TCXO_VOLTAGE;
 #else
@@ -64,7 +64,7 @@ bool radio_init() {
     Serial.println(status);
     return false;  // fail
   }
-  
+
   radio.setCRC(2);
   radio.explicitHeader();
 

+ 2 - 2
variants/thinknode_m3/target.h

@@ -3,7 +3,7 @@
 #define RADIOLIB_STATIC_ONLY 1
 #include <RadioLib.h>
 #include <helpers/radiolib/RadioLibWrappers.h>
-#include "ThinknodeM3Board.h"
+#include "ThinkNodeM3Board.h"
 #include <helpers/radiolib/CustomLR1110Wrapper.h>
 #include <helpers/ArduinoHelpers.h>
 #include <helpers/sensors/EnvironmentSensorManager.h>
@@ -17,7 +17,7 @@
   extern NullDisplayDriver display;
 #endif
 
-extern ThinknodeM3Board board;
+extern ThinkNodeM3Board board;
 extern WRAPPER_CLASS radio_driver;
 extern AutoDiscoverRTCClock rtc_clock;
 extern EnvironmentSensorManager sensors;

+ 9 - 4
variants/thinknode_m6/ThinkNodeM6Board.h

@@ -12,9 +12,14 @@
 #define PIN_VBAT_READ     BATTERY_PIN
 #define REAL_VBAT_MV_PER_LSB (VBAT_DIVIDER_COMP * VBAT_MV_PER_LSB)
 
-class ThinkNodeM6Board : public Nrf52BoardOTA {
+class ThinkNodeM6Board : public NRF52BoardDCDC {
+protected:
+#if NRF52_POWER_MANAGEMENT
+  void initiateShutdown(uint8_t reason) override;
+#endif
+
 public:
-  ThinkNodeM6Board() : NRF52BoardOTA("THINKNODE_M1_OTA") {}
+  ThinkNodeM6Board() : NRF52Board("THINKNODE_M6_OTA") {}
   void begin();
   uint16_t getBattMilliVolts() override;
 
@@ -25,10 +30,10 @@ public:
   void onAfterTransmit() override {
     digitalWrite(P_LORA_TX_LED, LOW);   // turn TX LED off
   }
-  #endif
+#endif
 
   const char* getManufacturerName() const override {
-    return "Elecrow ThinkNode-M6";
+    return "Elecrow ThinkNode M6";
   }
 
   void powerOff() override {