Files
Yona-W_OpeNITHM/Firmware/SerialOutput.cpp
T
veroxzik 514ab9740b Updates to match PCB
Changed pin names to match schematic and PCB per mickabrig7
Changed default pins numbers to match PCB
Added ability to use digitalRead for IR sensors
Changes tabs to 2 spaces (consistent with Arduino standard)
Fixes build for 32U4 based processors
(SerialOutput.h/.cpp is untested)
2019-04-18 23:17:19 -04:00

30 lines
826 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);
}