Browse Source

add led

main
Hendrik Langer 7 years ago
parent
commit
f14124a6f0
  1. 3
      software/platformio.ini
  2. 11
      software/src/hardware.h
  3. 15
      software/src/led.cpp
  4. 6
      software/src/led.h
  5. 3
      software/src/main.cpp

3
software/platformio.ini

@ -19,5 +19,6 @@ lib_deps =
; ESP Async WebServer ; ESP Async WebServer
; AsyncTCP ; AsyncTCP
FS FS
FastLED ; FastLED
https://github.com/samguyer/FastLED.git
lib_ignore = ESPAsyncTCP lib_ignore = ESPAsyncTCP

11
software/src/hardware.h

@ -1,11 +1,16 @@
#ifndef _HARDWARE_H #ifndef _HARDWARE_H
#define _HARDWARE_H #define _HARDWARE_H
#define WIFI_SSID "ssid" #define WIFI_SSID "nether.net"
#define WIFI_PASSWORD "password" #define WIFI_PASSWORD "threepwood"
#define LED_BUILTIN 13 #define LED_BUILTIN 13
static constexpr int SERVO_PINS[] = {5, 18, 24, 25}; static constexpr int SERVO_PINS[] = {23, 22, 1, 3, 21, 19};
static constexpr uint8_t LED_PIN = 4;
static constexpr uint8_t NUM_LEDS = 22;
#define LED_TYPE TM1829
#define COLOR_ORDER BRG
#endif /* _HARDWARE_H */ #endif /* _HARDWARE_H */

15
software/src/led.cpp

@ -1,4 +1,8 @@
#define FASTLED_ALLOW_INTERRUPTS 0
#include <FastLED.h>
#include "led.h" #include "led.h"
#include "hardware.h"
using namespace std; using namespace std;
@ -6,4 +10,15 @@ Led::Led(void) {
} }
void Led::setup(void) { void Led::setup(void) {
FastLED.addLeds<LED_TYPE, LED_PIN, COLOR_ORDER>(leds, NUM_LEDS);
leds[0] = CRGB::Red;
leds[1] = CRGB::Green;
leds[2] = CRGB::Blue;
leds[NUM_LEDS-6] = CRGB::White;
leds[NUM_LEDS-5] = CRGB::White;
leds[NUM_LEDS-4] = CRGB::White;
leds[NUM_LEDS-3] = CRGB::White;
leds[NUM_LEDS-2] = CRGB::White;
leds[NUM_LEDS-1] = CRGB::White;
FastLED.show();
} }

6
software/src/led.h

@ -1,11 +1,17 @@
#ifndef _LED_H #ifndef _LED_H
#define _LED_H #define _LED_H
#define FASTLED_ALLOW_INTERRUPTS 0
#include <FastLED.h>
#include "hardware.h"
class Led { class Led {
public: public:
Led(void); Led(void);
void setup(void); void setup(void);
private: private:
CRGB leds[NUM_LEDS];
}; };
#endif /* _LED_H */ #endif /* _LED_H */

3
software/src/main.cpp

@ -12,6 +12,7 @@
#include "webserver.h" #include "webserver.h"
#include "pusher.h" #include "pusher.h"
#include "shelf.h" #include "shelf.h"
#include "led.h"
volatile SemaphoreHandle_t xPreferencesSemaphore = xSemaphoreCreateMutex(); volatile SemaphoreHandle_t xPreferencesSemaphore = xSemaphoreCreateMutex();
@ -19,6 +20,7 @@ Wifi wifi;
Webserver webserver; Webserver webserver;
Pusher pusher; Pusher pusher;
Shelf* shelf; Shelf* shelf;
Led led;
void setup() void setup()
{ {
@ -34,6 +36,7 @@ void setup()
// initialize LED digital pin as an output. // initialize LED digital pin as an output.
pinMode(LED_BUILTIN, OUTPUT); pinMode(LED_BUILTIN, OUTPUT);
led.setup();
wifi.connect(); wifi.connect();
shelf = new Shelf(8); shelf = new Shelf(8);
pusher.setup(); pusher.setup();

Loading…
Cancel
Save