more configurable led
This commit is contained in:
@@ -143,7 +143,10 @@ int bootloader_bridge(uint8_t klen, uint8_t * keyh)
|
||||
void bootloader_heartbeat()
|
||||
{
|
||||
static int state = 0;
|
||||
static uint32_t val = 0x10;
|
||||
static uint32_t val = (LED_MAX_SCALER - LED_MIN_SCALER)/2;
|
||||
uint8_t r = (LED_INIT_VALUE >> 16) & 0xff;
|
||||
uint8_t g = (LED_INIT_VALUE >> 8) & 0xff;
|
||||
uint8_t b = (LED_INIT_VALUE >> 0) & 0xff;
|
||||
|
||||
if (state)
|
||||
{
|
||||
@@ -154,9 +157,10 @@ void bootloader_heartbeat()
|
||||
val++;
|
||||
}
|
||||
|
||||
if (val > 30 || val < 1)
|
||||
if (val > LED_MAX_SCALER || val < LED_MIN_SCALER)
|
||||
{
|
||||
state = !state;
|
||||
}
|
||||
led_rgb((val * 3)<<8 | (val*10) << 16);
|
||||
|
||||
led_rgb(((val * g)<<8) | ((val*r) << 16) | (val*b));
|
||||
}
|
||||
|
@@ -22,8 +22,20 @@
|
||||
#define DISABLE_CTAPHID_WINK
|
||||
#define DISABLE_CTAPHID_CBOR
|
||||
|
||||
|
||||
#define LED_INIT_VALUE 0x101000
|
||||
// 0xRRGGBB
|
||||
#define LED_INIT_VALUE 0x0a0300
|
||||
#define LED_MAX_SCALER 40
|
||||
#define LED_MIN_SCALER 1
|
||||
// # of ms between each change in LED
|
||||
#define HEARTBEAT_PERIOD 5
|
||||
// Each LED channel will be multiplied by a integer between LED_MAX_SCALER
|
||||
// and LED_MIN_SCALER to cause the slow pulse. E.g.
|
||||
// #define LED_INIT_VALUE 0x301000
|
||||
// #define LED_MAX_SCALER 30
|
||||
// #define LED_MIN_SCALER 1
|
||||
// #define HEARTBEAT_PERIOD 8
|
||||
// Will pulse from 0x301000 to 0x903000 to 0x301000 ...
|
||||
// Which will take ~8 * (30)*2 ms
|
||||
|
||||
// Button
|
||||
#define SOLO_BUTTON_PORT GPIOA
|
||||
|
@@ -107,12 +107,12 @@ int main(int argc, char * argv[])
|
||||
|
||||
memset(hidmsg,0,sizeof(hidmsg));
|
||||
|
||||
printf1(TAG_GEN,"recv'ing hid msg \n");
|
||||
printf1(TAG_GEN,"recv'ing hid msg \n");
|
||||
|
||||
|
||||
while(1)
|
||||
{
|
||||
if (millis() - t1 > 8)
|
||||
if (millis() - t1 > HEARTBEAT_PERIOD)
|
||||
{
|
||||
bootloader_heartbeat();
|
||||
t1 = millis();
|
||||
|
Reference in New Issue
Block a user