Basic buzzer framework
This commit is contained in:
24
crossbow.ino
24
crossbow.ino
@@ -1,5 +1,3 @@
|
||||
#define LORA_HARDWARE_SPI
|
||||
|
||||
#define DEVICE_MODE_TX
|
||||
// #define DEVICE_MODE_RX
|
||||
|
||||
@@ -12,16 +10,15 @@
|
||||
|
||||
#include <LoRa.h>
|
||||
#include "variables.h"
|
||||
#include "sbus.h"
|
||||
#include "qsp.h"
|
||||
|
||||
volatile int ppm[16] = {0};
|
||||
|
||||
// LoRa32u4 ports
|
||||
#define LORA32U4_SS_PIN 8
|
||||
#define LORA32U4_RST_PIN 4
|
||||
#define LORA32U4_DI0_PIN 7
|
||||
|
||||
volatile int ppm[16] = {0};
|
||||
|
||||
/*
|
||||
* Main defines for device working in TX mode
|
||||
*/
|
||||
@@ -29,6 +26,10 @@ volatile int ppm[16] = {0};
|
||||
#include <PPMReader.h>
|
||||
PPMReader ppmReader(PPM_INPUT_PIN, PPM_INPUT_INTERRUPT, true);
|
||||
|
||||
#include "txbuzzer.h"
|
||||
|
||||
BuzzerState_t buzzer;
|
||||
|
||||
#ifdef FEATURE_TX_OLED
|
||||
|
||||
#define OLED_RESET -1
|
||||
@@ -44,6 +45,9 @@ uint32_t lastOledTaskTime = 0;
|
||||
* Main defines for device working in RX mode
|
||||
*/
|
||||
#ifdef DEVICE_MODE_RX
|
||||
|
||||
#include "sbus.h"
|
||||
|
||||
uint32_t sbusTime = 0;
|
||||
uint8_t sbusPacket[SBUS_PACKET_LENGTH] = {0};
|
||||
uint32_t lastRxStateTaskTime = 0;
|
||||
@@ -56,7 +60,6 @@ volatile QspConfiguration_t qsp = {};
|
||||
volatile RxDeviceState_t rxDeviceState = {};
|
||||
volatile TxDeviceState_t txDeviceState = {};
|
||||
|
||||
#ifdef LORA_HARDWARE_SPI
|
||||
|
||||
uint8_t getRadioRssi(void)
|
||||
{
|
||||
@@ -90,8 +93,6 @@ void writeToRadio(uint8_t dataByte, QspConfiguration_t *qsp)
|
||||
LoRa.write(dataByte);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
void setup(void)
|
||||
{
|
||||
#ifdef DEBUG_SERIAL
|
||||
@@ -106,8 +107,6 @@ void setup(void)
|
||||
qsp.deviceState = DEVICE_STATE_OK;
|
||||
#endif
|
||||
|
||||
#ifdef LORA_HARDWARE_SPI
|
||||
|
||||
#ifdef WAIT_FOR_SERIAL
|
||||
while (!Serial) {
|
||||
; // wait for serial port to connect. Needed for native USB
|
||||
@@ -143,7 +142,6 @@ void setup(void)
|
||||
LoRa.onReceive(onReceive);
|
||||
// #endif
|
||||
LoRa.receive();
|
||||
#endif
|
||||
|
||||
#ifdef DEVICE_MODE_RX
|
||||
//initiallize default ppm values
|
||||
@@ -164,6 +162,8 @@ void setup(void)
|
||||
TCCR1B = 0;
|
||||
TCCR1B |= (1 << CS11); //set timer1 to increment every 0,5 us or 1us on 8MHz
|
||||
|
||||
pinMode(TX_BUZZER_PIN, OUTPUT);
|
||||
|
||||
#ifdef FEATURE_TX_OLED
|
||||
display.begin(SSD1306_SWITCHCAPVCC, 0x3C); // initialize with the I2C addr 0x3C (for the 128x32)
|
||||
display.setTextSize(1);
|
||||
@@ -398,6 +398,8 @@ void loop(void)
|
||||
|
||||
#ifdef DEVICE_MODE_TX
|
||||
|
||||
buzzerProcess(TX_BUZZER_PIN, currentMillis, &buzzer);
|
||||
|
||||
#ifdef FEATURE_TX_OLED
|
||||
if (
|
||||
currentMillis - lastOledTaskTime > OLED_UPDATE_RATE
|
||||
|
||||
Reference in New Issue
Block a user