Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependents: HIDScope TEST Project5-Motorcontrol EMG_HIDScope_Gr6 ... more
HIDScope.cpp
- Committer:
- tomlankhorst
- Date:
- 2016-10-06
- Revision:
- 5:80d551456856
- Parent:
- 0:79e3f3072f3b
File content as of revision 5:80d551456856:
#include "HIDScope.h"
HIDScope::HIDScope(int channels, bool non_blocking) : send_non_blocking(non_blocking), hid(64,64)
{
    bufferData      = new float[channels]();
    channelCount    = channels;
    scopeData.length = 64;
}
void HIDScope::set(int ch, float val)
{
    bufferData[ch] = val;
}
void HIDScope::set(int ch, int val)
{
    set(ch,(float)val);
}
void HIDScope::set(int ch, bool val)
{
    set(ch,(val ? 1.0f : 0.0f));
}
void HIDScope::set(int ch, double val)
{
    set(ch,(float)val);
}
void HIDScope::send()
{    
    memcpy(&scopeData.data, bufferData, sizeof( float ) * channelCount); // Copy a 4 byte float to the char array
    hid.sendNB(&scopeData);
}