Updated NeoPixel handling

This commit is contained in:
Mark Qvist 2022-12-04 20:00:21 +01:00
parent b3b7425c0a
commit a99c78a68c
3 changed files with 57 additions and 42 deletions

View File

@ -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;
@ -173,9 +174,14 @@
#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;
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;
@ -183,12 +189,17 @@
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;
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;
@ -196,9 +207,7 @@
const int pin_led_rx = 25;
const int pin_led_tx = 25;
#endif
#define HAS_DISPLAY true
#define HAS_BLUETOOTH true
#define HAS_PMU true
#endif
#else
#error An unsupported board was selected. Cannot compile RNode firmware.
#endif

View File

@ -48,8 +48,10 @@ void setup() {
serial_interrupt_init();
// Configure input and output pins
#if HAS_NP == false
pinMode(pin_led_rx, OUTPUT);
pinMode(pin_led_tx, OUTPUT);
#endif
// Initialise buffers
memset(pbuf, 0, sizeof(pbuf));

View 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);