2020-10-26 09:26:15 +00:00
|
|
|
#include "flipper_v2.h"
|
2020-10-15 16:15:53 +00:00
|
|
|
|
2020-10-26 09:26:15 +00:00
|
|
|
static void event_cb(const void* value, void* ctx) {
|
2020-10-15 16:15:53 +00:00
|
|
|
xSemaphoreGive((SemaphoreHandle_t*)ctx);
|
|
|
|
}
|
|
|
|
|
|
|
|
const uint32_t BACKLIGHT_TIME = 10000;
|
|
|
|
|
|
|
|
void backlight_control(void* p) {
|
2020-11-06 08:31:59 +00:00
|
|
|
// create pin
|
|
|
|
GpioPin backlight = backlight_gpio;
|
|
|
|
|
|
|
|
// TODO open record
|
|
|
|
GpioPin* backlight_record = &backlight;
|
|
|
|
|
|
|
|
// configure pin
|
|
|
|
gpio_init(backlight_record, GpioModeOutputPushPull);
|
|
|
|
gpio_write(backlight_record, true);
|
2020-10-15 16:15:53 +00:00
|
|
|
|
|
|
|
StaticSemaphore_t event_descriptor;
|
|
|
|
SemaphoreHandle_t update = xSemaphoreCreateCountingStatic(255, 0, &event_descriptor);
|
|
|
|
|
|
|
|
// open record
|
2020-10-26 09:26:15 +00:00
|
|
|
PubSub* event_record = furi_open("input_events");
|
2020-10-29 06:27:17 +00:00
|
|
|
furi_check(event_record);
|
2020-10-26 09:26:15 +00:00
|
|
|
subscribe_pubsub(event_record, event_cb, (void*)update);
|
2020-10-15 16:15:53 +00:00
|
|
|
|
|
|
|
// we ready to work
|
|
|
|
furiac_ready();
|
|
|
|
|
|
|
|
while(1) {
|
|
|
|
// wait for event
|
|
|
|
if(xSemaphoreTake(update, BACKLIGHT_TIME) == pdTRUE) {
|
2020-11-06 08:31:59 +00:00
|
|
|
gpio_write(backlight_record, true);
|
2020-10-15 16:15:53 +00:00
|
|
|
} else {
|
2020-11-06 08:31:59 +00:00
|
|
|
gpio_write(backlight_record, false);
|
2020-10-15 16:15:53 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|