Preparing for the RDM module
This commit is contained in:
parent
245eb45ff1
commit
ed9270663d
@ -1,38 +1,28 @@
|
|||||||
// Include Section
|
// Include Section
|
||||||
|
|
||||||
#include "esp_dmx.h"
|
#include "esp_dmx.h"
|
||||||
|
#include "rdm/controller.h"
|
||||||
|
#include "rdm/responder.h"
|
||||||
#include "UUID.h"
|
#include "UUID.h"
|
||||||
|
#include "EEPROM.h"
|
||||||
#define INTERRUPT_PIN 0
|
#define INTERRUPT_PIN 0
|
||||||
|
|
||||||
|
#include <BLEDevice.h>
|
||||||
|
#include <BLEServer.h>
|
||||||
|
#include <BLEUtils.h>
|
||||||
|
#include <BLE2902.h>
|
||||||
|
|
||||||
struct Button {
|
struct Button {
|
||||||
const uint8_t PIN;
|
const uint8_t PIN;
|
||||||
uint32_t numberKeyPresses;
|
uint32_t numberKeyPresses;
|
||||||
bool pressed;
|
bool pressed;
|
||||||
};
|
};
|
||||||
|
uint8_t dmxData[DMX_PACKET_SIZE] = {0};
|
||||||
struct Panel {
|
|
||||||
int led0;
|
|
||||||
int led1;
|
|
||||||
int led2;
|
|
||||||
int led3 = 0;
|
|
||||||
};
|
|
||||||
|
|
||||||
#include <BLEDevice.h>
|
|
||||||
#include <BLEServer.h>
|
|
||||||
#include <BLEUtils.h>
|
|
||||||
#include <BLE2902.h>
|
|
||||||
|
|
||||||
BLEServer* pServer = NULL;
|
BLEServer* pServer = NULL;
|
||||||
BLECharacteristic* pCharacteristic1 = NULL;
|
|
||||||
BLECharacteristic* pCharacteristic2 = NULL;
|
|
||||||
|
|
||||||
bool deviceConnected = false;
|
bool deviceConnected = false;
|
||||||
bool oldDeviceConnected = false;
|
bool oldDeviceConnected = false;
|
||||||
uint32_t value = 0;
|
uint32_t value = 0;
|
||||||
String btmessage;
|
|
||||||
|
|
||||||
// See the following for generating UUIDs:
|
|
||||||
// https://www.uuidgenerator.net/
|
|
||||||
|
|
||||||
uint16_t SERVICE_UUID = 20241115;
|
uint16_t SERVICE_UUID = 20241115;
|
||||||
const int panelAmount = 25;
|
const int panelAmount = 25;
|
||||||
@ -48,18 +38,6 @@ class MyServerCallbacks: public BLEServerCallbacks {
|
|||||||
deviceConnected = false;
|
deviceConnected = false;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
//void setupCharacteristic(BLEService *pService){
|
|
||||||
// for(int i = 0; i < panelAmount - 1; i++){
|
|
||||||
// pCharacteristics[i] = pService->createCharacteristic(
|
|
||||||
// CHARACTERISTIC_UUIDS[i],
|
|
||||||
// BLECharacteristic::PROPERTY_READ |
|
|
||||||
// BLECharacteristic::PROPERTY_WRITE |
|
|
||||||
// BLECharacteristic::PROPERTY_NOTIFY |
|
|
||||||
// BLECharacteristic::PROPERTY_INDICATE
|
|
||||||
// );
|
|
||||||
// };
|
|
||||||
//};
|
|
||||||
|
|
||||||
|
|
||||||
// Defining BOOT button on ESP32 as our built-in button.
|
// Defining BOOT button on ESP32 as our built-in button.
|
||||||
Button button1 = {INTERRUPT_PIN, 0, false};
|
Button button1 = {INTERRUPT_PIN, 0, false};
|
||||||
@ -268,11 +246,35 @@ void dmxSetup() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void setup() {
|
void setup() {
|
||||||
Serial.begin(115200);
|
Serial.begin(115200);
|
||||||
delay(2000);
|
delay(2000);
|
||||||
Serial.print("\nIf you receive this message, ESP32 module has finished setting up Serial Interface for communication.");
|
Serial.print("\nIf you receive this message, ESP32 module has finished setting up Serial Interface for communication.");
|
||||||
// Create the BLE Device
|
|
||||||
|
pinMode(INTERRUPT_PIN, INPUT_PULLUP);
|
||||||
|
attachInterrupt(digitalPinToInterrupt(INTERRUPT_PIN), isr, RISING);
|
||||||
|
|
||||||
|
//Begin of the DMX Setup
|
||||||
|
const dmx_port_t dmx_num = DMX_NUM_1;
|
||||||
|
dmxSetup();
|
||||||
|
|
||||||
|
Serial.println("Welcome to Pupilometer LED Billboard!");
|
||||||
|
const int array_size = 25;
|
||||||
|
rdm_uid_t uids[array_size];
|
||||||
|
|
||||||
|
// This function blocks and may take some time to complete!
|
||||||
|
Serial.printf("Attempting to Discover the Existing DMX Network... ");
|
||||||
|
int num_uids = rdm_discover_devices_simple(DMX_NUM_1, uids, array_size);
|
||||||
|
Serial.printf("Done!\n");
|
||||||
|
Serial.printf("Discovery found %i UIDs as following:\n", num_uids);
|
||||||
|
for (int i = 0; i < num_uids; i++){
|
||||||
|
printf(UIDSTR "\n", UID2STR(uids[i]));
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// Create the BLE Device
|
||||||
BLEDevice::init("Pupilometer LED Billboard");
|
BLEDevice::init("Pupilometer LED Billboard");
|
||||||
|
|
||||||
// Create the BLE Server
|
// Create the BLE Server
|
||||||
@ -300,7 +302,7 @@ void setup() {
|
|||||||
// pCharacteristics[i]->addDescriptor(new BLE2902());
|
// pCharacteristics[i]->addDescriptor(new BLE2902());
|
||||||
Serial.printf("Done\n");
|
Serial.printf("Done\n");
|
||||||
};
|
};
|
||||||
|
|
||||||
// Start the service
|
// Start the service
|
||||||
pService->start();
|
pService->start();
|
||||||
|
|
||||||
@ -311,11 +313,6 @@ void setup() {
|
|||||||
pAdvertising->setMinPreferred(0x0); // set value to 0x00 to not advertise this parameter
|
pAdvertising->setMinPreferred(0x0); // set value to 0x00 to not advertise this parameter
|
||||||
BLEDevice::startAdvertising();
|
BLEDevice::startAdvertising();
|
||||||
|
|
||||||
pinMode(INTERRUPT_PIN, INPUT_PULLUP);
|
|
||||||
attachInterrupt(digitalPinToInterrupt(INTERRUPT_PIN), isr, RISING);
|
|
||||||
dmxSetup();
|
|
||||||
const dmx_port_t dmx_num = DMX_NUM_1;
|
|
||||||
Serial.println("Welcome to Pupilometer LED Billboard!");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void loop() {
|
void loop() {
|
||||||
@ -323,7 +320,6 @@ void loop() {
|
|||||||
// Save Old Mode
|
// Save Old Mode
|
||||||
int modeOld = mode;
|
int modeOld = mode;
|
||||||
uint8_t* btMessage[panelAmount];
|
uint8_t* btMessage[panelAmount];
|
||||||
uint8_t dmxData[DMX_PACKET_SIZE] = {0};
|
|
||||||
// notify changed value
|
// notify changed value
|
||||||
if (deviceConnected) {
|
if (deviceConnected) {
|
||||||
Serial.printf("\nI received the following bytes: ");
|
Serial.printf("\nI received the following bytes: ");
|
||||||
@ -353,9 +349,6 @@ void loop() {
|
|||||||
// Increment the value of each slot, excluding the start code.
|
// Increment the value of each slot, excluding the start code.
|
||||||
button1.pressed = false; // Reset button status to FALSE
|
button1.pressed = false; // Reset button status to FALSE
|
||||||
};
|
};
|
||||||
if (modeOld != mode){
|
|
||||||
Serial.printf("\nChanging Lighting Preset to Preset %d", mode);
|
|
||||||
}
|
|
||||||
// Serial.printf("\nConstructing Payload using ");
|
// Serial.printf("\nConstructing Payload using ");
|
||||||
if (deviceConnected){
|
if (deviceConnected){
|
||||||
// Serial.printf("Bluetooth Data ...");
|
// Serial.printf("Bluetooth Data ...");
|
||||||
@ -368,9 +361,12 @@ void loop() {
|
|||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
// Serial.printf("Preset Data ...");
|
// Serial.printf("Preset Data ...");
|
||||||
for (int i = 0; i < sizeof(dataSeq[mode]); i++){
|
if (modeOld != mode){
|
||||||
dmxData[i] = dataSeq[mode][i];
|
Serial.printf("\nChanging Lighting Preset to Preset %d", mode);
|
||||||
};
|
for (int i = 0; i < sizeof(dataSeq[mode]); i++){
|
||||||
|
dmxData[i] = dataSeq[mode][i];
|
||||||
|
};
|
||||||
|
}
|
||||||
};
|
};
|
||||||
// Serial.printf(" Done");
|
// Serial.printf(" Done");
|
||||||
// Wait until the packet is finished being sent before proceeding.
|
// Wait until the packet is finished being sent before proceeding.
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user