Example #1
0
static void applyLedGpsLayer(bool updateNow, uint32_t *timer)
{
    static uint8_t gpsFlashCounter = 0;
    static uint8_t gpsPauseCounter = 0;
    const uint8_t blinkPauseLength = 4;

    if (updateNow) {
        if (gpsPauseCounter > 0) {
            gpsPauseCounter--;
        } else if (gpsFlashCounter >= GPS_numSat) {
            gpsFlashCounter = 0;
            gpsPauseCounter = blinkPauseLength;
        } else {
            gpsFlashCounter++;
            gpsPauseCounter = 1;
        }
        *timer += LED_STRIP_HZ(2.5);
    }

    const hsvColor_t *gpsColor;

    if (GPS_numSat == 0 || !sensors(SENSOR_GPS)) {
        gpsColor = getSC(LED_SCOLOR_GPSNOSATS);
    } else {
        bool colorOn = gpsPauseCounter == 0;  // each interval starts with pause
        if (STATE(GPS_FIX)) {
            gpsColor = colorOn ? getSC(LED_SCOLOR_GPSLOCKED) : getSC(LED_SCOLOR_BACKGROUND);
        } else {
            gpsColor = colorOn ? getSC(LED_SCOLOR_GPSNOLOCK) : getSC(LED_SCOLOR_GPSNOSATS);
        }
    }

    applyLedHsv(LED_MOV_FUNCTION(LED_FUNCTION_GPS), gpsColor);
}
Example #2
0
static void applyLedRssiLayer(bool updateNow, uint32_t *timer)
{
    static bool flash = false;

    int state;
    int timeOffset = 0;

    if (updateNow) {
       state = (rssi * 100) / 1023;

       if (state > 50) {
           flash = false;
           timeOffset = 1;
       } else if (state > 20) {
           timeOffset = 2;
       } else {
           timeOffset = 8;
       }
       flash = !flash;
    }


    *timer += LED_STRIP_HZ(timeOffset);

    if (!flash) {
       hsvColor_t *bgc = getSC(LED_SCOLOR_BACKGROUND);
       applyLedHsv(LED_MOV_FUNCTION(LED_FUNCTION_RSSI), bgc);
    }
}
Example #3
0
static void applyLedRssiLayer(bool updateNow, timeUs_t *timer)
{
    static bool flash = false;

    int timerDelay = HZ_TO_US(1);

    if (updateNow) {
        int state = (rssi * 100) / 1023;

        if (state > 50) {
            flash = true;
            timerDelay = HZ_TO_US(1);
        } else if (state > 20) {
            flash = !flash;
            timerDelay = HZ_TO_US(2);
        } else {
            flash = !flash;
            timerDelay = HZ_TO_US(8);
        }
    }

    *timer += timerDelay;

    if (!flash) {
        const hsvColor_t *bgc = getSC(LED_SCOLOR_BACKGROUND);
        applyLedHsv(LED_MOV_FUNCTION(LED_FUNCTION_RSSI), bgc);
    }
}
Example #4
0
static void applyLedBatteryLayer(bool updateNow, uint32_t *timer)
{
    static bool flash = false;

    int state;
    int timeOffset = 1;

    if (updateNow) {
       state = getBatteryState();

       switch (state) {
           case BATTERY_OK:
               flash = false;
               timeOffset = 1;
               break;
           case BATTERY_WARNING:
               timeOffset = 2;
               break;
           default:
               timeOffset = 8;
               break;
       }
       flash = !flash;
    }

    *timer += LED_STRIP_HZ(timeOffset);

    if (!flash) {
       hsvColor_t *bgc = getSC(LED_SCOLOR_BACKGROUND);
       applyLedHsv(LED_MOV_FUNCTION(LED_FUNCTION_BATTERY), bgc);
    }
}
Example #5
0
static void applyLedBatteryLayer(bool updateNow, timeUs_t *timer)
{
    static bool flash = false;

    int timerDelayUs = HZ_TO_US(1);

    if (updateNow) {

        switch (getBatteryState()) {
            case BATTERY_OK:
                flash = true;
                timerDelayUs = HZ_TO_US(1);

                break;
            case BATTERY_WARNING:
                flash = !flash;
                timerDelayUs = HZ_TO_US(2);

                break;
            default:
                flash = !flash;
                timerDelayUs = HZ_TO_US(8);

                break;
        }
    }

    *timer += timerDelayUs;

    if (!flash) {
       const hsvColor_t *bgc = getSC(LED_SCOLOR_BACKGROUND);
       applyLedHsv(LED_MOV_FUNCTION(LED_FUNCTION_BATTERY), bgc);
    }
}