mirror of
https://github.com/hyperion-project/hyperion.ng.git
synced 2023-10-10 13:36:59 +02:00
Merge pull request #563 from penfold42/master
Rename test device to "file" device Former-commit-id: 80e5098ae1cb792d5ebf6f0b88b1106f721ae7b4
This commit is contained in:
commit
c4ce0ce1f5
@ -5,7 +5,7 @@
|
|||||||
/// 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
|
/// * 'type' : The type of the device or leds (known types for now are
|
||||||
/// APA102, Adalight, AmbiLed, Atmo, Hyperion-USBASP-WS2801, Hyperion-USBASP-WS2812, Lightberry, Lightpack, LPD6803, LPD8806, Multi-Lightpack, P9813, Paintpack, PhilipsHUE, PiBlaster, SEDU, Test, ThinkerForge, TPM2, WS2801, WS2812b, None)
|
/// APA102, Adalight, AmbiLed, Atmo, Hyperion-USBASP-WS2801, Hyperion-USBASP-WS2812, Lightberry, Lightpack, LPD6803, LPD8806, Multi-Lightpack, P9813, Paintpack, PhilipsHUE, PiBlaster, SEDU, file, ThinkerForge, TPM2, WS2801, WS2812b, None)
|
||||||
/// * [device type specific configuration]
|
/// * [device type specific configuration]
|
||||||
/// * 'colorOrder' : The order of the color bytes ('rgb', 'rbg', 'bgr', etc.).
|
/// * 'colorOrder' : The order of the color bytes ('rgb', 'rbg', 'bgr', etc.).
|
||||||
"device" :
|
"device" :
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
/// 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', 'ldp8806',
|
/// * 'type' : The type of the device or leds (known types for now are 'ws2801', 'ldp8806',
|
||||||
/// 'lpd6803', 'sedu', 'adalight', 'lightpack', 'test' and 'none')
|
/// 'lpd6803', 'sedu', 'adalight', 'lightpack', 'file' and 'none')
|
||||||
/// * 'output' : The output specification depends on selected device. This can for example be the
|
/// * 'output' : The output specification depends on selected device. This can for example be the
|
||||||
/// device specifier, device serial number, or the output file name
|
/// device specifier, device serial number, or the output file name
|
||||||
/// * 'rate' : The baudrate of the output to the device
|
/// * 'rate' : The baudrate of the output to the device
|
||||||
|
@ -21,7 +21,7 @@ SET(Leddevice_QT_HEADERS
|
|||||||
${CURRENT_SOURCE_DIR}/LedDevicePhilipsHue.h
|
${CURRENT_SOURCE_DIR}/LedDevicePhilipsHue.h
|
||||||
${CURRENT_SOURCE_DIR}/LedHIDDevice.h
|
${CURRENT_SOURCE_DIR}/LedHIDDevice.h
|
||||||
${CURRENT_SOURCE_DIR}/LedDeviceRawHID.h
|
${CURRENT_SOURCE_DIR}/LedDeviceRawHID.h
|
||||||
${CURRENT_SOURCE_DIR}/LedDeviceTest.h
|
${CURRENT_SOURCE_DIR}/LedDeviceFile.h
|
||||||
${CURRENT_SOURCE_DIR}/LedDeviceFadeCandy.h
|
${CURRENT_SOURCE_DIR}/LedDeviceFadeCandy.h
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -34,7 +34,7 @@ SET(Leddevice_HEADERS
|
|||||||
${CURRENT_SOURCE_DIR}/LedDevicePaintpack.h
|
${CURRENT_SOURCE_DIR}/LedDevicePaintpack.h
|
||||||
${CURRENT_SOURCE_DIR}/LedDevicePiBlaster.h
|
${CURRENT_SOURCE_DIR}/LedDevicePiBlaster.h
|
||||||
${CURRENT_SOURCE_DIR}/LedDeviceSedu.h
|
${CURRENT_SOURCE_DIR}/LedDeviceSedu.h
|
||||||
${CURRENT_SOURCE_DIR}/LedDeviceTest.h
|
${CURRENT_SOURCE_DIR}/LedDeviceFile.h
|
||||||
${CURRENT_SOURCE_DIR}/LedDeviceFadeCandy.h
|
${CURRENT_SOURCE_DIR}/LedDeviceFadeCandy.h
|
||||||
${CURRENT_SOURCE_DIR}/LedDeviceUdp.h
|
${CURRENT_SOURCE_DIR}/LedDeviceUdp.h
|
||||||
${CURRENT_SOURCE_DIR}/LedDeviceHyperionUsbasp.h
|
${CURRENT_SOURCE_DIR}/LedDeviceHyperionUsbasp.h
|
||||||
@ -58,7 +58,7 @@ SET(Leddevice_SOURCES
|
|||||||
${CURRENT_SOURCE_DIR}/LedDevicePaintpack.cpp
|
${CURRENT_SOURCE_DIR}/LedDevicePaintpack.cpp
|
||||||
${CURRENT_SOURCE_DIR}/LedDevicePiBlaster.cpp
|
${CURRENT_SOURCE_DIR}/LedDevicePiBlaster.cpp
|
||||||
${CURRENT_SOURCE_DIR}/LedDeviceSedu.cpp
|
${CURRENT_SOURCE_DIR}/LedDeviceSedu.cpp
|
||||||
${CURRENT_SOURCE_DIR}/LedDeviceTest.cpp
|
${CURRENT_SOURCE_DIR}/LedDeviceFile.cpp
|
||||||
${CURRENT_SOURCE_DIR}/LedDeviceFadeCandy.cpp
|
${CURRENT_SOURCE_DIR}/LedDeviceFadeCandy.cpp
|
||||||
${CURRENT_SOURCE_DIR}/LedDeviceUdp.cpp
|
${CURRENT_SOURCE_DIR}/LedDeviceUdp.cpp
|
||||||
${CURRENT_SOURCE_DIR}/LedDeviceHyperionUsbasp.cpp
|
${CURRENT_SOURCE_DIR}/LedDeviceHyperionUsbasp.cpp
|
||||||
|
@ -29,7 +29,7 @@
|
|||||||
#include "LedDevicePaintpack.h"
|
#include "LedDevicePaintpack.h"
|
||||||
#include "LedDevicePiBlaster.h"
|
#include "LedDevicePiBlaster.h"
|
||||||
#include "LedDeviceSedu.h"
|
#include "LedDeviceSedu.h"
|
||||||
#include "LedDeviceTest.h"
|
#include "LedDeviceFile.h"
|
||||||
#include "LedDeviceFadeCandy.h"
|
#include "LedDeviceFadeCandy.h"
|
||||||
#include "LedDeviceUdp.h"
|
#include "LedDeviceUdp.h"
|
||||||
#include "LedDeviceHyperionUsbasp.h"
|
#include "LedDeviceHyperionUsbasp.h"
|
||||||
@ -275,10 +275,10 @@ LedDevice * LedDeviceFactory::construct(const Json::Value & deviceConfig)
|
|||||||
|
|
||||||
device = new LedDeviceAtmoOrb(output, switchOffOnBlack, transitiontime, port, numLeds, orbIds);
|
device = new LedDeviceAtmoOrb(output, switchOffOnBlack, transitiontime, port, numLeds, orbIds);
|
||||||
}
|
}
|
||||||
else if (type == "test")
|
else if (type == "file")
|
||||||
{
|
{
|
||||||
const std::string output = deviceConfig["output"].asString();
|
const std::string output = deviceConfig.get("output", "/dev/null").asString();
|
||||||
device = new LedDeviceTest(output);
|
device = new LedDeviceFile(output);
|
||||||
}
|
}
|
||||||
else if (type == "fadecandy")
|
else if (type == "fadecandy")
|
||||||
{
|
{
|
||||||
@ -324,12 +324,13 @@ LedDevice * LedDeviceFactory::construct(const Json::Value & deviceConfig)
|
|||||||
else if (type == "ws281x")
|
else if (type == "ws281x")
|
||||||
{
|
{
|
||||||
const int gpio = deviceConfig.get("gpio", 18).asInt();
|
const int gpio = deviceConfig.get("gpio", 18).asInt();
|
||||||
const int leds = deviceConfig.get("leds", 12).asInt();
|
const int leds = deviceConfig.get("leds", 256).asInt();
|
||||||
const uint32_t freq = deviceConfig.get("freq", (Json::UInt)800000ul).asInt();
|
const uint32_t freq = deviceConfig.get("freq", (Json::UInt)800000ul).asInt();
|
||||||
const int dmanum = deviceConfig.get("dmanum", 5).asInt();
|
const int dmanum = deviceConfig.get("dmanum", 5).asInt();
|
||||||
const int pwmchannel = deviceConfig.get("pwmchannel", 0).asInt();
|
const int pwmchannel = deviceConfig.get("pwmchannel", 0).asInt();
|
||||||
|
const int invert = deviceConfig.get("invert", 0).asInt();
|
||||||
|
|
||||||
LedDeviceWS281x * ledDeviceWS281x = new LedDeviceWS281x(gpio, leds, freq, dmanum, pwmchannel);
|
LedDeviceWS281x * ledDeviceWS281x = new LedDeviceWS281x(gpio, leds, freq, dmanum, pwmchannel, invert);
|
||||||
device = ledDeviceWS281x;
|
device = ledDeviceWS281x;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
31
libsrc/leddevice/LedDeviceFile.cpp
Normal file
31
libsrc/leddevice/LedDeviceFile.cpp
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
|
||||||
|
// Local-Hyperion includes
|
||||||
|
#include "LedDeviceFile.h"
|
||||||
|
|
||||||
|
LedDeviceFile::LedDeviceFile(const std::string& output) :
|
||||||
|
_ofs(output.empty()?"/dev/null":output.c_str())
|
||||||
|
{
|
||||||
|
// empty
|
||||||
|
}
|
||||||
|
|
||||||
|
LedDeviceFile::~LedDeviceFile()
|
||||||
|
{
|
||||||
|
// empty
|
||||||
|
}
|
||||||
|
|
||||||
|
int LedDeviceFile::write(const std::vector<ColorRgb> & ledValues)
|
||||||
|
{
|
||||||
|
_ofs << "[";
|
||||||
|
for (const ColorRgb& color : ledValues)
|
||||||
|
{
|
||||||
|
_ofs << color;
|
||||||
|
}
|
||||||
|
_ofs << "]" << std::endl;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int LedDeviceFile::switchOff()
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
@ -10,18 +10,18 @@
|
|||||||
/// Implementation of the LedDevice that write the led-colors to an
|
/// Implementation of the LedDevice that write the led-colors to an
|
||||||
/// ASCII-textfile('/home/pi/LedDevice.out')
|
/// ASCII-textfile('/home/pi/LedDevice.out')
|
||||||
///
|
///
|
||||||
class LedDeviceTest : public LedDevice
|
class LedDeviceFile : public LedDevice
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
///
|
///
|
||||||
/// Constructs the test-device, which opens an output stream to the file
|
/// Constructs the test-device, which opens an output stream to the file
|
||||||
///
|
///
|
||||||
LedDeviceTest(const std::string& output);
|
LedDeviceFile(const std::string& output);
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Destructor of this test-device
|
/// Destructor of this test-device
|
||||||
///
|
///
|
||||||
virtual ~LedDeviceTest();
|
virtual ~LedDeviceFile();
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Writes the given led-color values to the output stream
|
/// Writes the given led-color values to the output stream
|
@ -1,31 +0,0 @@
|
|||||||
|
|
||||||
// Local-Hyperion includes
|
|
||||||
#include "LedDeviceTest.h"
|
|
||||||
|
|
||||||
LedDeviceTest::LedDeviceTest(const std::string& output) :
|
|
||||||
_ofs(output.empty()?"/home/pi/LedDevice.out":output.c_str())
|
|
||||||
{
|
|
||||||
// empty
|
|
||||||
}
|
|
||||||
|
|
||||||
LedDeviceTest::~LedDeviceTest()
|
|
||||||
{
|
|
||||||
// empty
|
|
||||||
}
|
|
||||||
|
|
||||||
int LedDeviceTest::write(const std::vector<ColorRgb> & ledValues)
|
|
||||||
{
|
|
||||||
_ofs << "[";
|
|
||||||
for (const ColorRgb& color : ledValues)
|
|
||||||
{
|
|
||||||
_ofs << color;
|
|
||||||
}
|
|
||||||
_ofs << "]" << std::endl;
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int LedDeviceTest::switchOff()
|
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
|
@ -3,7 +3,7 @@
|
|||||||
#include "LedDeviceWS281x.h"
|
#include "LedDeviceWS281x.h"
|
||||||
|
|
||||||
// Constructor
|
// Constructor
|
||||||
LedDeviceWS281x::LedDeviceWS281x(const int gpio, const int leds, const uint32_t freq, const int dmanum, const int pwmchannel)
|
LedDeviceWS281x::LedDeviceWS281x(const int gpio, const int leds, const uint32_t freq, const int dmanum, const int pwmchannel, const int invert)
|
||||||
{
|
{
|
||||||
initialized = false;
|
initialized = false;
|
||||||
led_string.freq = freq;
|
led_string.freq = freq;
|
||||||
@ -14,13 +14,13 @@ LedDeviceWS281x::LedDeviceWS281x(const int gpio, const int leds, const uint32_t
|
|||||||
}
|
}
|
||||||
chan = pwmchannel;
|
chan = pwmchannel;
|
||||||
led_string.channel[chan].gpionum = gpio;
|
led_string.channel[chan].gpionum = gpio;
|
||||||
led_string.channel[chan].invert = 0;
|
led_string.channel[chan].invert = invert;
|
||||||
led_string.channel[chan].count = leds;
|
led_string.channel[chan].count = leds;
|
||||||
led_string.channel[chan].brightness = 255;
|
led_string.channel[chan].brightness = 255;
|
||||||
led_string.channel[chan].strip_type = WS2811_STRIP_RGB;
|
led_string.channel[chan].strip_type = WS2811_STRIP_RGB;
|
||||||
|
|
||||||
led_string.channel[!chan].gpionum = 0;
|
led_string.channel[!chan].gpionum = 0;
|
||||||
led_string.channel[!chan].invert = 0;
|
led_string.channel[!chan].invert = invert;
|
||||||
led_string.channel[!chan].count = 0;
|
led_string.channel[!chan].count = 0;
|
||||||
led_string.channel[!chan].brightness = 0;
|
led_string.channel[!chan].brightness = 0;
|
||||||
led_string.channel[!chan].strip_type = WS2811_STRIP_RGB;
|
led_string.channel[!chan].strip_type = WS2811_STRIP_RGB;
|
||||||
|
@ -16,8 +16,11 @@ public:
|
|||||||
/// @param leds The number of leds attached to the gpio pin
|
/// @param leds The number of leds attached to the gpio pin
|
||||||
/// @param freq The target frequency for the data line, default is 800000
|
/// @param freq The target frequency for the data line, default is 800000
|
||||||
/// @param dmanum The DMA channel to use, default is 5
|
/// @param dmanum The DMA channel to use, default is 5
|
||||||
|
/// @param pwmchannel The pwm channel to use
|
||||||
|
/// @param invert Invert the output line to support an inverting level shifter
|
||||||
|
|
||||||
///
|
///
|
||||||
LedDeviceWS281x(const int gpio, const int leds, const uint32_t freq, int dmanum, int pwmchannel);
|
LedDeviceWS281x(const int gpio, const int leds, const uint32_t freq, int dmanum, int pwmchannel, int invert);
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Destructor of the LedDevice, waits for DMA to complete and then cleans up
|
/// Destructor of the LedDevice, waits for DMA to complete and then cleans up
|
||||||
|
Loading…
Reference in New Issue
Block a user