From 0047b0de5668774192f1bd2e91a08b1d1e6e0498 Mon Sep 17 00:00:00 2001 From: "T. van der Zwan" Date: Mon, 27 Jan 2014 19:15:04 +0000 Subject: [PATCH] Numerous mods for ws2812b to no avail. Former-commit-id: 1fda06d3df5e5394ff23277e1361ab1dc35c3205 --- libsrc/leddevice/LedDeviceWs2812b.cpp | 2 +- libsrc/leddevice/LedRs232Device.cpp | 1 + test/TestNonInvWs2812b.cpp | 8 ++++---- test/TestNonUniformWs2812b.cpp | 28 ++++++++++++++------------- 4 files changed, 21 insertions(+), 18 deletions(-) diff --git a/libsrc/leddevice/LedDeviceWs2812b.cpp b/libsrc/leddevice/LedDeviceWs2812b.cpp index b800d0ad..dd0bbb94 100644 --- a/libsrc/leddevice/LedDeviceWs2812b.cpp +++ b/libsrc/leddevice/LedDeviceWs2812b.cpp @@ -6,7 +6,7 @@ #include "LedDeviceWs2812b.h" LedDeviceWs2812b::LedDeviceWs2812b() : - LedRs232Device("/dev/ttyAMA0", 2000000) + LedRs232Device("/dev/ttyUSB0", 2000000) { // empty } diff --git a/libsrc/leddevice/LedRs232Device.cpp b/libsrc/leddevice/LedRs232Device.cpp index ab289d78..6bc3560b 100644 --- a/libsrc/leddevice/LedRs232Device.cpp +++ b/libsrc/leddevice/LedRs232Device.cpp @@ -31,6 +31,7 @@ int LedRs232Device::open() { try { + std::cout << "Opening UART: " << mDeviceName << std::endl; _rs232Port.setPort(mDeviceName); _rs232Port.setBaudrate(mBaudRate_Hz); _rs232Port.open(); diff --git a/test/TestNonInvWs2812b.cpp b/test/TestNonInvWs2812b.cpp index 269c9d27..5db10dfb 100644 --- a/test/TestNonInvWs2812b.cpp +++ b/test/TestNonInvWs2812b.cpp @@ -62,7 +62,7 @@ void printClockSignal(const std::vector & signal) int main() { - const std::vector data(9, 0xff); + const std::vector data(9, 0x00); std::vector encData = encode(data); for (uint8_t encByte : encData) @@ -88,7 +88,7 @@ int main() // Configure the port struct termios options; tcgetattr(uart0_filestream, &options); - options.c_cflag = B4000000 | CS8 | CLOCAL; + options.c_cflag = B2500000 | CS8 | CLOCAL; options.c_iflag = IGNPAR; options.c_oflag = 0; options.c_lflag = 0; @@ -96,11 +96,11 @@ int main() tcflush(uart0_filestream, TCIFLUSH); tcsetattr(uart0_filestream, TCSANOW, &options); - char c = getchar(); + getchar(); const int breakLength_ms = 1; - encData = std::vector(128, 0x10); + encData = std::vector(128, 0x00); write(uart0_filestream, encData.data(), encData.size()); diff --git a/test/TestNonUniformWs2812b.cpp b/test/TestNonUniformWs2812b.cpp index 0a15339d..97f14695 100644 --- a/test/TestNonUniformWs2812b.cpp +++ b/test/TestNonUniformWs2812b.cpp @@ -46,7 +46,7 @@ void printClockSignal(const std::vector & signal) int main() { - const std::vector white{0xff, 0xff, 0xff}; + const std::vector white{0xff,0xff,0xff, 0xff,0xff,0xff, 0xff,0xff,0xff}; const std::vector green{0xff, 0x00, 0x00}; const std::vector red {0x00, 0xff, 0x00}; const std::vector blue {0x00, 0x00, 0xff}; @@ -87,20 +87,22 @@ int main() const std::vector encBlackData = encode(black); //std::cout << "Writing GREEN ("; printClockSignal(encode(green)); std::cout << ")" << std::endl; - const std::vector garbage {0x0f}; - write(uart0_filestream, garbage.data(), garbage.size()); - write(uart0_filestream, encGreenData.data(), encGreenData.size()); - write(uart0_filestream, encRedData.data(), encRedData.size()); - write(uart0_filestream, encBlueData.data(), encBlueData.size()); - write(uart0_filestream, encGrayData.data(), encGrayData.size()); - write(uart0_filestream, encBlackData.data(), encBlackData.size()); - } - { - getchar(); +// const std::vector garbage {0x0f}; +// write(uart0_filestream, garbage.data(), garbage.size()); +// write(uart0_filestream, encGreenData.data(), encGreenData.size()); +// write(uart0_filestream, encRedData.data(), encRedData.size()); +// write(uart0_filestream, encBlueData.data(), encBlueData.size()); +// write(uart0_filestream, encGrayData.data(), encGrayData.size()); +// write(uart0_filestream, encBlackData.data(), encBlackData.size()); +// } +// { +// getchar(); const std::vector encData = encode(white); std::cout << "Writing WHITE ("; printClockSignal(encode(white)); std::cout << ")" << std::endl; - const std::vector garbage {0x0f}; - write(uart0_filestream, garbage.data(), garbage.size()); +// const std::vector garbage {0x0f}; +// write(uart0_filestream, garbage.data(), garbage.size()); + write(uart0_filestream, encData.data(), encData.size()); + write(uart0_filestream, encData.data(), encData.size()); write(uart0_filestream, encData.data(), encData.size()); } {