56 lines
1.8 KiB
C++
56 lines
1.8 KiB
C++
#ifndef LEDMATRIX_H
|
|
#define LEDMATRIX_H
|
|
|
|
#include <Arduino.h>
|
|
#include <Adafruit_GFX.h>
|
|
#include <Adafruit_NeoMatrix.h>
|
|
#include "wordclock_constants.h"
|
|
#include "udp_logger.h"
|
|
|
|
#define DEFAULT_CURRENT_LIMIT 9999
|
|
|
|
extern const uint32_t colors_24bit[NUM_COLORS];
|
|
|
|
class LEDMatrix
|
|
{
|
|
public:
|
|
LEDMatrix(Adafruit_NeoMatrix * matrix, uint8_t brightness, UDPLogger * logger);
|
|
static uint16_t color_24_to_16bit(uint32_t color24bit);
|
|
static uint32_t color_24bit(uint8_t r, uint8_t g, uint8_t b);
|
|
static uint32_t interpolate_color_24bit(uint32_t color1, uint32_t color2, float factor);
|
|
static uint32_t wheel(uint8_t WheelPos);
|
|
void draw_on_matrix_instant();
|
|
void draw_on_matrix_smooth(float factor);
|
|
void flush(void);
|
|
void grid_add_pixel(uint8_t x, uint8_t y, uint32_t color);
|
|
void print_char(uint8_t xpos, uint8_t ypos, char character, uint32_t color);
|
|
void print_number(uint8_t xpos, uint8_t ypos, uint8_t number, uint32_t color);
|
|
void set_brightness(uint8_t mybrightness);
|
|
void set_current_limit(uint16_t new_current_limit);
|
|
void set_min_indicator(uint8_t pattern, uint32_t color);
|
|
void setup_matrix();
|
|
|
|
private:
|
|
Adafruit_NeoMatrix * _neomatrix;
|
|
UDPLogger * _logger;
|
|
|
|
uint8_t _brightness;
|
|
uint16_t _current_limit;
|
|
|
|
// target representation of matrix as 2D array
|
|
uint32_t _target_grid[MATRIX_HEIGHT][MATRIX_WIDTH] = {0};
|
|
|
|
// current representation of matrix as 2D array
|
|
uint32_t _current_grid[MATRIX_HEIGHT][MATRIX_WIDTH] = {0};
|
|
|
|
// target representation of minutes indicator LEDs
|
|
uint32_t _target_minute_indicators[4] = {0, 0, 0, 0};
|
|
|
|
// current representation of minutes indicator LEDs
|
|
uint32_t _current_minute_indicators[4] = {0, 0, 0, 0};
|
|
|
|
void _draw_on_matrix(float factor);
|
|
uint16_t _calc_estimated_led_current(uint32_t color);
|
|
};
|
|
|
|
#endif /* LEDMATRIX_H */ |