After discovering this VR Peripheral LEDs Manual. I tried to implement it myself however I am stuck with the Arduino code Arduino Code. I am using APA102 LEDs So I am trying to alter the original code to work to work with the APA102,
#include "FastLED.h"
#include <SPI.h>
#define LED_PIN 11 // arduino output pin
#define CLOCK_PIN 13 // arduino SPI output pin
#define NUM_LEDS 6 // Max LED count
#define BRIGHTNESS 96 // maximum brightness
#define FRAMES_PER_SECOND 30 // virtual serial port speed, must be the same in
boblight_config
CRGB leds[NUM_LEDS];
uint8_t * ledsRaw = (uint8_t *)leds;
// A 'magic word' (along with LED count & checksum) precedes each block
// of LED data; this assists the microcontroller in syncing up with the
// host-side software and properly issuing the latch (host I/O is
// likely buffered, making usleep() unreliable for latch). You may see
// an initial glitchy frame or two until the two come into alignment.
// The magic word can be whatever sequence you like, but each character
// should be unique, and frequent pixel values like 0 and 255 are
// avoided -- fewer false positives. The host software will need to
// generate a compatible header: immediately following the magic word
// are three bytes: a 16-bit count of the number of LEDs (high byte
// first) followed by a simple checksum value (high byte XOR low byte
// XOR 0x55). LED data follows, 3 bytes per LED, in order R, G, B,
// where 0 = off and 255 = max brightness.
static const uint8_t magic[] = {'A','d','a'};
#define MAGICSIZE sizeof(magic)
#define HEADERSIZE (MAGICSIZE + 3)
#define MODE_HEADER 0
#define MODE_DATA 2
// If no serial data is received for a while, the LEDs are shut off
// automatically. This avoids the annoying "stuck pixel" look when
// quitting LED display programs on the host computer.
static const unsigned long serialTimeout = 150000; // 150 seconds
void setup(){
delay(2000)
LEDS.addLeds<APA102,DATA_PIN, CLOCK_PIN, RGB>(LEDS,NUM_LEDS;
}
However I run into the problem that "Serial" does not name a type in this next part.
uint8_t
buffer[256],
indexIn = 0,
indexOut = 0,
mode = MODE_HEADER,
hi, lo, chk, i, spiFlag;
int16_t
bytesBuffered = 0,
hold = 0,
c;
int32_t
bytesRemaining;
unsigned long
startTime,
lastByteTime,
lastAckTime,
t;
int32_t outPos = 0;
Serial.begin(SPEED); // Teensy/32u4 disregards baud rate; is OK!
Serial.print("Ada\n"); // Send ACK string to host
"Serial" does not name a type for Serial.print