ik heb geen flauw idee waarom ik dit moet publishen

Dependencies:   USBDevice

Fork of HIDScope by Tom Tom

Committer:
RiP
Date:
Tue Oct 25 12:50:38 2016 +0000
Revision:
7:a04b4135c884
Parent:
5:80d551456856
werkend met 1 cm per seconde

Who changed what in which revision?

UserRevisionLine numberNew contents of line
tomlankhorst 0:79e3f3072f3b 1 #include "HIDScope.h"
tomlankhorst 0:79e3f3072f3b 2
tomlankhorst 5:80d551456856 3 HIDScope::HIDScope(int channels, bool non_blocking) : send_non_blocking(non_blocking), hid(64,64)
tomlankhorst 0:79e3f3072f3b 4 {
tomlankhorst 0:79e3f3072f3b 5 bufferData = new float[channels]();
tomlankhorst 0:79e3f3072f3b 6 channelCount = channels;
tomlankhorst 0:79e3f3072f3b 7 scopeData.length = 64;
tomlankhorst 0:79e3f3072f3b 8 }
tomlankhorst 0:79e3f3072f3b 9
tomlankhorst 0:79e3f3072f3b 10 void HIDScope::set(int ch, float val)
tomlankhorst 0:79e3f3072f3b 11 {
tomlankhorst 0:79e3f3072f3b 12 bufferData[ch] = val;
tomlankhorst 0:79e3f3072f3b 13 }
tomlankhorst 0:79e3f3072f3b 14
tomlankhorst 0:79e3f3072f3b 15 void HIDScope::set(int ch, int val)
tomlankhorst 0:79e3f3072f3b 16 {
tomlankhorst 0:79e3f3072f3b 17 set(ch,(float)val);
tomlankhorst 0:79e3f3072f3b 18 }
tomlankhorst 0:79e3f3072f3b 19
tomlankhorst 0:79e3f3072f3b 20 void HIDScope::set(int ch, bool val)
tomlankhorst 0:79e3f3072f3b 21 {
tomlankhorst 0:79e3f3072f3b 22 set(ch,(val ? 1.0f : 0.0f));
tomlankhorst 0:79e3f3072f3b 23 }
tomlankhorst 0:79e3f3072f3b 24
tomlankhorst 0:79e3f3072f3b 25 void HIDScope::set(int ch, double val)
tomlankhorst 0:79e3f3072f3b 26 {
tomlankhorst 0:79e3f3072f3b 27 set(ch,(float)val);
tomlankhorst 0:79e3f3072f3b 28 }
tomlankhorst 0:79e3f3072f3b 29
tomlankhorst 0:79e3f3072f3b 30 void HIDScope::send()
tomlankhorst 0:79e3f3072f3b 31 {
tomlankhorst 5:80d551456856 32 memcpy(&scopeData.data, bufferData, sizeof( float ) * channelCount); // Copy a 4 byte float to the char array
tomlankhorst 0:79e3f3072f3b 33 hid.sendNB(&scopeData);
tomlankhorst 0:79e3f3072f3b 34 }