fork/GramFirmware
git clone https://git.julia.blue/fork/GramFirmware
dccae31
gram
1#include "comms/B0XXInputViewer.hpp" 2 3#include "core/InputSource.hpp" 4#include "serial.hpp" 5 6#define ASCII_BIT (x ) (x ? '1' : '0'); 7 8B0XXInputViewer ::B0XXInputViewer ( 9InputState & inputs , 10InputSource ** input_sources , 11size_t input_source_count 12) 13 :CommunicationBackend (inputs ,input_sources ,input_source_count ) { 14 serial::init (115200 ); 15} 16 17B0XXInputViewer ::~B0XXInputViewer () { 18 serial::close (); 19} 20 21void B0XXInputViewer ::SendReport () { 22if (serial::available_for_write ()< 32 ) { 23return ; 24 } 25 26// Report clock is used to limit input viewer reports to being sent only once every 5 27// increments. 28if (_clock < 5 ) { 29_clock ++ ; 30return ; 31 } 32_clock = 0 ; 33 34_report [0 ]= ASCII_BIT (_inputs .mb1 ); 35_report [1 ]= ASCII_BIT (_inputs .rf6 ); 36_report [2 ]= ASCII_BIT (_inputs .rf2 ); 37_report [3 ]= ASCII_BIT (_inputs .rf1 ); 38_report [4 ]= ASCII_BIT (_inputs .rt1 ); 39_report [5 ]= ASCII_BIT (_inputs .lf4 ); 40_report [6 ]= ASCII_BIT (_inputs .rf5 ); 41_report [7 ]= ASCII_BIT (_inputs .rf3 ); 42_report [8 ]= ASCII_BIT (_inputs .rf4 ); 43_report [9 ]= ASCII_BIT (_inputs .lf2 ); 44_report [10 ]= ASCII_BIT (_inputs .lf1 ); 45_report [11 ]= ASCII_BIT (_inputs .lf3 ); 46_report [12 ]= ASCII_BIT (_inputs .lt1 ); 47_report [13 ]= ASCII_BIT (_inputs .lt2 ); 48_report [14 ]= ASCII_BIT (_inputs .rt3 ); 49_report [15 ]= ASCII_BIT (_inputs .rt5 ); 50_report [16 ]= ASCII_BIT (_inputs .rt4 ); 51_report [17 ]= ASCII_BIT (_inputs .rt2 ); 52_report [18 ]= ASCII_BIT (_inputs .rf7 ); 53_report [19 ]= ASCII_BIT (_inputs .rf8 ); 54_report [20 ]= ASCII_BIT (_inputs .lf6 ); 55_report [21 ]= ASCII_BIT (false); 56_report [22 ]= ASCII_BIT (false); 57_report [23 ]= ASCII_BIT (true); 58_report [24 ]= '\n' ; 59 60 serial::write (_report ,25 ); 61}