Unverified Commit e92b4ca6 authored by Holger Lembke's avatar Holger Lembke Committed by GitHub

Add: make digitalRead() for RGB_BUILTIN work (#9419)

* make digitalRead() for RGB_BUILTIN work

Standard Arduino-Way of blinking a LED can be the shortest with:

void loop() {
  static uint32_t ledticker = 0;
  if (millis() - ledticker > 1000) {
    ledticker = millis();
    digitalWrite(RGB_BUILTIN, !digitalRead(RGB_BUILTIN));
  }
}

Worked with the old LED_BUILTIN on Pin 2, now even works with Pin 48/neopixel.

* Add: make digitalRead() for RGB_BUILTIN work

Standard Arduino-Way of blinking a LED can be the shortest with:

void loop() {
  static uint32_t ledticker = 0;
  if (millis() - ledticker > 1000) {
    ledticker = millis();
    digitalWrite(RGB_BUILTIN, !digitalRead(RGB_BUILTIN));
  }
}

Worked with the old LED_BUILTIN on Pin 2, now even works with Pin 48/neopixel.

(Retry. Didn't sync my local sources. Sorry.)
parent 63453505
...@@ -151,11 +151,16 @@ extern void ARDUINO_ISR_ATTR __pinMode(uint8_t pin, uint8_t mode) ...@@ -151,11 +151,16 @@ extern void ARDUINO_ISR_ATTR __pinMode(uint8_t pin, uint8_t mode)
} }
} }
#ifdef RGB_BUILTIN
uint8_t RGB_BUILTIN_storage = 0;
#endif
extern void ARDUINO_ISR_ATTR __digitalWrite(uint8_t pin, uint8_t val) extern void ARDUINO_ISR_ATTR __digitalWrite(uint8_t pin, uint8_t val)
{ {
#ifdef RGB_BUILTIN #ifdef RGB_BUILTIN
if(pin == RGB_BUILTIN){ if(pin == RGB_BUILTIN){
//use RMT to set all channels on/off //use RMT to set all channels on/off
RGB_BUILTIN_storage=val;
const uint8_t comm_val = val != 0 ? RGB_BRIGHTNESS : 0; const uint8_t comm_val = val != 0 ? RGB_BRIGHTNESS : 0;
neopixelWrite(RGB_BUILTIN, comm_val, comm_val, comm_val); neopixelWrite(RGB_BUILTIN, comm_val, comm_val, comm_val);
return; return;
...@@ -170,6 +175,12 @@ extern void ARDUINO_ISR_ATTR __digitalWrite(uint8_t pin, uint8_t val) ...@@ -170,6 +175,12 @@ extern void ARDUINO_ISR_ATTR __digitalWrite(uint8_t pin, uint8_t val)
extern int ARDUINO_ISR_ATTR __digitalRead(uint8_t pin) extern int ARDUINO_ISR_ATTR __digitalRead(uint8_t pin)
{ {
#ifdef RGB_BUILTIN
if(pin == RGB_BUILTIN){
return RGB_BUILTIN_storage;
}
#endif
if(perimanGetPinBus(pin, ESP32_BUS_TYPE_GPIO) != NULL){ if(perimanGetPinBus(pin, ESP32_BUS_TYPE_GPIO) != NULL){
return gpio_get_level((gpio_num_t)pin); return gpio_get_level((gpio_num_t)pin);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment