Add support for 64-bit image drawing with MAX7219 8x8 LED Matrix
The MAX7219 driver has been extended to add support for bitmap drawing on an 8-by-8 LED matrix panel. Consumers can specify the targeted chip, which corresponds to a LED matrix panel, and provide a 64-bit image buffer specifying the pixels which should illuminate.
This commit is contained in:
parent
503e66a500
commit
22f84a15c3
5 changed files with 161 additions and 1 deletions
|
|
@ -119,7 +119,7 @@ void max7219_set_shutdown_mode(const max7219_display_t *disp, bool shutdown)
|
|||
|
||||
bool max7219_set_digit(const max7219_display_t *disp, uint8_t digit, uint8_t val)
|
||||
{
|
||||
if (digit >= disp->digits)
|
||||
if (digit >= (disp->digits * disp->cascade_size))
|
||||
{
|
||||
debug("Invalid digit: %d", digit);
|
||||
return false;
|
||||
|
|
@ -187,3 +187,9 @@ void max7219_draw_text(const max7219_display_t *disp, uint8_t pos, const char *s
|
|||
s++;
|
||||
}
|
||||
}
|
||||
|
||||
void max7219_draw_image_8x8(const max7219_display_t *disp, uint8_t pos, const void *image)
|
||||
{
|
||||
for (uint8_t i = (pos * disp->digits), offset = 0; i < (disp->digits * disp->cascade_size) && offset < 8; i++, offset++)
|
||||
max7219_set_digit(disp, i, *((uint8_t *)image + offset));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -88,6 +88,14 @@ void max7219_clear(const max7219_display_t *disp);
|
|||
*/
|
||||
void max7219_draw_text(const max7219_display_t *disp, uint8_t pos, const char *s);
|
||||
|
||||
/**
|
||||
* Draw 64-bit image on 8x8 matrix.
|
||||
* @param disp Pointer to display descriptor
|
||||
* @param pos Start digit
|
||||
* @param image 64-bit buffer with image data
|
||||
*/
|
||||
void max7219_draw_image_8x8(const max7219_display_t *disp, uint8_t pos, const void *image);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue