diff --git a/Tools/xremote/.clang-format b/Tools/xremote/.clang-format new file mode 100644 index 00000000000..4b76f7fa43b --- /dev/null +++ b/Tools/xremote/.clang-format @@ -0,0 +1,191 @@ +--- +Language: Cpp +AccessModifierOffset: -4 +AlignAfterOpenBracket: AlwaysBreak +AlignArrayOfStructures: None +AlignConsecutiveMacros: None +AlignConsecutiveAssignments: None +AlignConsecutiveBitFields: None +AlignConsecutiveDeclarations: None +AlignEscapedNewlines: Left +AlignOperands: Align +AlignTrailingComments: false +AllowAllArgumentsOnNextLine: true +AllowAllParametersOfDeclarationOnNextLine: false +AllowShortEnumsOnASingleLine: true +AllowShortBlocksOnASingleLine: Never +AllowShortCaseLabelsOnASingleLine: false +AllowShortFunctionsOnASingleLine: None +AllowShortLambdasOnASingleLine: All +AllowShortIfStatementsOnASingleLine: WithoutElse +AllowShortLoopsOnASingleLine: true +AlwaysBreakAfterDefinitionReturnType: None +AlwaysBreakAfterReturnType: None +AlwaysBreakBeforeMultilineStrings: false +AlwaysBreakTemplateDeclarations: Yes +AttributeMacros: + - __capability +BinPackArguments: false +BinPackParameters: false +BraceWrapping: + AfterCaseLabel: false + AfterClass: false + AfterControlStatement: Never + AfterEnum: false + AfterFunction: false + AfterNamespace: false + AfterObjCDeclaration: false + AfterStruct: false + AfterUnion: false + AfterExternBlock: false + BeforeCatch: false + BeforeElse: false + BeforeLambdaBody: false + BeforeWhile: false + IndentBraces: false + SplitEmptyFunction: true + SplitEmptyRecord: true + SplitEmptyNamespace: true +BreakBeforeBinaryOperators: None +BreakBeforeConceptDeclarations: true +BreakBeforeBraces: Attach +BreakBeforeInheritanceComma: false +BreakInheritanceList: BeforeColon +BreakBeforeTernaryOperators: false +BreakConstructorInitializersBeforeComma: false +BreakConstructorInitializers: BeforeComma +BreakAfterJavaFieldAnnotations: false +BreakStringLiterals: false +ColumnLimit: 99 +CommentPragmas: '^ IWYU pragma:' +QualifierAlignment: Leave +CompactNamespaces: false +ConstructorInitializerIndentWidth: 4 +ContinuationIndentWidth: 4 +Cpp11BracedListStyle: true +DeriveLineEnding: true +DerivePointerAlignment: false +DisableFormat: false +EmptyLineAfterAccessModifier: Never +EmptyLineBeforeAccessModifier: LogicalBlock +ExperimentalAutoDetectBinPacking: false +PackConstructorInitializers: BinPack +BasedOnStyle: '' +ConstructorInitializerAllOnOneLineOrOnePerLine: false +AllowAllConstructorInitializersOnNextLine: true +FixNamespaceComments: false +ForEachMacros: + - foreach + - Q_FOREACH + - BOOST_FOREACH +IfMacros: + - KJ_IF_MAYBE +IncludeBlocks: Preserve +IncludeCategories: + - Regex: '.*' + Priority: 1 + SortPriority: 0 + CaseSensitive: false + - Regex: '^(<|"(gtest|gmock|isl|json)/)' + Priority: 3 + SortPriority: 0 + CaseSensitive: false + - Regex: '.*' + Priority: 1 + SortPriority: 0 + CaseSensitive: false +IncludeIsMainRegex: '(Test)?$' +IncludeIsMainSourceRegex: '' +IndentAccessModifiers: false +IndentCaseLabels: false +IndentCaseBlocks: false +IndentGotoLabels: true +IndentPPDirectives: None +IndentExternBlock: AfterExternBlock +IndentRequires: false +IndentWidth: 4 +IndentWrappedFunctionNames: true +InsertTrailingCommas: None +JavaScriptQuotes: Leave +JavaScriptWrapImports: true +KeepEmptyLinesAtTheStartOfBlocks: false +LambdaBodyIndentation: Signature +MacroBlockBegin: '' +MacroBlockEnd: '' +MaxEmptyLinesToKeep: 1 +NamespaceIndentation: None +ObjCBinPackProtocolList: Auto +ObjCBlockIndentWidth: 4 +ObjCBreakBeforeNestedBlockParam: true +ObjCSpaceAfterProperty: true +ObjCSpaceBeforeProtocolList: true +PenaltyBreakAssignment: 10 +PenaltyBreakBeforeFirstCallParameter: 30 +PenaltyBreakComment: 10 +PenaltyBreakFirstLessLess: 0 +PenaltyBreakOpenParenthesis: 0 +PenaltyBreakString: 10 +PenaltyBreakTemplateDeclaration: 10 +PenaltyExcessCharacter: 100 +PenaltyReturnTypeOnItsOwnLine: 60 +PenaltyIndentedWhitespace: 0 +PointerAlignment: Left +PPIndentWidth: -1 +ReferenceAlignment: Pointer +ReflowComments: false +RemoveBracesLLVM: false +SeparateDefinitionBlocks: Leave +ShortNamespaceLines: 1 +SortIncludes: Never +SortJavaStaticImport: Before +SortUsingDeclarations: false +SpaceAfterCStyleCast: false +SpaceAfterLogicalNot: false +SpaceAfterTemplateKeyword: true +SpaceBeforeAssignmentOperators: true +SpaceBeforeCaseColon: false +SpaceBeforeCpp11BracedList: false +SpaceBeforeCtorInitializerColon: true +SpaceBeforeInheritanceColon: true +SpaceBeforeParens: Never +SpaceBeforeParensOptions: + AfterControlStatements: false + AfterForeachMacros: false + AfterFunctionDefinitionName: false + AfterFunctionDeclarationName: false + AfterIfMacros: false + AfterOverloadedOperator: false + BeforeNonEmptyParentheses: false +SpaceAroundPointerQualifiers: Default +SpaceBeforeRangeBasedForLoopColon: true +SpaceInEmptyBlock: false +SpaceInEmptyParentheses: false +SpacesBeforeTrailingComments: 1 +SpacesInAngles: Never +SpacesInConditionalStatement: false +SpacesInContainerLiterals: false +SpacesInCStyleCastParentheses: false +SpacesInLineCommentPrefix: + Minimum: 1 + Maximum: -1 +SpacesInParentheses: false +SpacesInSquareBrackets: false +SpaceBeforeSquareBrackets: false +BitFieldColonSpacing: Both +Standard: c++03 +StatementAttributeLikeMacros: + - Q_EMIT +StatementMacros: + - Q_UNUSED + - QT_REQUIRE_VERSION +TabWidth: 4 +UseCRLF: false +UseTab: Never +WhitespaceSensitiveMacros: + - STRINGIZE + - PP_STRINGIZE + - BOOST_PP_STRINGIZE + - NS_SWIFT_NAME + - CF_SWIFT_NAME +... + diff --git a/Tools/xremote/application.fam b/Tools/xremote/application.fam index cbe57fae7e8..01a13f90239 100644 --- a/Tools/xremote/application.fam +++ b/Tools/xremote/application.fam @@ -14,5 +14,9 @@ App( fap_libs=["assets"], fap_icon="icons/xremote_10px.png", fap_icon_assets="icons", - fap_category="Tools", + fap_version="0.8", + fap_category="Infrared", + fap_author="Leedave", + fap_description="One-Click, sends multiple commands", + fap_weburl="https://github.com/leedave/Leeds-Flipper-Zero-Applications" ) \ No newline at end of file diff --git a/Tools/xremote/docs/README.md b/Tools/xremote/docs/README.md new file mode 100644 index 00000000000..f2b1e88b6aa --- /dev/null +++ b/Tools/xremote/docs/README.md @@ -0,0 +1,22 @@ +## Cross Remote + +This app combines your IR commands into a playlist that can be run with one click. Pauses can be set inbetween, as IR devices typically are not so fast. + +## Features +- Read out commands you recorded in the IR app +- Combine commands to a chain/playlist +- Add pauses inbetween commands +- Save your command chain / playlist to flipper +- Disable LED effects if not wanted + +## In Development +- Ability to also add SubGhz commands + +## What good is this? + +Example what you command chain (playlist) could do with one click +- Turn on your TV with the IR TV remote +- Turn on your Bluray player with the Blueray IR remote +- Turn on your surround sound with the speaker IR remote +- Turn on your ceiling fan using a subGhz remote +- Turn on your AC using another remote diff --git a/Tools/xremote/docs/changelog.md b/Tools/xremote/docs/changelog.md new file mode 100644 index 00000000000..915530056c4 --- /dev/null +++ b/Tools/xremote/docs/changelog.md @@ -0,0 +1,6 @@ +## v0.8 + +First release to Application Catalog +- IR Feature Working +- Pause Features Working +- Added warning for block missing SubGhz Features diff --git a/Tools/xremote/helpers/xremote_custom_event.h b/Tools/xremote/helpers/xremote_custom_event.h index a6903ea48da..07099e44180 100644 --- a/Tools/xremote/helpers/xremote_custom_event.h +++ b/Tools/xremote/helpers/xremote_custom_event.h @@ -57,7 +57,8 @@ static inline uint32_t xremote_custom_menu_event_pack(uint16_t type, int16_t val return event.packed_value; } -static inline void xremote_custom_menu_event_unpack(uint32_t packed_value, uint16_t* type, int16_t* value) { +static inline void + xremote_custom_menu_event_unpack(uint32_t packed_value, uint16_t* type, int16_t* value) { XRemoteCustomEventMenu event = {.packed_value = packed_value}; if(type) *type = event.content.type; if(value) *value = event.content.value; diff --git a/Tools/xremote/helpers/xremote_haptic.c b/Tools/xremote/helpers/xremote_haptic.c index b5f8b949e5d..8868c5d1b81 100644 --- a/Tools/xremote/helpers/xremote_haptic.c +++ b/Tools/xremote/helpers/xremote_haptic.c @@ -1,10 +1,9 @@ #include "xremote_haptic.h" #include "../xremote.h" - void xremote_play_happy_bump(void* context) { XRemote* app = context; - if (app->haptic != 1) { + if(app->haptic != 1) { return; } notification_message(app->notification, &sequence_set_vibro_on); @@ -14,7 +13,7 @@ void xremote_play_happy_bump(void* context) { void xremote_play_bad_bump(void* context) { XRemote* app = context; - if (app->haptic != 1) { + if(app->haptic != 1) { return; } notification_message(app->notification, &sequence_set_vibro_on); @@ -24,10 +23,10 @@ void xremote_play_bad_bump(void* context) { void xremote_play_long_bump(void* context) { XRemote* app = context; - if (app->haptic != 1) { + if(app->haptic != 1) { return; } - for (int i = 0; i < 4; i++) { + for(int i = 0; i < 4; i++) { notification_message(app->notification, &sequence_set_vibro_on); furi_thread_flags_wait(0, FuriFlagWaitAny, 50); notification_message(app->notification, &sequence_reset_vibro); diff --git a/Tools/xremote/helpers/xremote_haptic.h b/Tools/xremote/helpers/xremote_haptic.h index 1c8fc3e26ee..526efeb6cea 100644 --- a/Tools/xremote/helpers/xremote_haptic.h +++ b/Tools/xremote/helpers/xremote_haptic.h @@ -5,4 +5,3 @@ void xremote_play_happy_bump(void* context); void xremote_play_bad_bump(void* context); void xremote_play_long_bump(void* context); - diff --git a/Tools/xremote/helpers/xremote_led.c b/Tools/xremote/helpers/xremote_led.c index 6f46c764eff..375b149874c 100644 --- a/Tools/xremote/helpers/xremote_led.c +++ b/Tools/xremote/helpers/xremote_led.c @@ -2,7 +2,7 @@ void xremote_led_set_rgb(void* context, int red, int green, int blue) { XRemote* app = context; - if (app->led != 1) { + if(app->led != 1) { return; } NotificationMessage notification_led_message_1; @@ -23,7 +23,8 @@ void xremote_led_set_rgb(void* context, int red, int green, int blue) { NULL, }; notification_message(app->notification, ¬ification_sequence); - furi_thread_flags_wait(0, FuriFlagWaitAny, 10); //Delay, prevent removal from RAM before LED value set + furi_thread_flags_wait( + 0, FuriFlagWaitAny, 10); //Delay, prevent removal from RAM before LED value set } void xremote_led_reset(void* context) { @@ -31,6 +32,7 @@ void xremote_led_reset(void* context) { notification_message(app->notification, &sequence_reset_red); notification_message(app->notification, &sequence_reset_green); notification_message(app->notification, &sequence_reset_blue); - - furi_thread_flags_wait(0, FuriFlagWaitAny, 300); //Delay, prevent removal from RAM before LED value set + + furi_thread_flags_wait( + 0, FuriFlagWaitAny, 300); //Delay, prevent removal from RAM before LED value set } diff --git a/Tools/xremote/helpers/xremote_led.h b/Tools/xremote/helpers/xremote_led.h index 37adf3c565e..2931d411736 100644 --- a/Tools/xremote/helpers/xremote_led.h +++ b/Tools/xremote/helpers/xremote_led.h @@ -5,4 +5,3 @@ void xremote_led_set_rgb(void* context, int red, int green, int blue); void xremote_led_reset(void* context); - diff --git a/Tools/xremote/helpers/xremote_speaker.c b/Tools/xremote/helpers/xremote_speaker.c index 3515c9cd4a3..d0cd91ad8eb 100644 --- a/Tools/xremote/helpers/xremote_speaker.c +++ b/Tools/xremote/helpers/xremote_speaker.c @@ -4,19 +4,18 @@ void xremote_play_input_sound(void* context) { XRemote* app = context; - if (app->speaker != 1) { + if(app->speaker != 1) { return; } float volume = 1.0f; if(furi_hal_speaker_is_mine() || furi_hal_speaker_acquire(30)) { furi_hal_speaker_start(NOTE_INPUT, volume); } - } void xremote_stop_all_sound(void* context) { XRemote* app = context; - if (app->speaker != 1) { + if(app->speaker != 1) { return; } if(furi_hal_speaker_is_mine()) { diff --git a/Tools/xremote/helpers/xremote_storage.c b/Tools/xremote/helpers/xremote_storage.c index d0db848d14f..c6c78ed9158 100644 --- a/Tools/xremote/helpers/xremote_storage.c +++ b/Tools/xremote/helpers/xremote_storage.c @@ -1,6 +1,5 @@ #include "xremote_storage.h" - static Storage* xremote_open_storage() { return furi_record_open(RECORD_STORAGE); } @@ -10,21 +9,21 @@ static void xremote_close_storage() { } static void xremote_close_config_file(FlipperFormat* file) { - if (file == NULL) return; + if(file == NULL) return; flipper_format_file_close(file); flipper_format_free(file); } void xremote_save_settings(void* context) { XRemote* app = context; - if (app->save_settings == 0) { + if(app->save_settings == 0) { return; } FURI_LOG_D(TAG, "Saving Settings"); Storage* storage = xremote_open_storage(); FlipperFormat* fff_file = flipper_format_file_alloc(storage); - + // Overwrite wont work, so delete first if(storage_file_exists(storage, XREMOTE_SETTINGS_SAVE_PATH)) { storage_simply_remove(storage, XREMOTE_SETTINGS_SAVE_PATH); @@ -32,12 +31,11 @@ void xremote_save_settings(void* context) { // Open File, create if not exists if(!storage_common_stat(storage, XREMOTE_SETTINGS_SAVE_PATH, NULL) == FSE_OK) { - FURI_LOG_D(TAG, "Config file %s is not found. Will create new.", XREMOTE_SETTINGS_SAVE_PATH); + FURI_LOG_D( + TAG, "Config file %s is not found. Will create new.", XREMOTE_SETTINGS_SAVE_PATH); if(storage_common_stat(storage, CONFIG_FILE_DIRECTORY_PATH, NULL) == FSE_NOT_EXIST) { FURI_LOG_D( - TAG, - "Directory %s doesn't exist. Will create new.", - CONFIG_FILE_DIRECTORY_PATH); + TAG, "Directory %s doesn't exist. Will create new.", CONFIG_FILE_DIRECTORY_PATH); if(!storage_simply_mkdir(storage, CONFIG_FILE_DIRECTORY_PATH)) { FURI_LOG_E(TAG, "Error creating directory %s", CONFIG_FILE_DIRECTORY_PATH); } @@ -50,19 +48,16 @@ void xremote_save_settings(void* context) { xremote_close_storage(); return; } - + // Store Settings flipper_format_write_header_cstr( fff_file, XREMOTE_SETTINGS_HEADER, XREMOTE_SETTINGS_FILE_VERSION); - flipper_format_write_uint32( - fff_file, XREMOTE_SETTINGS_KEY_HAPTIC, &app->haptic, 1); - flipper_format_write_uint32( - fff_file, XREMOTE_SETTINGS_KEY_SPEAKER, &app->speaker, 1); - flipper_format_write_uint32( - fff_file, XREMOTE_SETTINGS_KEY_LED, &app->led, 1); + flipper_format_write_uint32(fff_file, XREMOTE_SETTINGS_KEY_HAPTIC, &app->haptic, 1); + flipper_format_write_uint32(fff_file, XREMOTE_SETTINGS_KEY_SPEAKER, &app->speaker, 1); + flipper_format_write_uint32(fff_file, XREMOTE_SETTINGS_KEY_LED, &app->led, 1); flipper_format_write_uint32( fff_file, XREMOTE_SETTINGS_KEY_SAVE_SETTINGS, &app->save_settings, 1); - + if(!flipper_format_rewind(fff_file)) { xremote_close_config_file(fff_file); FURI_LOG_E(TAG, "Rewind error"); @@ -87,7 +82,7 @@ void xremote_read_settings(void* context) { uint32_t file_version; FuriString* temp_str = furi_string_alloc(); - if (!flipper_format_file_open_existing(fff_file, XREMOTE_SETTINGS_SAVE_PATH)) { + if(!flipper_format_file_open_existing(fff_file, XREMOTE_SETTINGS_SAVE_PATH)) { FURI_LOG_E(TAG, "Cannot open file %s", XREMOTE_SETTINGS_SAVE_PATH); xremote_close_config_file(fff_file); xremote_close_storage(); @@ -111,7 +106,8 @@ void xremote_read_settings(void* context) { flipper_format_read_uint32(fff_file, XREMOTE_SETTINGS_KEY_HAPTIC, &app->haptic, 1); flipper_format_read_uint32(fff_file, XREMOTE_SETTINGS_KEY_SPEAKER, &app->speaker, 1); flipper_format_read_uint32(fff_file, XREMOTE_SETTINGS_KEY_LED, &app->led, 1); - flipper_format_read_uint32(fff_file, XREMOTE_SETTINGS_KEY_SAVE_SETTINGS, &app->save_settings, 1); + flipper_format_read_uint32( + fff_file, XREMOTE_SETTINGS_KEY_SAVE_SETTINGS, &app->save_settings, 1); flipper_format_rewind(fff_file); diff --git a/Tools/xremote/models/cross/xremote_remote.c b/Tools/xremote/models/cross/xremote_remote.c index 6d022b0d389..7d7345892e9 100644 --- a/Tools/xremote/models/cross/xremote_remote.c +++ b/Tools/xremote/models/cross/xremote_remote.c @@ -138,7 +138,6 @@ void cross_remote_rename_item(CrossRemote* remote, size_t index, const char* nam xremote_remote_item_set_name(item, name); } - bool cross_remote_load(CrossRemote* remote, FuriString* path) { Storage* storage = furi_record_open(RECORD_STORAGE); FlipperFormat* ff = flipper_format_buffered_file_alloc(storage); @@ -191,7 +190,7 @@ bool cross_remote_save_new(CrossRemote* remote, const char* name) { FuriString *new_name, *new_path; new_name = furi_string_alloc_set(name); new_path = furi_string_alloc_set(XREMOTE_APP_FOLDER); - + cross_remote_find_vacant_remote_name(new_name, furi_string_get_cstr(new_path)); furi_string_cat_printf( new_path, "/%s%s", furi_string_get_cstr(new_name), XREMOTE_APP_EXTENSION); @@ -238,15 +237,13 @@ bool cross_remote_store(CrossRemote* remote) { CrossRemoteItemArray_next(it)) { CrossRemoteItem* item = *CrossRemoteItemArray_cref(it); success = false; - if (item->type == XRemoteRemoteItemTypeInfrared) { + if(item->type == XRemoteRemoteItemTypeInfrared) { success = xremote_ir_signal_save( xremote_remote_item_get_ir_signal(item), ff, xremote_remote_item_get_name(item)); } else if(item->type == XRemoteRemoteItemTypePause) { - success = xremote_pause_save(ff, - item->time, - xremote_remote_item_get_name(item)); + success = xremote_pause_save(ff, item->time, xremote_remote_item_get_name(item)); } else if(item->type == XRemoteRemoteItemTypeSubGhz) { success = xremote_sg_signal_save( xremote_remote_item_get_sg_signal(item), diff --git a/Tools/xremote/models/cross/xremote_remote_item.c b/Tools/xremote/models/cross/xremote_remote_item.c index c9d629615b8..409c7627deb 100644 --- a/Tools/xremote/models/cross/xremote_remote_item.c +++ b/Tools/xremote/models/cross/xremote_remote_item.c @@ -1,6 +1,5 @@ #include "xremote_remote_item.h" - CrossRemoteItem* xremote_remote_item_alloc() { CrossRemoteItem* item = malloc(sizeof(CrossRemoteItem)); item->name = furi_string_alloc(); @@ -8,7 +7,7 @@ CrossRemoteItem* xremote_remote_item_alloc() { item->type = 0; item->ir_signal = xremote_ir_signal_alloc(); item->sg_signal = xremote_sg_remote_alloc(); - + return item; } @@ -92,7 +91,7 @@ bool xremote_remote_item_read_ir(CrossRemoteItem* item, FlipperFormat* ff) { buf = furi_string_alloc(); item->type = XRemoteRemoteItemTypeInfrared; item->time = 0; - + do { if(!flipper_format_read_string(ff, "name", item->name)) break; if(!flipper_format_read_string(ff, "type", buf)) break; @@ -139,7 +138,8 @@ bool xremote_remote_item_read_ir_signal_raw(CrossRemoteItem* item, FlipperFormat success = flipper_format_read_uint32(ff, "data", timings, timings_size); if(success) { - xremote_ir_signal_set_raw_signal(item->ir_signal, timings, timings_size, frequency, duty_cycle); + xremote_ir_signal_set_raw_signal( + item->ir_signal, timings, timings_size, frequency, duty_cycle); } free(timings); @@ -168,7 +168,6 @@ bool xremote_remote_item_read_message(CrossRemoteItem* item, FlipperFormat* ff) return success; } - void xremote_remote_item_free(CrossRemoteItem* item) { furi_string_free(item->name); //Determine type before free @@ -210,8 +209,8 @@ SubGhzRemote* xremote_remote_item_get_sg_signal(CrossRemoteItem* item) { } bool xremote_ir_signal_save(InfraredSignal* signal, FlipperFormat* ff, const char* name) { - if(!flipper_format_write_comment_cstr(ff, "") || - !flipper_format_write_string_cstr(ff, "remote_type", "IR") || + if(!flipper_format_write_comment_cstr(ff, "") || + !flipper_format_write_string_cstr(ff, "remote_type", "IR") || !flipper_format_write_string_cstr(ff, "name", name)) { return false; } else if(signal->is_raw) { @@ -224,16 +223,16 @@ bool xremote_ir_signal_save(InfraredSignal* signal, FlipperFormat* ff, const cha bool xremote_pause_save(FlipperFormat* ff, int32_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_string_cstr(ff, "name", name) || !flipper_format_write_int32(ff, "time", &time, 1)) { - return false; + return false; } return true; } bool xremote_sg_signal_save(SubGhzRemote* remote, FlipperFormat* ff, const char* name) { - if(!flipper_format_write_comment_cstr(ff, "") || - !flipper_format_write_string_cstr(ff, "remote_type", "SG") || + if(!flipper_format_write_comment_cstr(ff, "") || + !flipper_format_write_string_cstr(ff, "remote_type", "SG") || !flipper_format_write_string_cstr(ff, "name", name)) { return false; } diff --git a/Tools/xremote/models/cross/xremote_remote_item.h b/Tools/xremote/models/cross/xremote_remote_item.h index dca72db24e3..6e13cc68c2f 100644 --- a/Tools/xremote/models/cross/xremote_remote_item.h +++ b/Tools/xremote/models/cross/xremote_remote_item.h @@ -5,7 +5,6 @@ #include "../subghz/subghz_i.h" #include "../../xremote_i.h" - bool xremote_remote_item_read(CrossRemoteItem* item, FlipperFormat* ff); bool xremote_remote_item_read_ir(CrossRemoteItem* item, FlipperFormat* ff); bool xremote_remote_item_read_ir_signal_raw(CrossRemoteItem* item, FlipperFormat* ff); @@ -30,5 +29,3 @@ void xremote_remote_item_set_sg_signal(CrossRemoteItem* item, SubGhzRemote* subg bool xremote_pause_save(FlipperFormat* ff, int32_t time, const char* name); bool xremote_ir_signal_save(InfraredSignal* signal, FlipperFormat* ff, const char* name); bool xremote_sg_signal_save(SubGhzRemote* remote, FlipperFormat* ff, const char* name); - - diff --git a/Tools/xremote/models/infrared/xremote_ir_remote.c b/Tools/xremote/models/infrared/xremote_ir_remote.c index da2dee0c101..7e1ff724cb7 100644 --- a/Tools/xremote/models/infrared/xremote_ir_remote.c +++ b/Tools/xremote/models/infrared/xremote_ir_remote.c @@ -63,8 +63,9 @@ bool xremote_ir_remote_load(InfraredRemote* remote, FuriString* path) { for(bool can_read = true; can_read;) { InfraredRemoteButton* button = xremote_ir_remote_button_alloc(); - can_read = xremote_ir_signal_read(xremote_ir_remote_button_get_signal(button), ff, buf); - if (can_read) { + can_read = + xremote_ir_signal_read(xremote_ir_remote_button_get_signal(button), ff, buf); + if(can_read) { xremote_ir_remote_button_set_name(button, furi_string_get_cstr(buf)); InfraredButtonArray_push_back(remote->buttons, button); } else { diff --git a/Tools/xremote/models/infrared/xremote_ir_signal.h b/Tools/xremote/models/infrared/xremote_ir_signal.h index 8a3974b203e..8f3fd1fc7d0 100644 --- a/Tools/xremote/models/infrared/xremote_ir_signal.h +++ b/Tools/xremote/models/infrared/xremote_ir_signal.h @@ -25,10 +25,10 @@ bool xremote_ir_signal_is_valid(InfraredSignal* signal); void xremote_ir_signal_set_signal(InfraredSignal* signal, const InfraredSignal* other); void xremote_ir_signal_set_raw_signal( - InfraredSignal* signal, - const uint32_t* timings, - size_t timings_size, - uint32_t frequency, + InfraredSignal* signal, + const uint32_t* timings, + size_t timings_size, + uint32_t frequency, float duty_cycle); InfraredRawSignal* xremote_ir_signal_get_raw_signal(InfraredSignal* signal); diff --git a/Tools/xremote/models/subghz/subghz_i.h b/Tools/xremote/models/subghz/subghz_i.h index 5df7d67259b..61b59f778ca 100644 --- a/Tools/xremote/models/subghz/subghz_i.h +++ b/Tools/xremote/models/subghz/subghz_i.h @@ -53,5 +53,3 @@ struct SubGhzTxRx { }; typedef struct SubGhzTxRx SubGhzTxRx; - - diff --git a/Tools/xremote/models/subghz/xremote_sg_remote.c b/Tools/xremote/models/subghz/xremote_sg_remote.c index 0bc570d3ace..01b40a8ff3b 100644 --- a/Tools/xremote/models/subghz/xremote_sg_remote.c +++ b/Tools/xremote/models/subghz/xremote_sg_remote.c @@ -22,8 +22,6 @@ #define TAG "Xremote" - - struct SubGhzRemote { FuriString* name; FuriString* path; @@ -59,7 +57,7 @@ SubGhzRemote* xremote_sg_remote_alloc() { SubGhzRemote* remote = malloc(sizeof(SubGhzRemote)); remote->name = furi_string_alloc(); remote->path = furi_string_alloc(); - + // SubGhz Settings remote->setting = subghz_setting_alloc(); subghz_setting_load(remote->setting, EXT_PATH("subghz/assets/setting_user")); @@ -142,8 +140,8 @@ bool xremote_sg_remote_load(SubGhzRemote* remote, FuriString* path) { const char* fullPath = furi_string_get_cstr(path); char* fileName = strrchr(fullPath, '/') + 1; char* dotPosition = strrchr(fileName, '.'); - if (dotPosition != NULL) { // check if there is a dot in the file name - *dotPosition = '\0'; // set the dot position to NULL character to truncate the string + if(dotPosition != NULL) { // check if there is a dot in the file name + *dotPosition = '\0'; // set the dot position to NULL character to truncate the string } //remote->name = fileName; furi_string_set_str(remote->name, fileName); @@ -172,9 +170,7 @@ bool xremote_sg_remote_load(SubGhzRemote* remote, FuriString* path) { remote->setting, furi_string_get_cstr(remote->txrx->preset->name)); //load custom preset from file if(!subghz_setting_load_custom_preset( - remote->setting, - furi_string_get_cstr(remote->txrx->preset->name), - ff)) { + remote->setting, furi_string_get_cstr(remote->txrx->preset->name), ff)) { FURI_LOG_E(TAG, "Missing Custom preset"); break; } @@ -186,7 +182,10 @@ bool xremote_sg_remote_load(SubGhzRemote* remote, FuriString* path) { } if(!strcmp(furi_string_get_cstr(buf), "RAW")) { - subghz_protocol_raw_gen_fff_data(remote->txrx->fff_data, furi_string_get_cstr(path), subghz_txrx_radio_device_get_name(remote->txrx)); + subghz_protocol_raw_gen_fff_data( + remote->txrx->fff_data, + furi_string_get_cstr(path), + subghz_txrx_radio_device_get_name(remote->txrx)); } else { stream_copy_full( flipper_format_get_raw_stream(ff), diff --git a/Tools/xremote/scenes/xremote_scene_create.c b/Tools/xremote/scenes/xremote_scene_create.c index 7c22120e645..5566ad27587 100644 --- a/Tools/xremote/scenes/xremote_scene_create.c +++ b/Tools/xremote/scenes/xremote_scene_create.c @@ -9,7 +9,7 @@ typedef enum { static void xremote_create_callback(void* context, int32_t index, InputType type) { XRemote* app = context; - + uint16_t custom_type; if(type == InputTypePress) { custom_type = XRemoteCustomEventMenuSelected; @@ -22,7 +22,8 @@ static void xremote_create_callback(void* context, int32_t index, InputType type furi_crash("Unexpected Input Type"); } - view_dispatcher_send_custom_event(app->view_dispatcher, xremote_custom_menu_event_pack(custom_type, index)); + view_dispatcher_send_custom_event( + app->view_dispatcher, xremote_custom_menu_event_pack(custom_type, index)); } void xremote_scene_create_on_enter(void* context) { @@ -71,7 +72,7 @@ void xremote_scene_create_on_enter(void* context) { bool xremote_scene_create_on_event(void* context, SceneManagerEvent event) { XRemote* app = context; bool consumed = false; - + if(event.type == SceneManagerEventTypeBack) { scene_manager_next_scene(app->scene_manager, XRemoteSceneMenu); consumed = true; @@ -86,8 +87,8 @@ bool xremote_scene_create_on_event(void* context, SceneManagerEvent event) { const uint16_t custom_type = xremote_custom_menu_event_get_type(event.event); const int16_t button_index = xremote_custom_menu_event_get_value(event.event); scene_manager_set_scene_state( - app->scene_manager, XRemoteSceneCreate, (unsigned)button_index); - if (custom_type == XRemoteCustomEventMenuSelected && button_index < 0) { + app->scene_manager, XRemoteSceneCreate, (unsigned)button_index); + if(custom_type == XRemoteCustomEventMenuSelected && button_index < 0) { //scene_manager_set_scene_state( // app->scene_manager, XRemoteSceneCreate, (unsigned)button_index); if(button_index == ButtonIndexPlus) { @@ -120,7 +121,7 @@ bool xremote_scene_create_on_event(void* context, SceneManagerEvent event) { break; }*/ } - + return consumed; } diff --git a/Tools/xremote/scenes/xremote_scene_create_add.c b/Tools/xremote/scenes/xremote_scene_create_add.c index 728bf699b05..3ba71095676 100644 --- a/Tools/xremote/scenes/xremote_scene_create_add.c +++ b/Tools/xremote/scenes/xremote_scene_create_add.c @@ -10,7 +10,7 @@ typedef enum { static void xremote_create_add_callback(void* context, int32_t index, InputType type) { XRemote* app = context; - + uint16_t custom_type; if(type == InputTypePress) { custom_type = XRemoteCustomEventMenuVoid; @@ -22,7 +22,8 @@ static void xremote_create_add_callback(void* context, int32_t index, InputType furi_crash("Unexpected Input Type"); } - view_dispatcher_send_custom_event(app->view_dispatcher, xremote_custom_menu_event_pack(custom_type, index)); + view_dispatcher_send_custom_event( + app->view_dispatcher, xremote_custom_menu_event_pack(custom_type, index)); } void xremote_scene_create_add_on_enter(void* context) { @@ -66,11 +67,11 @@ void xremote_scene_create_add_on_enter(void* context) { bool xremote_scene_create_add_on_event(void* context, SceneManagerEvent event) { XRemote* app = context; bool consumed = false; - + if(event.type == SceneManagerEventTypeCustom) { const uint16_t custom_type = xremote_custom_menu_event_get_type(event.event); const int16_t button_index = xremote_custom_menu_event_get_value(event.event); - if (custom_type == XRemoteCustomEventMenuAddSelected) { + if(custom_type == XRemoteCustomEventMenuAddSelected) { furi_assert(button_index < 0); scene_manager_set_scene_state( app->scene_manager, XRemoteSceneCreate, (unsigned)button_index); @@ -87,7 +88,7 @@ bool xremote_scene_create_add_on_event(void* context, SceneManagerEvent event) { consumed = true; } } - + return consumed; } diff --git a/Tools/xremote/scenes/xremote_scene_edit_item.c b/Tools/xremote/scenes/xremote_scene_edit_item.c index 049a2f81f13..3f611f90006 100644 --- a/Tools/xremote/scenes/xremote_scene_edit_item.c +++ b/Tools/xremote/scenes/xremote_scene_edit_item.c @@ -11,26 +11,27 @@ void xremote_scene_edit_item_submenu_callback(void* context, uint32_t index) { view_dispatcher_send_custom_event(app->view_dispatcher, index); } -void xremote_scene_edit_item_on_enter(void* context) -{ +void xremote_scene_edit_item_on_enter(void* context) { XRemote* app = context; - submenu_add_item(app->editmenu, "Rename", SubmenuIndexRename, xremote_scene_edit_item_submenu_callback, app); - submenu_add_item(app->editmenu, "Delete", SubmenuIndexDelete, xremote_scene_edit_item_submenu_callback, app); + submenu_add_item( + app->editmenu, "Rename", SubmenuIndexRename, xremote_scene_edit_item_submenu_callback, app); + submenu_add_item( + app->editmenu, "Delete", SubmenuIndexDelete, xremote_scene_edit_item_submenu_callback, app); - submenu_set_selected_item(app->editmenu, scene_manager_get_scene_state(app->scene_manager, XRemoteSceneMenu)); + submenu_set_selected_item( + app->editmenu, scene_manager_get_scene_state(app->scene_manager, XRemoteSceneMenu)); view_dispatcher_switch_to_view(app->view_dispatcher, XRemoteViewIdEditItem); } -bool xremote_scene_edit_item_on_event(void* context, SceneManagerEvent event) -{ +bool xremote_scene_edit_item_on_event(void* context, SceneManagerEvent event) { XRemote* app = context; if(event.type == SceneManagerEventTypeBack) { //exit app scene_manager_previous_scene(app->scene_manager); return true; } else if(event.type == SceneManagerEventTypeCustom) { - if(event.event == SubmenuIndexDelete) { + if(event.event == SubmenuIndexDelete) { cross_remote_remove_item(app->cross_remote, app->edit_item); } else if(event.event == SubmenuIndexRename) { scene_manager_next_scene(app->scene_manager, XRemoteSceneSaveRemoteItem); @@ -42,9 +43,7 @@ bool xremote_scene_edit_item_on_event(void* context, SceneManagerEvent event) return 0; } - -void xremote_scene_edit_item_on_exit(void* context) -{ +void xremote_scene_edit_item_on_exit(void* context) { XRemote* app = context; submenu_reset(app->editmenu); } \ No newline at end of file diff --git a/Tools/xremote/scenes/xremote_scene_infoscreen.c b/Tools/xremote/scenes/xremote_scene_infoscreen.c index 881e24bbbef..b8290955fe8 100644 --- a/Tools/xremote/scenes/xremote_scene_infoscreen.c +++ b/Tools/xremote/scenes/xremote_scene_infoscreen.c @@ -11,40 +11,41 @@ void xremote_scene_infoscreen_callback(XRemoteCustomEvent event, void* context) void xremote_scene_infoscreen_on_enter(void* context) { furi_assert(context); XRemote* app = context; - xremote_infoscreen_set_callback(app->xremote_infoscreen, xremote_scene_infoscreen_callback, app); + xremote_infoscreen_set_callback( + app->xremote_infoscreen, xremote_scene_infoscreen_callback, app); view_dispatcher_switch_to_view(app->view_dispatcher, XRemoteViewIdInfoscreen); } bool xremote_scene_infoscreen_on_event(void* context, SceneManagerEvent event) { XRemote* app = context; bool consumed = false; - + if(event.type == SceneManagerEventTypeCustom) { switch(event.event) { - case XRemoteCustomEventInfoscreenLeft: - case XRemoteCustomEventInfoscreenRight: - break; - case XRemoteCustomEventInfoscreenUp: - case XRemoteCustomEventInfoscreenDown: - break; - case XRemoteCustomEventInfoscreenOk: - scene_manager_next_scene(app->scene_manager, XRemoteSceneMenu); - consumed = true; - break; - case XRemoteCustomEventInfoscreenBack: - notification_message(app->notification, &sequence_reset_red); - notification_message(app->notification, &sequence_reset_green); - notification_message(app->notification, &sequence_reset_blue); - if(!scene_manager_search_and_switch_to_previous_scene( - app->scene_manager, XRemoteSceneInfoscreen)) { - scene_manager_stop(app->scene_manager); - view_dispatcher_stop(app->view_dispatcher); - } - consumed = true; - break; + case XRemoteCustomEventInfoscreenLeft: + case XRemoteCustomEventInfoscreenRight: + break; + case XRemoteCustomEventInfoscreenUp: + case XRemoteCustomEventInfoscreenDown: + break; + case XRemoteCustomEventInfoscreenOk: + scene_manager_next_scene(app->scene_manager, XRemoteSceneMenu); + consumed = true; + break; + case XRemoteCustomEventInfoscreenBack: + notification_message(app->notification, &sequence_reset_red); + notification_message(app->notification, &sequence_reset_green); + notification_message(app->notification, &sequence_reset_blue); + if(!scene_manager_search_and_switch_to_previous_scene( + app->scene_manager, XRemoteSceneInfoscreen)) { + scene_manager_stop(app->scene_manager); + view_dispatcher_stop(app->view_dispatcher); + } + consumed = true; + break; } } - + return consumed; } diff --git a/Tools/xremote/scenes/xremote_scene_ir_list.c b/Tools/xremote/scenes/xremote_scene_ir_list.c index c1c9ffc2c80..fcb5d8ac33f 100644 --- a/Tools/xremote/scenes/xremote_scene_ir_list.c +++ b/Tools/xremote/scenes/xremote_scene_ir_list.c @@ -2,7 +2,7 @@ void xremote_scene_ir_list_on_enter(void* context) { XRemote* app = context; - + DialogsFileBrowserOptions browser_options; dialog_file_browser_set_basic_options(&browser_options, INFRARED_APP_EXTENSION, &I_ir_10px); browser_options.base_path = INFRARED_APP_FOLDER; @@ -10,8 +10,7 @@ void xremote_scene_ir_list_on_enter(void* context) { FuriString* path; path = furi_string_alloc(); furi_string_set(path, INFRARED_APP_FOLDER); - bool success = dialog_file_browser_show( - app->dialogs, app->file_path, path, &browser_options); + bool success = dialog_file_browser_show(app->dialogs, app->file_path, path, &browser_options); furi_string_free(path); if(success) { diff --git a/Tools/xremote/scenes/xremote_scene_ir_remote.c b/Tools/xremote/scenes/xremote_scene_ir_remote.c index 44ef7156f59..be822bef13f 100644 --- a/Tools/xremote/scenes/xremote_scene_ir_remote.c +++ b/Tools/xremote/scenes/xremote_scene_ir_remote.c @@ -6,7 +6,8 @@ typedef enum { ButtonIndexNA = 0, } ButtonIndex; -static void xremote_scene_ir_remote_button_menu_callback(void* context, int32_t index, InputType type) { +static void + xremote_scene_ir_remote_button_menu_callback(void* context, int32_t index, InputType type) { XRemote* app = context; uint16_t custom_type; @@ -41,7 +42,7 @@ void xremote_scene_ir_remote_on_enter(void* context) { } button_menu_set_header(button_menu, "Select Cmd"); - const int16_t button_index = + const int16_t button_index = (signed)scene_manager_get_scene_state(app->scene_manager, XRemoteViewIdIrRemote); button_menu_set_selected_item(button_menu, button_index); @@ -51,15 +52,16 @@ void xremote_scene_ir_remote_on_enter(void* context) { bool xremote_scene_ir_remote_on_event(void* context, SceneManagerEvent event) { XRemote* app = context; bool consumed = false; - + if(event.type == SceneManagerEventTypeCustom) { const uint16_t custom_type = xremote_custom_menu_event_get_type(event.event); const int16_t button_index = xremote_custom_menu_event_get_value(event.event); - if (custom_type == XRemoteCustomEventMenuAddIrSelected) { + if(custom_type == XRemoteCustomEventMenuAddIrSelected) { scene_manager_set_scene_state( app->scene_manager, XRemoteSceneIrRemote, (unsigned)button_index); - - InfraredRemoteButton* ir_button = xremote_ir_remote_get_button(app->ir_remote_buffer, button_index); + + InfraredRemoteButton* ir_button = + xremote_ir_remote_get_button(app->ir_remote_buffer, button_index); const char* button_name = xremote_ir_remote_button_get_name(ir_button); InfraredSignal* signal = xremote_ir_remote_button_get_signal(ir_button); @@ -68,7 +70,7 @@ bool xremote_scene_ir_remote_on_event(void* context, SceneManagerEvent event) { consumed = true; } } - + return consumed; } diff --git a/Tools/xremote/scenes/xremote_scene_menu.c b/Tools/xremote/scenes/xremote_scene_menu.c index 734d921943d..9c031f7224e 100644 --- a/Tools/xremote/scenes/xremote_scene_menu.c +++ b/Tools/xremote/scenes/xremote_scene_menu.c @@ -16,13 +16,31 @@ void xremote_scene_menu_submenu_callback(void* context, uint32_t index) { void xremote_scene_menu_on_enter(void* context) { XRemote* app = context; - submenu_add_item(app->submenu, "New Command Chain", SubmenuIndexCreate, xremote_scene_menu_submenu_callback, app); - submenu_add_item(app->submenu, "Run Saved Command", SubmenuIndexLoad, xremote_scene_menu_submenu_callback, app); - submenu_add_item(app->submenu, "Edit / Delete Command", SubmenuIndexEdit, xremote_scene_menu_submenu_callback, app); - submenu_add_item(app->submenu, "Settings", SubmenuIndexSettings, xremote_scene_menu_submenu_callback, app); - submenu_add_item(app->submenu, "App Info", SubmenuIndexInfoscreen, xremote_scene_menu_submenu_callback, app); + submenu_add_item( + app->submenu, + "New Command Chain", + SubmenuIndexCreate, + xremote_scene_menu_submenu_callback, + app); + submenu_add_item( + app->submenu, + "Run Saved Command", + SubmenuIndexLoad, + xremote_scene_menu_submenu_callback, + app); + submenu_add_item( + app->submenu, + "Edit / Delete Command", + SubmenuIndexEdit, + xremote_scene_menu_submenu_callback, + app); + submenu_add_item( + app->submenu, "Settings", SubmenuIndexSettings, xremote_scene_menu_submenu_callback, app); + submenu_add_item( + app->submenu, "App Info", SubmenuIndexInfoscreen, xremote_scene_menu_submenu_callback, app); - submenu_set_selected_item(app->submenu, scene_manager_get_scene_state(app->scene_manager, XRemoteSceneMenu)); + submenu_set_selected_item( + app->submenu, scene_manager_get_scene_state(app->scene_manager, XRemoteSceneMenu)); view_dispatcher_switch_to_view(app->view_dispatcher, XRemoteViewIdMenu); } @@ -40,24 +58,22 @@ bool xremote_scene_menu_on_event(void* context, SceneManagerEvent event) { app->scene_manager, XRemoteSceneMenu, SubmenuIndexCreate); scene_manager_next_scene(app->scene_manager, XRemoteSceneCreate); return true; - } else if (event.event == SubmenuIndexLoad) { - scene_manager_set_scene_state( - app->scene_manager, XRemoteSceneMenu, SubmenuIndexLoad); + } else if(event.event == SubmenuIndexLoad) { + scene_manager_set_scene_state(app->scene_manager, XRemoteSceneMenu, SubmenuIndexLoad); scene_manager_next_scene(app->scene_manager, XRemoteSceneXrList); return true; - } else if (event.event == SubmenuIndexSettings) { + } else if(event.event == SubmenuIndexSettings) { scene_manager_set_scene_state( app->scene_manager, XRemoteSceneMenu, SubmenuIndexSettings); scene_manager_next_scene(app->scene_manager, XRemoteSceneSettings); return true; - } else if (event.event == SubmenuIndexInfoscreen) { + } else if(event.event == SubmenuIndexInfoscreen) { scene_manager_set_scene_state( app->scene_manager, XRemoteSceneMenu, SubmenuIndexInfoscreen); scene_manager_next_scene(app->scene_manager, XRemoteSceneInfoscreen); return true; - } else if (event.event == SubmenuIndexEdit) { - scene_manager_set_scene_state( - app->scene_manager, XRemoteSceneMenu, SubmenuIndexEdit); + } else if(event.event == SubmenuIndexEdit) { + scene_manager_set_scene_state(app->scene_manager, XRemoteSceneMenu, SubmenuIndexEdit); scene_manager_next_scene(app->scene_manager, XRemoteSceneXrListEdit); } } diff --git a/Tools/xremote/scenes/xremote_scene_pause_set.c b/Tools/xremote/scenes/xremote_scene_pause_set.c index e34e43b2dc7..82f495140c2 100644 --- a/Tools/xremote/scenes/xremote_scene_pause_set.c +++ b/Tools/xremote/scenes/xremote_scene_pause_set.c @@ -17,38 +17,38 @@ void xremote_scene_pause_set_on_enter(void* context) { bool xremote_scene_pause_set_on_event(void* context, SceneManagerEvent event) { XRemote* app = context; bool consumed = false; - + if(event.type == SceneManagerEventTypeCustom) { switch(event.event) { - case XRemoteCustomEventInfoscreenLeft: - case XRemoteCustomEventInfoscreenRight: - break; - case XRemoteCustomEventInfoscreenUp: - case XRemoteCustomEventInfoscreenDown: - break; - case XRemoteCustomEventInfoscreenOk: - scene_manager_next_scene(app->scene_manager, XRemoteSceneMenu); - consumed = true; - break; - case XRemoteCustomEventPauseSetBack: - if(!scene_manager_search_and_switch_to_previous_scene( - app->scene_manager, XRemoteSceneCreateAdd)) { - scene_manager_stop(app->scene_manager); - view_dispatcher_stop(app->view_dispatcher); - } - consumed = true; - break; - case XRemoteCustomEventPauseSetOk: - //cross_remote_add_pause(app->cross_remote, time); - scene_manager_search_and_switch_to_previous_scene(app->scene_manager, XRemoteSceneCreate); - consumed = true; - break; + case XRemoteCustomEventInfoscreenLeft: + case XRemoteCustomEventInfoscreenRight: + break; + case XRemoteCustomEventInfoscreenUp: + case XRemoteCustomEventInfoscreenDown: + break; + case XRemoteCustomEventInfoscreenOk: + scene_manager_next_scene(app->scene_manager, XRemoteSceneMenu); + consumed = true; + break; + case XRemoteCustomEventPauseSetBack: + if(!scene_manager_search_and_switch_to_previous_scene( + app->scene_manager, XRemoteSceneCreateAdd)) { + scene_manager_stop(app->scene_manager); + view_dispatcher_stop(app->view_dispatcher); + } + consumed = true; + break; + case XRemoteCustomEventPauseSetOk: + //cross_remote_add_pause(app->cross_remote, time); + scene_manager_search_and_switch_to_previous_scene( + app->scene_manager, XRemoteSceneCreate); + consumed = true; + break; } } return consumed; } - void xremote_scene_pause_set_on_exit(void* context) { UNUSED(context); } diff --git a/Tools/xremote/scenes/xremote_scene_save_remote.c b/Tools/xremote/scenes/xremote_scene_save_remote.c index f19609e83c0..d2cef095eb4 100644 --- a/Tools/xremote/scenes/xremote_scene_save_remote.c +++ b/Tools/xremote/scenes/xremote_scene_save_remote.c @@ -20,9 +20,7 @@ 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, - cross_remote_get_name(remote)); + furi_string_get_cstr(folder_path), XREMOTE_APP_EXTENSION, cross_remote_get_name(remote)); text_input_set_validator(text_input, validator_is_file_callback, validator_is_file); furi_string_free(folder_path); @@ -43,7 +41,7 @@ bool xremote_scene_save_remote_on_event(void* context, SceneManagerEvent event) CrossRemote* remote = app->cross_remote; SceneManager* scene_manager = app->scene_manager; bool consumed = false; - + if(event.type == SceneManagerEventTypeCustom) { bool success = false; diff --git a/Tools/xremote/scenes/xremote_scene_save_remote_item.c b/Tools/xremote/scenes/xremote_scene_save_remote_item.c index 7e171c5784d..d84eb585722 100644 --- a/Tools/xremote/scenes/xremote_scene_save_remote_item.c +++ b/Tools/xremote/scenes/xremote_scene_save_remote_item.c @@ -9,7 +9,7 @@ void xremote_scene_save_remote_item_on_enter(void* context) { TextInput* text_input = app->text_input; text_input_set_header_text(text_input, "Name the Sequence"); - + size_t enter_name_length = XREMOTE_MAX_REMOTE_NAME_LENGTH; CrossRemoteItem* item = cross_remote_get_item(app->cross_remote, app->edit_item); strncpy(app->text_store[0], furi_string_get_cstr(item->name), enter_name_length); @@ -20,7 +20,7 @@ void xremote_scene_save_remote_item_on_enter(void* context) { app->text_store[0], enter_name_length, false); - + view_dispatcher_switch_to_view(app->view_dispatcher, XRemoteViewIdTextInput); } @@ -29,7 +29,7 @@ bool xremote_scene_save_remote_item_on_event(void* context, SceneManagerEvent ev CrossRemote* remote = app->cross_remote; SceneManager* scene_manager = app->scene_manager; bool consumed = false; - + if(event.type == SceneManagerEventTypeCustom) { cross_remote_rename_item(remote, app->edit_item, app->text_store[0]); scene_manager_next_scene(scene_manager, XRemoteSceneCreate); diff --git a/Tools/xremote/scenes/xremote_scene_settings.c b/Tools/xremote/scenes/xremote_scene_settings.c index 1c40fa8b22f..2b34576a495 100644 --- a/Tools/xremote/scenes/xremote_scene_settings.c +++ b/Tools/xremote/scenes/xremote_scene_settings.c @@ -43,7 +43,6 @@ const uint32_t settings_value[2] = { XRemoteSettingsOn, }; - static void xremote_scene_settings_set_haptic(VariableItem* item) { XRemote* app = variable_item_get_context(item); uint8_t index = variable_item_get_current_value_index(item); @@ -85,48 +84,32 @@ void xremote_scene_settings_on_enter(void* context) { // Vibro on/off item = variable_item_list_add( - app->variable_item_list, - "Vibro/Haptic:", - 2, - xremote_scene_settings_set_haptic, - app); + 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( - app->variable_item_list, - "Sound:", - 2, - xremote_scene_settings_set_speaker, - app); + 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); variable_item_set_current_value_text(item, speaker_text[value_index]); // LED Effects on/off item = variable_item_list_add( - app->variable_item_list, - "LED FX:", - 2, - xremote_scene_settings_set_led, - app); + app->variable_item_list, "LED FX:", 2, xremote_scene_settings_set_led, app); value_index = value_index_uint32(app->led, led_value, 2); variable_item_set_current_value_index(item, value_index); variable_item_set_current_value_text(item, led_text[value_index]); // Save Settings to File item = variable_item_list_add( - app->variable_item_list, - "Save Settings", - 2, - xremote_scene_settings_set_save_settings, - app); + app->variable_item_list, "Save Settings", 2, xremote_scene_settings_set_save_settings, app); value_index = value_index_uint32(app->save_settings, settings_value, 2); variable_item_set_current_value_index(item, value_index); variable_item_set_current_value_text(item, settings_text[value_index]); - + view_dispatcher_switch_to_view(app->view_dispatcher, XRemoteViewIdSettings); } @@ -135,7 +118,6 @@ bool xremote_scene_settings_on_event(void* context, SceneManagerEvent event) { UNUSED(app); bool consumed = false; if(event.type == SceneManagerEventTypeCustom) { - } return consumed; } diff --git a/Tools/xremote/scenes/xremote_scene_sg_list.c b/Tools/xremote/scenes/xremote_scene_sg_list.c index c525e971b9f..25eea98daaf 100644 --- a/Tools/xremote/scenes/xremote_scene_sg_list.c +++ b/Tools/xremote/scenes/xremote_scene_sg_list.c @@ -2,7 +2,7 @@ void xremote_scene_sg_list_on_enter(void* context) { XRemote* app = context; - + DialogsFileBrowserOptions browser_options; dialog_file_browser_set_basic_options(&browser_options, SUBGHZ_APP_EXTENSION, &I_sub1_10px); browser_options.base_path = SUBGHZ_APP_FOLDER; @@ -10,8 +10,7 @@ void xremote_scene_sg_list_on_enter(void* context) { FuriString* path; path = furi_string_alloc(); furi_string_set(path, SUBGHZ_APP_FOLDER); - bool success = dialog_file_browser_show( - app->dialogs, app->file_path, path, &browser_options); + bool success = dialog_file_browser_show(app->dialogs, app->file_path, path, &browser_options); furi_string_free(path); if(success) { diff --git a/Tools/xremote/scenes/xremote_scene_transmit.c b/Tools/xremote/scenes/xremote_scene_transmit.c index 630d29fae97..51823a60d8e 100644 --- a/Tools/xremote/scenes/xremote_scene_transmit.c +++ b/Tools/xremote/scenes/xremote_scene_transmit.c @@ -24,13 +24,13 @@ void xremote_transmit_callback(XRemoteCustomEvent event, void* context) { } void xremote_scene_ir_notification_message(XRemote* app, uint32_t message) { - if (app->led == 1) { + if(app->led == 1) { notification_message(app->notification, xremote_notification_sequences[message]); } } bool xremote_scene_ir_signal_is_raw(InfraredSignal* signal) { - if (signal->is_raw) { + if(signal->is_raw) { return true; } return false; @@ -50,9 +50,10 @@ void xremote_scene_transmit_send_ir_signal(XRemote* app, CrossRemoteItem* item) InfraredSignal* signal = xremote_remote_item_get_ir_signal(item); dolphin_deed(DolphinDeedIrSend); xremote_scene_ir_notification_message(app, InfraredNotificationMessageBlinkStartSend); - if (xremote_scene_ir_signal_is_raw(signal)) { + if(xremote_scene_ir_signal_is_raw(signal)) { InfraredRawSignal* raw = xremote_ir_signal_get_raw_signal(signal); - infrared_worker_set_raw_signal(app->ir_worker, raw->timings, raw->timings_size, raw->frequency, raw->duty_cycle); + infrared_worker_set_raw_signal( + app->ir_worker, raw->timings, raw->timings_size, raw->frequency, raw->duty_cycle); } else { InfraredMessage* message = xremote_ir_signal_get_message(signal); infrared_worker_set_decoded_signal(app->ir_worker, message); @@ -60,7 +61,7 @@ void xremote_scene_transmit_send_ir_signal(XRemote* app, CrossRemoteItem* item) infrared_worker_tx_set_get_signal_callback( app->ir_worker, infrared_worker_tx_get_signal_steady_callback, app); infrared_worker_tx_start(app->ir_worker); - app->transmitting = true; + app->transmitting = true; furi_thread_flags_wait(0, FuriFlagWaitAny, 1000); xremote_scene_transmit_stop_ir_signal(app); } @@ -77,7 +78,7 @@ void xremote_scene_transmit_send_subghz(XRemote* app, CrossRemoteItem* item) { UNUSED(item); app->transmitting = true; xremote_scene_ir_notification_message(app, SubGhzNotificationMessageBlinkStartSend); - // ADD SEND METHOD HERE + // ADD SEND METHOD HERE furi_thread_flags_wait(0, FuriFlagWaitAny, 2000); //Remove later app->transmitting = false; xremote_scene_ir_notification_message(app, SubGhzNotificationMessageBlinkStop); @@ -91,12 +92,12 @@ void xremote_scene_transmit_send_signal(void* context, CrossRemoteItem* item) { if(app->transmitting) { return; } - + xremote_transmit_model_set_name(app->xremote_transmit, xremote_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); - } else if(item->type == XRemoteRemoteItemTypePause) { + } else if(item->type == XRemoteRemoteItemTypePause) { xremote_scene_transmit_send_pause(app, item); } else if(item->type == XRemoteRemoteItemTypeSubGhz) { xremote_scene_transmit_send_subghz(app, item); @@ -112,7 +113,7 @@ void xremote_scene_transmit_run_remote(void* context) { size_t item_count = cross_remote_get_item_count(remote); for(size_t i = 0; i < item_count;) { - if (cross_remote_get_transmitting(remote) == XRemoteTransmittingIdle) { + if(cross_remote_get_transmitting(remote) == XRemoteTransmittingIdle) { cross_remote_set_transmitting(remote, XRemoteTransmittingStart); CrossRemoteItem* item = cross_remote_get_item(remote, i); xremote_scene_transmit_send_signal(app, item); @@ -121,7 +122,7 @@ void xremote_scene_transmit_run_remote(void* context) { } else if(cross_remote_get_transmitting(remote) == XRemoteTransmittingStop) { i++; cross_remote_set_transmitting(remote, XRemoteTransmittingIdle); - } + } } xremote_scene_ir_notification_message(app, InfraredNotificationMessageBlinkStop); @@ -134,7 +135,7 @@ void xremote_scene_transmit_on_enter(void* context) { furi_assert(context); XRemote* app = context; xremote_transmit_set_callback(app->xremote_transmit, xremote_transmit_callback, app); - + view_dispatcher_switch_to_view(app->view_dispatcher, XRemoteViewIdTransmit); xremote_scene_transmit_run_remote(app); } diff --git a/Tools/xremote/scenes/xremote_scene_wip.c b/Tools/xremote/scenes/xremote_scene_wip.c index 3dce925e349..3ac6bf1d7ab 100644 --- a/Tools/xremote/scenes/xremote_scene_wip.c +++ b/Tools/xremote/scenes/xremote_scene_wip.c @@ -4,9 +4,9 @@ void xremote_scene_wip_on_enter(void* context) { furi_assert(context); XRemote* app = context; Popup* popup = app->popup; - + //popup_set_icon(popup, 0, 2, &I_DolphinMafia_115x62); - popup_set_header(popup, "Work in Progress", 10, 19, AlignLeft, AlignBottom); + popup_set_header(popup, "SubGhz coming soon", 10, 19, AlignLeft, AlignBottom); popup_set_text(popup, "Check back later", 10, 29, AlignLeft, AlignBottom); popup_set_text(popup, "Press back long", 10, 39, AlignLeft, AlignBottom); @@ -22,14 +22,13 @@ bool xremote_scene_wip_on_event(void* context, SceneManagerEvent event) { XRemote* app = context; UNUSED(app); bool consumed = false; - - if(event.type == SceneManagerEventTypeCustom) { - if (event.event == XRemoteCustomEventTypePopupClosed) { + if(event.type == SceneManagerEventTypeCustom) { + if(event.event == XRemoteCustomEventTypePopupClosed) { } consumed = true; } - + return consumed; } diff --git a/Tools/xremote/scenes/xremote_scene_xr_list.c b/Tools/xremote/scenes/xremote_scene_xr_list.c index c174d11d291..887ab7a25bc 100644 --- a/Tools/xremote/scenes/xremote_scene_xr_list.c +++ b/Tools/xremote/scenes/xremote_scene_xr_list.c @@ -2,7 +2,7 @@ void xremote_scene_xr_list_on_enter(void* context) { XRemote* app = context; - + DialogsFileBrowserOptions browser_options; dialog_file_browser_set_basic_options(&browser_options, XREMOTE_APP_EXTENSION, &I_xr_10px); browser_options.base_path = XREMOTE_APP_FOLDER; @@ -13,7 +13,10 @@ void xremote_scene_xr_list_on_enter(void* context) { bool success = dialog_file_browser_show( //app->dialogs, app->file_path, app->file_path, &browser_options); - app->dialogs, app->file_path, path, &browser_options); + app->dialogs, + app->file_path, + path, + &browser_options); furi_string_free(path); if(success) { diff --git a/Tools/xremote/scenes/xremote_scene_xr_list_edit.c b/Tools/xremote/scenes/xremote_scene_xr_list_edit.c index de7e31d6169..747a1801273 100644 --- a/Tools/xremote/scenes/xremote_scene_xr_list_edit.c +++ b/Tools/xremote/scenes/xremote_scene_xr_list_edit.c @@ -2,7 +2,7 @@ void xremote_scene_xr_list_edit_on_enter(void* context) { XRemote* app = context; - + DialogsFileBrowserOptions browser_options; dialog_file_browser_set_basic_options(&browser_options, XREMOTE_APP_EXTENSION, &I_xr_10px); browser_options.base_path = XREMOTE_APP_FOLDER; @@ -11,8 +11,7 @@ void xremote_scene_xr_list_edit_on_enter(void* context) { path = furi_string_alloc(); furi_string_set(path, XREMOTE_APP_FOLDER); - bool success = dialog_file_browser_show( - app->dialogs, app->file_path, path, &browser_options); + bool success = dialog_file_browser_show(app->dialogs, app->file_path, path, &browser_options); furi_string_free(path); if(success) { diff --git a/Tools/xremote/scenes/xremote_scene_xr_list_edit_item.c b/Tools/xremote/scenes/xremote_scene_xr_list_edit_item.c index 625d39d9c6b..f1c089fa86d 100644 --- a/Tools/xremote/scenes/xremote_scene_xr_list_edit_item.c +++ b/Tools/xremote/scenes/xremote_scene_xr_list_edit_item.c @@ -14,10 +14,21 @@ void xremote_scene_xr_list_edit_item_submenu_callback(void* context, uint32_t in void xremote_scene_xr_list_edit_item_on_enter(void* context) { XRemote* app = context; //submenu_add_item(app->editmenu, "Rename", SubmenuIndexRename, xremote_scene_xr_list_edit_item_submenu_callback, app); - submenu_add_item(app->editmenu, "Edit", SubmenuIndexEdit, xremote_scene_xr_list_edit_item_submenu_callback, app); - submenu_add_item(app->editmenu, "Delete", SubmenuIndexDelete, xremote_scene_xr_list_edit_item_submenu_callback, app); + submenu_add_item( + app->editmenu, + "Edit", + SubmenuIndexEdit, + xremote_scene_xr_list_edit_item_submenu_callback, + app); + submenu_add_item( + app->editmenu, + "Delete", + SubmenuIndexDelete, + xremote_scene_xr_list_edit_item_submenu_callback, + app); - submenu_set_selected_item(app->editmenu, scene_manager_get_scene_state(app->scene_manager, XRemoteSceneMenu)); + submenu_set_selected_item( + app->editmenu, scene_manager_get_scene_state(app->scene_manager, XRemoteSceneMenu)); view_dispatcher_switch_to_view(app->view_dispatcher, XRemoteViewIdEditItem); } @@ -29,10 +40,13 @@ bool xremote_scene_xr_list_edit_item_on_event(void* context, SceneManagerEvent e scene_manager_previous_scene(app->scene_manager); return true; } else if(event.type == SceneManagerEventTypeCustom) { - if(event.event == SubmenuIndexDelete) { + if(event.event == SubmenuIndexDelete) { cross_remote_delete(app->cross_remote); } else if(event.event == SubmenuIndexEdit) { - strncpy(app->text_store[0], cross_remote_get_name(app->cross_remote), XREMOTE_MAX_REMOTE_NAME_LENGTH); + strncpy( + app->text_store[0], + cross_remote_get_name(app->cross_remote), + XREMOTE_MAX_REMOTE_NAME_LENGTH); scene_manager_next_scene(app->scene_manager, XRemoteSceneCreate); return 0; } else if(event.event == SubmenuIndexRename) { diff --git a/Tools/xremote/screenshots/xremote_1.png b/Tools/xremote/screenshots/xremote_1.png new file mode 100644 index 00000000000..138e9304137 Binary files /dev/null and b/Tools/xremote/screenshots/xremote_1.png differ diff --git a/Tools/xremote/screenshots/xremote_2.png b/Tools/xremote/screenshots/xremote_2.png new file mode 100644 index 00000000000..b8a2d0ecc0b Binary files /dev/null and b/Tools/xremote/screenshots/xremote_2.png differ diff --git a/Tools/xremote/screenshots/xremote_3.png b/Tools/xremote/screenshots/xremote_3.png new file mode 100644 index 00000000000..86209609e8d Binary files /dev/null and b/Tools/xremote/screenshots/xremote_3.png differ diff --git a/Tools/xremote/screenshots/xremote_4.png b/Tools/xremote/screenshots/xremote_4.png new file mode 100644 index 00000000000..0b4d5177761 Binary files /dev/null and b/Tools/xremote/screenshots/xremote_4.png differ diff --git a/Tools/xremote/screenshots/xremote_5.png b/Tools/xremote/screenshots/xremote_5.png new file mode 100644 index 00000000000..58c07ea4db0 Binary files /dev/null and b/Tools/xremote/screenshots/xremote_5.png differ diff --git a/Tools/xremote/screenshots/xremote_6.png b/Tools/xremote/screenshots/xremote_6.png new file mode 100644 index 00000000000..f4f01be6ed8 Binary files /dev/null and b/Tools/xremote/screenshots/xremote_6.png differ diff --git a/Tools/xremote/views/xremote_infoscreen.c b/Tools/xremote/views/xremote_infoscreen.c index 5ae0b9a856b..92477e1c033 100644 --- a/Tools/xremote/views/xremote_infoscreen.c +++ b/Tools/xremote/views/xremote_infoscreen.c @@ -7,7 +7,6 @@ struct XRemoteInfoscreen { void* context; }; - typedef struct { int some_value; } XRemoteInfoscreenModel; @@ -27,11 +26,11 @@ void xremote_infoscreen_draw(Canvas* canvas, XRemoteInfoscreenModel* model) { canvas_clear(canvas); canvas_set_color(canvas, ColorBlack); canvas_set_font(canvas, FontPrimary); - canvas_draw_str_aligned(canvas, 64, 10, AlignCenter, AlignTop, "Cross Remote"); + canvas_draw_str_aligned(canvas, 64, 10, AlignCenter, AlignTop, "Cross Remote"); canvas_set_font(canvas, FontSecondary); - canvas_draw_str_aligned(canvas, 64, 22, AlignCenter, AlignTop, "Chain IR and SubGhz"); + canvas_draw_str_aligned(canvas, 64, 22, AlignCenter, AlignTop, "Chain IR and SubGhz"); canvas_draw_str_aligned(canvas, 64, 32, AlignCenter, AlignTop, "Commands"); - elements_button_center(canvas, "Back"); + elements_button_center(canvas, "Back"); } static void xremote_infoscreen_model_init(XRemoteInfoscreenModel* const model) { @@ -39,36 +38,36 @@ static void xremote_infoscreen_model_init(XRemoteInfoscreenModel* const model) { } bool xremote_infoscreen_input(InputEvent* event, void* context) { - furi_assert(context); + furi_assert(context); XRemoteInfoscreen* instance = context; - if (event->type == InputTypeRelease) { + if(event->type == InputTypeRelease) { switch(event->key) { - case InputKeyBack: - with_view_model( - instance->view, - XRemoteInfoscreenModel * model, - { - UNUSED(model); - instance->callback(XRemoteCustomEventInfoscreenBack, instance->context); - }, - true); - break; - case InputKeyLeft: - case InputKeyRight: - case InputKeyUp: - case InputKeyDown: - case InputKeyOk: - with_view_model( - instance->view, - XRemoteInfoscreenModel* model, - { - UNUSED(model); - instance->callback(XRemoteCustomEventInfoscreenOk, instance->context); - }, - true); - break; - case InputKeyMAX: - break; + case InputKeyBack: + with_view_model( + instance->view, + XRemoteInfoscreenModel * model, + { + UNUSED(model); + instance->callback(XRemoteCustomEventInfoscreenBack, instance->context); + }, + true); + break; + case InputKeyLeft: + case InputKeyRight: + case InputKeyUp: + case InputKeyDown: + case InputKeyOk: + with_view_model( + instance->view, + XRemoteInfoscreenModel * model, + { + UNUSED(model); + instance->callback(XRemoteCustomEventInfoscreenOk, instance->context); + }, + true); + break; + case InputKeyMAX: + break; } } return true; @@ -84,11 +83,8 @@ void xremote_infoscreen_enter(void* context) { with_view_model( instance->view, XRemoteInfoscreenModel * model, - { - xremote_infoscreen_model_init(model); - }, - true - ); + { xremote_infoscreen_model_init(model); }, + true); } XRemoteInfoscreen* xremote_infoscreen_alloc() { @@ -104,12 +100,9 @@ XRemoteInfoscreen* xremote_infoscreen_alloc() { with_view_model( instance->view, XRemoteInfoscreenModel * model, - { - xremote_infoscreen_model_init(model); - }, - true - ); - + { xremote_infoscreen_model_init(model); }, + true); + return instance; } @@ -117,12 +110,7 @@ void xremote_infoscreen_free(XRemoteInfoscreen* instance) { furi_assert(instance); with_view_model( - instance->view, - XRemoteInfoscreenModel * model, - { - UNUSED(model); - }, - true); + instance->view, XRemoteInfoscreenModel * model, { UNUSED(model); }, true); view_free(instance->view); free(instance); } @@ -131,4 +119,3 @@ View* xremote_infoscreen_get_view(XRemoteInfoscreen* instance) { furi_assert(instance); return instance->view; } - diff --git a/Tools/xremote/views/xremote_pause_set.c b/Tools/xremote/views/xremote_pause_set.c index cfd77157a22..cc0d9e3fcd8 100644 --- a/Tools/xremote/views/xremote_pause_set.c +++ b/Tools/xremote/views/xremote_pause_set.c @@ -33,64 +33,63 @@ void xremote_pause_set_draw(Canvas* canvas, XRemotePauseSetModel* model) { canvas_clear(canvas); canvas_set_color(canvas, ColorBlack); canvas_set_font(canvas, FontPrimary); - canvas_draw_str_aligned(canvas, 64, 10, AlignCenter, AlignTop, "Pause duration"); + canvas_draw_str_aligned(canvas, 64, 10, AlignCenter, AlignTop, "Pause duration"); canvas_set_font(canvas, FontSecondary); canvas_draw_icon(canvas, 59, 22, &I_ButtonUp_10x5); canvas_draw_icon(canvas, 59, 42, &I_ButtonDown_10x5); - canvas_draw_str_aligned(canvas, 64, 31, AlignCenter, AlignTop, seconds); - elements_button_center(canvas, "Add"); + canvas_draw_str_aligned(canvas, 64, 31, AlignCenter, AlignTop, seconds); + elements_button_center(canvas, "Add"); } bool xremote_pause_set_input(InputEvent* event, void* context) { furi_assert(context); XRemotePauseSet* instance = context; - if (event->type == InputTypeRelease) { + if(event->type == InputTypeRelease) { switch(event->key) { - case InputKeyBack: - instance->callback(XRemoteCustomEventPauseSetBack, instance->context); - break; - case InputKeyLeft: - case InputKeyRight: - break; - case InputKeyUp: - with_view_model( - instance->view, - XRemotePauseSetModel* model, - { - model->time++; - if (model->time > 9) { - model->time = 0; - } - }, - true); - break; - case InputKeyDown: - with_view_model( - instance->view, - XRemotePauseSetModel* model, - { - model->time--; - if (model->time < 0) { - model->time = 9; - } - }, - true); - break; - case InputKeyOk: - with_view_model( - instance->view, - XRemotePauseSetModel * model, - { - XRemote* app = instance->context; - cross_remote_add_pause(app->cross_remote, model->time); - }, - true - ); + case InputKeyBack: + instance->callback(XRemoteCustomEventPauseSetBack, instance->context); + break; + case InputKeyLeft: + case InputKeyRight: + break; + case InputKeyUp: + with_view_model( + instance->view, + XRemotePauseSetModel * model, + { + model->time++; + if(model->time > 9) { + model->time = 0; + } + }, + true); + break; + case InputKeyDown: + with_view_model( + instance->view, + XRemotePauseSetModel * model, + { + model->time--; + if(model->time < 0) { + model->time = 9; + } + }, + true); + break; + case InputKeyOk: + with_view_model( + instance->view, + XRemotePauseSetModel * model, + { + XRemote* app = instance->context; + cross_remote_add_pause(app->cross_remote, model->time); + }, + true); - instance->callback(XRemoteCustomEventPauseSetOk, instance->context); - break; - case InputKeyMAX: - break; + instance->callback(XRemoteCustomEventPauseSetOk, instance->context); + break; + case InputKeyMAX: + break; } } return true; @@ -104,30 +103,24 @@ XRemotePauseSet* xremote_pause_set_alloc() { view_set_draw_callback(instance->view, (ViewDrawCallback)xremote_pause_set_draw); view_set_enter_callback(instance->view, xremote_pause_set_enter); view_set_input_callback(instance->view, xremote_pause_set_input); - + with_view_model( instance->view, XRemotePauseSetModel * model, - { - xremote_pause_set_model_init(model); - }, - true - ); + { xremote_pause_set_model_init(model); }, + true); return instance; } void xremote_pause_set_enter(void* context) { furi_assert(context); - XRemotePauseSet* instance = (XRemotePauseSet*) context; + XRemotePauseSet* instance = (XRemotePauseSet*)context; with_view_model( instance->view, XRemotePauseSetModel * model, - { - xremote_pause_set_model_init(model); - }, - true - ); + { xremote_pause_set_model_init(model); }, + true); } View* xremote_pause_set_get_view(XRemotePauseSet* instance) { diff --git a/Tools/xremote/views/xremote_transmit.c b/Tools/xremote/views/xremote_transmit.c index db153681664..c627248ba89 100644 --- a/Tools/xremote/views/xremote_transmit.c +++ b/Tools/xremote/views/xremote_transmit.c @@ -48,11 +48,11 @@ void xremote_transmit_draw_ir(Canvas* canvas, XRemoteTransmitModel* model) { canvas_set_color(canvas, ColorBlack); canvas_draw_icon(canvas, 0, 0, &I_ir_transmit_128x64); canvas_set_font(canvas, FontPrimary); - canvas_draw_str_aligned(canvas, 74, 5, AlignLeft, AlignTop, "Sending"); + canvas_draw_str_aligned(canvas, 74, 5, AlignLeft, AlignTop, "Sending"); canvas_set_font(canvas, FontSecondary); - canvas_draw_str_aligned(canvas, 74, 20, AlignLeft, AlignTop, "Infrared"); + canvas_draw_str_aligned(canvas, 74, 20, AlignLeft, AlignTop, "Infrared"); canvas_draw_str_aligned(canvas, 74, 30, AlignLeft, AlignTop, model->name); - + char temp_str[18]; snprintf(temp_str, 18, "%u", model->time); canvas_draw_str_aligned(canvas, 74, 40, AlignLeft, AlignTop, temp_str); @@ -64,11 +64,11 @@ void xremote_transmit_draw_pause(Canvas* canvas, XRemoteTransmitModel* model) { canvas_set_color(canvas, ColorBlack); canvas_draw_icon(canvas, 0, 0, &I_pause_128x64); canvas_set_font(canvas, FontPrimary); - canvas_draw_str_aligned(canvas, 74, 5, AlignLeft, AlignTop, "Waiting"); + canvas_draw_str_aligned(canvas, 74, 5, AlignLeft, AlignTop, "Waiting"); canvas_set_font(canvas, FontSecondary); - canvas_draw_str_aligned(canvas, 74, 20, AlignLeft, AlignTop, "Sequence"); + canvas_draw_str_aligned(canvas, 74, 20, AlignLeft, AlignTop, "Sequence"); canvas_draw_str_aligned(canvas, 74, 30, AlignLeft, AlignTop, model->name); - + char temp_str[18]; snprintf(temp_str, 18, "%u", model->time); canvas_draw_str_aligned(canvas, 74, 40, AlignLeft, AlignTop, temp_str); @@ -80,11 +80,11 @@ void xremote_transmit_draw_subghz(Canvas* canvas, XRemoteTransmitModel* model) { canvas_set_color(canvas, ColorBlack); canvas_draw_icon(canvas, 0, 0, &I_sg_transmit_128x64); canvas_set_font(canvas, FontPrimary); - canvas_draw_str_aligned(canvas, 74, 5, AlignLeft, AlignTop, "Sending"); + canvas_draw_str_aligned(canvas, 74, 5, AlignLeft, AlignTop, "Sending"); canvas_set_font(canvas, FontSecondary); - canvas_draw_str_aligned(canvas, 74, 20, AlignLeft, AlignTop, "SubGhz"); + canvas_draw_str_aligned(canvas, 74, 20, AlignLeft, AlignTop, "SubGhz"); canvas_draw_str_aligned(canvas, 74, 30, AlignLeft, AlignTop, model->name); - + char temp_str[18]; snprintf(temp_str, 18, "%u", model->time); canvas_draw_str_aligned(canvas, 74, 40, AlignLeft, AlignTop, temp_str); @@ -109,38 +109,27 @@ XRemoteTransmit* xremote_transmit_alloc() { with_view_model( instance->view, XRemoteTransmitModel * model, - { - xremote_transmit_model_init(model); - }, - true - ); + { xremote_transmit_model_init(model); }, + true); return instance; } void xremote_transmit_enter(void* context) { furi_assert(context); - XRemoteTransmit* instance = (XRemoteTransmit*) context; + XRemoteTransmit* instance = (XRemoteTransmit*)context; with_view_model( instance->view, XRemoteTransmitModel * model, - { - xremote_transmit_model_init(model); - }, - true - ); + { xremote_transmit_model_init(model); }, + true); } void xremote_transmit_free(XRemoteTransmit* instance) { furi_assert(instance); with_view_model( - instance->view, - XRemoteTransmitModel * model, - { - UNUSED(model); - }, - true); + instance->view, XRemoteTransmitModel * model, { UNUSED(model); }, true); view_free(instance->view); free(instance); } diff --git a/Tools/xremote/xremote.c b/Tools/xremote/xremote.c index c273aab32d4..511c4b31d11 100644 --- a/Tools/xremote/xremote.c +++ b/Tools/xremote/xremote.c @@ -23,7 +23,7 @@ XRemote* xremote_app_alloc() { XRemote* app = malloc(sizeof(XRemote)); app->gui = furi_record_open(RECORD_GUI); app->notification = furi_record_open(RECORD_NOTIFICATION); - + //Turn backlight on, believe me this makes testing your app easier notification_message(app->notification, &sequence_display_backlight_on); @@ -33,8 +33,10 @@ XRemote* xremote_app_alloc() { app->scene_manager = scene_manager_alloc(&xremote_scene_handlers, app); view_dispatcher_set_event_callback_context(app->view_dispatcher, app); - view_dispatcher_set_navigation_event_callback(app->view_dispatcher, xremote_navigation_event_callback); - view_dispatcher_set_tick_event_callback(app->view_dispatcher, xremote_tick_event_callback, 100); + view_dispatcher_set_navigation_event_callback( + app->view_dispatcher, xremote_navigation_event_callback); + view_dispatcher_set_tick_event_callback( + app->view_dispatcher, xremote_tick_event_callback, 100); view_dispatcher_set_custom_event_callback(app->view_dispatcher, xremote_custom_event_callback); app->submenu = submenu_alloc(); app->editmenu = submenu_alloc(); @@ -57,29 +59,49 @@ XRemote* xremote_app_alloc() { app->cross_remote = cross_remote_alloc(); app->sg_remote_buffer = xremote_sg_remote_alloc(); - + app->loading = loading_alloc(); app->text_input = text_input_alloc(); - view_dispatcher_add_view(app->view_dispatcher, XRemoteViewIdTextInput, text_input_get_view(app->text_input)); + view_dispatcher_add_view( + app->view_dispatcher, XRemoteViewIdTextInput, text_input_get_view(app->text_input)); - view_dispatcher_add_view(app->view_dispatcher, XRemoteViewIdMenu, submenu_get_view(app->submenu)); - view_dispatcher_add_view(app->view_dispatcher, XRemoteViewIdEditItem, submenu_get_view(app->editmenu)); + view_dispatcher_add_view( + app->view_dispatcher, XRemoteViewIdMenu, submenu_get_view(app->submenu)); + view_dispatcher_add_view( + app->view_dispatcher, XRemoteViewIdEditItem, submenu_get_view(app->editmenu)); app->xremote_infoscreen = xremote_infoscreen_alloc(); - view_dispatcher_add_view(app->view_dispatcher, XRemoteViewIdInfoscreen, xremote_infoscreen_get_view(app->xremote_infoscreen)); + view_dispatcher_add_view( + app->view_dispatcher, + XRemoteViewIdInfoscreen, + xremote_infoscreen_get_view(app->xremote_infoscreen)); app->xremote_transmit = xremote_transmit_alloc(); - view_dispatcher_add_view(app->view_dispatcher, XRemoteViewIdTransmit, xremote_transmit_get_view(app->xremote_transmit)); + view_dispatcher_add_view( + app->view_dispatcher, + XRemoteViewIdTransmit, + xremote_transmit_get_view(app->xremote_transmit)); app->xremote_pause_set = xremote_pause_set_alloc(); - view_dispatcher_add_view(app->view_dispatcher, XRemoteViewIdPauseSet, xremote_pause_set_get_view(app->xremote_pause_set)); + view_dispatcher_add_view( + app->view_dispatcher, + XRemoteViewIdPauseSet, + xremote_pause_set_get_view(app->xremote_pause_set)); app->button_menu_create = button_menu_alloc(); - view_dispatcher_add_view(app->view_dispatcher, XRemoteViewIdCreate, button_menu_get_view(app->button_menu_create)); + view_dispatcher_add_view( + app->view_dispatcher, XRemoteViewIdCreate, button_menu_get_view(app->button_menu_create)); app->button_menu_create_add = button_menu_alloc(); - view_dispatcher_add_view(app->view_dispatcher, XRemoteViewIdCreateAdd, button_menu_get_view(app->button_menu_create_add)); + view_dispatcher_add_view( + app->view_dispatcher, + XRemoteViewIdCreateAdd, + button_menu_get_view(app->button_menu_create_add)); app->button_menu_ir = button_menu_alloc(); - view_dispatcher_add_view(app->view_dispatcher, XRemoteViewIdIrRemote, button_menu_get_view(app->button_menu_ir)); + view_dispatcher_add_view( + app->view_dispatcher, XRemoteViewIdIrRemote, button_menu_get_view(app->button_menu_ir)); app->variable_item_list = variable_item_list_alloc(); - view_dispatcher_add_view(app->view_dispatcher, XRemoteViewIdSettings, variable_item_list_get_view(app->variable_item_list)); - + view_dispatcher_add_view( + app->view_dispatcher, + XRemoteViewIdSettings, + variable_item_list_get_view(app->variable_item_list)); + app->popup = popup_alloc(); view_dispatcher_add_view(app->view_dispatcher, XRemoteViewIdWip, popup_get_view(app->popup)); app->view_stack = view_stack_alloc(); @@ -109,7 +131,7 @@ void xremote_show_loading_popup(XRemote* app, bool show) { void xremote_app_free(XRemote* app) { furi_assert(app); - + // Scene manager scene_manager_free(app->scene_manager); @@ -135,7 +157,7 @@ void xremote_app_free(XRemote* app) { view_dispatcher_free(app->view_dispatcher); furi_record_close(RECORD_GUI); - + app->gui = NULL; app->notification = NULL; @@ -146,8 +168,7 @@ void xremote_app_free(XRemote* app) { void xremote_popup_closed_callback(void* context) { furi_assert(context); XRemote* app = context; - view_dispatcher_send_custom_event( - app->view_dispatcher, XRemoteCustomEventTypePopupClosed); + view_dispatcher_send_custom_event(app->view_dispatcher, XRemoteCustomEventTypePopupClosed); } void xremote_text_input_callback(void* context) { @@ -159,23 +180,21 @@ void xremote_text_input_callback(void* context) { int32_t xremote_app(void* p) { UNUSED(p); XRemote* app = xremote_app_alloc(); - + view_dispatcher_attach_to_gui(app->view_dispatcher, app->gui, ViewDispatcherTypeFullscreen); - + //scene_manager_next_scene(app->scene_manager, XRemoteSceneInfoscreen); //Start with start screen - scene_manager_next_scene(app->scene_manager, XRemoteSceneMenu); //if you want to directly start with Menu + scene_manager_next_scene( + app->scene_manager, XRemoteSceneMenu); //if you want to directly start with Menu furi_hal_power_suppress_charge_enter(); view_dispatcher_run(app->view_dispatcher); xremote_save_settings(app); - + furi_hal_power_suppress_charge_exit(); xremote_app_free(app); return 0; } - - - diff --git a/Tools/xremote/xremote.h b/Tools/xremote/xremote.h index cbe61e36748..7895fa4529a 100644 --- a/Tools/xremote/xremote.h +++ b/Tools/xremote/xremote.h @@ -33,7 +33,7 @@ typedef struct { InfraredWorker* ir_worker; SubGhzRemote* sg_remote_buffer; CrossRemote* cross_remote; - uint32_t haptic; + uint32_t haptic; uint32_t speaker; uint32_t led; uint32_t save_settings;