2daf65b62b
* Notification app: init * Notification app: separate message sequences * Notification app: rename notifications to notification * Notification app: rework api * Notification app: new sequences for charger * Power app: add state for better led handling * Power app: NotificationSequence type, notification led process * Blink app: use notifications * Notification app: sound and vibro notifications * Notification app: note messages * Notification app: more messages * Notification app: update note message generator * Blink app: fix state counter * Notification app: fix delay event * App sd-filesystem: notifications * App notifications: headers c++ compatibility * App notifications: Cmaj success chord sequence * App iButton: use notifications * App notification: display backlight notifications * App notification: add "display on" message to success and error sequences * App accessor: use notifications * App ibutton: guard onewire key read * Lib-RFAL: remove api_hal_light usage * App notification: add blocking mode, rework display api * Cli led command: use internal notification instead of direc access to leds. * App unit test: use notifications * App lfrfid: use notifications * Apps: close notification record * App subghz: rough use of notifications * App notificaton: ignore reset flag * App strobe: removed * Lib irda decoder: fix nec decoding * App irda: fix assert, use notifications * Apps: use notifications * Fix IRDA tests * Cli: better var naming * App notification: readable sources Co-authored-by: Albert Kharisov <albert@flipperdevices.com> Co-authored-by: あく <alleteam@gmail.com>
67 lines
1.9 KiB
C
67 lines
1.9 KiB
C
#include <stdio.h>
|
|
#include <furi.h>
|
|
#include <api-hal-irda.h>
|
|
#include <api-hal.h>
|
|
#include <notification/notification-messages.h>
|
|
|
|
#define IRDA_TIMINGS_SIZE 2000
|
|
|
|
typedef struct {
|
|
uint32_t timing_cnt;
|
|
struct {
|
|
uint8_t level;
|
|
uint32_t duration;
|
|
} timing[IRDA_TIMINGS_SIZE];
|
|
} IrdaDelaysArray;
|
|
|
|
static void irda_rx_callback(void* ctx, bool level, uint32_t duration) {
|
|
IrdaDelaysArray* delays = ctx;
|
|
|
|
if(delays->timing_cnt < IRDA_TIMINGS_SIZE) {
|
|
if(delays->timing_cnt > 1)
|
|
furi_check(level != delays->timing[delays->timing_cnt - 1].level);
|
|
delays->timing[delays->timing_cnt].level = level;
|
|
delays->timing[delays->timing_cnt].duration = duration;
|
|
delays->timing_cnt++; // Read-Modify-Write in ISR only: no need to add synchronization
|
|
}
|
|
}
|
|
|
|
int32_t irda_monitor_app(void* p) {
|
|
(void)p;
|
|
static uint32_t counter = 0;
|
|
|
|
IrdaDelaysArray* delays = furi_alloc(sizeof(IrdaDelaysArray));
|
|
NotificationApp* notification = furi_record_open("notification");
|
|
|
|
api_hal_irda_rx_irq_init();
|
|
api_hal_irda_rx_irq_set_callback(irda_rx_callback, delays);
|
|
|
|
while(1) {
|
|
delay(20);
|
|
|
|
if(counter != delays->timing_cnt) {
|
|
notification_message(notification, &sequence_blink_blue_100);
|
|
|
|
counter = delays->timing_cnt;
|
|
}
|
|
|
|
if(delays->timing_cnt >= IRDA_TIMINGS_SIZE) {
|
|
api_hal_irda_rx_irq_deinit();
|
|
printf("== IRDA MONITOR FOUND (%d) records) ==\r\n", IRDA_TIMINGS_SIZE);
|
|
printf("{");
|
|
for(int i = 0; i < IRDA_TIMINGS_SIZE; ++i) {
|
|
printf(
|
|
"%s%lu, ",
|
|
(delays->timing[i].duration > 15000) ? "\r\n" : "",
|
|
delays->timing[i].duration);
|
|
}
|
|
printf("\r\n};\r\n");
|
|
break;
|
|
}
|
|
}
|
|
|
|
free(delays);
|
|
|
|
return 0;
|
|
}
|