Fixed debug flags
This commit is contained in:
34
crossbow.ino
34
crossbow.ino
@@ -13,19 +13,20 @@ FIXME
|
||||
* RX canTransmit is always false. For unknown reason first received frame does not enables it
|
||||
|
||||
*/
|
||||
#include <LoRa.h>
|
||||
#include "variables.h"
|
||||
#include "qsp.h"
|
||||
|
||||
#define DEBUG_SERIAL
|
||||
#define DEBUG_LED
|
||||
#define WAIT_FOR_SERIAL
|
||||
|
||||
// #define LORA_HARDWARE_SERIAL
|
||||
#define LORA_HARDWARE_SPI
|
||||
|
||||
#define DEVICE_MODE_TX
|
||||
// #define DEVICE_MODE_RX
|
||||
// #define DEVICE_MODE_TX
|
||||
#define DEVICE_MODE_RX
|
||||
|
||||
#define DEBUG_SERIAL
|
||||
#define DEBUG_LED
|
||||
// #define WAIT_FOR_SERIAL
|
||||
|
||||
#include <LoRa.h>
|
||||
#include "variables.h"
|
||||
#include "qsp.h"
|
||||
|
||||
// LoRa32u4 ports
|
||||
#define SS 8
|
||||
@@ -231,9 +232,20 @@ void setup(void)
|
||||
|
||||
pinMode(LED_BUILTIN, OUTPUT);
|
||||
|
||||
// #ifdef DEVICE_MODE_TX
|
||||
/*
|
||||
* TX should start talking imediately after power up
|
||||
*/
|
||||
#ifdef DEVICE_MODE_TX
|
||||
qsp.canTransmit = true;
|
||||
// #endif
|
||||
#endif
|
||||
|
||||
#ifdef DEBUG_SERIAL
|
||||
qsp.debugConfig |= DEBUG_FLAG_SERIAL;
|
||||
#endif
|
||||
#ifdef DEBUG_LED
|
||||
qsp.debugConfig |= DEBUG_FLAG_LED;
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
#ifdef DEVICE_MODE_RX
|
||||
|
||||
10
qsp.cpp
10
qsp.cpp
@@ -201,10 +201,8 @@ void qspDecodeIncomingFrame(QspConfiguration_t *qsp, uint8_t incomingByte, int p
|
||||
if (qsp->crc == incomingByte) {
|
||||
//CRC is correct
|
||||
|
||||
#ifdef DEVICE_MODE_RX
|
||||
//If devide received a valid frame, that means it can start to talk
|
||||
qsp->canTransmit = true;
|
||||
#endif
|
||||
|
||||
//Store the last timestamp when frame was received
|
||||
if (frameId < QSP_FRAME_COUNT) {
|
||||
@@ -213,18 +211,18 @@ void qspDecodeIncomingFrame(QspConfiguration_t *qsp, uint8_t incomingByte, int p
|
||||
|
||||
qsp->lastReceivedPacketId = packetId;
|
||||
|
||||
#ifdef DEBUG_SERIAL
|
||||
if (qsp->debugConfig & DEBUG_FLAG_SERIAL) {
|
||||
Serial.print("Frame ");
|
||||
Serial.print(frameId);
|
||||
Serial.println(" received");
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef DEBUG_LED
|
||||
if (qsp->debugConfig & DEBUG_FLAG_LED) {
|
||||
digitalWrite(LED_BUILTIN, HIGH);
|
||||
delay(10);
|
||||
digitalWrite(LED_BUILTIN, LOW);
|
||||
delay(100);
|
||||
#endif
|
||||
}
|
||||
|
||||
switch (frameId) {
|
||||
case QSP_FRAME_RC_DATA:
|
||||
|
||||
@@ -36,6 +36,11 @@ enum deviceStates {
|
||||
DEVICE_STATE_FAILSAFE
|
||||
};
|
||||
|
||||
enum debugConfigFlags {
|
||||
DEBUG_FLAG_SERIAL = 0b00000001,
|
||||
DEBUG_FLAG_LED = 0b00000010
|
||||
};
|
||||
|
||||
#define PPM_INPUT_PIN 2
|
||||
#define PPM_INPUT_INTERRUPT 1 //For Pro Micro 1, For Pro Mini 0
|
||||
|
||||
@@ -56,6 +61,7 @@ struct QspConfiguration_t {
|
||||
void (* hardwareWriteFunction)(uint8_t, QspConfiguration_t*);
|
||||
uint8_t lastReceivedPacketId = 0;
|
||||
bool canTransmit = false;
|
||||
uint8_t debugConfig = 0;
|
||||
};
|
||||
|
||||
struct RxDeviceState_t {
|
||||
|
||||
Reference in New Issue
Block a user