mirror of
https://github.com/hyperion-project/hyperion.ng.git
synced 2023-10-10 13:36:59 +02:00
Merge branch 'HEAD' of https://github.com/tvdzwan/hyperion.git
Former-commit-id: a5e2aa216f14a7916ce4c36fa958baf3d80608a2
This commit is contained in:
commit
5225f1149a
@ -4,10 +4,10 @@
|
|||||||
{
|
{
|
||||||
/// Device configuration contains the following fields:
|
/// Device configuration contains the following fields:
|
||||||
/// * 'name' : The user friendly name of the device (only used for display purposes)
|
/// * 'name' : The user friendly name of the device (only used for display purposes)
|
||||||
/// * 'type' : The type of the device or leds (known types for now are 'ws2801', 'lpd6803', 'sedu', 'test' and 'none')
|
/// * 'type' : The type of the device or leds (known types for now are 'ws2801', 'lpd6803', 'sedu',
|
||||||
/// * 'output' : The output specification depends on selected device
|
/// 'adalight', 'test' and 'none')
|
||||||
/// - 'ws2801' this is the device (eg '/dev/spidev0.0 or /dev/ttyS0')
|
/// * 'output' : The output specification depends on selected device. This can for example be the
|
||||||
/// - 'test' this is the file used to write test output (eg '/home/pi/hyperion.out')
|
/// device specifier or the output file name
|
||||||
/// * 'rate' : The baudrate of the output to the device
|
/// * 'rate' : The baudrate of the output to the device
|
||||||
/// * 'colorOrder' : The order of the color bytes ('rgb', 'rbg', 'bgr', etc.).
|
/// * 'colorOrder' : The order of the color bytes ('rgb', 'rbg', 'bgr', etc.).
|
||||||
"device" :
|
"device" :
|
||||||
@ -15,7 +15,7 @@
|
|||||||
"name" : "MyPi",
|
"name" : "MyPi",
|
||||||
"type" : "ws2801",
|
"type" : "ws2801",
|
||||||
"output" : "/dev/spidev0.0",
|
"output" : "/dev/spidev0.0",
|
||||||
"rate" : 1000000,
|
"rate" : 500000,
|
||||||
"colorOrder" : "rgb"
|
"colorOrder" : "rgb"
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -1 +1 @@
|
|||||||
1c3031eb536b2af5ced172f1eb071011f705cc86
|
f888f2f1ce44fca56ac8c6326c8615849cbd6a5d
|
@ -1 +1 @@
|
|||||||
9e9b710c8305a3445a621d322334a14b6934b87a
|
992962914879591c2740a1b2769269d790284766
|
@ -27,6 +27,7 @@ SET(Hyperion_HEADERS
|
|||||||
${CURRENT_SOURCE_DIR}/device/LedDeviceSedu.h
|
${CURRENT_SOURCE_DIR}/device/LedDeviceSedu.h
|
||||||
${CURRENT_SOURCE_DIR}/device/LedDeviceWs2801.h
|
${CURRENT_SOURCE_DIR}/device/LedDeviceWs2801.h
|
||||||
${CURRENT_SOURCE_DIR}/device/LedDeviceLpd6803.h
|
${CURRENT_SOURCE_DIR}/device/LedDeviceLpd6803.h
|
||||||
|
${CURRENT_SOURCE_DIR}/device/LedDeviceAdalight.h
|
||||||
)
|
)
|
||||||
|
|
||||||
SET(Hyperion_SOURCES
|
SET(Hyperion_SOURCES
|
||||||
@ -47,6 +48,7 @@ SET(Hyperion_SOURCES
|
|||||||
${CURRENT_SOURCE_DIR}/device/LedDeviceTest.cpp
|
${CURRENT_SOURCE_DIR}/device/LedDeviceTest.cpp
|
||||||
${CURRENT_SOURCE_DIR}/device/LedDeviceWs2801.cpp
|
${CURRENT_SOURCE_DIR}/device/LedDeviceWs2801.cpp
|
||||||
${CURRENT_SOURCE_DIR}/device/LedDeviceLpd6803.cpp
|
${CURRENT_SOURCE_DIR}/device/LedDeviceLpd6803.cpp
|
||||||
|
${CURRENT_SOURCE_DIR}/device/LedDeviceAdalight.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
set(Hyperion_RESOURCES
|
set(Hyperion_RESOURCES
|
||||||
|
@ -17,6 +17,7 @@
|
|||||||
#include "device/LedDeviceSedu.h"
|
#include "device/LedDeviceSedu.h"
|
||||||
#include "device/LedDeviceTest.h"
|
#include "device/LedDeviceTest.h"
|
||||||
#include "device/LedDeviceWs2801.h"
|
#include "device/LedDeviceWs2801.h"
|
||||||
|
#include "device/LedDeviceAdalight.h"
|
||||||
|
|
||||||
#include "LinearColorSmoothing.h"
|
#include "LinearColorSmoothing.h"
|
||||||
|
|
||||||
@ -61,6 +62,16 @@ LedDevice* Hyperion::createDevice(const Json::Value& deviceConfig)
|
|||||||
|
|
||||||
device = deviceSedu;
|
device = deviceSedu;
|
||||||
}
|
}
|
||||||
|
else if (type == "adalight")
|
||||||
|
{
|
||||||
|
const std::string output = deviceConfig["output"].asString();
|
||||||
|
const unsigned rate = deviceConfig["rate"].asInt();
|
||||||
|
|
||||||
|
LedDeviceAdalight* deviceAdalight = new LedDeviceAdalight(output, rate);
|
||||||
|
deviceAdalight->open();
|
||||||
|
|
||||||
|
device = deviceAdalight;
|
||||||
|
}
|
||||||
else if (type == "test")
|
else if (type == "test")
|
||||||
{
|
{
|
||||||
const std::string output = deviceConfig["output"].asString();
|
const std::string output = deviceConfig["output"].asString();
|
||||||
|
42
libsrc/hyperion/device/LedDeviceAdalight.cpp
Normal file
42
libsrc/hyperion/device/LedDeviceAdalight.cpp
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
|
||||||
|
// STL includes
|
||||||
|
#include <cstring>
|
||||||
|
#include <cstdio>
|
||||||
|
#include <iostream>
|
||||||
|
|
||||||
|
// Linux includes
|
||||||
|
#include <fcntl.h>
|
||||||
|
#include <sys/ioctl.h>
|
||||||
|
|
||||||
|
// hyperion local includes
|
||||||
|
#include "LedDeviceAdalight.h"
|
||||||
|
|
||||||
|
LedDeviceAdalight::LedDeviceAdalight(const std::string& outputDevice, const unsigned baudrate) :
|
||||||
|
LedRs232Device(outputDevice, baudrate),
|
||||||
|
_ledBuffer(0)
|
||||||
|
{
|
||||||
|
// empty
|
||||||
|
}
|
||||||
|
|
||||||
|
int LedDeviceAdalight::write(const std::vector<RgbColor> &ledValues)
|
||||||
|
{
|
||||||
|
if (_ledBuffer.size() == 0)
|
||||||
|
{
|
||||||
|
_ledBuffer.resize(6 + 3*ledValues.size());
|
||||||
|
_ledBuffer[0] = 'A';
|
||||||
|
_ledBuffer[1] = 'd';
|
||||||
|
_ledBuffer[2] = 'a';
|
||||||
|
_ledBuffer[3] = ((ledValues.size() - 1) >> 8) & 0xFF; // LED count high byte
|
||||||
|
_ledBuffer[4] = (ledValues.size() - 1) & 0xFF; // LED count low byte
|
||||||
|
_ledBuffer[5] = _ledBuffer[3] ^ _ledBuffer[4] ^ 0x55; // Checksum
|
||||||
|
}
|
||||||
|
|
||||||
|
memcpy(6 + _ledBuffer.data(), ledValues.data(), ledValues.size() * 3);
|
||||||
|
return writeBytes(_ledBuffer.size(), _ledBuffer.data());
|
||||||
|
}
|
||||||
|
|
||||||
|
int LedDeviceAdalight::switchOff()
|
||||||
|
{
|
||||||
|
memset(6 + _ledBuffer.data(), 0, _ledBuffer.size()-6);
|
||||||
|
return writeBytes(_ledBuffer.size(), _ledBuffer.data());
|
||||||
|
}
|
37
libsrc/hyperion/device/LedDeviceAdalight.h
Normal file
37
libsrc/hyperion/device/LedDeviceAdalight.h
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
// STL includes
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
// hyperion incluse
|
||||||
|
#include "LedRs232Device.h"
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Implementation of the LedDevice interface for writing to an Adalight led device.
|
||||||
|
///
|
||||||
|
class LedDeviceAdalight : public LedRs232Device
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
///
|
||||||
|
/// Constructs the LedDevice for attached Adalight device
|
||||||
|
///
|
||||||
|
/// @param outputDevice The name of the output device (eg '/dev/ttyS0')
|
||||||
|
/// @param baudrate The used baudrate for writing to the output device
|
||||||
|
///
|
||||||
|
LedDeviceAdalight(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;
|
||||||
|
};
|
@ -15,7 +15,7 @@ public:
|
|||||||
///
|
///
|
||||||
/// Constructs the LedDevice for attached via SEDU device
|
/// Constructs the LedDevice for attached via SEDU device
|
||||||
///
|
///
|
||||||
/// @param outputDevice The name of the output device (eg '/etc/ttyS0')
|
/// @param outputDevice The name of the output device (eg '/dev/ttyS0')
|
||||||
/// @param baudrate The used baudrate for writing to the output device
|
/// @param baudrate The used baudrate for writing to the output device
|
||||||
///
|
///
|
||||||
LedDeviceSedu(const std::string& outputDevice, const unsigned baudrate);
|
LedDeviceSedu(const std::string& outputDevice, const unsigned baudrate);
|
||||||
|
@ -26,10 +26,10 @@ public class DeviceConfig {
|
|||||||
|
|
||||||
strBuf.append("\t/// Device configuration contains the following fields: \n");
|
strBuf.append("\t/// Device configuration contains the following fields: \n");
|
||||||
strBuf.append("\t/// * 'name' : The user friendly name of the device (only used for display purposes)\n");
|
strBuf.append("\t/// * 'name' : The user friendly name of the device (only used for display purposes)\n");
|
||||||
strBuf.append("\t/// * 'type' : The type of the device or leds (known types for now are 'ws2801', 'lpd6803', 'sedu', 'test' and 'none')\n");
|
strBuf.append("\t/// * 'type' : The type of the device or leds (known types for now are 'ws2801', 'lpd6803', 'sedu',\n");
|
||||||
strBuf.append("\t/// * 'output' : The output specification depends on selected device\n");
|
strBuf.append("\t/// 'adalight', 'test' and 'none')\n");
|
||||||
strBuf.append("\t/// - 'ws2801' this is the device (eg '/dev/spidev0.0 or /dev/ttyS0')\n");
|
strBuf.append("\t/// * 'output' : The output specification depends on selected device. This can for example be the\n");
|
||||||
strBuf.append("\t/// - 'test' this is the file used to write test output (eg '/home/pi/hyperion.out')\n");
|
strBuf.append("\t/// device specifier or the output file name\n");
|
||||||
strBuf.append("\t/// * 'rate' : The baudrate of the output to the device\n");
|
strBuf.append("\t/// * 'rate' : The baudrate of the output to the device\n");
|
||||||
strBuf.append("\t/// * 'colorOrder' : The order of the color bytes ('rgb', 'rbg', 'bgr', etc.).\n");
|
strBuf.append("\t/// * 'colorOrder' : The order of the color bytes ('rgb', 'rbg', 'bgr', etc.).\n");
|
||||||
|
|
||||||
|
@ -10,6 +10,8 @@ public enum DeviceType {
|
|||||||
lpd6803("LPD6803"),
|
lpd6803("LPD6803"),
|
||||||
/** SEDU LED device */
|
/** SEDU LED device */
|
||||||
sedu("SEDU"),
|
sedu("SEDU"),
|
||||||
|
/** Adalight device */
|
||||||
|
adalight("Adalight"),
|
||||||
/** Test device for writing color values to file-output */
|
/** Test device for writing color values to file-output */
|
||||||
test("Test"),
|
test("Test"),
|
||||||
/** No device, no output is generated */
|
/** No device, no output is generated */
|
||||||
|
Loading…
Reference in New Issue
Block a user