more configurable led
This commit is contained in:
parent
e107a9aa86
commit
9b4b18e1a4
@ -78,7 +78,7 @@ int main(int argc, char * argv[])
|
|||||||
|
|
||||||
while(1)
|
while(1)
|
||||||
{
|
{
|
||||||
if (millis() - t1 > 100)
|
if (millis() - t1 > HEARTBEAT_PERIOD)
|
||||||
{
|
{
|
||||||
heartbeat();
|
heartbeat();
|
||||||
t1 = millis();
|
t1 = millis();
|
||||||
|
@ -143,7 +143,10 @@ int bootloader_bridge(uint8_t klen, uint8_t * keyh)
|
|||||||
void bootloader_heartbeat()
|
void bootloader_heartbeat()
|
||||||
{
|
{
|
||||||
static int state = 0;
|
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)
|
if (state)
|
||||||
{
|
{
|
||||||
@ -154,9 +157,10 @@ void bootloader_heartbeat()
|
|||||||
val++;
|
val++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (val > 30 || val < 1)
|
if (val > LED_MAX_SCALER || val < LED_MIN_SCALER)
|
||||||
{
|
{
|
||||||
state = !state;
|
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_WINK
|
||||||
#define DISABLE_CTAPHID_CBOR
|
#define DISABLE_CTAPHID_CBOR
|
||||||
|
|
||||||
|
// 0xRRGGBB
|
||||||
#define LED_INIT_VALUE 0x101000
|
#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
|
// Button
|
||||||
#define SOLO_BUTTON_PORT GPIOA
|
#define SOLO_BUTTON_PORT GPIOA
|
||||||
|
@ -107,12 +107,12 @@ int main(int argc, char * argv[])
|
|||||||
|
|
||||||
memset(hidmsg,0,sizeof(hidmsg));
|
memset(hidmsg,0,sizeof(hidmsg));
|
||||||
|
|
||||||
printf1(TAG_GEN,"recv'ing hid msg \n");
|
printf1(TAG_GEN,"recv'ing hid msg \n");
|
||||||
|
|
||||||
|
|
||||||
while(1)
|
while(1)
|
||||||
{
|
{
|
||||||
if (millis() - t1 > 8)
|
if (millis() - t1 > HEARTBEAT_PERIOD)
|
||||||
{
|
{
|
||||||
bootloader_heartbeat();
|
bootloader_heartbeat();
|
||||||
t1 = millis();
|
t1 = millis();
|
||||||
|
@ -27,7 +27,20 @@ void hw_init(void);
|
|||||||
//#define TEST
|
//#define TEST
|
||||||
//#define TEST_POWER
|
//#define TEST_POWER
|
||||||
|
|
||||||
#define LED_INIT_VALUE 0x001000
|
// 0xRRGGBB
|
||||||
|
#define LED_INIT_VALUE 0x000800
|
||||||
|
#define LED_MAX_SCALER 30
|
||||||
|
#define LED_MIN_SCALER 1
|
||||||
|
// # of ms between each change in LED
|
||||||
|
#define HEARTBEAT_PERIOD 100
|
||||||
|
// 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
|
// Button
|
||||||
#define SOLO_BUTTON_PORT GPIOA
|
#define SOLO_BUTTON_PORT GPIOA
|
||||||
|
@ -149,7 +149,10 @@ void main_loop_delay()
|
|||||||
void heartbeat()
|
void heartbeat()
|
||||||
{
|
{
|
||||||
static int state = 0;
|
static int state = 0;
|
||||||
static uint32_t val = (LED_INIT_VALUE >> 8) & 0xff;
|
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;
|
||||||
int but = IS_BUTTON_PRESSED();
|
int but = IS_BUTTON_PRESSED();
|
||||||
|
|
||||||
if (state)
|
if (state)
|
||||||
@ -161,13 +164,13 @@ void heartbeat()
|
|||||||
val++;
|
val++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (val > 30 || val < 1)
|
if (val > LED_MAX_SCALER || val < LED_MIN_SCALER)
|
||||||
{
|
{
|
||||||
state = !state;
|
state = !state;
|
||||||
}
|
}
|
||||||
if (but) led_rgb(val * 2);
|
if (but) led_rgb((val*b));
|
||||||
else
|
else
|
||||||
led_rgb((val << 16) | (val*2 << 8));
|
led_rgb(((val * g)<<8) | ((val*r) << 16) | (val*b));
|
||||||
}
|
}
|
||||||
|
|
||||||
void authenticator_read_state(AuthenticatorState * a)
|
void authenticator_read_state(AuthenticatorState * a)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user