<PAL_NOTICE>
This board behavior is for the NOTICE PAL.
In addition to the common definitions, this behavior enables access to onboard sensors.
- LED driver PCA9632
- Accelerometer MC3630
void setup() {
auto&& brd = the_twelite.board.use<PAL_NOTICE>();
}
Member Objects
sns_PCA9632
Object for the PCA9632 device. The board definition handles Wire initialization and device setup. Use the control methods described later to interact with the device.
If using a coin battery, pulsed lighting (e.g., flashing briefly every second) can reduce peak current draw.
For example, turning on the LED for about 20ms every 1 second can still appear bright enough while minimizing the current (e.g., 5mA * 20ms per second = 0.1mA average).
sns_MC3630
Object for the MC3630 sensor. Handles SPI setup, device initialization, and interrupt processing. Use the methods provided in sns_MC3630
.
PCA9632 Definitions
static const uint8_t LED_OFF = SnsPCA9632::LED_OFF;
static const uint8_t LED_ON = SnsPCA9632::LED_PWM;
static const uint8_t LED_BLINK = SnsPCA9632::LED_BLINK;
static const uint8_t LED_NOP = SnsPCA9632::LED_NOP;
static const uint8_t LED_R = SnsPCA9632::LED1;
static const uint8_t LED_G = SnsPCA9632::LED2;
static const uint8_t LED_B = SnsPCA9632::LED3;
static const uint8_t LED_W = SnsPCA9632::LED4;
static const uint8_t LED_REG_MAX_PWM = 127;
static const uint8_t LED_REG_BOOST_PWM = 255;
LED States
Definition | Description |
---|---|
PAL_NOTICE::LED_OFF | Off |
PAL_NOTICE::LED_ON | On (PWM brightness control) |
PAL_NOTICE::LED_BLINK | Blinking |
PAL_NOTICE::LED_NOP | No change |
LED Identifiers
Definition | Description |
---|---|
PAL_NOTICE::LED_R | Red LED |
PAL_NOTICE::LED_G | Green LED |
PAL_NOTICE::LED_B | Blue LED |
PAL_NOTICE::LED_W | White LED |
Register Brightness Settings
Definition | Description |
---|---|
PAL_NOTICE::LED_REG_MAX_PWM | Standard brightness PWM register value (approx. 50%) |
PAL_NOTICE::LED_REG_BOOST_PWM | Boost brightness PWM register value |
PCA9632 Control Methods
Master Switch
void set_led_master_sw_on() { digitalWrite(PIN_SNS_EN, LOW); }
void set_led_master_sw_off() { digitalWrite(PIN_SNS_EN, HIGH); }
NOTICE PAL includes a FET switch after the PCA9632 output. LEDs will not light unless this switch is turned ON.
LED State Control
void set_led_r_blink()
void set_led_r_on()
void set_led_r_off()
void set_led_g_on()
void set_led_g_blink()
void set_led_g_off()
void set_led_b_on()
void set_led_b_blink()
void set_led_b_off()
void set_led_w_on()
void set_led_w_blink()
void set_led_w_off()
These functions set individual LEDs to ON, OFF, or BLINK state.
void set_leds(uint8_t r, uint8_t g, uint8_t b, uint8_t w)
void set_leds_off()
set_leds()
controls the state of all LEDs. Each parameter must be one of: PAL_NOTICE::LED_OFF
, PAL_NOTICE::LED_ON
, PAL_NOTICE::LED_BLINK
, or PAL_NOTICE::LED_NOP
.
LED Brightness Control
void set_led_brightness_r_reg(uint8_t duty)
void set_led_brightness_g_reg(uint8_t duty)
void set_led_brightness_b_reg(uint8_t duty)
void set_led_brightness_w_reg(uint8_t duty)
void set_leds_brightness_reg(uint8_t r, uint8_t g, uint8_t b, uint8_t w)
void set_led_brightness_r1000(uint16_t duty, bool boost = false)
void set_led_brightness_g1000(uint16_t duty, bool boost = false)
void set_led_brightness_b1000(uint16_t duty, bool boost = false)
void set_led_brightness_w1000(uint16_t duty, bool boost = false)
void set_leds_brightness1000(
uint16_t r, uint16_t g, uint16_t b, uint16_t w, bool boost = false)
Controls PWM duty cycle (brightness) of LEDs.
set_led_brightness_?_reg()
and set_leds_brightness_reg()
directly specify 0–255 register values, where brightness is duty/256
.
set_led_brightness_?1000()
and set_leds_brightness1000()
accept values from 0 to 1000. 0 means off, higher values increase brightness. When boost=false
, a value of 1000 maps to register value 127; when boost=true
, it maps to 255.
Blink Control
void set_blink_cycle_ms(uint16_t x)
void set_blink_duty1000(uint16_t x)
LEDs set to PAL_NOTICE::LED_BLINK
blink based on the specified cycle and duty.
- Per-LED blinking patterns are not supported.
- Brightness during blink is set by the current PWM duty configuration.
set_blink_cycle_ms()
sets blink cycle in milliseconds.
set_blink_duty1000()
sets ON duration as cycle * x / 1000
.
LED Test
void test_led()
Briefly lights up all four LEDs. After this, the master switch is left ON (set_led_master_sw_on()
).