@@ -32,6 +32,7 @@ void lf_rfid_workaround(void* p);
|
||||
void nfc_task(void* p);
|
||||
void irukagotchi_task(void* p);
|
||||
void power_task(void* p);
|
||||
void application_vibro(void* p);
|
||||
|
||||
const FlipperStartupApp FLIPPER_STARTUP[] = {
|
||||
#ifdef APP_DISPLAY
|
||||
@@ -138,4 +139,8 @@ const FlipperStartupApp FLIPPER_APPS[] = {
|
||||
#ifdef BUILD_SPEAKER_DEMO
|
||||
{.app = coreglitch_demo_0, .name = "coreglitch_demo_0", .libs = {0}},
|
||||
#endif
|
||||
|
||||
#ifdef BUILD_VIBRO_DEMO
|
||||
{.app = application_vibro, .name = "application_vibro", .libs = {1, FURI_LIB{"input_task"}}},
|
||||
#endif
|
||||
};
|
@@ -19,6 +19,7 @@ BUILD_EXAMPLE_INPUT_DUMP = 1
|
||||
BUILD_CC1101 = 1
|
||||
BUILD_LF_RFID = 1
|
||||
BUILD_SPEAKER_DEMO = 1
|
||||
BUILD_VIBRO_DEMO = 1
|
||||
endif
|
||||
|
||||
APP_NFC ?= 0
|
||||
@@ -204,6 +205,13 @@ APP_INPUT = 1
|
||||
APP_GUI = 1
|
||||
endif
|
||||
|
||||
BUILD_VIBRO_DEMO ?= 0
|
||||
ifeq ($(BUILD_VIBRO_DEMO), 1)
|
||||
CFLAGS += -DBUILD_VIBRO_DEMO
|
||||
C_SOURCES += $(wildcard $(APP_DIR)/examples/vibro.c)
|
||||
APP_INPUT = 1
|
||||
endif
|
||||
|
||||
# device drivers
|
||||
|
||||
APP_GUI ?= 0
|
||||
|
34
applications/examples/vibro.c
Normal file
34
applications/examples/vibro.c
Normal 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);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user