Numerous mods for ws2812b to no avail.

Former-commit-id: 1fda06d3df5e5394ff23277e1361ab1dc35c3205
This commit is contained in:
T. van der Zwan 2014-01-27 19:15:04 +00:00
parent af08b9b5d0
commit 0047b0de56
4 changed files with 21 additions and 18 deletions

View File

@ -6,7 +6,7 @@
#include "LedDeviceWs2812b.h"
LedDeviceWs2812b::LedDeviceWs2812b() :
LedRs232Device("/dev/ttyAMA0", 2000000)
LedRs232Device("/dev/ttyUSB0", 2000000)
{
// empty
}

View File

@ -31,6 +31,7 @@ int LedRs232Device::open()
{
try
{
std::cout << "Opening UART: " << mDeviceName << std::endl;
_rs232Port.setPort(mDeviceName);
_rs232Port.setBaudrate(mBaudRate_Hz);
_rs232Port.open();

View File

@ -62,7 +62,7 @@ void printClockSignal(const std::vector<uint8_t> & signal)
int main()
{
const std::vector<uint8_t> data(9, 0xff);
const std::vector<uint8_t> data(9, 0x00);
std::vector<uint8_t> 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<uint8_t>(128, 0x10);
encData = std::vector<uint8_t>(128, 0x00);
write(uart0_filestream, encData.data(), encData.size());

View File

@ -46,7 +46,7 @@ void printClockSignal(const std::vector<uint8_t> & signal)
int main()
{
const std::vector<uint8_t> white{0xff, 0xff, 0xff};
const std::vector<uint8_t> white{0xff,0xff,0xff, 0xff,0xff,0xff, 0xff,0xff,0xff};
const std::vector<uint8_t> green{0xff, 0x00, 0x00};
const std::vector<uint8_t> red {0x00, 0xff, 0x00};
const std::vector<uint8_t> blue {0x00, 0x00, 0xff};
@ -87,20 +87,22 @@ int main()
const std::vector<uint8_t> encBlackData = encode(black);
//std::cout << "Writing GREEN ("; printClockSignal(encode(green)); std::cout << ")" << std::endl;
const std::vector<uint8_t> 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<uint8_t> 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<uint8_t> encData = encode(white);
std::cout << "Writing WHITE ("; printClockSignal(encode(white)); std::cout << ")" << std::endl;
const std::vector<uint8_t> garbage {0x0f};
write(uart0_filestream, garbage.data(), garbage.size());
// const std::vector<uint8_t> 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());
}
{