From c179b86b8d8c5f3c6b02c2c2254ccaf3adde4680 Mon Sep 17 00:00:00 2001 From: penfold42 Date: Sun, 22 May 2016 20:56:44 +1000 Subject: [PATCH] fix LedDeviceWs2812SPI to compile on gcc 4.6 (#643) * Removed -HUP so the default -TERM signal is sent instead. - hyperiond only listens for TERM and INT. HUP is often used to get an exe to reread its config Changed pgrep to add '-x' so it wont partial match on the exe name. - I have multiple instances with multiple hyperiond-instance1 names - this ensures the service script only kills the right process * reversing errant change to hyperion.systemd.sh * cleaned up a couple of compiler warnings * moved bitpair_to_byte initialiser to (hopefully) work with older GCC * compiler warning in udp driver removed some tabs in ws2812b.cpp * formatting - spaces to tabs Former-commit-id: 42cc7325177c9fcc3d1bd29cbfe72f02118d3233 --- libsrc/leddevice/LedDevicePiBlaster.cpp | 4 ++-- libsrc/leddevice/LedDeviceUdp.cpp | 2 +- libsrc/leddevice/LedDeviceWS2812b.cpp | 18 +++++++++--------- libsrc/leddevice/LedDeviceWs2812SPI.cpp | 9 ++++++++- libsrc/leddevice/LedDeviceWs2812SPI.h | 8 +------- 5 files changed, 21 insertions(+), 20 deletions(-) diff --git a/libsrc/leddevice/LedDevicePiBlaster.cpp b/libsrc/leddevice/LedDevicePiBlaster.cpp index dc09fe15..ced94ed4 100644 --- a/libsrc/leddevice/LedDevicePiBlaster.cpp +++ b/libsrc/leddevice/LedDevicePiBlaster.cpp @@ -27,7 +27,7 @@ LedDevicePiBlaster::LedDevicePiBlaster(const std::string & deviceName, const Jso // { "gpio" : 4, "ledindex" : 0, "ledcolor" : "r" }, #define TABLE_SZ sizeof(_gpio_to_led)/sizeof(_gpio_to_led[0]) - for (int i=0; i < TABLE_SZ; i++ ) + for (unsigned i=0; i < TABLE_SZ; i++ ) { _gpio_to_led[i] = -1; _gpio_to_color[i] = 'z'; @@ -41,7 +41,7 @@ LedDevicePiBlaster::LedDevicePiBlaster(const std::string & deviceName, const Jso const std::string ledcolor = gpioMap.get("ledcolor","z").asString(); // printf ("got gpio %d ledindex %d color %c\n", gpio,ledindex, ledcolor[0]); // ignore missing/invalid settings - if ( (gpio >= 0) && (gpio < TABLE_SZ) && (ledindex >= 0) ){ + if ( (gpio >= 0) && (gpio < signed(TABLE_SZ)) && (ledindex >= 0) ){ _gpio_to_led[gpio] = ledindex; _gpio_to_color[gpio] = ledcolor[0]; // 1st char of string } else { diff --git a/libsrc/leddevice/LedDeviceUdp.cpp b/libsrc/leddevice/LedDeviceUdp.cpp index 1fc67647..48c2a8d7 100644 --- a/libsrc/leddevice/LedDeviceUdp.cpp +++ b/libsrc/leddevice/LedDeviceUdp.cpp @@ -17,7 +17,7 @@ struct addrinfo hints, *servinfo, *p; //char udpbuffer[1024]; int sockfd; int ledprotocol; -int leds_per_pkt; +unsigned leds_per_pkt; int update_number; int fragment_number; diff --git a/libsrc/leddevice/LedDeviceWS2812b.cpp b/libsrc/leddevice/LedDeviceWS2812b.cpp index 67a10947..c012639b 100644 --- a/libsrc/leddevice/LedDeviceWS2812b.cpp +++ b/libsrc/leddevice/LedDeviceWS2812b.cpp @@ -666,15 +666,15 @@ void LedDeviceWS2812b::initHardware() // Allocate memory for the DMA control block & data to be sent // --------------------------------------------------------------- virtbase = (uint8_t *) mmap( - NULL, // Address - NUM_PAGES * PAGE_SIZE, // Length - PROT_READ | PROT_WRITE, // Protection - MAP_SHARED | // Shared - MAP_ANONYMOUS | // Not file-based, init contents to 0 - MAP_NORESERVE | // Don't reserve swap space - MAP_LOCKED, // Lock in RAM (don't swap) - -1, // File descriptor - 0); // Offset + NULL, // Address + NUM_PAGES * PAGE_SIZE, // Length + PROT_READ | PROT_WRITE, // Protection + MAP_SHARED | // Shared + MAP_ANONYMOUS | // Not file-based, init contents to 0 + MAP_NORESERVE | // Don't reserve swap space + MAP_LOCKED, // Lock in RAM (don't swap) + -1, // File descriptor + 0); // Offset if (virtbase == MAP_FAILED) { diff --git a/libsrc/leddevice/LedDeviceWs2812SPI.cpp b/libsrc/leddevice/LedDeviceWs2812SPI.cpp index 7b915595..b9dc8a3d 100644 --- a/libsrc/leddevice/LedDeviceWs2812SPI.cpp +++ b/libsrc/leddevice/LedDeviceWs2812SPI.cpp @@ -13,7 +13,14 @@ LedDeviceWs2812SPI::LedDeviceWs2812SPI(const std::string& outputDevice, const unsigned baudrate) : LedSpiDevice(outputDevice, baudrate, 0), - mLedCount(0) + mLedCount(0), + bitpair_to_byte { + 0b10001000, + 0b10001100, + 0b11001000, + 0b11001100, + } + { // empty } diff --git a/libsrc/leddevice/LedDeviceWs2812SPI.h b/libsrc/leddevice/LedDeviceWs2812SPI.h index e82d9134..408e2b9f 100644 --- a/libsrc/leddevice/LedDeviceWs2812SPI.h +++ b/libsrc/leddevice/LedDeviceWs2812SPI.h @@ -42,11 +42,5 @@ private: size_t mLedCount; std::vector _spiBuffer; - uint8_t bitpair_to_byte[4] = { - 0b10001000, - 0b10001100, - 0b11001000, - 0b11001100, - }; - + uint8_t bitpair_to_byte[4]; };