mirror of
https://github.com/hyperion-project/hyperion.ng.git
synced 2023-10-10 13:36:59 +02:00
Rename WS2812s to WS2812b (spelling error)
Former-commit-id: 83c92c9ef99d45b8683860f199a14952c05d0f5d
This commit is contained in:
parent
61da05e108
commit
39ddfca5c0
@ -70,11 +70,11 @@ endif(ENABLE_SPIDEV)
|
||||
|
||||
SET(Leddevice_HEADERS
|
||||
${Leddevice_HEADERS}
|
||||
${CURRENT_SOURCE_DIR}/LedDeviceWS2812s.h
|
||||
${CURRENT_SOURCE_DIR}/LedDeviceWS2812b.h
|
||||
)
|
||||
SET(Leddevice_SOURCES
|
||||
${Leddevice_SOURCES}
|
||||
${CURRENT_SOURCE_DIR}/LedDeviceWS2812s.cpp
|
||||
${CURRENT_SOURCE_DIR}/LedDeviceWS2812b.cpp
|
||||
)
|
||||
|
||||
if(ENABLE_TINKERFORGE)
|
||||
|
@ -31,7 +31,7 @@
|
||||
#include "LedDevicePhilipsHue.h"
|
||||
#include "LedDeviceTpm2.h"
|
||||
|
||||
#include "LedDeviceWS2812s.h"
|
||||
#include "LedDeviceWS2812b.h"
|
||||
|
||||
LedDevice * LedDeviceFactory::construct(const Json::Value & deviceConfig)
|
||||
{
|
||||
@ -183,10 +183,10 @@ LedDevice * LedDeviceFactory::construct(const Json::Value & deviceConfig)
|
||||
LedDeviceTpm2* deviceTpm2 = new LedDeviceTpm2(output, rate);
|
||||
deviceTpm2->open();
|
||||
device = deviceTpm2;
|
||||
}else if (type == "ws2812s")
|
||||
}else if (type == "ws2812b")
|
||||
{
|
||||
LedDeviceWS2812s * ledDeviceWS2812s = new LedDeviceWS2812s();
|
||||
device = ledDeviceWS2812s;
|
||||
LedDeviceWS2812b * ledDeviceWS2812b = new LedDeviceWS2812b();
|
||||
device = ledDeviceWS2812b;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -1,4 +1,4 @@
|
||||
// For license and other informations see LedDeviceWS2812s.h
|
||||
// For license and other informations see LedDeviceWS2812b.h
|
||||
// To activate: use led device "ws2812s" in the hyperion configuration
|
||||
|
||||
// STL includes
|
||||
@ -15,7 +15,7 @@
|
||||
//#include <sys/ioctl.h>
|
||||
|
||||
// hyperion local includes
|
||||
#include "LedDeviceWS2812s.h"
|
||||
#include "LedDeviceWS2812b.h"
|
||||
|
||||
// ==== Defines and Vars ====
|
||||
|
||||
@ -227,7 +227,7 @@
|
||||
|
||||
|
||||
|
||||
LedDeviceWS2812s::LedDeviceWS2812s() :
|
||||
LedDeviceWS2812b::LedDeviceWS2812b() :
|
||||
LedDevice(),
|
||||
mLedCount(0)
|
||||
{
|
||||
@ -237,7 +237,7 @@ LedDeviceWS2812s::LedDeviceWS2812s() :
|
||||
}
|
||||
|
||||
|
||||
int LedDeviceWS2812s::write(const std::vector<ColorRgb> &ledValues)
|
||||
int LedDeviceWS2812b::write(const std::vector<ColorRgb> &ledValues)
|
||||
{
|
||||
mLedCount = ledValues.size();
|
||||
//printf("Set leds, number: %d\n", mLedCount);
|
||||
@ -315,12 +315,12 @@ int LedDeviceWS2812s::write(const std::vector<ColorRgb> &ledValues)
|
||||
return 0;
|
||||
}
|
||||
|
||||
int LedDeviceWS2812s::switchOff()
|
||||
int LedDeviceWS2812b::switchOff()
|
||||
{
|
||||
return write(std::vector<ColorRgb>(mLedCount, ColorRgb{0,0,0}));
|
||||
}
|
||||
|
||||
LedDeviceWS2812s::~LedDeviceWS2812s()
|
||||
LedDeviceWS2812b::~LedDeviceWS2812b()
|
||||
{
|
||||
// Exit cleanly, freeing memory and stopping the DMA & PWM engines
|
||||
// We trap all signals (including Ctrl+C), so even if you don't get here, it terminates correctly
|
||||
@ -340,7 +340,7 @@ LedDeviceWS2812s::~LedDeviceWS2812s()
|
||||
// Convenience functions
|
||||
// --------------------------------------------------------------------------------------------------
|
||||
// Print some bits of a binary number (2nd arg is how many bits)
|
||||
void LedDeviceWS2812s::printBinary(unsigned int i, unsigned int bits) {
|
||||
void LedDeviceWS2812b::printBinary(unsigned int i, unsigned int bits) {
|
||||
int x;
|
||||
for(x=bits-1; x>=0; x--) {
|
||||
printf("%d", (i & (1 << x)) ? 1 : 0);
|
||||
@ -378,7 +378,7 @@ static void udelay(int us) {
|
||||
|
||||
// Shutdown functions
|
||||
// --------------------------------------------------------------------------------------------------
|
||||
void LedDeviceWS2812s::terminate(int dummy) {
|
||||
void LedDeviceWS2812b::terminate(int dummy) {
|
||||
// Shut down the DMA controller
|
||||
if(dma_reg) {
|
||||
CLRBIT(dma_reg[DMA_CS], DMA_CS_ACTIVE);
|
||||
@ -402,7 +402,7 @@ void LedDeviceWS2812s::terminate(int dummy) {
|
||||
//exit(1);
|
||||
}
|
||||
|
||||
void LedDeviceWS2812s::fatal(const char *fmt, ...) {
|
||||
void LedDeviceWS2812b::fatal(const char *fmt, ...) {
|
||||
va_list ap;
|
||||
va_start(ap, fmt);
|
||||
vfprintf(stderr, fmt, ap);
|
||||
@ -414,13 +414,13 @@ void LedDeviceWS2812s::fatal(const char *fmt, ...) {
|
||||
// Memory management
|
||||
// --------------------------------------------------------------------------------------------------
|
||||
// Translate from virtual address to physical
|
||||
unsigned int LedDeviceWS2812s::mem_virt_to_phys(void *virt) {
|
||||
unsigned int LedDeviceWS2812b::mem_virt_to_phys(void *virt) {
|
||||
unsigned int offset = (uint8_t *)virt - virtbase;
|
||||
return page_map[offset >> PAGE_SHIFT].physaddr + (offset % PAGE_SIZE);
|
||||
}
|
||||
|
||||
// Translate from physical address to virtual
|
||||
unsigned int LedDeviceWS2812s::mem_phys_to_virt(uint32_t phys) {
|
||||
unsigned int LedDeviceWS2812b::mem_phys_to_virt(uint32_t phys) {
|
||||
unsigned int pg_offset = phys & (PAGE_SIZE - 1);
|
||||
unsigned int pg_addr = phys - pg_offset;
|
||||
|
||||
@ -435,7 +435,7 @@ unsigned int LedDeviceWS2812s::mem_phys_to_virt(uint32_t phys) {
|
||||
}
|
||||
|
||||
// Map a peripheral's IO memory into our virtual memory, so we can read/write it directly
|
||||
void * LedDeviceWS2812s::map_peripheral(uint32_t base, uint32_t len) {
|
||||
void * LedDeviceWS2812b::map_peripheral(uint32_t base, uint32_t len) {
|
||||
int fd = open("/dev/mem", O_RDWR);
|
||||
void * vaddr;
|
||||
|
||||
@ -450,7 +450,7 @@ void * LedDeviceWS2812s::map_peripheral(uint32_t base, uint32_t len) {
|
||||
}
|
||||
|
||||
// Zero out the PWM waveform buffer
|
||||
void LedDeviceWS2812s::clearPWMBuffer() {
|
||||
void LedDeviceWS2812b::clearPWMBuffer() {
|
||||
memset(PWMWaveform, 0, NUM_DATA_WORDS * 4); // Times four because memset deals in bytes.
|
||||
}
|
||||
|
||||
@ -458,7 +458,7 @@ void LedDeviceWS2812s::clearPWMBuffer() {
|
||||
// The (31 - bitIdx) is so that we write the data backwards, correcting its endianness
|
||||
// This means getPWMBit will return something other than what was written, so it would be nice
|
||||
// if the logic that calls this function would figure it out instead. (However, that's trickier)
|
||||
void LedDeviceWS2812s::setPWMBit(unsigned int bitPos, unsigned char bit) {
|
||||
void LedDeviceWS2812b::setPWMBit(unsigned int bitPos, unsigned char bit) {
|
||||
|
||||
// Fetch word the bit is in
|
||||
unsigned int wordOffset = (int)(bitPos / 32);
|
||||
@ -480,7 +480,7 @@ void LedDeviceWS2812s::setPWMBit(unsigned int bitPos, unsigned char bit) {
|
||||
|
||||
// ==== Init Hardware ====
|
||||
|
||||
void LedDeviceWS2812s::initHardware() {
|
||||
void LedDeviceWS2812b::initHardware() {
|
||||
int pid;
|
||||
int fd;
|
||||
char pagemap_fn[64];
|
||||
@ -722,7 +722,7 @@ void LedDeviceWS2812s::initHardware() {
|
||||
}
|
||||
|
||||
// Begin the transfer
|
||||
void LedDeviceWS2812s::startTransfer() {
|
||||
void LedDeviceWS2812b::startTransfer() {
|
||||
// Enable DMA
|
||||
dma_reg[DMA_CONBLK_AD] = mem_virt_to_phys(ctl->cb);
|
||||
dma_reg[DMA_CS] = DMA_CS_CONFIGWORD | (1 << DMA_CS_ACTIVE);
|
@ -1,5 +1,5 @@
|
||||
#ifndef LEDDEVICEWS2812S_H_
|
||||
#define LEDDEVICEWS2812S_H_
|
||||
#ifndef LEDDEVICEWS2812B_H_
|
||||
#define LEDDEVICEWS2812B_H_
|
||||
|
||||
#pragma once
|
||||
|
||||
@ -126,14 +126,14 @@ typedef struct {
|
||||
///
|
||||
/// Implementation of the LedDevice interface for writing to Ws2801 led device.
|
||||
///
|
||||
class LedDeviceWS2812s : public LedDevice
|
||||
class LedDeviceWS2812b : public LedDevice
|
||||
{
|
||||
public:
|
||||
///
|
||||
/// Constructs the LedDevice for a string containing leds of the type WS2812
|
||||
LedDeviceWS2812s();
|
||||
LedDeviceWS2812b();
|
||||
|
||||
~LedDeviceWS2812s();
|
||||
~LedDeviceWS2812b();
|
||||
///
|
||||
/// Writes the led color values to the led-device
|
||||
///
|
||||
@ -206,4 +206,4 @@ private:
|
||||
|
||||
|
||||
|
||||
#endif /* LEDDEVICEWS2812S_H_ */
|
||||
#endif /* LEDDEVICEWS2812B_H_ */
|
Loading…
Reference in New Issue
Block a user