I have rewritten the code to
Code: Select all
#include <bluefruit.h>
#define PIN 15 //The pin to which your strip data in pin is connected
#define NUMPIXELS 12 //Edit this to match the number of pixels in your strip
#include <Adafruit_NeoPixel.h>
Adafruit_NeoPixel pixels = Adafruit_NeoPixel(NUMPIXELS, PIN, NEO_GRBW+ NEO_KHZ800);
// OTA DFU service
BLEDfu bledfu;
// Uart over BLE service
BLEUart bleuart;
// Function prototypes for packetparser.cpp
uint8_t readPacket (BLEUart *ble_uart, uint16_t timeout);
float parsefloat (uint8_t *buffer);
void printHex (const uint8_t * data, const uint32_t numBytes);
// Packet buffer
extern uint8_t packetbuffer[];
void setup(void)
{
Serial.begin(115200);
while ( !Serial ) delay(10); // for nrf52840 with native usb
Serial.println(F("Adafruit Bluefruit52 Controller App Example"));
Serial.println(F("-------------------------------------------"));
Bluefruit.begin();
Bluefruit.setTxPower(4); // Check bluefruit.h for supported values
// To be consistent OTA DFU should be added first if it exists
bledfu.begin();
// Configure and start the BLE Uart service
bleuart.begin();
// Set up and start advertising
startAdv();
Serial.println(F("Please use Adafruit Bluefruit LE app to connect in Controller mode"));
Serial.println(F("Then activate/use the sensors, color picker, game controller, etc!"));
Serial.println();
}
void startAdv(void)
{
// Advertising packet
Bluefruit.Advertising.addFlags(BLE_GAP_ADV_FLAGS_LE_ONLY_GENERAL_DISC_MODE);
Bluefruit.Advertising.addTxPower();
// Include the BLE UART (AKA 'NUS') 128-bit UUID
Bluefruit.Advertising.addService(bleuart);
// Secondary Scan Response packet (optional)
// Since there is no room for 'Name' in Advertising packet
Bluefruit.ScanResponse.addName();
/* Start Advertising
* - Enable auto advertising if disconnected
* - Interval: fast mode = 20 ms, slow mode = 152.5 ms
* - Timeout for fast mode is 30 seconds
* - Start(timeout) with timeout = 0 will advertise forever (until connected)
*
* For recommended advertising interval
* https://developer.apple.com/library/content/qa/qa1931/_index.html
*/
Bluefruit.Advertising.restartOnDisconnect(true);
Bluefruit.Advertising.setInterval(32, 244); // in unit of 0.625 ms
Bluefruit.Advertising.setFastTimeout(30); // number of seconds in fast mode
Bluefruit.Advertising.start(0); // 0 = Don't stop advertising after n seconds
}
/**************************************************************************/
/*!
@brief Constantly poll for new command or response data
*/
/**************************************************************************/
void loop(void)
{
// Wait for new data to arrive
uint8_t len = readPacket(&bleuart, 500);
if (len == 0) return;
// Got a packet!
// printHex(packetbuffer, len);
// Color
if (packetbuffer[1] == 'C') {
uint8_t red = packetbuffer[2];
uint8_t green = packetbuffer[3];
uint8_t blue = packetbuffer[4];
uint8_t white = packetbuffer[0];
Serial.print ("WRGB #");
if (red < 0x10) Serial.print("0");
Serial.print(red, HEX);
if (green < 0x10) Serial.print("0");
Serial.print(green, HEX);
if (blue < 0x10) Serial.print("0");
Serial.println(blue, HEX);
if (white < 0x10) Serial.print("0");
Serial.println(white, HEX);
for(int i=0;i<NUMPIXELS;i++) { //loop through all pixels setting to selected color
pixels.setPixelColor(i, pixels.Color(red, green, blue, white));
pixels.show();
}
}
// Buttons
if (packetbuffer[1] == 'B') {
uint8_t buttnum = packetbuffer[2] - '0';
boolean pressed = packetbuffer[3] - '0';
Serial.print ("Button "); Serial.print(buttnum);
if (pressed) {
Serial.println(" pressed");
} else {
Serial.println(" released");
}
}
// GPS Location
if (packetbuffer[1] == 'L') {
float lat, lon, alt;
lat = parsefloat(packetbuffer+2);
lon = parsefloat(packetbuffer+6);
alt = parsefloat(packetbuffer+10);
Serial.print("GPS Location\t");
Serial.print("Lat: "); Serial.print(lat, 4); // 4 digits of precision!
Serial.print('\t');
Serial.print("Lon: "); Serial.print(lon, 4); // 4 digits of precision!
Serial.print('\t');
Serial.print(alt, 4); Serial.println(" meters");
}
// Accelerometer
if (packetbuffer[1] == 'A') {
float x, y, z;
x = parsefloat(packetbuffer+2);
y = parsefloat(packetbuffer+6);
z = parsefloat(packetbuffer+10);
Serial.print("Accel\t");
Serial.print(x); Serial.print('\t');
Serial.print(y); Serial.print('\t');
Serial.print(z); Serial.println();
}
// Magnetometer
if (packetbuffer[1] == 'M') {
float x, y, z;
x = parsefloat(packetbuffer+2);
y = parsefloat(packetbuffer+6);
z = parsefloat(packetbuffer+10);
Serial.print("Mag\t");
Serial.print(x); Serial.print('\t');
Serial.print(y); Serial.print('\t');
Serial.print(z); Serial.println();
}
// Gyroscope
if (packetbuffer[1] == 'G') {
float x, y, z;
x = parsefloat(packetbuffer+2);
y = parsefloat(packetbuffer+6);
z = parsefloat(packetbuffer+10);
Serial.print("Gyro\t");
Serial.print(x); Serial.print('\t');
Serial.print(y); Serial.print('\t');
Serial.print(z); Serial.println();
}
// Quaternions
if (packetbuffer[1] == 'Q') {
float x, y, z, w;
x = parsefloat(packetbuffer+2);
y = parsefloat(packetbuffer+6);
z = parsefloat(packetbuffer+10);
w = parsefloat(packetbuffer+14);
Serial.print("Quat\t");
Serial.print(x); Serial.print('\t');
Serial.print(y); Serial.print('\t');
Serial.print(z); Serial.print('\t');
Serial.print(w); Serial.println();
}
}
but now when ever I go to compile it I get this error
Code: Select all
c:\Users\deell\Documents\Arduino\libraries\Adafruit_BANNED\src\Adafruit_BLE_UART.cpp:24:10: fatal error: ble_system.h: No such file or directory
24 | #include <ble_system.h>
| ^~~~~~~~~~~~~~
compilation terminated.
Multiple libraries were found for "Adafruit_BANNED.h"
Used: C:\Users\deell\Documents\Arduino\libraries\Adafruit_BANNED
Not used: C:\Users\deell\AppData\Local\Arduino15\packages\adafruit\hardware\nrf52\1.4.0\libraries\Adafruit_BANNED
exit status 1
Compilation error: exit status 1
All of my libarys are up to date and I am on a fresh install of the Arduino IDE