Skip to content

Commit

Permalink
Linting
Browse files Browse the repository at this point in the history
  • Loading branch information
David Lee committed Jan 30, 2024
1 parent b64e36d commit 32041e2
Show file tree
Hide file tree
Showing 9 changed files with 53 additions and 34 deletions.
1 change: 0 additions & 1 deletion helpers/subghz/subghz.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ void subghz_scene_transmit_callback_end_tx(void* context) {
view_dispatcher_send_custom_event(
app->view_dispatcher, XRemoteCustomEventViewTransmitterSendStop);


//app->state_notifications = SubGhzNotificationStateIDLE;
//subghz_txrx_stop(app->subghz->txrx);
//app->transmitting = false;
Expand Down
10 changes: 7 additions & 3 deletions models/cross/xremote_cross_remote.c
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,11 @@ const char* xremote_cross_remote_get_name(CrossRemote* remote) {
return furi_string_get_cstr(remote->name);
}

bool xremote_cross_remote_add_ir_item(CrossRemote* remote, const char* name, InfraredSignal* signal, uint32_t timing) {
bool xremote_cross_remote_add_ir_item(
CrossRemote* remote,
const char* name,
InfraredSignal* signal,
uint32_t timing) {
CrossRemoteItem* item = xremote_cross_remote_item_alloc();
xremote_cross_remote_item_set_type(item, XRemoteRemoteItemTypeInfrared);
xremote_cross_remote_item_set_name(item, name);
Expand Down Expand Up @@ -213,7 +217,8 @@ static bool xremote_cross_remote_store(CrossRemote* remote) {
xremote_cross_remote_item_get_name(item),
xremote_cross_remote_item_get_time(item));
} else if(item->type == XRemoteRemoteItemTypePause) {
success = xremote_cross_remote_item_pause_save(ff, item->time, xremote_cross_remote_item_get_name(item));
success = xremote_cross_remote_item_pause_save(
ff, item->time, xremote_cross_remote_item_get_name(item));
} else if(item->type == XRemoteRemoteItemTypeSubGhz) {
success = xremote_cross_remote_item_sg_signal_save(
xremote_cross_remote_item_get_sg_signal(item),
Expand Down Expand Up @@ -264,4 +269,3 @@ bool xremote_cross_remote_delete(CrossRemote* remote) {
xremote_cross_remote_reset(remote);
return (status == FSE_OK || status == FSE_NOT_EXIST);
}

6 changes: 5 additions & 1 deletion models/cross/xremote_cross_remote.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,11 @@ const char* xremote_cross_remote_get_name(CrossRemote* remote);
void xremote_cross_remote_set_transmitting(CrossRemote* remote, int status);
int xremote_cross_remote_get_transmitting(CrossRemote* remote);
bool xremote_cross_remote_add_pause(CrossRemote* remote, int time);
bool xremote_cross_remote_add_ir_item(CrossRemote* remote, const char* name, InfraredSignal* signal, uint32_t timing);
bool xremote_cross_remote_add_ir_item(
CrossRemote* remote,
const char* name,
InfraredSignal* signal,
uint32_t timing);
bool xremote_cross_remote_add_subghz(CrossRemote* remote, SubGhzRemote* subghz);
void xremote_cross_remote_remove_item(CrossRemote* remote, size_t index);
void xremote_cross_remote_rename_item(CrossRemote* remote, size_t index, const char* name);
Expand Down
17 changes: 13 additions & 4 deletions models/cross/xremote_cross_remote_item.c
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,8 @@ static bool xremote_cross_remote_item_read_sg(CrossRemoteItem* item, FlipperForm
return success;
}

static bool xremote_cross_remote_item_read_ir_signal_raw(CrossRemoteItem* item, FlipperFormat* ff) {
static bool
xremote_cross_remote_item_read_ir_signal_raw(CrossRemoteItem* item, FlipperFormat* ff) {
uint32_t timings_size, frequency;
float duty_cycle;

Expand Down Expand Up @@ -243,10 +244,14 @@ 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, uint32_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_string_cstr(ff, "name", name) ||
!flipper_format_write_uint32(ff, "time", &time, 1)) {
return false;
} else if(signal->is_raw) {
Expand All @@ -266,7 +271,11 @@ bool xremote_cross_remote_item_pause_save(FlipperFormat* ff, uint32_t time, cons
return true;
}

bool xremote_cross_remote_item_sg_signal_save(SubGhzRemote* remote, FlipperFormat* ff, const char* name, const char* filename) {
bool xremote_cross_remote_item_sg_signal_save(
SubGhzRemote* remote,
FlipperFormat* ff,
const char* name,
const char* filename) {
if(!flipper_format_write_comment_cstr(ff, "") ||
!flipper_format_write_string_cstr(ff, "remote_type", "SG") ||
!flipper_format_write_string_cstr(ff, "name", name) ||
Expand Down
12 changes: 10 additions & 2 deletions models/cross/xremote_cross_remote_item.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,13 @@ 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, 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, const char* filename);
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,
const char* filename);
3 changes: 2 additions & 1 deletion scenes/xremote_scene_ir_remote.c
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,8 @@ bool xremote_scene_ir_remote_on_event(void* context, SceneManagerEvent event) {
const char* button_name = xremote_ir_remote_button_get_name(ir_button);
InfraredSignal* signal = xremote_ir_remote_button_get_signal(ir_button);

xremote_cross_remote_add_ir_item(app->cross_remote, button_name, signal, app->ir_timing);
xremote_cross_remote_add_ir_item(
app->cross_remote, button_name, signal, app->ir_timing);
scene_manager_next_scene(app->scene_manager, XRemoteSceneCreate);
consumed = true;
}
Expand Down
4 changes: 3 additions & 1 deletion scenes/xremote_scene_save_remote.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@ void xremote_scene_save_remote_on_enter(void* context) {
//A lot missing here

ValidatorIsFile* validator_is_file = validator_is_file_alloc_init(
furi_string_get_cstr(folder_path), XREMOTE_APP_EXTENSION, xremote_cross_remote_get_name(remote));
furi_string_get_cstr(folder_path),
XREMOTE_APP_EXTENSION,
xremote_cross_remote_get_name(remote));
text_input_set_validator(text_input, validator_is_file_callback, validator_is_file);

furi_string_free(folder_path);
Expand Down
4 changes: 2 additions & 2 deletions scenes/xremote_scene_settings.c
Original file line number Diff line number Diff line change
Expand Up @@ -92,14 +92,14 @@ void xremote_scene_settings_on_enter(void* context) {
uint8_t value_index;

// Vibro on/off
/* item = variable_item_list_add(
/* item = variable_item_list_add(
app->variable_item_list, "Vibro/Haptic:", 2, xremote_scene_settings_set_haptic, app);
value_index = value_index_uint32(app->haptic, haptic_value, 2);
variable_item_set_current_value_index(item, value_index);
variable_item_set_current_value_text(item, haptic_text[value_index]);*/

// Sound on/off
/* item = variable_item_list_add(
/* item = variable_item_list_add(
app->variable_item_list, "Sound:", 2, xremote_scene_settings_set_speaker, app);
value_index = value_index_uint32(app->speaker, speaker_value, 2);
variable_item_set_current_value_index(item, value_index);
Expand Down
30 changes: 11 additions & 19 deletions scenes/xremote_scene_transmit.c
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ void xremote_scene_transmit_send_ir_signal(XRemote* app, CrossRemoteItem* item)
infrared_worker_tx_start(app->ir_worker);
app->transmitting = true;
uint32_t time = app->ir_timing;
if (item->time > 0) {
if(item->time > 0) {
time = item->time;
}
furi_thread_flags_wait(0, FuriFlagWaitAny, time);
Expand All @@ -82,12 +82,12 @@ void xremote_scene_transmit_send_pause(XRemote* app, CrossRemoteItem* item) {
void xremote_scene_transmit_send_subghz(XRemote* app, CrossRemoteItem* item) {
app->transmitting = true;
xremote_scene_ir_notification_message(app, SubGhzNotificationMessageBlinkStartSend);
if (furi_string_utf8_length(item->filename) < 3) {
if(furi_string_utf8_length(item->filename) < 3) {
xremote_cross_remote_set_transmitting(app->cross_remote, XRemoteTransmittingStop);
app->transmitting = false;
return;
}
subghz_send(app, furi_string_get_cstr(item->filename));
subghz_send(app, furi_string_get_cstr(item->filename));
//furi_thread_flags_wait(0, FuriFlagWaitAny, 2000);
}

Expand All @@ -100,7 +100,8 @@ void xremote_scene_transmit_send_signal(void* context, CrossRemoteItem* item) {
return;
}

xremote_transmit_model_set_name(app->xremote_transmit, xremote_cross_remote_item_get_name(item));
xremote_transmit_model_set_name(
app->xremote_transmit, xremote_cross_remote_item_get_name(item));
xremote_transmit_model_set_type(app->xremote_transmit, item->type);
if(item->type == XRemoteRemoteItemTypeInfrared) {
xremote_scene_transmit_send_ir_signal(app, item);
Expand Down Expand Up @@ -160,33 +161,24 @@ bool xremote_scene_transmit_on_event(void* context, SceneManagerEvent event) {
if(event.type == SceneManagerEventTypeCustom) {
FURI_LOG_D(TAG, "Custom Event");
switch(event.event) {
case XRemoteCustomEventViewTransmitterSendStop:
FURI_LOG_D("SUBGHZ", "stop event"); // doesn't trigger
//app->stop_transmit = true;
/*app->state_notifications = SubGhzNotificationStateIDLE;
app->transmitting = false;
subghz_txrx_stop(app->subghz->txrx);
xremote_scene_ir_notification_message(app, SubGhzNotificationMessageBlinkStop);
xremote_cross_remote_set_transmitting(app->cross_remote, XRemoteTransmittingStop);*/
break;
default:
break;
case XRemoteCustomEventViewTransmitterSendStop:
FURI_LOG_D("SUBGHZ", "stop event"); // doesn't trigger
break;
default:
break;
}
} else if(event.type == SceneManagerEventTypeTick) {
FURI_LOG_D(TAG, "Tick Event");
if (app->state_notifications == SubGhzNotificationStateTx && app->led == 1) {
if(app->state_notifications == SubGhzNotificationStateTx && app->led == 1) {
//blink for subghz
}
}


return consumed;
}

void xremote_scene_transmit_on_exit(void* context) {
XRemote* app = context;
app->transmitting = false;
app->state_notifications = SubGhzNotificationStateIDLE;
//subghz_txrx_stop(app->subghz->txrx);
//xremote_cross_remote_set_transmitting(remote, XRemoteTransmittingIdle);
}

0 comments on commit 32041e2

Please sign in to comment.