From ca24450618cda5763fcaacd23a57483f173ac508 Mon Sep 17 00:00:00 2001 From: penfold42 Date: Sat, 13 Feb 2016 23:00:31 +1100 Subject: [PATCH 1/2] added configurable latchtime for 2801 SPI driver Former-commit-id: a10b0bd24a85580b021c735b30ebd2635180a514 --- libsrc/leddevice/LedDeviceFactory.cpp | 3 ++- libsrc/leddevice/LedDeviceWs2801.cpp | 9 ++++++++- libsrc/leddevice/LedDeviceWs2801.h | 4 ++++ 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/libsrc/leddevice/LedDeviceFactory.cpp b/libsrc/leddevice/LedDeviceFactory.cpp index 6e7b3da8..1a0e1709 100755 --- a/libsrc/leddevice/LedDeviceFactory.cpp +++ b/libsrc/leddevice/LedDeviceFactory.cpp @@ -128,8 +128,9 @@ LedDevice * LedDeviceFactory::construct(const Json::Value & deviceConfig) { const std::string output = deviceConfig["output"].asString(); const unsigned rate = deviceConfig["rate"].asInt(); + const unsigned latchtime = deviceConfig.get("latchtime",500000).asInt(); - LedDeviceWs2801* deviceWs2801 = new LedDeviceWs2801(output, rate); + LedDeviceWs2801* deviceWs2801 = new LedDeviceWs2801(output, rate, latchtime); deviceWs2801->open(); device = deviceWs2801; diff --git a/libsrc/leddevice/LedDeviceWs2801.cpp b/libsrc/leddevice/LedDeviceWs2801.cpp index 31bb43cd..b36d2f49 100644 --- a/libsrc/leddevice/LedDeviceWs2801.cpp +++ b/libsrc/leddevice/LedDeviceWs2801.cpp @@ -11,13 +11,20 @@ // hyperion local includes #include "LedDeviceWs2801.h" -LedDeviceWs2801::LedDeviceWs2801(const std::string& outputDevice, const unsigned baudrate) : +LedDeviceWs2801::LedDeviceWs2801(const std::string& outputDevice, const unsigned baudrate ) : LedSpiDevice(outputDevice, baudrate, 500000), mLedCount(0) { // empty } +LedDeviceWs2801::LedDeviceWs2801(const std::string& outputDevice, const unsigned baudrate, const unsigned latchTime) : + LedSpiDevice(outputDevice, baudrate, latchTime), + mLedCount(0) +{ + // empty +} + int LedDeviceWs2801::write(const std::vector &ledValues) { mLedCount = ledValues.size(); diff --git a/libsrc/leddevice/LedDeviceWs2801.h b/libsrc/leddevice/LedDeviceWs2801.h index e7ff6998..c2231cd7 100644 --- a/libsrc/leddevice/LedDeviceWs2801.h +++ b/libsrc/leddevice/LedDeviceWs2801.h @@ -21,6 +21,10 @@ public: LedDeviceWs2801(const std::string& outputDevice, const unsigned baudrate); + LedDeviceWs2801(const std::string& outputDevice, + const unsigned baudrate, + const unsigned latchTime); + /// /// Writes the led color values to the led-device /// From 3be4ebe6dcfb4d5cfbf8b2cc83ca40d92259580f Mon Sep 17 00:00:00 2001 From: penfold42 Date: Thu, 25 Feb 2016 22:33:13 +1100 Subject: [PATCH 2/2] clean up formatting Former-commit-id: dc3a3c7597af42b8fb37f09011d52ebacffd8959 --- libsrc/leddevice/LedDeviceWs2801.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libsrc/leddevice/LedDeviceWs2801.cpp b/libsrc/leddevice/LedDeviceWs2801.cpp index b36d2f49..aaee8cf6 100644 --- a/libsrc/leddevice/LedDeviceWs2801.cpp +++ b/libsrc/leddevice/LedDeviceWs2801.cpp @@ -11,7 +11,7 @@ // hyperion local includes #include "LedDeviceWs2801.h" -LedDeviceWs2801::LedDeviceWs2801(const std::string& outputDevice, const unsigned baudrate ) : +LedDeviceWs2801::LedDeviceWs2801(const std::string& outputDevice, const unsigned baudrate) : LedSpiDevice(outputDevice, baudrate, 500000), mLedCount(0) {