Tom Tom / HIDScope

Dependencies:   USBDevice

Dependents:   HIDScope TEST Project5-Motorcontrol EMG_HIDScope_Gr6 ... more

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers HIDScope.cpp Source File

HIDScope.cpp

00001 #include "HIDScope.h"
00002 
00003 HIDScope::HIDScope(int channels, bool non_blocking) : send_non_blocking(non_blocking), hid(64,64)
00004 {
00005     bufferData      = new float[channels]();
00006     channelCount    = channels;
00007     scopeData.length = 64;
00008 }
00009 
00010 void HIDScope::set(int ch, float val)
00011 {
00012     bufferData[ch] = val;
00013 }
00014 
00015 void HIDScope::set(int ch, int val)
00016 {
00017     set(ch,(float)val);
00018 }
00019 
00020 void HIDScope::set(int ch, bool val)
00021 {
00022     set(ch,(val ? 1.0f : 0.0f));
00023 }
00024 
00025 void HIDScope::set(int ch, double val)
00026 {
00027     set(ch,(float)val);
00028 }
00029 
00030 void HIDScope::send()
00031 {    
00032     memcpy(&scopeData.data, bufferData, sizeof( float ) * channelCount); // Copy a 4 byte float to the char array
00033     hid.sendNB(&scopeData);
00034 }