Can now use the buttons to change programs, change active LED zones, change LED brightness and enter and exit programming mode. Exiting programming mode will save settings. Holding MODE upon boot will load defaults (though not overwrite them in EEPROM). Also added basic power management. If the badge is still for 15min, LEDs will go out. When LEDs are blank due to brightness off setting or timeout, they are turned off to save power. Moving badge, entering programming mode, changing the program, or changing brightness will enable the LEDs.
45 lines
1.0 KiB
C
45 lines
1.0 KiB
C
/*
|
|
* led_sk6x_spi.h
|
|
*
|
|
* Created on: Jun 19, 2023
|
|
* Author: true
|
|
*/
|
|
|
|
#ifndef CODE_INC_LED_SK6X_SPI_H_
|
|
#define CODE_INC_LED_SK6X_SPI_H_
|
|
|
|
|
|
|
|
#include <stdint.h>
|
|
|
|
#define SK6X_LED_MAX_COUNT 8
|
|
|
|
#define SK6X_BUF_SIZE (((SK6X_LED_MAX_COUNT * 24) * 5) / 8) // always a whole number
|
|
|
|
#define SK6X_HI 0x10 // 0b000_10000, or 0.25/1.00uS on/off
|
|
#define SK6X_LO 0x1c // 0b000_11100, or 0.75/0.50uS on/off
|
|
//#define SK6X_HI 0xc0 // 0b11000000, or 0.25/0.75uS on/off
|
|
//#define SK6X_LO 0xfc // 0b11111100, or 0.75/0.25uS on/off
|
|
|
|
#define SK6X_ZONE_MAIN 0x01
|
|
#define SK6X_ZONE_SIDE 0x02
|
|
#define SK6X_ZONE_REAR 0x04
|
|
#define SK6X_ZONE_ALL (SK6X_ZONE_MAIN | SK6X_ZONE_SIDE | SK6X_ZONE_REAR)
|
|
|
|
|
|
|
|
void led_sk6x_init();
|
|
|
|
void led_sk6x_set(uint8_t index, uint8_t r, uint8_t g, uint8_t b);
|
|
void led_sk6x_set_all(uint8_t r, uint8_t g, uint8_t b);
|
|
|
|
void led_sk6x_process();
|
|
void led_sk6x_update();
|
|
|
|
void led_sk6x_zone_ena(uint8_t zone_mask);
|
|
void led_sk6x_brightness(uint8_t brightness);
|
|
|
|
|
|
|
|
#endif /* CODE_INC_LED_SK6X_SPI_H_ */
|