led driver
This commit is contained in:
parent
1943426294
commit
edf050fd2b
@ -1,7 +1,27 @@
|
|||||||
#include "leds.h"
|
#include "leds.h"
|
||||||
|
|
||||||
|
led_strip_handle_t leds;
|
||||||
|
|
||||||
|
void init_leds(void) {
|
||||||
|
led_strip_config_t strip_config = {
|
||||||
|
.strip_gpio_num = NEOPIXEL_PIN,
|
||||||
|
.max_leds = PIXEL_COUNT,
|
||||||
|
.led_pixel_format = LED_PIXEL_FORMAT_GRB,
|
||||||
|
.led_model = LED_MODEL_WS2812
|
||||||
|
};
|
||||||
|
|
||||||
#define PIXEL_COUNT 21
|
led_strip_rmt_config_t rmt_config = {
|
||||||
#define NEOPIXEL_PIN GPIO_NUM_7
|
.clk_src = RMT_CLK_SRC_DEFAULT,
|
||||||
|
.resolution_hz = LED_STRIP_RMT_RES_HZ,
|
||||||
|
};
|
||||||
|
rmt_config.flags.with_dma = false;
|
||||||
|
|
||||||
|
ESP_ERROR_CHECK(led_strip_new_rmt_device(&strip_config, &rmt_config, &leds));
|
||||||
|
}
|
||||||
|
|
||||||
|
void example_leds(void) {
|
||||||
|
for (int i = 0; i < PIXEL_COUNT; i++) {
|
||||||
|
ESP_ERROR_CHECK(led_strip_set_pixel(leds, i, i, PIXEL_COUNT-i, 0));
|
||||||
|
}
|
||||||
|
ESP_ERROR_CHECK(led_strip_refresh(leds));
|
||||||
|
}
|
||||||
@ -1,5 +1,20 @@
|
|||||||
#ifndef LEDS_H
|
#ifndef LEDS_H
|
||||||
#define LEDS_H
|
#define LEDS_H
|
||||||
|
|
||||||
|
#include "led_strip.h"
|
||||||
|
|
||||||
|
#define PIXEL_COUNT 21
|
||||||
|
#define NEOPIXEL_PIN GPIO_NUM_7
|
||||||
|
// 10MHz resolution, 1 tick = 0.1us (led strip needs a high resolution)
|
||||||
|
#define LED_STRIP_RMT_RES_HZ (10 * 1000 * 1000)
|
||||||
|
|
||||||
|
extern led_strip_handle_t leds;
|
||||||
|
|
||||||
|
typedef enum {
|
||||||
|
|
||||||
|
} Led;
|
||||||
|
|
||||||
|
void init_leds(void);
|
||||||
|
void example_leds(void);
|
||||||
|
|
||||||
#endif /* LEDS_H */
|
#endif /* LEDS_H */
|
||||||
@ -12,6 +12,7 @@
|
|||||||
#include "drivers/speaker.h"
|
#include "drivers/speaker.h"
|
||||||
#include "drivers/char_lcd.h"
|
#include "drivers/char_lcd.h"
|
||||||
#include "esp_rom_gpio.h"
|
#include "esp_rom_gpio.h"
|
||||||
|
#include "drivers/leds.h"
|
||||||
|
|
||||||
#include "steps/step0.hpp"
|
#include "steps/step0.hpp"
|
||||||
#include "steps/step1.hpp"
|
#include "steps/step1.hpp"
|
||||||
@ -21,9 +22,6 @@
|
|||||||
#include "steps/step5.hpp"
|
#include "steps/step5.hpp"
|
||||||
#include "steps/step6.hpp"
|
#include "steps/step6.hpp"
|
||||||
|
|
||||||
#define WIRES_ADDR 125
|
|
||||||
#define WIRES_REG_WIRES
|
|
||||||
|
|
||||||
static const char *TAG = "main";
|
static const char *TAG = "main";
|
||||||
|
|
||||||
extern "C" void app_main(void) {
|
extern "C" void app_main(void) {
|
||||||
@ -34,6 +32,7 @@ extern "C" void app_main(void) {
|
|||||||
init_speaker();
|
init_speaker();
|
||||||
init_sseg();
|
init_sseg();
|
||||||
init_game_module_timer();
|
init_game_module_timer();
|
||||||
|
init_leds();
|
||||||
init_wires();
|
init_wires();
|
||||||
|
|
||||||
init_bottom_half();
|
init_bottom_half();
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user