Lixie_II.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. /*
  2. Lixie_II.h - Library for controlling the Lixie II!
  3. Created by Connor Nishijma July 6th, 2019
  4. Released under the GPLv3 License
  5. */
  6. #ifndef lixie_II_h
  7. #define lixie_II_h
  8. #include "Arduino.h"
  9. #if defined(ARDUINO_ARCH_ESP8266) || defined(ARDUINO_ARCH_ESP32)
  10. #include <Ticker.h> // ESP ONLY
  11. // FastLED has issues with the ESP8266, especially
  12. // when used with networking, so we fix that here.
  13. #define FASTLED_ESP8266_RAW_PIN_ORDER
  14. #define FASTLED_ALLOW_INTERRUPTS 0
  15. #define FASTLED_INTERRUPT_RETRY_COUNT 0
  16. #endif
  17. // Aside from those issues, it's my tool of choice for WS2812B
  18. #include "FastLED.h"
  19. #define ON 1
  20. #define OFF 0
  21. #define INSTANT 0
  22. #define CROSSFADE 1
  23. // Functions
  24. class Lixie_II
  25. {
  26. public:
  27. Lixie_II(const uint8_t pin, uint8_t n_digits);
  28. void build_controller(const uint8_t pin);
  29. void begin();
  30. void transition_type(uint8_t type);
  31. void transition_time(uint16_t ms);
  32. void max_power(uint8_t V, uint16_t mA);
  33. void color_all(uint8_t layer, CRGB col);
  34. void color_all_dual(uint8_t layer, CRGB col_left, CRGB col_right);
  35. void color_display(uint8_t display, uint8_t layer, CRGB col);
  36. void gradient_rgb(uint8_t layer, CRGB col_left, CRGB col_right);
  37. void start_animation();
  38. void stop_animation();
  39. void write(uint32_t input);
  40. void write(char* input);
  41. void write_float(float input, uint8_t dec_places = 1);
  42. void clear_all();
  43. void write_digit(uint8_t digit, uint8_t num);
  44. void push_digit(uint8_t number);
  45. void clear_digit(uint8_t digit, uint8_t num);
  46. void mask_update();
  47. void fade_in();
  48. void fade_out();
  49. void brightness(uint8_t level);
  50. void run();
  51. void wait();
  52. void streak(CRGB col, float pos, uint8_t blur);
  53. void sweep_color(CRGB col, uint16_t speed, uint8_t blur, bool reverse = false);
  54. void sweep_gradient(CRGB col_left, CRGB col_right, uint16_t speed, uint8_t blur, bool reverse = false);
  55. void nixie();
  56. void white_balance(CRGB c_adj);
  57. void rainbow(uint8_t r_hue, uint8_t r_sep);
  58. // ----------------------------------------------
  59. // Deprecated Lixie 1 functions and overloads:
  60. // ----------------------------------------------
  61. void clear(bool show_change = true);
  62. void clear_digit(uint8_t index, bool show_change = true);
  63. void show();
  64. void write_flip(uint32_t input, uint16_t flip_time = 100, uint8_t flip_speed = 10);
  65. void write_fade(uint32_t input, uint16_t fade_time = 250);
  66. void sweep(CRGB col, uint8_t speed = 15);
  67. void progress(float percent, CRGB col1, CRGB col2);
  68. void fill_fade_in(CRGB col, uint8_t fade_speed = 20);
  69. void fill_fade_out(CRGB col, uint8_t fade_speed = 20);
  70. void color(uint8_t r, uint8_t g, uint8_t b);
  71. void color(CRGB c);
  72. void color(uint8_t r, uint8_t g, uint8_t b, uint8_t index);
  73. void color(CRGB c, uint8_t index);
  74. void color_off(uint8_t r, uint8_t g, uint8_t b);
  75. void color_off(CRGB c);
  76. void color_off(uint8_t r, uint8_t g, uint8_t b, uint8_t index);
  77. void color_off(CRGB c, uint8_t index);
  78. void color_fade(CRGB col, uint16_t duration);
  79. void color_fade(CRGB col, uint16_t duration, uint8_t index);
  80. void color_array_fade(CRGB *cols, uint16_t duration);
  81. void color_array_fade(CHSV *cols, uint16_t duration);
  82. void color_wipe(CRGB col1, CRGB col2);
  83. void nixie_mode(bool enabled, bool has_aura = true);
  84. void nixie_aura_intensity(uint8_t val);
  85. private:
  86. uint8_t get_size(uint32_t input);
  87. };
  88. #endif