mirror of
https://github.com/MarlinFirmware/Marlin.git
synced 2026-01-13 03:12:56 -07:00
set custom address, ad optional swap color channels
This commit is contained in:
parent
2bf26d7458
commit
94b91dbbe1
1 changed files with 26 additions and 9 deletions
|
|
@ -81,7 +81,11 @@
|
|||
#define LED_ON 0x01
|
||||
#define LED_PWM 0x02
|
||||
|
||||
#define PCA9632_ADDRESS 0b01100000
|
||||
#if !defined(PCA9632_ADDRESS)
|
||||
#define PCA9632_ADDRESS 0b01100000
|
||||
#warning "Using default PCA9632 I2C address=" STRINGIFY(PCA9632_ADDRESS)
|
||||
#endif
|
||||
#warning "Using PCA9632 I2C address=" STRINGIFY(PCA9632_ADDRESS)
|
||||
|
||||
byte PCA_init = 0;
|
||||
|
||||
|
|
@ -132,15 +136,28 @@ void PCA9632_set_led_color(const LED1Color_t &color) {
|
|||
PCA9632_WriteRegister(PCA9632_ADDRESS,PCA9632_MODE2, PCA9632_MODE2_VALUE);
|
||||
}
|
||||
|
||||
const byte LEDOUT = (color.r ? LED_PWM << PCA9632_RED : 0)
|
||||
| (color.g ? LED_PWM << PCA9632_GRN : 0)
|
||||
| (color.b ? LED_PWM << PCA9632_BLU : 0)
|
||||
| (TERN0(PCA9632_RGBW, color.w ? LED_PWM << PCA9632_WHT : 0));
|
||||
#if ENABLED(PCA9632_SWAP_RB)
|
||||
const byte LEDOUT = (color.b ? LED_PWM << PCA9632_RED : 0)
|
||||
| (color.g ? LED_PWM << PCA9632_GRN : 0)
|
||||
| (color.r ? LED_PWM << PCA9632_BLU : 0)
|
||||
| (TERN0(PCA9632_RGBW, color.w ? LED_PWM << PCA9632_WHT : 0));
|
||||
|
||||
PCA9632_WriteAllRegisters(PCA9632_ADDRESS,PCA9632_PWM0, color.b, color.g, color.r
|
||||
OPTARG(PCA9632_RGBW, color.w)
|
||||
);
|
||||
PCA9632_WriteRegister(PCA9632_ADDRESS,PCA9632_LEDOUT, LEDOUT);
|
||||
#else
|
||||
const byte LEDOUT = (color.r ? LED_PWM << PCA9632_RED : 0)
|
||||
| (color.g ? LED_PWM << PCA9632_GRN : 0)
|
||||
| (color.b ? LED_PWM << PCA9632_BLU : 0)
|
||||
| (TERN0(PCA9632_RGBW, color.w ? LED_PWM << PCA9632_WHT : 0));
|
||||
|
||||
PCA9632_WriteAllRegisters(PCA9632_ADDRESS,PCA9632_PWM0, color.r, color.g, color.b
|
||||
OPTARG(PCA9632_RGBW, color.w)
|
||||
);
|
||||
PCA9632_WriteRegister(PCA9632_ADDRESS,PCA9632_LEDOUT, LEDOUT);
|
||||
#endif
|
||||
|
||||
PCA9632_WriteAllRegisters(PCA9632_ADDRESS,PCA9632_PWM0, color.r, color.g, color.b
|
||||
OPTARG(PCA9632_RGBW, color.w)
|
||||
);
|
||||
PCA9632_WriteRegister(PCA9632_ADDRESS,PCA9632_LEDOUT, LEDOUT);
|
||||
}
|
||||
|
||||
#if ENABLED(PCA9632_BUZZER)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue