Skip to content

Commit

Permalink
Aligned format for IR and pause timing
Browse files Browse the repository at this point in the history
  • Loading branch information
David Lee committed Jan 29, 2024
1 parent cdeb124 commit f8b524d
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 12 deletions.
14 changes: 7 additions & 7 deletions models/cross/xremote_cross_remote_item.c
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ static bool xremote_cross_remote_item_read_ir(CrossRemoteItem* item, FlipperForm

do {
if(!flipper_format_read_string(ff, "name", item->name)) break;
if(!flipper_format_read_int32(ff, "time", &item->time, 1)) item->time = 1000;
if(!flipper_format_read_uint32(ff, "time", &item->time, 1)) item->time = 1000;
if(!flipper_format_read_string(ff, "type", buf)) break;
if(furi_string_equal(buf, "raw")) {
if(!xremote_cross_remote_item_read_ir_signal_raw(item, ff)) break;
Expand All @@ -159,7 +159,7 @@ static bool xremote_cross_remote_item_read_pause(CrossRemoteItem* item, FlipperF

do {
if(!flipper_format_read_string(ff, "name", item->name)) break;
if(!flipper_format_read_int32(ff, "time", &item->time, 1)) break;
if(!flipper_format_read_uint32(ff, "time", &item->time, 1)) break;
success = true;
} while(false);

Expand Down Expand Up @@ -202,7 +202,7 @@ void xremote_cross_remote_item_set_name(CrossRemoteItem* item, const char* name)
furi_string_set(item->name, name);
}

void xremote_cross_remote_item_set_time(CrossRemoteItem* item, int32_t time) {
void xremote_cross_remote_item_set_time(CrossRemoteItem* item, uint32_t time) {
item->time = time;
}

Expand Down Expand Up @@ -230,11 +230,11 @@ uint32_t xremote_cross_remote_item_get_time(CrossRemoteItem* item) {
return item->time;
}

bool xremote_cross_remote_item_ir_signal_save(InfraredSignal* signal, FlipperFormat* ff, const char* name, int32_t time) {
bool xremote_cross_remote_item_ir_signal_save(InfraredSignal* signal, FlipperFormat* ff, const char* name, uint32_t time) {
if(!flipper_format_write_comment_cstr(ff, "") ||
!flipper_format_write_string_cstr(ff, "remote_type", "IR") ||
!flipper_format_write_string_cstr(ff, "name", name) ||
!flipper_format_write_int32(ff, "time", &time, 1)) {
!flipper_format_write_uint32(ff, "time", &time, 1)) {
return false;
} else if(signal->is_raw) {
return xremote_ir_signal_save_raw(&signal->payload.raw, ff);
Expand All @@ -243,11 +243,11 @@ bool xremote_cross_remote_item_ir_signal_save(InfraredSignal* signal, FlipperFor
}
}

bool xremote_cross_remote_item_pause_save(FlipperFormat* ff, int32_t time, const char* name) {
bool xremote_cross_remote_item_pause_save(FlipperFormat* ff, uint32_t time, const char* name) {
if(!flipper_format_write_comment_cstr(ff, "") ||
!flipper_format_write_string_cstr(ff, "remote_type", "PAUSE") ||
!flipper_format_write_string_cstr(ff, "name", name) ||
!flipper_format_write_int32(ff, "time", &time, 1)) {
!flipper_format_write_uint32(ff, "time", &time, 1)) {
return false;
}
return true;
Expand Down
6 changes: 3 additions & 3 deletions models/cross/xremote_cross_remote_item.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@ void xremote_cross_remote_item_set_name(CrossRemoteItem* item, const char* name)
const char* xremote_cross_remote_item_get_name(CrossRemoteItem* item);

void xremote_cross_remote_item_set_type(CrossRemoteItem* item, int type);
void xremote_cross_remote_item_set_time(CrossRemoteItem* item, int32_t time);
void xremote_cross_remote_item_set_time(CrossRemoteItem* item, uint32_t time);
uint32_t xremote_cross_remote_item_get_time(CrossRemoteItem* item);

InfraredSignal* xremote_cross_remote_item_get_ir_signal(CrossRemoteItem* item);
void xremote_cross_remote_item_set_ir_signal(CrossRemoteItem* item, InfraredSignal* signal);
SubGhzRemote* xremote_cross_remote_item_get_sg_signal(CrossRemoteItem* item);
void xremote_cross_remote_item_set_sg_signal(CrossRemoteItem* item, SubGhzRemote* subghz);

bool xremote_cross_remote_item_pause_save(FlipperFormat* ff, int32_t time, const char* name);
bool xremote_cross_remote_item_ir_signal_save(InfraredSignal* signal, FlipperFormat* ff, const char* name, int32_t time);
bool xremote_cross_remote_item_pause_save(FlipperFormat* ff, uint32_t time, const char* name);
bool xremote_cross_remote_item_ir_signal_save(InfraredSignal* signal, FlipperFormat* ff, const char* name, uint32_t time);
bool xremote_cross_remote_item_sg_signal_save(SubGhzRemote* remote, FlipperFormat* ff, const char* name);
6 changes: 5 additions & 1 deletion scenes/xremote_scene_transmit.c
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,11 @@ void xremote_scene_transmit_send_ir_signal(XRemote* app, CrossRemoteItem* item)
app->ir_worker, infrared_worker_tx_get_signal_steady_callback, app);
infrared_worker_tx_start(app->ir_worker);
app->transmitting = true;
furi_thread_flags_wait(0, FuriFlagWaitAny, app->ir_timing);
uint32_t time = app->ir_timing;
if (item->time > 0) {
time = item->time;
}
furi_thread_flags_wait(0, FuriFlagWaitAny, time);
xremote_scene_transmit_stop_ir_signal(app);
}

Expand Down
2 changes: 1 addition & 1 deletion xremote_i.h
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ struct CrossRemoteItem {
InfraredSignal* ir_signal;
SubGhzRemote* sg_signal;
int16_t type;
int32_t time;
uint32_t time;
};

typedef struct CrossRemote CrossRemote;
Expand Down

0 comments on commit f8b524d

Please sign in to comment.