Files
skogaby_OpeNITHM/Firmware/OpeNITHM/SerialOutput.cpp
T
veroxzik f508624907 Addition of Serial-controlled RGB lights
Serial-controlled lights expects the following format:
Two header bytes, both 0xAA.
96 LED bytes, in BRG format, starting from the left of the slider and alternating between key and separator.
Two footer bytes, both 0xDD.
2019-11-10 14:08:01 -05:00

35 lines
870 B
C++

//
//
//
#include "SerialOutput.h"
// Workaround for microcontrollers without USB functionality
// use a serial line to talk to a UC with USB, which will then act as a USB peripheral
// Only needed because I didn't receive my Atmega328p until late in the project
void SerialOutput::sendKeyEvent(int key, bool pressed, bool doublePressed)
{
builtPacket.data = 0;
builtPacket.keyEvent.isKeyboard = true;
builtPacket.keyEvent.isPressed = pressed;
builtPacket.keyEvent.isDoublePressed = doublePressed;
builtPacket.keyEvent.key = key;
Serial.write(builtPacket.data);
}
void SerialOutput::sendSensorEvent(float position)
{
builtPacket.data = 0;
builtPacket.sensorEvent.isKeyboard = false;
builtPacket.sensorEvent.position = position * 127;
Serial.write(builtPacket.data);
}
// Implement at a later date
void SerialOutput::sendSensor(int sensor)
{
}