-
Notifications
You must be signed in to change notification settings - Fork 7.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1,107 changed files
with
79,640 additions
and
8,880 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
#include "esp32-hal-rgb-led.h" | ||
|
||
|
||
void neopixelWrite(uint8_t pin, uint8_t red_val, uint8_t green_val, uint8_t blue_val){ | ||
rmt_data_t led_data[24]; | ||
static rmt_obj_t* rmt_send = NULL; | ||
static bool initialized = false; | ||
|
||
uint8_t _pin = pin; | ||
#ifdef BOARD_HAS_NEOPIXEL | ||
if(pin == LED_BUILTIN){ | ||
_pin = LED_BUILTIN-SOC_GPIO_PIN_COUNT; | ||
} | ||
#endif | ||
|
||
if(!initialized){ | ||
if((rmt_send = rmtInit(_pin, RMT_TX_MODE, RMT_MEM_64)) == NULL){ | ||
log_e("RGB LED driver initialization failed!"); | ||
rmt_send = NULL; | ||
return; | ||
} | ||
rmtSetTick(rmt_send, 100); | ||
initialized = true; | ||
} | ||
|
||
int color[] = {green_val, red_val, blue_val}; // Color coding is in order GREEN, RED, BLUE | ||
int i = 0; | ||
for(int col=0; col<3; col++ ){ | ||
for(int bit=0; bit<8; bit++){ | ||
if((color[col] & (1<<(7-bit)))){ | ||
// HIGH bit | ||
led_data[i].level0 = 1; // T1H | ||
led_data[i].duration0 = 8; // 0.8us | ||
led_data[i].level1 = 0; // T1L | ||
led_data[i].duration1 = 4; // 0.4us | ||
}else{ | ||
// LOW bit | ||
led_data[i].level0 = 1; // T0H | ||
led_data[i].duration0 = 4; // 0.4us | ||
led_data[i].level1 = 0; // T0L | ||
led_data[i].duration1 = 8; // 0.8us | ||
} | ||
i++; | ||
} | ||
} | ||
rmtWrite(rmt_send, led_data, 24); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#ifndef MAIN_ESP32_HAL_RGB_LED_H_ | ||
#define MAIN_ESP32_HAL_RGB_LED_H_ | ||
|
||
#ifdef __cplusplus | ||
extern "C" { | ||
#endif | ||
|
||
#include "esp32-hal.h" | ||
|
||
#ifndef LED_BRIGHTNESS | ||
#define LED_BRIGHTNESS 64 | ||
#endif | ||
|
||
void neopixelWrite(uint8_t pin, uint8_t red_val, uint8_t green_val, uint8_t blue_val); | ||
|
||
#ifdef __cplusplus | ||
} | ||
#endif | ||
|
||
#endif /* MAIN_ESP32_HAL_RGB_LED_H_ */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.