Add visual indicator of RX/TX
Option CC_SIGNAL_NEOPIXEL or CC_SIGNAL_GPIO13 to activate or suppress it
This commit is contained in:
parent
450cad78a7
commit
f30fdc42b3
47
src/main.cpp
47
src/main.cpp
|
@ -5,7 +5,7 @@ void setup() {
|
||||||
Serial.begin(115200);
|
Serial.begin(115200);
|
||||||
delay(5000);
|
delay(5000);
|
||||||
#endif
|
#endif
|
||||||
|
init_signalize();
|
||||||
msgID.clear();
|
msgID.clear();
|
||||||
txQueue.clear();
|
txQueue.clear();
|
||||||
NodeDB.clear();
|
NodeDB.clear();
|
||||||
|
@ -39,6 +39,7 @@ void loop() {
|
||||||
|
|
||||||
if (PacketReceived) {
|
if (PacketReceived) {
|
||||||
PacketReceived = false;
|
PacketReceived = false;
|
||||||
|
signalizeRX_ON();
|
||||||
Packet_t pck;
|
Packet_t pck;
|
||||||
pck.packetTime = millis();
|
pck.packetTime = millis();
|
||||||
pck.size = radio.getPacketLength();
|
pck.size = radio.getPacketLength();
|
||||||
|
@ -145,6 +146,7 @@ void loop() {
|
||||||
// wait for serial output to conplete
|
// wait for serial output to conplete
|
||||||
delay(10);
|
delay(10);
|
||||||
#endif
|
#endif
|
||||||
|
signalizeLED_OFF();
|
||||||
MCU_deepsleep(); // sleep until IRQ
|
MCU_deepsleep(); // sleep until IRQ
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -199,6 +201,7 @@ bool perhapsSend(Packet_t* p) {
|
||||||
MSG("failed, ERR = %i - resume RX\n\r", err);
|
MSG("failed, ERR = %i - resume RX\n\r", err);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
signalizeTX_ON();
|
||||||
delay(10);
|
delay(10);
|
||||||
MCU_deepsleep(); // wait for TX to complete, will wake on any DIO1
|
MCU_deepsleep(); // wait for TX to complete, will wake on any DIO1
|
||||||
err = radio.getIrqStatus();
|
err = radio.getIrqStatus();
|
||||||
|
@ -652,3 +655,45 @@ void NodeStoreClass::add(meshtastic_NodeInfo* Node) {
|
||||||
strncpy(this->nodeDB[idx].user.long_name, Node->user.long_name, sizeof(this->nodeDB[idx].user.long_name) - 1);
|
strncpy(this->nodeDB[idx].user.long_name, Node->user.long_name, sizeof(this->nodeDB[idx].user.long_name) - 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void init_signalize(void) {
|
||||||
|
#ifdef CC_SIGNAL_NEOPIXEL
|
||||||
|
pinMode(Vext,OUTPUT);
|
||||||
|
digitalWrite(Vext,LOW);
|
||||||
|
pixels.begin();
|
||||||
|
pixels.clear();
|
||||||
|
#endif
|
||||||
|
#ifdef CC_SIGNAL_GPIO13
|
||||||
|
pinMode(GPIO13, OUTPUT);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
void signalizeRX_ON(void){
|
||||||
|
#ifdef CC_SIGNAL_NEOPIXEL
|
||||||
|
pixels.setPixelColor(0, pixels.Color(0, 32, 0));
|
||||||
|
pixels.show();
|
||||||
|
#endif
|
||||||
|
#ifdef CC_SIGNAL_GPIO13
|
||||||
|
digitalWrite(GPIO13, HIGH);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
void signalizeTX_ON(void){
|
||||||
|
#ifdef CC_SIGNAL_NEOPIXEL
|
||||||
|
pixels.setPixelColor(0, pixels.Color(32, 0, 0));
|
||||||
|
pixels.show();
|
||||||
|
#endif
|
||||||
|
#ifdef CC_SIGNAL_GPIO13
|
||||||
|
digitalWrite(GPIO13, HIGH);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
void signalizeLED_OFF(void){
|
||||||
|
#ifdef CC_SIGNAL_NEOPIXEL
|
||||||
|
pixels.clear();
|
||||||
|
pixels.show();
|
||||||
|
#endif
|
||||||
|
#ifdef CC_SIGNAL_GPIO13
|
||||||
|
digitalWrite(GPIO13, LOW);
|
||||||
|
#endif
|
||||||
|
}
|
15
src/main.h
15
src/main.h
|
@ -1,3 +1,4 @@
|
||||||
|
#pragma Once
|
||||||
#include <Arduino.h>
|
#include <Arduino.h>
|
||||||
|
|
||||||
// #define SILENT // turn off serial output
|
// #define SILENT // turn off serial output
|
||||||
|
@ -18,6 +19,10 @@
|
||||||
|
|
||||||
#define CC_MONITOR_ONLY false // set true to suppress transmitting of packets (just monitor the traffic)
|
#define CC_MONITOR_ONLY false // set true to suppress transmitting of packets (just monitor the traffic)
|
||||||
|
|
||||||
|
#define CC_SIGNAL_NEOPIXEL // signal received packets with a green blink, signal transmits with red blink
|
||||||
|
//#define CC_SIGNAL_GPIO13 // signal received packets with the green LED on HTCC-AB02A
|
||||||
|
// http://community.heltec.cn/t/htcc-ab02a-has-a-secret-green-led/3092/7
|
||||||
|
|
||||||
#define MAX_ID_LIST 64 // number of stored packet IDs to prevent unnecesary repeating
|
#define MAX_ID_LIST 64 // number of stored packet IDs to prevent unnecesary repeating
|
||||||
#define MAX_NODE_LIST 20 // number of stored known nodes
|
#define MAX_NODE_LIST 20 // number of stored known nodes
|
||||||
#define MAX_TX_QUEUE 8 // max number of packets which can be waiting for transmission
|
#define MAX_TX_QUEUE 8 // max number of packets which can be waiting for transmission
|
||||||
|
@ -62,6 +67,11 @@ static const uint8_t mypsk[] = {0xd4, 0xf1, 0xbb, 0x3a, 0x20, 0x29, 0x07, 0x59,
|
||||||
extern uint32_t systime; // CubeCell global system time count, Millis
|
extern uint32_t systime; // CubeCell global system time count, Millis
|
||||||
SX1262 radio = new Module(RADIOLIB_BUILTIN_MODULE);
|
SX1262 radio = new Module(RADIOLIB_BUILTIN_MODULE);
|
||||||
|
|
||||||
|
#ifdef CC_SIGNAL_NEOPIXEL
|
||||||
|
#include "CubeCell_NeoPixel.h"
|
||||||
|
CubeCell_NeoPixel pixels(1, RGB, NEO_GRB + NEO_KHZ800);
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif // CUBECELL
|
#endif // CUBECELL
|
||||||
/****************/
|
/****************/
|
||||||
|
|
||||||
|
@ -158,6 +168,11 @@ bool perhapsDecode(Packet_t* p);
|
||||||
void printPacket(void);
|
void printPacket(void);
|
||||||
void printVariants(void);
|
void printVariants(void);
|
||||||
|
|
||||||
|
void signalizeRX_ON(void);
|
||||||
|
void signalizeTX_ON(void);
|
||||||
|
void signalizeLED_OFF(void);
|
||||||
|
void init_signalize(void);
|
||||||
|
|
||||||
/**************
|
/**************
|
||||||
* Meshtastic * https://github.com/meshtastic/firmware
|
* Meshtastic * https://github.com/meshtastic/firmware
|
||||||
**************/
|
**************/
|
||||||
|
|
Loading…
Reference in New Issue