#ifndef _LED_RGB_ #define _LED_RGB_ /* * Project : mainHome * Authors : C.Varin * File : ledRGB.h * Abstract : Header for LedRGB class managing an RGB strip. * The user will be able to interact with the * configured strip and get its status. * * strip : * Parameter 1 = number of pixels in strip * Parameter 2 = pin number (most are valid) * Parameter 3 = pixel type flags, add together as needed: * NEO_KHZ800 800 KHz bitstream (most NeoPixel products w/WS2812 LEDs) * NEO_KHZ400 400 KHz (classic 'v1' (not v2) FLORA pixels, WS2811 drivers) * NEO_GRB Pixels are wired for GRB bitstream (most NeoPixel products) * NEO_RGB Pixels are wired for RGB bitstream (v1 FLORA pixels, not v2) * * Date : 02-16-2017 * */ /* includes */ #include #include "Adafruit_NeoPixel.h" #include /* class definition */ class ledRGB : public Adafruit_NeoPixel { public: //------------------------------------ // constructors ledRGB(uint16_t param_size, uint8_t param_pin, uint8_t param_neo); // return the strip status (each led's color) as a String. String ledRGB_getStatus(); //test function void s_all_test(); //------------------------------------ // SWITCH ON // allow the user to switch on all leds. // by default, switch on all led with white color (R255,G255, B255). void s_all_on(); // switch on all leds with a specified RGB value. void s_all_on(uint8_t param_led_g, uint8_t param_led_r, uint8_t param_led_b); // switch on all leds with a specified value coded in hexa. void s_all_on(int param_rgb_hex); // test if the R, G or B value are into [0;255] range. bool value_limit_test(int val); // get the rgb int value from R, G and B parameters uint32_t getIntRGB(uint8_t param_g, uint8_t param_r, uint8_t param_b); //------------------------------------ // SPECIALS FUNCTIONS // // Smooth blink // others // =====> TO BE DEFINE : 03-28-2017 //------------------------------------ // SWITCH OFF // allow user to switch off all leds. void s_all_off(); //------------------------------------ // GENERAL FUNCTIONS // // enumeration of all possible states enum state {ON, COLOR, OFF, COLOR_WIPE, BLINK}; // the active state. state ActiveState; unsigned long interval; unsigned long lastUpdate; private: // the control pin of the strip. uint8_t s_pin; // the bitstream speed. int s_f_bitstream; // the amount of rgb leds. uint16_t s_size; // the strip type. String s_neo_type; // status led array. uint8_t *sts_r_leds; uint8_t *sts_g_leds; uint8_t *sts_b_leds; // single status for the whole strip. uint8_t sts_r; uint8_t sts_g; uint8_t sts_b; }; #endif