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
3
examples/max7219_8x8/Makefile
Normal file
3
examples/max7219_8x8/Makefile
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
PROGRAM = max7219_8x8
|
||||
EXTRA_COMPONENTS = extras/max7219
|
||||
include ../../common.mk
|
||||
95
examples/max7219_8x8/digit_font.h
Normal file
95
examples/max7219_8x8/digit_font.h
Normal file
|
|
@ -0,0 +1,95 @@
|
|||
const uint8_t DIGITS[][8] = {
|
||||
{
|
||||
0x0,
|
||||
0x3c,
|
||||
0x66,
|
||||
0x6e,
|
||||
0x76,
|
||||
0x66,
|
||||
0x66,
|
||||
0x3c
|
||||
}, {
|
||||
0x0,
|
||||
0x18,
|
||||
0x18,
|
||||
0x38,
|
||||
0x18,
|
||||
0x18,
|
||||
0x18,
|
||||
0x7e
|
||||
}, {
|
||||
0x0,
|
||||
0x3c,
|
||||
0x66,
|
||||
0x6,
|
||||
0xc,
|
||||
0x30,
|
||||
0x60,
|
||||
0x7e
|
||||
}, {
|
||||
0x0,
|
||||
0x3c,
|
||||
0x66,
|
||||
0x6,
|
||||
0x1c,
|
||||
0x6,
|
||||
0x66,
|
||||
0x3c
|
||||
}, {
|
||||
0x0,
|
||||
0xc,
|
||||
0x1c,
|
||||
0x2c,
|
||||
0x4c,
|
||||
0x7e,
|
||||
0xc,
|
||||
0xc
|
||||
}, {
|
||||
0x0,
|
||||
0x7e,
|
||||
0x60,
|
||||
0x7c,
|
||||
0x6,
|
||||
0x6,
|
||||
0x66,
|
||||
0x3c
|
||||
}, {
|
||||
0x0,
|
||||
0x3c,
|
||||
0x66,
|
||||
0x60,
|
||||
0x7c,
|
||||
0x66,
|
||||
0x66,
|
||||
0x3c
|
||||
}, {
|
||||
0x0,
|
||||
0x7e,
|
||||
0x66,
|
||||
0xc,
|
||||
0xc,
|
||||
0x18,
|
||||
0x18,
|
||||
0x18
|
||||
}, {
|
||||
0x0,
|
||||
0x3c,
|
||||
0x66,
|
||||
0x66,
|
||||
0x3c,
|
||||
0x66,
|
||||
0x66,
|
||||
0x3c
|
||||
}, {
|
||||
0x0,
|
||||
0x3c,
|
||||
0x66,
|
||||
0x66,
|
||||
0x3e,
|
||||
0x6,
|
||||
0x66,
|
||||
0x3c
|
||||
}
|
||||
};
|
||||
|
||||
const int DIGITS_LEN = sizeof(DIGITS)/8;
|
||||
48
examples/max7219_8x8/main.c
Normal file
48
examples/max7219_8x8/main.c
Normal file
|
|
@ -0,0 +1,48 @@
|
|||
/*
|
||||
* Example of using MAX7219 driver with 8x8 LED Matrix displays
|
||||
*
|
||||
* MAX7219 driver uses the hardware SPI bus, so connect with pinout:
|
||||
* DIN -> HSPID/HMOSI
|
||||
* CS -> HSPICS/HCS
|
||||
* CLK -> HSPICLK/HSCLK
|
||||
*/
|
||||
#include <esp/uart.h>
|
||||
#include <espressif/esp_common.h>
|
||||
#include <stdio.h>
|
||||
#include <max7219/max7219.h>
|
||||
#include <FreeRTOS.h>
|
||||
#include <task.h>
|
||||
|
||||
#include "./digit_font.h"
|
||||
|
||||
#define CS_PIN 15
|
||||
#define DELAY 1000
|
||||
|
||||
static max7219_display_t disp = {
|
||||
.cs_pin = CS_PIN,
|
||||
.digits = 8,
|
||||
.cascade_size = 4,
|
||||
.mirrored = false
|
||||
};
|
||||
|
||||
void user_init(void) {
|
||||
uart_set_baud(0, 115200);
|
||||
printf("SDK version:%s\n", sdk_system_get_sdk_version());
|
||||
|
||||
max7219_init(&disp);
|
||||
//max7219_set_decode_mode(&disp, true);
|
||||
|
||||
uint8_t counter = 0;
|
||||
while (true) {
|
||||
max7219_clear(&disp);
|
||||
|
||||
max7219_draw_image_8x8(&disp, 0, DIGITS[counter % 10]);
|
||||
max7219_draw_image_8x8(&disp, 1, DIGITS[(counter+1) % 10]);
|
||||
max7219_draw_image_8x8(&disp, 2, DIGITS[(counter+2) % 10]);
|
||||
max7219_draw_image_8x8(&disp, 3, DIGITS[(counter+3) % 10]);
|
||||
|
||||
vTaskDelay(DELAY / portTICK_PERIOD_MS);
|
||||
|
||||
counter++;
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue