A simple but very effective scope. Up to 6 channels of 32 bit float data at 1 kHz.

Dependencies:   QEI USBDevice

Fork of HIDScope by Tom Tom

HIDScope.cpp

Committer:
RickB
Date:
2016-11-03
Revision:
7:b9f0bf62081e
Parent:
5:80d551456856

File content as of revision 7:b9f0bf62081e:

#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);
}