Implement ValueManager and ValueComposer (#183)
* Fix ValueManager implementation * Implement ValueComposer * Add constructor for ValueManager * Add value-expanders.h to flipper_v2.h set * Move COPY_COMPOSE body into a .c file * Add test for ValueManager * Add destructors for ValueMutex, ValueManager and ValueComposer * Use destructors in tests * Move composition logic into perform_compose() * Add docs for perform_compose() * Add test for ValueComposer * Replace atomic_bool with bool as g++ compiler doesn't support C11 atomics * Add Event type * Add semaphore support to the local target * Add test for Event * Update input records and relevant examples * Rename Event to AppEvent in the cc1101-workaround example * Rename Event to AppEvent in the irda example * Use Event in ValueComposer to wait for update request * Add perform_compose_internal() function * fix Event/AppEvent Co-authored-by: aanper <mail@s3f.ru>
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
#include "u8g2/u8g2.h"
|
||||
#include "fatfs/ff.h"
|
||||
#include "flipper.h"
|
||||
#include "flipper_v2.h"
|
||||
#include <stdio.h>
|
||||
|
||||
// TODO currently we have small stack, so it will be static
|
||||
@@ -26,7 +26,7 @@ typedef struct {
|
||||
AppEventType type;
|
||||
} AppEvent;
|
||||
|
||||
static void event_cb(const void* value, size_t size, void* ctx) {
|
||||
static void event_cb(const void* value, void* ctx) {
|
||||
QueueHandle_t event_queue = (QueueHandle_t)ctx;
|
||||
|
||||
AppEvent event;
|
||||
@@ -56,9 +56,13 @@ void fatfs_list(void* p) {
|
||||
furiac_exit(NULL);
|
||||
}
|
||||
|
||||
FuriRecordSubscriber* event_record =
|
||||
furi_open_deprecated("input_events", false, false, event_cb, NULL, event_queue);
|
||||
PubSub* event_record = furi_open("input_events");
|
||||
if(event_record == NULL) {
|
||||
fuprintf(furi_log, "[widget][fatfs_list] cannot open input_events record\n");
|
||||
furiac_exit(NULL);
|
||||
}
|
||||
PubSubItem* subscription = subscribe_pubsub(event_record, event_cb, event_queue);
|
||||
if(subscription == NULL) {
|
||||
fuprintf(furi_log, "[widget][fatfs_list] cannot register input_events callback\n");
|
||||
furiac_exit(NULL);
|
||||
}
|
||||
|
@@ -1,13 +1,13 @@
|
||||
#include "flipper.h"
|
||||
#include "flipper_v2.h"
|
||||
#include <stdio.h>
|
||||
|
||||
static void state_cb(const void* value, size_t size, void* ctx) {
|
||||
static void state_cb(const void* value, void* ctx) {
|
||||
const InputState* state = value;
|
||||
|
||||
printf("state: %02x\n", *state);
|
||||
}
|
||||
|
||||
static void event_cb(const void* value, size_t size, void* ctx) {
|
||||
static void event_cb(const void* value, void* ctx) {
|
||||
const InputEvent* event = value;
|
||||
|
||||
printf("event: %02x %s\n", event->input, event->state ? "pressed" : "released");
|
||||
@@ -15,10 +15,13 @@ static void event_cb(const void* value, size_t size, void* ctx) {
|
||||
|
||||
void application_input_dump(void* p) {
|
||||
// open record
|
||||
FuriRecordSubscriber* state_record =
|
||||
furi_open_deprecated("input_state", false, false, state_cb, NULL, NULL);
|
||||
FuriRecordSubscriber* event_record =
|
||||
furi_open_deprecated("input_events", false, false, event_cb, NULL, NULL);
|
||||
ValueManager* state_record = furi_open("input_state");
|
||||
assert(state_record != NULL);
|
||||
subscribe_pubsub(&state_record->pubsub, state_cb, NULL);
|
||||
|
||||
PubSub* event_record = furi_open("input_events");
|
||||
assert(event_record != NULL);
|
||||
subscribe_pubsub(event_record, event_cb, NULL);
|
||||
|
||||
for(;;) {
|
||||
delay(100);
|
||||
|
Reference in New Issue
Block a user