FL-186 Add vibro demo (#234)

* add vibro demo
* add F2 support
This commit is contained in:
coreglitch
2020-11-13 01:26:49 +06:00
committed by GitHub
parent bf2f6e89ca
commit a61eef0f99
9 changed files with 59 additions and 2 deletions

View File

@@ -0,0 +1,34 @@
#include "flipper_v2.h"
typedef struct {
GpioPin* led;
GpioPin* vibro;
} Ctx;
static void button_handler(const void* value, void* _ctx) {
const InputEvent* event = value;
Ctx* ctx = (Ctx*)_ctx;
if(event->input == InputOk) {
gpio_write(ctx->vibro, event->state);
gpio_write(ctx->led, !event->state);
}
}
void application_vibro(void* p) {
Ctx ctx = {.led = (GpioPin*)&led_gpio[1], .vibro = (GpioPin*)&vibro_gpio};
gpio_init(ctx.led, GpioModeOutputOpenDrain);
gpio_init(ctx.vibro, GpioModeOutputPushPull);
gpio_write(ctx.led, true);
gpio_write(ctx.vibro, false);
// subscribe on buttons
PubSub* event_record = furi_open("input_events");
furi_check(event_record);
subscribe_pubsub(event_record, button_handler, &ctx);
while(1) {
osDelay(osWaitForever);
}
}