]> git.tnoah.ca Git - lora-radio.git/commitdiff
Updated NeoPixel handling
authorMark Qvist <mark@unsigned.io>
Sun, 4 Dec 2022 19:00:21 +0000 (20:00 +0100)
committerMark Qvist <mark@unsigned.io>
Sun, 4 Dec 2022 19:00:21 +0000 (20:00 +0100)
Config.h
RNode_Firmware.ino
Utilities.h

index 818042ca8a69831a8c4ce7b4ac5e259df1bbf13d..a172ec610fdb5e105979e8fb3db57366c74f0814 100644 (file)
--- a/Config.h
+++ b/Config.h
@@ -4,7 +4,7 @@
        #define CONFIG_H
 
        #define MAJ_VERS  0x01
-       #define MIN_VERS  0x34
+       #define MIN_VERS  0x35
 
        #define PLATFORM_AVR   0x90
     #define PLATFORM_ESP32 0x80
@@ -67,6 +67,7 @@
     #define HAS_DISPLAY false
     #define HAS_BLUETOOTH false
     #define HAS_PMU false
+    #define HAS_NP false
 
        #if MCU_VARIANT == MCU_1284P
                const int pin_cs = 4;
             #define HAS_DISPLAY true
                        #define HAS_BLUETOOTH true
                #elif BOARD_MODEL == BOARD_RNODE_NG_20
+            #define HAS_DISPLAY true
+            #define HAS_BLUETOOTH true
+                       #define HAS_NP true
                        const int pin_cs = 18;
                        const int pin_reset = 12;
                        const int pin_dio = 26;
-                       #if defined(EXTERNAL_LEDS)
-                               const int pin_led_rx = 2;
-                               const int pin_led_tx = 0;
-                       #else
-                               const int pin_led_rx = 22;
-                               const int pin_led_tx = 22;
+                       const int pin_np = 4;
+                       #if HAS_NP == false
+                               #if defined(EXTERNAL_LEDS)
+                                       const int pin_led_rx = 2;
+                                       const int pin_led_tx = 0;
+                               #else
+                                       const int pin_led_rx = 22;
+                                       const int pin_led_tx = 22;
+                               #endif
                        #endif
+               #elif BOARD_MODEL == BOARD_RNODE_NG_21
             #define HAS_DISPLAY true
             #define HAS_BLUETOOTH true
-               #elif BOARD_MODEL == BOARD_RNODE_NG_21
+            #define HAS_PMU true
+                       #define HAS_NP true
                        const int pin_cs = 18;
                        const int pin_reset = 23;
                        const int pin_dio = 26;
-                       #if defined(EXTERNAL_LEDS)
-                               const int pin_led_rx = 15;
-                               const int pin_led_tx = 4;
-                       #else
-                               const int pin_led_rx = 25;
-                               const int pin_led_tx = 25;
+                       const int pin_np = 15;
+                       #if HAS_NP == false
+                               #if defined(EXTERNAL_LEDS)
+                                       const int pin_led_rx = 15;
+                                       const int pin_led_tx = 4;
+                               #else
+                                       const int pin_led_rx = 25;
+                                       const int pin_led_tx = 25;
+                               #endif
                        #endif
-            #define HAS_DISPLAY true
-            #define HAS_BLUETOOTH true
-            #define HAS_PMU true
                #else
                        #error An unsupported board was selected. Cannot compile RNode firmware.
                #endif
index 61a16a7fa5ebce2cca0c729356922c81eb11d2a7..1dac3f5ea44145ffb82590d3436d60c675b3d5dc 100644 (file)
@@ -48,8 +48,10 @@ void setup() {
   serial_interrupt_init();
 
   // Configure input and output pins
-  pinMode(pin_led_rx, OUTPUT);
-  pinMode(pin_led_tx, OUTPUT);
+  #if HAS_NP == false
+    pinMode(pin_led_rx, OUTPUT);
+    pinMode(pin_led_tx, OUTPUT);
+  #endif
 
   // Initialise buffers
   memset(pbuf, 0, sizeof(pbuf));
index 2494ca07b1c7362f52ed23dce7d41b183509eab8..3e3203dea73134fb8fddb4ccc338b987cba7bb01 100644 (file)
@@ -43,12 +43,11 @@ uint8_t boot_vector = 0x00;
        // TODO: Get ESP32 boot flags
 #endif
 
-#if BOARD_MODEL == BOARD_RNODE_NG_20 || BOARD_RNODE_NG_21
+#if HAS_NP == true
        #include <Adafruit_NeoPixel.h>
-       #define NP_PIN 4
        #define NUMPIXELS 1
        #define NP_M 0.15
-       Adafruit_NeoPixel pixels(NUMPIXELS, NP_PIN, NEO_GRB + NEO_KHZ800);
+       Adafruit_NeoPixel pixels(NUMPIXELS, pin_np, NEO_GRB + NEO_KHZ800);
 
        uint8_t npr = 0;
   uint8_t npg = 0;
@@ -88,7 +87,22 @@ uint8_t boot_vector = 0x00;
        void led_tx_on()  { digitalWrite(pin_led_tx, HIGH); }
        void led_tx_off() { digitalWrite(pin_led_tx, LOW); }
 #elif MCU_VARIANT == MCU_ESP32
-       #if BOARD_MODEL == BOARD_TBEAM
+       #if HAS_NP == true
+               void led_rx_on()  { npset(0, 0, 0xFF); }
+               void led_rx_off() {     npset(0, 0, 0); }
+               void led_tx_on()  { npset(0xFF, 0x50, 0x00); }
+               void led_tx_off() { npset(0, 0, 0); }
+       #elif BOARD_MODEL == BOARD_RNODE_NG_20
+               void led_rx_on()  { digitalWrite(pin_led_rx, HIGH); }
+               void led_rx_off() {     digitalWrite(pin_led_rx, LOW); }
+               void led_tx_on()  { digitalWrite(pin_led_tx, HIGH); }
+               void led_tx_off() { digitalWrite(pin_led_tx, LOW); }
+       #elif BOARD_MODEL == BOARD_RNODE_NG_21
+               void led_rx_on()  { digitalWrite(pin_led_rx, HIGH); }
+               void led_rx_off() {     digitalWrite(pin_led_rx, LOW); }
+               void led_tx_on()  { digitalWrite(pin_led_tx, HIGH); }
+               void led_tx_off() { digitalWrite(pin_led_tx, LOW); }
+       #elif BOARD_MODEL == BOARD_TBEAM
                void led_rx_on()  { digitalWrite(pin_led_rx, HIGH); }
                void led_rx_off() {     digitalWrite(pin_led_rx, LOW); }
                void led_tx_on()  { digitalWrite(pin_led_tx, LOW); }
@@ -122,16 +136,6 @@ uint8_t boot_vector = 0x00;
                void led_rx_off() {     digitalWrite(pin_led_rx, LOW); }
                void led_tx_on()  { digitalWrite(pin_led_tx, HIGH); }
                void led_tx_off() { digitalWrite(pin_led_tx, LOW); }
-       #elif BOARD_MODEL == BOARD_RNODE_NG_20
-               void led_rx_on()  { npset(0, 0, 0xFF); }
-               void led_rx_off() {     npset(0, 0, 0); }
-               void led_tx_on()  { npset(0xFF, 0x50, 0x00); }
-               void led_tx_off() { npset(0, 0, 0); }
-       #elif BOARD_MODEL == BOARD_RNODE_NG_21
-               void led_rx_on()  { digitalWrite(pin_led_rx, HIGH); }
-               void led_rx_off() {     digitalWrite(pin_led_rx, LOW); }
-               void led_tx_on()  { digitalWrite(pin_led_tx, HIGH); }
-               void led_tx_off() { digitalWrite(pin_led_tx, LOW); }
        #elif BOARD_MODEL == BOARD_HUZZAH32
                void led_rx_on()  { digitalWrite(pin_led_rx, HIGH); }
                void led_rx_off() {     digitalWrite(pin_led_rx, LOW); }
@@ -158,7 +162,7 @@ void hard_reset(void) {
 
 // LED Indication: Error
 void led_indicate_error(int cycles) {
-       #if BOARD_MODEL == BOARD_RNODE_NG_20
+       #if HAS_NP == true
                bool forever = (cycles == 0) ? true : false;
                cycles = forever ? 1 : cycles;
                while(cycles > 0) {
@@ -188,7 +192,7 @@ void led_indicate_error(int cycles) {
 
 // LED Indication: Boot Error
 void led_indicate_boot_error() {
-       #if BOARD_MODEL == BOARD_RNODE_NG_20
+       #if HAS_NP == true
                while(true) {
                        npset(0xFF, 0xFF, 0xFF);
                }
@@ -206,7 +210,7 @@ void led_indicate_boot_error() {
 
 // LED Indication: Warning
 void led_indicate_warning(int cycles) {
-       #if BOARD_MODEL == BOARD_RNODE_NG_20
+       #if HAS_NP == true
                bool forever = (cycles == 0) ? true : false;
                cycles = forever ? 1 : cycles;
                while(cycles > 0) {
@@ -247,7 +251,7 @@ void led_indicate_warning(int cycles) {
          led_rx_off();
        }
 #elif MCU_VARIANT == MCU_ESP32
-       #if BOARD_MODEL == BOARD_RNODE_NG_20
+       #if HAS_NP == true
                void led_indicate_info(int cycles) {
                        bool forever = (cycles == 0) ? true : false;
                        cycles = forever ? 1 : cycles;
@@ -357,7 +361,7 @@ int8_t  led_standby_direction = 0;
        }
 
 #elif MCU_VARIANT == MCU_ESP32
-       #if BOARD_MODEL == BOARD_RNODE_NG_20
+       #if HAS_NP == true
                void led_indicate_standby() {
                        led_standby_ticks++;
 
@@ -431,7 +435,7 @@ int8_t  led_standby_direction = 0;
                }
        }
 #elif MCU_VARIANT == MCU_ESP32
-       #if BOARD_MODEL == BOARD_RNODE_NG_20 || BOARD_MODEL == BOARD_RNODE_NG_21
+       #if HAS_NP == true
     void led_indicate_not_ready() {
        led_standby_ticks++;
 
@@ -797,7 +801,7 @@ void set_implicit_length(uint8_t len) {
 
 void setTXPower() {
        if (radio_online) {
-               if (model == MODEL_A2) LoRa.setTxPower(lora_txp, PA_OUTPUT_RFO_PIN);
+               if (model == MODEL_A2) LoRa.setTxPower(lora_txp, PA_OUTPUT_PA_BOOST_PIN);
                if (model == MODEL_A3) LoRa.setTxPower(lora_txp, PA_OUTPUT_RFO_PIN);
                if (model == MODEL_A4) LoRa.setTxPower(lora_txp, PA_OUTPUT_RFO_PIN);
                if (model == MODEL_A7) LoRa.setTxPower(lora_txp, PA_OUTPUT_PA_BOOST_PIN);