Moved all device to seperate directory

Added 'sedu' device based on RS232 device


Former-commit-id: 918cbde65a4a14f532c2e08e104745715c3fdd37
This commit is contained in:
T. van der Zwan 2013-11-05 16:18:04 +00:00
parent cb2cc5c259
commit c787241747
15 changed files with 118 additions and 14 deletions

View File

@ -20,11 +20,13 @@ SET(Hyperion_HEADERS
${CURRENT_SOURCE_DIR}/BlackBorderDetector.h
${CURRENT_SOURCE_DIR}/BlackBorderProcessor.h
${CURRENT_SOURCE_DIR}/ImageToLedsMap.h
${CURRENT_SOURCE_DIR}/LedSpiDevice.h
${CURRENT_SOURCE_DIR}/LedRs232Device.h
${CURRENT_SOURCE_DIR}/LedDeviceTest.h
${CURRENT_SOURCE_DIR}/LedDeviceWs2801.h
${CURRENT_SOURCE_DIR}/LedDeviceLdp6803.h
${CURRENT_SOURCE_DIR}/device/LedSpiDevice.h
${CURRENT_SOURCE_DIR}/device/LedRs232Device.h
${CURRENT_SOURCE_DIR}/device/LedDeviceTest.h
${CURRENT_SOURCE_DIR}/device/LedDeviceSedu.h
${CURRENT_SOURCE_DIR}/device/LedDeviceWs2801.h
${CURRENT_SOURCE_DIR}/device/LedDeviceLdp6803.h
)
SET(Hyperion_SOURCES
@ -37,12 +39,14 @@ SET(Hyperion_SOURCES
${CURRENT_SOURCE_DIR}/BlackBorderDetector.cpp
${CURRENT_SOURCE_DIR}/BlackBorderProcessor.cpp
${CURRENT_SOURCE_DIR}/ImageToLedsMap.cpp
${CURRENT_SOURCE_DIR}/LedSpiDevice.cpp
${CURRENT_SOURCE_DIR}/LedRs232Device.cpp
${CURRENT_SOURCE_DIR}/LedDeviceTest.cpp
${CURRENT_SOURCE_DIR}/LedDeviceWs2801.cpp
${CURRENT_SOURCE_DIR}/LedDeviceLdp6803.cpp
${CURRENT_SOURCE_DIR}/LinearColorSmoothing.cpp
${CURRENT_SOURCE_DIR}/device/LedSpiDevice.cpp
${CURRENT_SOURCE_DIR}/device/LedRs232Device.cpp
${CURRENT_SOURCE_DIR}/device/LedDeviceSedu.cpp
${CURRENT_SOURCE_DIR}/device/LedDeviceTest.cpp
${CURRENT_SOURCE_DIR}/device/LedDeviceWs2801.cpp
${CURRENT_SOURCE_DIR}/device/LedDeviceLdp6803.cpp
)
set(Hyperion_RESOURCES

View File

@ -10,9 +10,9 @@
#include <hyperion/LedDevice.h>
#include <hyperion/ImageProcessorFactory.h>
#include "LedDeviceLdp6803.h"
#include "LedDeviceTest.h"
#include "LedDeviceWs2801.h"
#include "device/LedDeviceLdp6803.h"
#include "device/LedDeviceTest.h"
#include "device/LedDeviceWs2801.h"
#include "LinearColorSmoothing.h"

View File

@ -0,0 +1,63 @@
// STL includes
#include <cstring>
#include <cstdio>
#include <iostream>
// Linux includes
#include <fcntl.h>
#include <sys/ioctl.h>
// hyperion local includes
#include "LedDeviceSedu.h"
struct FrameSpec
{
uint8_t id;
size_t size;
};
LedDeviceSedu::LedDeviceSedu(const std::string& outputDevice, const unsigned baudrate) :
LedRs232Device(outputDevice, baudrate),
_ledBuffer(0)
{
// empty
}
int LedDeviceSedu::write(const std::vector<RgbColor> &ledValues)
{
if (_ledBuffer.size() == 0)
{
std::vector<FrameSpec> frameSpecs{{0xA0, 96}, {0xA1, 256}, {0xA2, 512}, {0xB0, 768}, {0xB1, 1536}, {0xB2, 3072} };
const unsigned reqColorChannels = ledValues.size() * sizeof(RgbColor);
for (const FrameSpec& frameSpec : frameSpecs)
{
if (reqColorChannels <= frameSpec.size)
{
_ledBuffer.clear();
_ledBuffer.resize(frameSpec.size + 3, 0);
_ledBuffer[0] = 0x5A;
_ledBuffer[1] = frameSpec.id;
_ledBuffer.back() = 0xA5;
break;
}
}
if (_ledBuffer.size() == 0)
{
std::cout << "More rgb-channels required then available" << std::endl;
return -1;
}
}
memcpy(_ledBuffer.data()+2, ledValues.data(), ledValues.size() * sizeof(RgbColor));
return writeBytes(_ledBuffer.size(), _ledBuffer.data());
}
int LedDeviceSedu::switchOff()
{
memset(_ledBuffer.data()+2, 0, _ledBuffer.size()-3);
return writeBytes(_ledBuffer.size(), _ledBuffer.data());
}

View File

@ -0,0 +1,37 @@
#pragma once
// STL includes
#include <string>
// hyperion incluse
#include "LedRs232Device.h"
///
/// Implementation of the LedDevice interface for writing to SEDU led device.
///
class LedDeviceSedu : public LedRs232Device
{
public:
///
/// Constructs the LedDevice for attached via SEDU device
///
/// @param outputDevice The name of the output device (eg '/etc/ttyS0')
/// @param baudrate The used baudrate for writing to the output device
///
LedDeviceSedu(const std::string& outputDevice, const unsigned baudrate);
///
/// Writes the led color values to the led-device
///
/// @param ledValues The color-value per led
/// @return Zero on succes else negative
///
virtual int write(const std::vector<RgbColor> &ledValues);
/// Switch the leds off
virtual int switchOff();
private:
/// The buffer containing the packed RGB values
std::vector<uint8_t> _ledBuffer;
};

View File

@ -10,7 +10,7 @@
// Local includes
#include <utils/RgbColor.h>
#include "../libsrc/hyperion/LedDeviceWs2801.h"
#include "../libsrc/hyperion/device/LedDeviceWs2801.h"
void setColor(char* colorStr)
{