Skip to content

Commit

Permalink
Dimm lights during the night
Browse files Browse the repository at this point in the history
  • Loading branch information
mrbig committed Jun 3, 2016
1 parent a21fa53 commit a6c095e
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions alertled.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include <EventManager.h>
#include <Ticker.h>
#include "alertled_anim.h"
#include "gps.h"

// Alert levels
#define ALERT_NONE -1
Expand Down Expand Up @@ -33,6 +34,7 @@ class AlertLED {
*/
static void tickCallback() {
ALED_CFG anim;
float mult = GPS::isNight() ? 0.05 : 1;

if (alertStatus == ALERT_NONE) {
if (!animPtr) return;
Expand All @@ -46,8 +48,8 @@ class AlertLED {
if (animPtr >= sizeof(anim_warning[alertStatus])/sizeof(ALED_CFG)) animPtr = 0;

memcpy_P(&anim, &anim_warning[alertStatus][animPtr], sizeof(ALED_CFG));
analogWrite(CFG_LED_ALERT1, anim.lft);
analogWrite(CFG_LED_ALERT2, anim.rgt);
analogWrite(CFG_LED_ALERT1, (anim.lft - 1023) * mult + 1023);
analogWrite(CFG_LED_ALERT2, (anim.rgt - 1023) * mult + 1023);
analogWrite(CFG_BEEPER, anim.beeper);

animPtr++;
Expand Down

0 comments on commit a6c095e

Please sign in to comment.