logging migration for ws281x and LedUdpDevice (#45)

This commit is contained in:
penfold42 2016-06-25 01:46:23 +10:00 committed by brindosch
parent 33ebdcaffc
commit b6a0b7261d
4 changed files with 6 additions and 6 deletions

View File

@ -6,13 +6,13 @@
LedDeviceWS281x::LedDeviceWS281x(const int gpio, const int leds, const uint32_t freq, const int dmanum, const int pwmchannel, const int invert, const int rgbw, const std::string& whiteAlgorithm) LedDeviceWS281x::LedDeviceWS281x(const int gpio, const int leds, const uint32_t freq, const int dmanum, const int pwmchannel, const int invert, const int rgbw, const std::string& whiteAlgorithm)
{ {
_whiteAlgorithm = whiteAlgorithm; _whiteAlgorithm = whiteAlgorithm;
std::cout << "whiteAlgorithm :" << whiteAlgorithm << ":\n"; Debug( Logger::getInstance("LedDevice"), "whiteAlgorithm : %s", whiteAlgorithm.c_str());
initialized = false; initialized = false;
led_string.freq = freq; led_string.freq = freq;
led_string.dmanum = dmanum; led_string.dmanum = dmanum;
if (pwmchannel != 0 && pwmchannel != 1) { if (pwmchannel != 0 && pwmchannel != 1) {
std::cout << "WS281x: invalid PWM channel; must be 0 or 1." << std::endl; Error( Logger::getInstance("LedDevice"), "WS281x: invalid PWM channel; must be 0 or 1.");
throw -1; throw -1;
} }
chan = pwmchannel; chan = pwmchannel;
@ -32,7 +32,7 @@ std::cout << "whiteAlgorithm :" << whiteAlgorithm << ":\n";
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;
if (ws2811_init(&led_string) < 0) { if (ws2811_init(&led_string) < 0) {
std::cout << "Unable to initialize ws281x library." << std::endl; Error( Logger::getInstance("LedDevice"), "Unable to initialize ws281x library.");
throw -1; throw -1;
} }
initialized = true; initialized = true;
@ -95,7 +95,6 @@ LedDeviceWS281x::~LedDeviceWS281x()
{ {
if (initialized) if (initialized)
{ {
std::cout << "Shutdown WS281x PWM and DMA channel" << std::endl;
ws2811_fini(&led_string); ws2811_fini(&led_string);
} }
initialized = false; initialized = false;

View File

@ -5,6 +5,7 @@
#include <leddevice/LedDevice.h> #include <leddevice/LedDevice.h>
#include <ws2811.h> #include <ws2811.h>
#include <utils/Logger.h>
class LedDeviceWS281x : public LedDevice class LedDeviceWS281x : public LedDevice
{ {

View File

@ -15,7 +15,6 @@
// Local Hyperion includes // Local Hyperion includes
#include "LedUdpDevice.h" #include "LedUdpDevice.h"
LedUdpDevice::LedUdpDevice(const std::string& outputDevice, const unsigned baudrate, const int latchTime_ns) : LedUdpDevice::LedUdpDevice(const std::string& outputDevice, const unsigned baudrate, const int latchTime_ns) :
mDeviceName(outputDevice), mDeviceName(outputDevice),
mBaudRate_Hz(baudrate), mBaudRate_Hz(baudrate),
@ -26,7 +25,7 @@ LedUdpDevice::LedUdpDevice(const std::string& outputDevice, const unsigned baudr
QString str = QString::fromStdString(mDeviceName); QString str = QString::fromStdString(mDeviceName);
QStringList _list = str.split(":"); QStringList _list = str.split(":");
if (_list.size() != 2) { if (_list.size() != 2) {
printf ("ERROR: LedUdpDevice: Error parsing hostname:port\n"); Error( Logger::getInstance("LedDevice"), "LedUdpDevice: Error parsing hostname:port");
exit (-1); exit (-1);
} }
QHostInfo info = QHostInfo::fromName(_list.at(0)); QHostInfo info = QHostInfo::fromName(_list.at(0));

View File

@ -7,6 +7,7 @@
// Hyperion includes // Hyperion includes
#include <leddevice/LedDevice.h> #include <leddevice/LedDevice.h>
#include <utils/Logger.h>
/// ///
/// The LedUdpDevice implements an abstract base-class for LedDevices using the SPI-device. /// The LedUdpDevice implements an abstract base-class for LedDevices using the SPI-device.