Compare commits
2 Commits
| Author | SHA1 | Date |
|---|---|---|
|
|
7da7389f18 | |
|
|
12aa3a714a |
|
|
@ -1,2 +1,2 @@
|
|||
idf_component_register(SRCS "esp32_eurorack_generic.c"
|
||||
idf_component_register(SRCS "esp32_eurorack_generic.c" "led.c"
|
||||
INCLUDE_DIRS ".")
|
||||
|
|
|
|||
|
|
@ -1,6 +1,9 @@
|
|||
#include <stdio.h>
|
||||
|
||||
#include "led.h"
|
||||
|
||||
void app_main(void)
|
||||
{
|
||||
|
||||
/* Initialize LEDC driver */
|
||||
ledc_init();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,54 @@
|
|||
#include <stdio.h>
|
||||
|
||||
#include "esp_log.h"
|
||||
#include "esp_err.h"
|
||||
#include "driver/ledc.h"
|
||||
#include "hal/ledc_types.h"
|
||||
|
||||
/* Rotary Encoder LED Pins */
|
||||
#define R1B_PIN 18 /* Rotary Encoder 1 Blue Pin */
|
||||
#define R1G_PIN 8 /* Rotary Encoder 1 Green Pin */
|
||||
#define R2B_PIN 45 /* Rotary Encoder 2 Blue Pin */
|
||||
#define R2G_PIN 0 /* Rotary Encoder 2 Green Pin */
|
||||
|
||||
static const char *TAG = "ledc";
|
||||
|
||||
|
||||
void ledc_init(void)
|
||||
{
|
||||
ESP_LOGI(TAG, "Initializing LEDC driver");
|
||||
|
||||
/* Configure and initialize ledc PWM timer */
|
||||
ledc_timer_config_t timer_config = {
|
||||
.speed_mode = LEDC_LOW_SPEED_MODE,
|
||||
.timer_num = LEDC_TIMER_0,
|
||||
.duty_resolution = LEDC_TIMER_12_BIT,
|
||||
.clk_cfg = LEDC_AUTO_CLK,
|
||||
.freq_hz = 5000
|
||||
};
|
||||
ESP_ERROR_CHECK(ledc_timer_config(&timer_config));
|
||||
|
||||
/* Configure Rotary Encoder 1 B chan */
|
||||
ledc_channel_config_t R1B_config = {
|
||||
.channel = LEDC_CHANNEL_0,
|
||||
.gpio_num = R1B_PIN,
|
||||
.speed_mode = LEDC_LOW_SPEED_MODE,
|
||||
.timer_sel = LEDC_TIMER_0,
|
||||
.intr_type = LEDC_INTR_DISABLE,
|
||||
.duty = 2048,
|
||||
.hpoint = 0
|
||||
};
|
||||
ESP_ERROR_CHECK(ledc_channel_config(&R1B_config));
|
||||
|
||||
/* Configure Rotary Encoder 1 G chan */
|
||||
ledc_channel_config_t R1G_config = {
|
||||
.channel = LEDC_CHANNEL_1,
|
||||
.gpio_num = R1G_PIN,
|
||||
.speed_mode = LEDC_LOW_SPEED_MODE,
|
||||
.timer_sel = LEDC_TIMER_0,
|
||||
.intr_type = LEDC_INTR_DISABLE,
|
||||
.duty = 2048,
|
||||
.hpoint = 0
|
||||
};
|
||||
ESP_ERROR_CHECK(ledc_channel_config(&R1G_config));
|
||||
}
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
#ifndef LED_H_
|
||||
#define LED_H_
|
||||
|
||||
/* Configuration and initialization of ledc driver */
|
||||
void ledc_init(void);
|
||||
|
||||
#endif
|
||||
Loading…
Reference in New Issue