Welcome to mirror list, hosted at ThFree Co, Russian Federation.

furi-hal-light.c « furi-hal « f7 « targets « firmware - github.com/ClusterM/flipperzero-firmware.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: ecf0d4f2d5b2d91e28ef18eca145a32d740b21e9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#include <furi-hal-light.h>
#include <lp5562.h>

#define TAG "FuriHalLight"

#define LED_CURRENT_RED     50
#define LED_CURRENT_GREEN   50
#define LED_CURRENT_BLUE    50
#define LED_CURRENT_WHITE   150

void furi_hal_light_init() {
    lp5562_reset();

    lp5562_set_channel_current(LP5562ChannelRed, LED_CURRENT_RED);
    lp5562_set_channel_current(LP5562ChannelGreen, LED_CURRENT_GREEN);
    lp5562_set_channel_current(LP5562ChannelBlue, LED_CURRENT_BLUE);
    lp5562_set_channel_current(LP5562ChannelWhite, LED_CURRENT_WHITE);

    lp5562_set_channel_value(LP5562ChannelRed, 0x00);
    lp5562_set_channel_value(LP5562ChannelGreen, 0x00);
    lp5562_set_channel_value(LP5562ChannelBlue, 0x00);
    lp5562_set_channel_value(LP5562ChannelWhite, 0x00);

    lp5562_enable();
    lp5562_configure();
    FURI_LOG_I(TAG, "Init OK");
}

void furi_hal_light_set(Light light, uint8_t value) {
    switch(light) {
        case LightRed:
            lp5562_set_channel_value(LP5562ChannelRed, value);
        break;
        case LightGreen:
            lp5562_set_channel_value(LP5562ChannelGreen, value);
        break;
        case LightBlue:
            lp5562_set_channel_value(LP5562ChannelBlue, value);
        break;
        case LightBacklight:
            lp5562_set_channel_value(LP5562ChannelWhite, value);
        break;
        default:
        break;
    }
}