mirror of
https://github.com/DarkFlippers/unleashed-firmware.git
synced 2025-12-12 20:49:49 +04:00
some improvement and cleanup
This commit is contained in:
@@ -6,69 +6,17 @@ typedef enum {
|
|||||||
// SubRemCustomEventManagerSetRAW,
|
// SubRemCustomEventManagerSetRAW,
|
||||||
|
|
||||||
//SubmenuIndex
|
//SubmenuIndex
|
||||||
SubmenuIndexOpenMapFile,
|
SubmenuIndexSubRemOpenMapFile,
|
||||||
SubmenuIndexOpenView, // TODO: temp debug
|
SubmenuIndexSubRemRemoteView, // TODO: temp debug
|
||||||
|
SubmenuIndexSubRemAbout,
|
||||||
|
|
||||||
//SubRemCustomEvent
|
//SubRemCustomEvent
|
||||||
SubRemCustomEventViewRemoteBack = 100,
|
SubRemCustomEventViewRemoteStartUP = 100,
|
||||||
SubRemCustomEventViewRemoteStartUP,
|
|
||||||
SubRemCustomEventViewRemoteStartDOWN,
|
SubRemCustomEventViewRemoteStartDOWN,
|
||||||
SubRemCustomEventViewRemoteStartLEFT,
|
SubRemCustomEventViewRemoteStartLEFT,
|
||||||
SubRemCustomEventViewRemoteStartRIGHT,
|
SubRemCustomEventViewRemoteStartRIGHT,
|
||||||
SubRemCustomEventViewRemoteStartOK,
|
SubRemCustomEventViewRemoteStartOK,
|
||||||
|
SubRemCustomEventViewRemoteBack,
|
||||||
SubRemCustomEventViewRemoteStop,
|
SubRemCustomEventViewRemoteStop,
|
||||||
|
SubRemCustomEventViewRemoteForcedStop,
|
||||||
// SubRemCustomEventSceneDeleteSuccess = 100,
|
|
||||||
// SubRemCustomEventSceneDelete,
|
|
||||||
// SubRemCustomEventSceneDeleteRAW,
|
|
||||||
// SubRemCustomEventSceneDeleteRAWBack,
|
|
||||||
|
|
||||||
// SubRemCustomEventSceneReceiverInfoTxStart,
|
|
||||||
// SubRemCustomEventSceneReceiverInfoTxStop,
|
|
||||||
// SubRemCustomEventSceneReceiverInfoSave,
|
|
||||||
// SubRemCustomEventSceneSaveName,
|
|
||||||
// SubRemCustomEventSceneSaveSuccess,
|
|
||||||
// SubRemCustomEventSceneShowErrorBack,
|
|
||||||
// SubRemCustomEventSceneShowErrorOk,
|
|
||||||
// SubRemCustomEventSceneShowErrorSub,
|
|
||||||
// SubRemCustomEventSceneShowOnlyRX,
|
|
||||||
// SubRemCustomEventSceneAnalyzerLock,
|
|
||||||
// SubRemCustomEventSceneAnalyzerUnlock,
|
|
||||||
// SubRemCustomEventSceneSettingLock,
|
|
||||||
|
|
||||||
// SubRemCustomEventSceneExit,
|
|
||||||
// SubRemCustomEventSceneStay,
|
|
||||||
|
|
||||||
// SubRemCustomEventSceneRpcLoad,
|
|
||||||
// SubRemCustomEventSceneRpcButtonPress,
|
|
||||||
// SubRemCustomEventSceneRpcButtonRelease,
|
|
||||||
// SubRemCustomEventSceneRpcSessionClose,
|
|
||||||
|
|
||||||
// SubRemCustomEventViewReceiverOK,
|
|
||||||
// SubRemCustomEventViewReceiverConfig,
|
|
||||||
// SubRemCustomEventViewReceiverBack,
|
|
||||||
// SubRemCustomEventViewReceiverOffDisplay,
|
|
||||||
// SubRemCustomEventViewReceiverUnlock,
|
|
||||||
// SubRemCustomEventViewReceiverDeleteItem,
|
|
||||||
|
|
||||||
// SubRemCustomEventViewReadRAWBack,
|
|
||||||
// SubRemCustomEventViewReadRAWIDLE,
|
|
||||||
// SubRemCustomEventViewReadRAWREC,
|
|
||||||
// SubRemCustomEventViewReadRAWConfig,
|
|
||||||
// SubRemCustomEventViewReadRAWErase,
|
|
||||||
// SubRemCustomEventViewReadRAWSendStart,
|
|
||||||
// SubRemCustomEventViewReadRAWSendStop,
|
|
||||||
// SubRemCustomEventViewReadRAWSave,
|
|
||||||
// SubRemCustomEventViewReadRAWTXRXStop,
|
|
||||||
// SubRemCustomEventViewReadRAWMore,
|
|
||||||
|
|
||||||
// SubRemCustomEventViewTransmitterBack,
|
|
||||||
// SubRemCustomEventViewTransmitterSendStart,
|
|
||||||
// SubRemCustomEventViewTransmitterSendStop,
|
|
||||||
// SubRemCustomEventViewTransmitterError,
|
|
||||||
|
|
||||||
// SubRemCustomEventViewFreqAnalOkShort,
|
|
||||||
// SubRemCustomEventViewFreqAnalOkLong,
|
|
||||||
|
|
||||||
// SubRemCustomEventByteInputDone,
|
|
||||||
} SubRemCustomEvent;
|
} SubRemCustomEvent;
|
||||||
@@ -2,50 +2,39 @@
|
|||||||
|
|
||||||
#include <furi.h>
|
#include <furi.h>
|
||||||
#include <furi_hal.h>
|
#include <furi_hal.h>
|
||||||
/*
|
|
||||||
#define AVR_ISP_VERSION_APP "0.1"
|
|
||||||
#define AVR_ISP_DEVELOPED "SkorP"
|
|
||||||
#define AVR_ISP_GITHUB "https://github.com/flipperdevices/flipperzero-firmware"
|
|
||||||
|
|
||||||
#define AVR_ISP_APP_FILE_VERSION 1
|
// #define SUBREM_APP_APP_FILE_VERSION 1
|
||||||
#define AVR_ISP_APP_FILE_TYPE "Flipper Dump AVR"
|
// #define SUBREM_APP_APP_FILE_TYPE "Flipper SubRem Map file"
|
||||||
#define AVR_ISP_APP_EXTENSION ".avr"
|
#define SUBREM_APP_EXTENSION ".txt"
|
||||||
*/
|
|
||||||
|
typedef enum {
|
||||||
// TODO: rename Filepath
|
SubRemSubKeyNameUp = (0U),
|
||||||
//#define SUBREMOTEMAP_FOLDER "/ext/subghz_remote"
|
SubRemSubKeyNameDown,
|
||||||
#define SUBGHZ_REMOTE_APP_EXTENSION ".txt"
|
SubRemSubKeyNameLeft,
|
||||||
#define SUBGHZ_REMOTE_APP_PATH_PREFIX "/ext/subghz_remote"
|
SubRemSubKeyNameRight,
|
||||||
|
SubRemSubKeyNameOk,
|
||||||
|
SubRemSubKeyNameMaxCount,
|
||||||
|
} SubRemSubKeyName;
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
//SubRemViewVariableItemList,
|
|
||||||
SubRemViewSubmenu,
|
SubRemViewSubmenu,
|
||||||
//SubRemViewProgrammer,
|
|
||||||
//SubRemViewReader,
|
|
||||||
//SubRemViewWriter,
|
|
||||||
SubRemViewWidget,
|
SubRemViewWidget,
|
||||||
SubRemViewPopup,
|
SubRemViewPopup,
|
||||||
SubRemViewTextInput,
|
SubRemViewTextInput,
|
||||||
SubRemViewIDRemote,
|
SubRemViewIDRemote,
|
||||||
//SubRemViewChipDetect,
|
|
||||||
} SubRemViewID;
|
} SubRemViewID;
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
// Loadin State
|
// Loadin State
|
||||||
SubRemSubKeyTypeNoData = 0,
|
SubRemSubKeyTypeNoData = 0,
|
||||||
SubRemSubKeyTypeHaveFileName,
|
// SubRemSubKeyTypeHaveFileName,
|
||||||
|
|
||||||
// Key Type
|
// Key Type
|
||||||
SubRemSubKeyTypeStaticKey = 100,
|
SubRemSubKeyTypeStaticKey = 100,
|
||||||
SubRemSubKeyTypeDynamicKey,
|
SubRemSubKeyTypeDynamicKey,
|
||||||
SubRemSubKeyTypeRawKey,
|
SubRemSubKeyTypeRawKey,
|
||||||
} SubRemSubKeyType;
|
} SubRemSubKeyType; // TODO: depricated
|
||||||
|
|
||||||
/*
|
// typedef enum {
|
||||||
typedef enum {
|
//
|
||||||
SubRemErrorNoError,
|
// } SubRemLoadMapState;
|
||||||
SubRemErrorReading,
|
|
||||||
SubRemErrorWriting,
|
|
||||||
SubRemErrorVerification,
|
|
||||||
SubRemErrorWritingFuse,
|
|
||||||
} SubRemError;*/
|
|
||||||
@@ -4,14 +4,9 @@ void subrem_scene_openmapfile_on_enter(void* context) {
|
|||||||
SubGhzRemoteApp* app = context;
|
SubGhzRemoteApp* app = context;
|
||||||
|
|
||||||
if(subrem_load_from_file(app)) {
|
if(subrem_load_from_file(app)) {
|
||||||
// if(subghz_get_load_type_file(subghz) == SubGhzLoadTypeFileRaw) {
|
|
||||||
// subghz_rx_key_state_set(subghz, SubGhzRxKeyStateRAWLoad);
|
|
||||||
// scene_manager_next_scene(subghz->scene_manager, SubGhzSceneReadRAW);
|
|
||||||
// } else {
|
|
||||||
// scene_manager_next_scene(subghz->scene_manager, SubGhzSceneSavedMenu);
|
|
||||||
// }
|
|
||||||
scene_manager_next_scene(app->scene_manager, SubRemSceneRemote);
|
scene_manager_next_scene(app->scene_manager, SubRemSceneRemote);
|
||||||
} else {
|
} else {
|
||||||
|
// TODO: Map Preset Reset
|
||||||
scene_manager_search_and_switch_to_previous_scene(app->scene_manager, SubRemSceneStart);
|
scene_manager_search_and_switch_to_previous_scene(app->scene_manager, SubRemSceneStart);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,9 @@
|
|||||||
#include "../subghz_remote_app_i.h"
|
#include "../subghz_remote_app_i.h"
|
||||||
#include "../views/transmitter.h"
|
#include "../views/remote.h"
|
||||||
|
|
||||||
|
#include <lib/subghz/protocols/raw.h>
|
||||||
|
|
||||||
|
#define TAG "SubRemScenRemote"
|
||||||
|
|
||||||
// TODO:
|
// TODO:
|
||||||
// #include <lib/subghz/protocols/keeloq.h>
|
// #include <lib/subghz/protocols/keeloq.h>
|
||||||
@@ -13,61 +17,48 @@ void subrem_scene_remote_callback(SubRemCustomEvent event, void* context) {
|
|||||||
view_dispatcher_send_custom_event(app->view_dispatcher, event);
|
view_dispatcher_send_custom_event(app->view_dispatcher, event);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool subrem_scene_remote_update_data_show(void* context) {
|
void subrem_scene_remote_raw_callback_end_tx(void* context) {
|
||||||
|
furi_assert(context);
|
||||||
|
SubGhzRemoteApp* app = context;
|
||||||
|
view_dispatcher_send_custom_event(app->view_dispatcher, SubRemCustomEventViewRemoteForcedStop);
|
||||||
|
}
|
||||||
|
|
||||||
|
static uint8_t subrem_scene_remote_event_to_index(SubRemCustomEvent event_id) {
|
||||||
|
uint8_t ret = 0;
|
||||||
|
|
||||||
|
if(event_id == SubRemCustomEventViewRemoteStartUP) {
|
||||||
|
ret = SubRemSubKeyNameUp;
|
||||||
|
} else if(event_id == SubRemCustomEventViewRemoteStartDOWN) {
|
||||||
|
ret = SubRemSubKeyNameDown;
|
||||||
|
} else if(event_id == SubRemCustomEventViewRemoteStartLEFT) {
|
||||||
|
ret = SubRemSubKeyNameLeft;
|
||||||
|
} else if(event_id == SubRemCustomEventViewRemoteStartRIGHT) {
|
||||||
|
ret = SubRemSubKeyNameRight;
|
||||||
|
} else if(event_id == SubRemCustomEventViewRemoteStartOK) {
|
||||||
|
ret = SubRemSubKeyNameOk;
|
||||||
|
}
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool subrem_scene_remote_update_data_show(void* context) {
|
||||||
SubGhzRemoteApp* app = context;
|
SubGhzRemoteApp* app = context;
|
||||||
//UNUSED(app);
|
|
||||||
bool ret = false;
|
bool ret = false;
|
||||||
|
|
||||||
subrem_view_remote_add_data_to_show(
|
subrem_view_remote_add_data_to_show(
|
||||||
//app->subrem_remote_view, "N/A", "N/A", "N/A", "N/A", "N/A");
|
|
||||||
app->subrem_remote_view,
|
app->subrem_remote_view,
|
||||||
// "UP",
|
|
||||||
// "DOWN",
|
|
||||||
// "LEFT",
|
|
||||||
// "RIGHT",
|
|
||||||
// "OK");
|
|
||||||
|
|
||||||
furi_string_get_cstr(app->subs_preset[0]->label),
|
furi_string_get_cstr(app->subs_preset[0]->label),
|
||||||
furi_string_get_cstr(app->subs_preset[1]->label),
|
furi_string_get_cstr(app->subs_preset[1]->label),
|
||||||
furi_string_get_cstr(app->subs_preset[2]->label),
|
furi_string_get_cstr(app->subs_preset[2]->label),
|
||||||
furi_string_get_cstr(app->subs_preset[3]->label),
|
furi_string_get_cstr(app->subs_preset[3]->label),
|
||||||
furi_string_get_cstr(app->subs_preset[4]->label));
|
furi_string_get_cstr(app->subs_preset[4]->label));
|
||||||
|
|
||||||
// SubGhzProtocolDecoderBase* decoder = subghz_txrx_get_decoder(app->txrx);
|
|
||||||
|
|
||||||
// if(decoder) {
|
|
||||||
// FuriString* key_str = furi_string_alloc();
|
|
||||||
// FuriString* frequency_str = furi_string_alloc();
|
|
||||||
// FuriString* modulation_str = furi_string_alloc();
|
|
||||||
|
|
||||||
// if(subghz_protocol_decoder_base_deserialize(
|
|
||||||
// decoder, subghz_txrx_get_fff_data(app->txrx)) == SubGhzProtocolStatusOk) {
|
|
||||||
// subghz_protocol_decoder_base_get_string(decoder, key_str);
|
|
||||||
|
|
||||||
// subghz_txrx_get_frequency_and_modulation(
|
|
||||||
// app->txrx, frequency_str, modulation_str, false);
|
|
||||||
// subghz_view_transmitter_add_data_to_show(
|
|
||||||
// app->subghz_transmitter,
|
|
||||||
// furi_string_get_cstr(key_str),
|
|
||||||
// furi_string_get_cstr(frequency_str),
|
|
||||||
// furi_string_get_cstr(modulation_str),
|
|
||||||
// subghz_txrx_protocol_is_transmittable(app->txrx, false));
|
|
||||||
// ret = true;
|
|
||||||
// }
|
|
||||||
// furi_string_free(frequency_str);
|
|
||||||
// furi_string_free(modulation_str);
|
|
||||||
// furi_string_free(key_str);
|
|
||||||
// }
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
void subrem_scene_remote_on_enter(void* context) {
|
void subrem_scene_remote_on_enter(void* context) {
|
||||||
SubGhzRemoteApp* app = context;
|
SubGhzRemoteApp* app = context;
|
||||||
|
|
||||||
// TODO: reset custom btns
|
|
||||||
// keeloq_reset_original_btn();
|
|
||||||
// subghz_custom_btns_reset();
|
|
||||||
|
|
||||||
// TODO: init view data
|
// TODO: init view data
|
||||||
|
|
||||||
if(!subrem_scene_remote_update_data_show(app)) {
|
if(!subrem_scene_remote_update_data_show(app)) {
|
||||||
@@ -84,63 +75,71 @@ void subrem_scene_remote_on_enter(void* context) {
|
|||||||
bool subrem_scene_remote_on_event(void* context, SceneManagerEvent event) {
|
bool subrem_scene_remote_on_event(void* context, SceneManagerEvent event) {
|
||||||
SubGhzRemoteApp* app = context;
|
SubGhzRemoteApp* app = context;
|
||||||
if(event.type == SceneManagerEventTypeCustom) {
|
if(event.type == SceneManagerEventTypeCustom) {
|
||||||
// if(event.event == SubGhzCustomEventViewTransmitterSendStart) {
|
|
||||||
// app->state_notifications = SubGhzNotificationStateIDLE;
|
|
||||||
|
|
||||||
// if(subghz_tx_start(app, subghz_txrx_get_fff_data(app->txrx))) {
|
|
||||||
// app->state_notifications = SubGhzNotificationStateTx;
|
|
||||||
// subrem_scene_remote_update_data_show(app);
|
|
||||||
// DOLPHIN_DEED(DolphinDeedSubGhzSend);
|
|
||||||
// }
|
|
||||||
// return true;
|
|
||||||
// } else if(event.event == SubGhzCustomEventViewTransmitterSendStop) {
|
|
||||||
// app->state_notifications = SubGhzNotificationStateIDLE;
|
|
||||||
// subghz_txrx_stop(app->txrx);
|
|
||||||
// if(subghz_custom_btn_get() != 0) {
|
|
||||||
// subghz_custom_btn_set(0);
|
|
||||||
// uint8_t tmp_counter = furi_hal_subghz_get_rolling_counter_mult();
|
|
||||||
// furi_hal_subghz_set_rolling_counter_mult(0);
|
|
||||||
// // Calling restore!
|
|
||||||
// subghz_tx_start(app, subghz_txrx_get_fff_data(app->txrx));
|
|
||||||
// subghz_txrx_stop(app->txrx);
|
|
||||||
// furi_hal_subghz_set_rolling_counter_mult(tmp_counter);
|
|
||||||
// }
|
|
||||||
// return true;
|
|
||||||
// } else
|
|
||||||
if(event.event == SubRemCustomEventViewRemoteBack) {
|
if(event.event == SubRemCustomEventViewRemoteBack) {
|
||||||
// app->state_notifications = SubGhzNotificationStateIDLE; //TODO: notification
|
if(!scene_manager_search_and_switch_to_previous_scene(
|
||||||
scene_manager_search_and_switch_to_previous_scene(
|
app->scene_manager, SubRemSceneOpenMapFile)) {
|
||||||
app->scene_manager, SubRemSceneStart);
|
if(!scene_manager_search_and_switch_to_previous_scene(
|
||||||
return true;
|
app->scene_manager, SubRemSceneStart)) {
|
||||||
} else if(event.event == SubRemCustomEventViewRemoteStartUP) {
|
scene_manager_stop(app->scene_manager);
|
||||||
if(subghz_tx_start_sub(app, app->subs_preset[0])) {
|
view_dispatcher_stop(app->view_dispatcher);
|
||||||
notification_message(app->notifications, &sequence_blink_start_magenta);
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
} else if(
|
||||||
|
event.event == SubRemCustomEventViewRemoteStartUP ||
|
||||||
|
event.event == SubRemCustomEventViewRemoteStartDOWN ||
|
||||||
|
event.event == SubRemCustomEventViewRemoteStartLEFT ||
|
||||||
|
event.event == SubRemCustomEventViewRemoteStartRIGHT ||
|
||||||
|
event.event == SubRemCustomEventViewRemoteStartOK) {
|
||||||
|
// Start sending sub
|
||||||
|
subghz_tx_stop_sub(app, true);
|
||||||
|
app->chusen_sub = subrem_scene_remote_event_to_index(event.event);
|
||||||
|
subrem_view_remote_set_state(app->subrem_remote_view, SubRemViewRemoteStateLoading);
|
||||||
|
if(subghz_tx_start_sub(
|
||||||
|
app,
|
||||||
|
app->subs_preset[app->chusen_sub],
|
||||||
|
subrem_scene_remote_raw_callback_end_tx)) {
|
||||||
|
subrem_view_remote_set_presed_btn(app->subrem_remote_view, app->chusen_sub);
|
||||||
|
subrem_view_remote_set_state(
|
||||||
|
app->subrem_remote_view, SubRemViewRemoteStateSending);
|
||||||
|
notification_message(app->notifications, &sequence_blink_start_magenta);
|
||||||
|
} else {
|
||||||
|
subrem_view_remote_set_state(app->subrem_remote_view, SubRemViewRemoteStateIdle);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
} else if(event.event == SubRemCustomEventViewRemoteForcedStop) {
|
||||||
|
subghz_tx_stop_sub(app, true);
|
||||||
|
subrem_view_remote_set_presed_btn(app->subrem_remote_view, 0);
|
||||||
|
subrem_view_remote_set_state(app->subrem_remote_view, SubRemViewRemoteStateIdle);
|
||||||
|
|
||||||
|
notification_message(app->notifications, &sequence_blink_stop);
|
||||||
|
return true;
|
||||||
} else if(event.event == SubRemCustomEventViewRemoteStop) {
|
} else if(event.event == SubRemCustomEventViewRemoteStop) {
|
||||||
subghz_tx_stop_sub(app, app->subs_preset[0]);
|
if(subghz_tx_stop_sub(app, false)) {
|
||||||
|
subrem_view_remote_set_presed_btn(app->subrem_remote_view, 0);
|
||||||
|
subrem_view_remote_set_state(app->subrem_remote_view, SubRemViewRemoteStateIdle);
|
||||||
|
|
||||||
notification_message(app->notifications, &sequence_blink_stop);
|
notification_message(app->notifications, &sequence_blink_stop);
|
||||||
}
|
}
|
||||||
// notification_message(app->notification, &sequence_blink_stop);
|
return true;
|
||||||
|
|
||||||
// else if(event.event == SubGhzCustomEventViewTransmitterError) {
|
|
||||||
// furi_string_set(app->error_str, "Protocol not\nfound!");
|
|
||||||
// scene_manager_next_scene(app->scene_manager, SubGhzSceneShowErrorSub);
|
|
||||||
// }
|
|
||||||
} else if(event.type == SceneManagerEventTypeTick) {
|
|
||||||
// if(app->state_notifications == SubGhzNotificationStateTx) {
|
|
||||||
// notification_message(app->notifications, &sequence_blink_magenta_10);
|
|
||||||
// }
|
|
||||||
// return true;
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
// } else if(event.type == SceneManagerEventTypeTick) {
|
||||||
|
// }
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void subrem_scene_remote_on_exit(void* context) {
|
void subrem_scene_remote_on_exit(void* context) {
|
||||||
SubGhzRemoteApp* app = context;
|
SubGhzRemoteApp* app = context;
|
||||||
UNUSED(app);
|
|
||||||
// TODO: notifications and reset KL
|
|
||||||
|
|
||||||
//app->state_notifications = SubGhzNotificationStateIDLE;
|
subghz_tx_stop_sub(app, true);
|
||||||
|
|
||||||
|
subrem_view_remote_set_presed_btn(app->subrem_remote_view, 0);
|
||||||
|
subrem_view_remote_set_state(app->subrem_remote_view, SubRemViewRemoteStateIdle);
|
||||||
|
|
||||||
|
notification_message(app->notifications, &sequence_blink_stop);
|
||||||
|
|
||||||
|
// TODO: notifications and reset KL
|
||||||
|
|
||||||
// keeloq_reset_mfname();
|
// keeloq_reset_mfname();
|
||||||
// keeloq_reset_kl_type();
|
// keeloq_reset_kl_type();
|
||||||
|
|||||||
@@ -16,23 +16,17 @@ void subrem_scene_start_on_enter(void* context) {
|
|||||||
submenu_add_item(
|
submenu_add_item(
|
||||||
submenu,
|
submenu,
|
||||||
"Open Map File",
|
"Open Map File",
|
||||||
SubmenuIndexOpenMapFile,
|
SubmenuIndexSubRemOpenMapFile,
|
||||||
subrem_scene_start_submenu_callback,
|
subrem_scene_start_submenu_callback,
|
||||||
app);
|
app);
|
||||||
|
#if FURI_DEBUG
|
||||||
submenu_add_item(
|
submenu_add_item(
|
||||||
submenu, "Remote", SubmenuIndexOpenView, subrem_scene_start_submenu_callback, app);
|
submenu,
|
||||||
// submenu_add_item(
|
"Remote_Debug",
|
||||||
// submenu,
|
SubmenuIndexSubRemRemoteView,
|
||||||
// "ISP Programmer",
|
subrem_scene_start_submenu_callback,
|
||||||
// SubmenuIndexSubGhzRemoteProgrammer,
|
app);
|
||||||
// subrem_scene_start_submenu_callback,
|
#endif
|
||||||
// app);
|
|
||||||
// submenu_add_item(
|
|
||||||
// submenu,
|
|
||||||
// "Wiring",
|
|
||||||
// SubmenuIndexAvrIsWiring,
|
|
||||||
// subrem_scene_start_submenu_callback,
|
|
||||||
// app);
|
|
||||||
// submenu_add_item(
|
// submenu_add_item(
|
||||||
// submenu,
|
// submenu,
|
||||||
// "About",
|
// "About",
|
||||||
@@ -53,33 +47,21 @@ bool subrem_scene_start_on_event(void* context, SceneManagerEvent event) {
|
|||||||
bool consumed = false;
|
bool consumed = false;
|
||||||
|
|
||||||
if(event.type == SceneManagerEventTypeCustom) {
|
if(event.type == SceneManagerEventTypeCustom) {
|
||||||
if(event.event == SubmenuIndexOpenMapFile) {
|
if(event.event == SubmenuIndexSubRemOpenMapFile) {
|
||||||
|
//scene_manager_set_scene_state(app->scene_manager, SubRemSceneStart, event.event);
|
||||||
scene_manager_next_scene(app->scene_manager, SubRemSceneOpenMapFile);
|
scene_manager_next_scene(app->scene_manager, SubRemSceneOpenMapFile);
|
||||||
consumed = true;
|
consumed = true;
|
||||||
} else if(event.event == SubmenuIndexOpenView) {
|
}
|
||||||
|
// } else if(event.event == SubmenuIndexSubRemAbout) {
|
||||||
|
// scene_manager_next_scene(app->scene_manager, SubRemSceneAbout);
|
||||||
|
// consumed = true;
|
||||||
|
// }
|
||||||
|
#if FURI_DEBUG
|
||||||
|
else if(event.event == SubmenuIndexSubRemRemoteView) {
|
||||||
scene_manager_next_scene(app->scene_manager, SubRemSceneRemote);
|
scene_manager_next_scene(app->scene_manager, SubRemSceneRemote);
|
||||||
consumed = true;
|
consumed = true;
|
||||||
}
|
}
|
||||||
// } else if(event.event == SubmenuIndexSubGhzRemoteProgrammer) {
|
#endif
|
||||||
// scene_manager_set_scene_state(
|
|
||||||
// app->scene_manager, SubRemSceneChipDetect, SubGhzRemoteViewProgrammer);
|
|
||||||
// scene_manager_next_scene(app->scene_manager, SubRemSceneChipDetect);
|
|
||||||
// consumed = true;
|
|
||||||
// } else if(event.event == SubmenuIndexSubGhzRemoteReader) {
|
|
||||||
// scene_manager_set_scene_state(
|
|
||||||
// app->scene_manager, SubRemSceneChipDetect, SubGhzRemoteViewReader);
|
|
||||||
// scene_manager_next_scene(app->scene_manager, SubRemSceneChipDetect);
|
|
||||||
// consumed = true;
|
|
||||||
// } else if(event.event == SubmenuIndexSubGhzRemoteWriter) {
|
|
||||||
// scene_manager_set_scene_state(
|
|
||||||
// app->scene_manager, SubRemSceneChipDetect, SubGhzRemoteViewWriter);
|
|
||||||
// scene_manager_next_scene(app->scene_manager, SubRemSceneChipDetect);
|
|
||||||
// consumed = true;
|
|
||||||
// } else if(event.event == SubmenuIndexAvrIsWiring) {
|
|
||||||
// scene_manager_next_scene(app->scene_manager, SubRemSceneWiring);
|
|
||||||
// consumed = true;
|
|
||||||
// }
|
|
||||||
scene_manager_set_scene_state(app->scene_manager, SubRemSceneStart, event.event);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return consumed;
|
return consumed;
|
||||||
|
|||||||
@@ -93,29 +93,8 @@ SubGhzRemoteApp* subghz_remote_app_alloc() {
|
|||||||
app->view_dispatcher,
|
app->view_dispatcher,
|
||||||
SubRemViewIDRemote,
|
SubRemViewIDRemote,
|
||||||
subrem_view_remote_get_view(app->subrem_remote_view));
|
subrem_view_remote_get_view(app->subrem_remote_view));
|
||||||
/*
|
|
||||||
// Reader view
|
|
||||||
app->subghz_remote_reader_view = subghz_remote_reader_view_alloc();
|
|
||||||
view_dispatcher_add_view(
|
|
||||||
app->view_dispatcher,
|
|
||||||
SubRemViewReader,
|
|
||||||
subghz_remote_reader_view_get_view(app->subghz_remote_reader_view));
|
|
||||||
|
|
||||||
// Writer view
|
for(uint8_t i = 0; i < SubRemSubKeyNameMaxCount; i++) {
|
||||||
app->subghz_remote_writer_view = subghz_remote_writer_view_alloc();
|
|
||||||
view_dispatcher_add_view(
|
|
||||||
app->view_dispatcher,
|
|
||||||
SubRemViewWriter,
|
|
||||||
subghz_remote_writer_view_get_view(app->subghz_remote_writer_view));
|
|
||||||
|
|
||||||
// Chip detect view
|
|
||||||
app->subghz_remote_chip_detect_view = subghz_remote_chip_detect_view_alloc();
|
|
||||||
view_dispatcher_add_view(
|
|
||||||
app->view_dispatcher,
|
|
||||||
SubRemViewChipDetect,
|
|
||||||
subghz_remote_chip_detect_view_get_view(app->subghz_remote_chip_detect_view));
|
|
||||||
*/
|
|
||||||
for(uint8_t i = 0; i < SUBREM_MAX_SUB_KEY_COUNT; i++) {
|
|
||||||
app->subs_preset[i] = subrem_sub_file_preset_alloc();
|
app->subs_preset[i] = subrem_sub_file_preset_alloc();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -137,6 +116,8 @@ SubGhzRemoteApp* subghz_remote_app_alloc() {
|
|||||||
|
|
||||||
app->receiver = subghz_receiver_alloc_init(app->environment);
|
app->receiver = subghz_receiver_alloc_init(app->environment);
|
||||||
|
|
||||||
|
app->tx_running = false;
|
||||||
|
|
||||||
scene_manager_next_scene(app->scene_manager, SubRemSceneStart);
|
scene_manager_next_scene(app->scene_manager, SubRemSceneStart);
|
||||||
|
|
||||||
return app;
|
return app;
|
||||||
@@ -179,26 +160,10 @@ void subghz_remote_app_free(SubGhzRemoteApp* app) {
|
|||||||
subghz_environment_free(app->environment);
|
subghz_environment_free(app->environment);
|
||||||
subghz_setting_free(app->setting);
|
subghz_setting_free(app->setting);
|
||||||
|
|
||||||
for(uint8_t i = 0; i < SUBREM_MAX_SUB_KEY_COUNT; i++) {
|
for(uint8_t i = 0; i < SubRemSubKeyNameMaxCount; i++) {
|
||||||
subrem_sub_file_preset_free(app->subs_preset[i]);
|
subrem_sub_file_preset_free(app->subs_preset[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
// // Reader view
|
|
||||||
// view_dispatcher_remove_view(app->view_dispatcher, SubRemViewReader);
|
|
||||||
// subghz_remote_reader_view_free(app->subghz_remote_reader_view);
|
|
||||||
|
|
||||||
// // Writer view
|
|
||||||
// view_dispatcher_remove_view(app->view_dispatcher, SubRemViewWriter);
|
|
||||||
// subghz_remote_writer_view_free(app->subghz_remote_writer_view);
|
|
||||||
|
|
||||||
// // Chip detect view
|
|
||||||
// view_dispatcher_remove_view(app->view_dispatcher, SubRemViewChipDetect);
|
|
||||||
// subghz_remote_chip_detect_view_free(app->subghz_remote_chip_detect_view);
|
|
||||||
|
|
||||||
// // View dispatcher
|
|
||||||
// view_dispatcher_free(app->view_dispatcher);
|
|
||||||
// scene_manager_free(app->scene_manager);
|
|
||||||
|
|
||||||
// Notifications
|
// Notifications
|
||||||
furi_record_close(RECORD_NOTIFICATION);
|
furi_record_close(RECORD_NOTIFICATION);
|
||||||
app->notifications = NULL;
|
app->notifications = NULL;
|
||||||
@@ -209,11 +174,6 @@ void subghz_remote_app_free(SubGhzRemoteApp* app) {
|
|||||||
// Path strings
|
// Path strings
|
||||||
furi_string_free(app->file_path);
|
furi_string_free(app->file_path);
|
||||||
|
|
||||||
// Disable 5v power
|
|
||||||
// if(furi_hal_power_is_otg_enabled()) {
|
|
||||||
// furi_hal_power_disable_otg();
|
|
||||||
// }
|
|
||||||
|
|
||||||
free(app);
|
free(app);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -7,15 +7,16 @@
|
|||||||
|
|
||||||
#define TAG "SubGhzRemote"
|
#define TAG "SubGhzRemote"
|
||||||
|
|
||||||
static const char* map_file_labels[SUBREM_MAX_SUB_KEY_COUNT][2] = {
|
static const char* map_file_labels[SubRemSubKeyNameMaxCount][2] = {
|
||||||
{"UP", "ULABEL"},
|
[SubRemSubKeyNameUp] = {"UP", "ULABEL"},
|
||||||
{"DOWN", "DLABEL"},
|
[SubRemSubKeyNameDown] = {"DOWN", "DLABEL"},
|
||||||
{"LEFT", "LLABEL"},
|
[SubRemSubKeyNameLeft] = {"LEFT", "LLABEL"},
|
||||||
{"RIGHT", "RLABEL"},
|
[SubRemSubKeyNameRight] = {"RIGHT", "RLABEL"},
|
||||||
{"OK", "OKLABEL"},
|
[SubRemSubKeyNameOk] = {"OK", "OKLABEL"},
|
||||||
};
|
};
|
||||||
|
|
||||||
bool subrem_set_preset_data(SubGhzSetting* setting, FreqPreset* freq_preset, const char* preset) {
|
static bool
|
||||||
|
subrem_set_preset_data(SubGhzSetting* setting, FreqPreset* freq_preset, const char* preset) {
|
||||||
const char* preset_name = "";
|
const char* preset_name = "";
|
||||||
if(!strcmp(preset, "FuriHalSubGhzPresetOok270Async")) {
|
if(!strcmp(preset, "FuriHalSubGhzPresetOok270Async")) {
|
||||||
preset_name = "AM270";
|
preset_name = "AM270";
|
||||||
@@ -45,7 +46,7 @@ SubRemSubFilePreset* subrem_sub_file_preset_alloc() {
|
|||||||
sub_preset->protocaol_name = furi_string_alloc();
|
sub_preset->protocaol_name = furi_string_alloc();
|
||||||
sub_preset->label = furi_string_alloc_set_str("N/A");
|
sub_preset->label = furi_string_alloc_set_str("N/A");
|
||||||
|
|
||||||
sub_preset->type = SubRemSubKeyTypeNoData;
|
sub_preset->type = SubGhzProtocolTypeUnknown;
|
||||||
|
|
||||||
return sub_preset;
|
return sub_preset;
|
||||||
}
|
}
|
||||||
@@ -61,7 +62,7 @@ void subrem_sub_file_preset_free(SubRemSubFilePreset* sub_preset) {
|
|||||||
free(sub_preset);
|
free(sub_preset);
|
||||||
}
|
}
|
||||||
|
|
||||||
void subrem_subs_file_preset_reset(SubRemSubFilePreset* sub_preset) {
|
static void subrem_sub_file_preset_reset(SubRemSubFilePreset* sub_preset) {
|
||||||
furi_assert(sub_preset);
|
furi_assert(sub_preset);
|
||||||
|
|
||||||
furi_string_set_str(sub_preset->label, "N/A");
|
furi_string_set_str(sub_preset->label, "N/A");
|
||||||
@@ -71,43 +72,45 @@ void subrem_subs_file_preset_reset(SubRemSubFilePreset* sub_preset) {
|
|||||||
Stream* fff_data_stream = flipper_format_get_raw_stream(sub_preset->fff_data);
|
Stream* fff_data_stream = flipper_format_get_raw_stream(sub_preset->fff_data);
|
||||||
stream_clean(fff_data_stream);
|
stream_clean(fff_data_stream);
|
||||||
|
|
||||||
sub_preset->type = SubRemSubKeyTypeNoData;
|
sub_preset->type = SubGhzProtocolTypeUnknown;
|
||||||
}
|
}
|
||||||
|
|
||||||
void subrem_sub_file_presets_reset(SubGhzRemoteApp* app) {
|
void subrem_map_preset_reset(SubGhzRemoteApp* app) {
|
||||||
furi_assert(app);
|
furi_assert(app);
|
||||||
|
|
||||||
for(uint8_t i = 0; i < SUBREM_MAX_SUB_KEY_COUNT; i++) {
|
for(uint8_t i = 0; i < SubRemSubKeyNameMaxCount; i++) {
|
||||||
subrem_subs_file_preset_reset(app->subs_preset[i]);
|
subrem_sub_file_preset_reset(app->subs_preset[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool subrem_sub_file_presets_load(SubGhzRemoteApp* app, FlipperFormat* fff_data_file) {
|
static bool subrem_map_preset_load(SubGhzRemoteApp* app, FlipperFormat* fff_data_file) {
|
||||||
furi_assert(app);
|
furi_assert(app);
|
||||||
bool ret = false;
|
bool ret = false;
|
||||||
|
SubRemSubFilePreset* sub_preset;
|
||||||
for(uint8_t i = 0; i < SUBREM_MAX_SUB_KEY_COUNT; i++) {
|
for(uint8_t i = 0; i < SubRemSubKeyNameMaxCount; i++) {
|
||||||
|
sub_preset = app->subs_preset[i];
|
||||||
if(!flipper_format_read_string(
|
if(!flipper_format_read_string(
|
||||||
fff_data_file, map_file_labels[i][0], app->subs_preset[i]->file_path)) {
|
fff_data_file, map_file_labels[i][0], sub_preset->file_path)) {
|
||||||
|
#if FURO_LOG
|
||||||
FURI_LOG_W(TAG, "No file patch for %s", map_file_labels[i][0]);
|
FURI_LOG_W(TAG, "No file patch for %s", map_file_labels[i][0]);
|
||||||
app->subs_preset[i]->type = SubRemSubKeyTypeNoData;
|
#endif
|
||||||
//continue;
|
sub_preset->type = SubGhzProtocolTypeUnknown;
|
||||||
} else if(!flipper_format_rewind(fff_data_file)) {
|
} else if(!flipper_format_rewind(fff_data_file)) {
|
||||||
// Rewind error
|
// Rewind error
|
||||||
//continue;
|
|
||||||
} else if(!flipper_format_read_string(
|
} else if(!flipper_format_read_string(
|
||||||
fff_data_file, map_file_labels[i][1], app->subs_preset[i]->label)) {
|
fff_data_file, map_file_labels[i][1], sub_preset->label)) {
|
||||||
|
#if FURO_LOG
|
||||||
FURI_LOG_W(TAG, "No Label for %s", map_file_labels[i][0]);
|
FURI_LOG_W(TAG, "No Label for %s", map_file_labels[i][0]);
|
||||||
furi_string_set_str(app->subs_preset[i]->label, "N/A");
|
#endif
|
||||||
|
furi_string_set_str(sub_preset->label,
|
||||||
|
"N/A"); // TODO: Standart name or part of name
|
||||||
} else {
|
} else {
|
||||||
FURI_LOG_I(
|
FURI_LOG_I(
|
||||||
TAG,
|
TAG,
|
||||||
// "Loaded %s key \r\nLabel %s file %s",
|
"%-5s: %s %s",
|
||||||
"Loaded %s key: %s %s",
|
|
||||||
map_file_labels[i][0],
|
map_file_labels[i][0],
|
||||||
furi_string_get_cstr(app->subs_preset[i]->label),
|
furi_string_get_cstr(sub_preset->label),
|
||||||
furi_string_get_cstr(app->subs_preset[i]->file_path));
|
furi_string_get_cstr(sub_preset->file_path));
|
||||||
app->subs_preset[i]->type = SubRemSubKeyTypeHaveFileName; // TODO:
|
|
||||||
ret = true;
|
ret = true;
|
||||||
}
|
}
|
||||||
flipper_format_rewind(fff_data_file);
|
flipper_format_rewind(fff_data_file);
|
||||||
@@ -115,11 +118,20 @@ static bool subrem_sub_file_presets_load(SubGhzRemoteApp* app, FlipperFormat* ff
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool subghz_tx_start_sub(SubGhzRemoteApp* app, SubRemSubFilePreset* sub_preset) {
|
bool subghz_tx_start_sub(
|
||||||
|
SubGhzRemoteApp* app,
|
||||||
|
SubRemSubFilePreset* sub_preset,
|
||||||
|
SubGhzProtocolEncoderRAWCallbackEnd callback) {
|
||||||
furi_assert(app);
|
furi_assert(app);
|
||||||
furi_assert(sub_preset);
|
furi_assert(sub_preset);
|
||||||
bool ret = false;
|
bool ret = false;
|
||||||
|
|
||||||
|
subghz_tx_stop_sub(app, true);
|
||||||
|
|
||||||
|
if(sub_preset->type == SubGhzProtocolTypeUnknown) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
FURI_LOG_I(TAG, "Send %s", furi_string_get_cstr(sub_preset->label));
|
FURI_LOG_I(TAG, "Send %s", furi_string_get_cstr(sub_preset->label));
|
||||||
|
|
||||||
do {
|
do {
|
||||||
@@ -152,19 +164,27 @@ bool subghz_tx_start_sub(SubGhzRemoteApp* app, SubRemSubFilePreset* sub_preset)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(sub_preset->type == SubGhzProtocolTypeRAW) {
|
||||||
|
subghz_protocol_raw_file_encoder_worker_set_callback_end(
|
||||||
|
(SubGhzProtocolEncoderRAW*)subghz_transmitter_get_protocol_instance(
|
||||||
|
app->transmitter),
|
||||||
|
callback,
|
||||||
|
app);
|
||||||
|
}
|
||||||
|
|
||||||
furi_hal_subghz_start_async_tx(subghz_transmitter_yield, app->transmitter);
|
furi_hal_subghz_start_async_tx(subghz_transmitter_yield, app->transmitter);
|
||||||
|
|
||||||
ret = true;
|
ret = true;
|
||||||
}
|
}
|
||||||
} while(false);
|
} while(false);
|
||||||
|
|
||||||
// ret = false; // TODO:
|
app->tx_running = ret; // TODO:
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
void subghz_tx_stop_sub(SubGhzRemoteApp* app, SubRemSubFilePreset* sub_preset) {
|
static void subghz_tx_stop(SubGhzRemoteApp* app) {
|
||||||
furi_assert(app);
|
furi_assert(app);
|
||||||
furi_assert(sub_preset);
|
|
||||||
|
|
||||||
//Stop TX
|
//Stop TX
|
||||||
furi_hal_subghz_stop_async_tx();
|
furi_hal_subghz_stop_async_tx();
|
||||||
@@ -172,29 +192,46 @@ void subghz_tx_stop_sub(SubGhzRemoteApp* app, SubRemSubFilePreset* sub_preset) {
|
|||||||
subghz_transmitter_stop(app->transmitter);
|
subghz_transmitter_stop(app->transmitter);
|
||||||
subghz_transmitter_free(app->transmitter);
|
subghz_transmitter_free(app->transmitter);
|
||||||
furi_hal_subghz_idle();
|
furi_hal_subghz_idle();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool subghz_tx_stop_sub(SubGhzRemoteApp* app, bool forced) {
|
||||||
|
furi_assert(app);
|
||||||
|
|
||||||
|
if(forced || (app->subs_preset[app->chusen_sub]->type != SubGhzProtocolTypeRAW)) {
|
||||||
|
// SubRemSubKeyTypeRawKey)) {
|
||||||
|
if(app->tx_running) {
|
||||||
|
subghz_tx_stop(app);
|
||||||
|
app->tx_running = false;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
|
||||||
|
// SubRemSubFilePreset* sub_preset = app->subs_preset[app->chusen_sub];
|
||||||
|
|
||||||
// TODO: need saving logic
|
// TODO: need saving logic
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool subrem_sub_presets_check(SubGhzRemoteApp* app, FlipperFormat* fff_data_file) {
|
static bool subrem_map_preset_check(SubGhzRemoteApp* app, FlipperFormat* fff_data_file) {
|
||||||
furi_assert(app);
|
furi_assert(app);
|
||||||
FuriString* temp_str = furi_string_alloc();
|
FuriString* temp_str = furi_string_alloc();
|
||||||
uint32_t temp_data32;
|
uint32_t temp_data32;
|
||||||
bool ret = false;
|
bool ret = false;
|
||||||
|
bool sub_preset_loaded = false;
|
||||||
SubRemSubFilePreset* sub_preset;
|
SubRemSubFilePreset* sub_preset;
|
||||||
|
|
||||||
for(uint8_t i = 0; i < SUBREM_MAX_SUB_KEY_COUNT; i++) {
|
for(uint8_t i = 0; i < SubRemSubKeyNameMaxCount; i++) {
|
||||||
sub_preset = app->subs_preset[i];
|
sub_preset = app->subs_preset[i];
|
||||||
if(sub_preset->type == SubRemSubKeyTypeNoData) {
|
sub_preset_loaded = false;
|
||||||
|
if(furi_string_empty(sub_preset->file_path)) {
|
||||||
|
// FURI_LOG_I(TAG, "Empty file path");
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
do {
|
do {
|
||||||
if(!flipper_format_file_open_existing(
|
if(!flipper_format_file_open_existing(
|
||||||
fff_data_file, furi_string_get_cstr(sub_preset->file_path))) {
|
fff_data_file, furi_string_get_cstr(sub_preset->file_path))) {
|
||||||
FURI_LOG_E(
|
FURI_LOG_W(TAG, "Error open file %s", furi_string_get_cstr(sub_preset->file_path));
|
||||||
TAG,
|
|
||||||
"Error open file %s",
|
|
||||||
furi_string_get_cstr(sub_preset->file_path)); // TODO: warning
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -213,9 +250,9 @@ static bool subrem_sub_presets_check(SubGhzRemoteApp* app, FlipperFormat* fff_da
|
|||||||
|
|
||||||
//Load frequency
|
//Load frequency
|
||||||
if(!flipper_format_read_uint32(fff_data_file, "Frequency", &temp_data32, 1)) {
|
if(!flipper_format_read_uint32(fff_data_file, "Frequency", &temp_data32, 1)) {
|
||||||
FURI_LOG_W(TAG, "Cannot read frequency. Defaulting to 433.92 MHz");
|
FURI_LOG_W(TAG, "Cannot read frequency. Set default frequency");
|
||||||
sub_preset->freq_preset.frequency = subghz_setting_get_default_frequency(
|
sub_preset->freq_preset.frequency =
|
||||||
app->setting); // TODO: Get default from settings
|
subghz_setting_get_default_frequency(app->setting);
|
||||||
} else if(!furi_hal_subghz_is_tx_allowed(temp_data32)) {
|
} else if(!furi_hal_subghz_is_tx_allowed(temp_data32)) {
|
||||||
FURI_LOG_E(TAG, "This frequency can only be used for RX");
|
FURI_LOG_E(TAG, "This frequency can only be used for RX");
|
||||||
break;
|
break;
|
||||||
@@ -246,7 +283,6 @@ static bool subrem_sub_presets_check(SubGhzRemoteApp* app, FlipperFormat* fff_da
|
|||||||
//if RAW
|
//if RAW
|
||||||
subghz_protocol_raw_gen_fff_data(
|
subghz_protocol_raw_gen_fff_data(
|
||||||
fff_data, furi_string_get_cstr(sub_preset->file_path));
|
fff_data, furi_string_get_cstr(sub_preset->file_path));
|
||||||
sub_preset->type = SubRemSubKeyTypeRawKey;
|
|
||||||
} else {
|
} else {
|
||||||
stream_copy_full(
|
stream_copy_full(
|
||||||
flipper_format_get_raw_stream(fff_data_file),
|
flipper_format_get_raw_stream(fff_data_file),
|
||||||
@@ -262,70 +298,82 @@ static bool subrem_sub_presets_check(SubGhzRemoteApp* app, FlipperFormat* fff_da
|
|||||||
if(!protocol) {
|
if(!protocol) {
|
||||||
FURI_LOG_E(TAG, "Protocol not found");
|
FURI_LOG_E(TAG, "Protocol not found");
|
||||||
break;
|
break;
|
||||||
} else if(protocol->flag & SubGhzProtocolFlag_Send) { // FIXME:
|
} else if(protocol->flag & SubGhzProtocolFlag_Send) {
|
||||||
|
if((protocol->type == SubGhzProtocolTypeStatic) ||
|
||||||
if(protocol->type == SubGhzProtocolTypeStatic) {
|
(protocol->type == SubGhzProtocolTypeDynamic) ||
|
||||||
sub_preset->type = SubRemSubKeyTypeStaticKey;
|
// (protocol->type == SubGhzProtocolTypeBinRAW) || // TODO: BINRAW
|
||||||
} else if(protocol->type == SubGhzProtocolTypeDynamic) {
|
(protocol->type == SubGhzProtocolTypeRAW)) {
|
||||||
sub_preset->type = SubRemSubKeyTypeDynamicKey;
|
sub_preset->type = protocol->type;
|
||||||
} else if(protocol->type == SubGhzProtocolTypeRAW) {
|
|
||||||
sub_preset->type = SubRemSubKeyTypeRawKey;
|
|
||||||
// } else if(protocol->type == SubGhzProtocolTypeBinRAW) { // TODO: BINRAW
|
|
||||||
} else {
|
} else {
|
||||||
FURI_LOG_E(TAG, "Unsuported Protocol");
|
FURI_LOG_E(TAG, "Unsuported Protocol");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
furi_string_set(sub_preset->protocaol_name, temp_str);
|
furi_string_set(sub_preset->protocaol_name, temp_str);
|
||||||
} // TODO: check dynamic and protocol found
|
} else {
|
||||||
|
FURI_LOG_E(TAG, "Protocol does not support transmission");
|
||||||
ret |= true;
|
|
||||||
|
|
||||||
if(ret) {
|
|
||||||
FURI_LOG_I(TAG, "Protocol Loaded");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sub_preset_loaded = true;
|
||||||
|
ret |= true;
|
||||||
|
#if FURI_DEBUG
|
||||||
|
FURI_LOG_I(TAG, "%-16s - protocol Loaded", furi_string_get_cstr(sub_preset->label));
|
||||||
|
#endif
|
||||||
} while(false);
|
} while(false);
|
||||||
|
|
||||||
|
// TODO:
|
||||||
|
// Load file state logic
|
||||||
|
// Label depending on the state
|
||||||
|
|
||||||
|
if(!sub_preset_loaded) {
|
||||||
|
furi_string_set_str(sub_preset->label, "N/A");
|
||||||
|
}
|
||||||
|
|
||||||
flipper_format_file_close(fff_data_file);
|
flipper_format_file_close(fff_data_file);
|
||||||
}
|
}
|
||||||
furi_string_free(temp_str);
|
furi_string_free(temp_str);
|
||||||
|
|
||||||
//ret = false; // TODO:
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool subrem_map_file_load(SubGhzRemoteApp* app, const char* file_path) {
|
bool subrem_map_file_load(SubGhzRemoteApp* app, const char* file_path) {
|
||||||
furi_assert(app);
|
furi_assert(app);
|
||||||
furi_assert(file_path);
|
furi_assert(file_path);
|
||||||
// TODO: drop furi log
|
#if FURI_DEBUG
|
||||||
FURI_LOG_I(TAG, "Load Map File Start"); // drop
|
FURI_LOG_I(TAG, "Load Map File Start");
|
||||||
|
#endif
|
||||||
Storage* storage = furi_record_open(RECORD_STORAGE);
|
Storage* storage = furi_record_open(RECORD_STORAGE);
|
||||||
FlipperFormat* fff_data_file = flipper_format_file_alloc(storage);
|
FlipperFormat* fff_data_file = flipper_format_file_alloc(storage);
|
||||||
bool ret = false;
|
bool ret = false;
|
||||||
FURI_LOG_I(TAG, "Open Map File.."); // drop
|
#if FURI_DEBUG
|
||||||
|
FURI_LOG_I(TAG, "Open Map File..");
|
||||||
subrem_sub_file_presets_reset(app);
|
#endif
|
||||||
|
subrem_map_preset_reset(app);
|
||||||
|
|
||||||
if(!flipper_format_file_open_existing(fff_data_file, file_path)) {
|
if(!flipper_format_file_open_existing(fff_data_file, file_path)) {
|
||||||
FURI_LOG_E(TAG, "Could not open MAP file %s", file_path);
|
FURI_LOG_E(TAG, "Could not open MAP file %s", file_path);
|
||||||
} else {
|
} else {
|
||||||
if(!subrem_sub_file_presets_load(app, fff_data_file)) {
|
if(!subrem_map_preset_load(app, fff_data_file)) {
|
||||||
// TODO: error popup or return error type
|
|
||||||
FURI_LOG_E(TAG, "Could no Sub file path in MAP file");
|
FURI_LOG_E(TAG, "Could no Sub file path in MAP file");
|
||||||
|
// ret = // error for popup
|
||||||
} else if(
|
} else if(
|
||||||
(flipper_format_file_close(fff_data_file)) &&
|
(flipper_format_file_close(fff_data_file)) &&
|
||||||
(subrem_sub_presets_check(app, fff_data_file))) {
|
(subrem_map_preset_check(app, fff_data_file))) {
|
||||||
FURI_LOG_I(TAG, "Load Map File Seccesful");
|
FURI_LOG_I(TAG, "Load Map File Seccesful");
|
||||||
ret = true;
|
ret = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: Pop for error or return error type
|
||||||
|
if(!ret) {
|
||||||
|
FURI_LOG_E(TAG, "Broken Map File");
|
||||||
|
}
|
||||||
|
|
||||||
flipper_format_file_close(fff_data_file);
|
flipper_format_file_close(fff_data_file);
|
||||||
flipper_format_free(fff_data_file);
|
flipper_format_free(fff_data_file);
|
||||||
|
|
||||||
furi_record_close(RECORD_STORAGE);
|
furi_record_close(RECORD_STORAGE);
|
||||||
|
|
||||||
//ret = false; // TODO:
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -344,7 +392,6 @@ bool subrem_load_from_file(SubGhzRemoteApp* app) {
|
|||||||
|
|
||||||
if(res) {
|
if(res) {
|
||||||
res = subrem_map_file_load(app, furi_string_get_cstr(app->file_path));
|
res = subrem_map_file_load(app, furi_string_get_cstr(app->file_path));
|
||||||
// FIXME res = subghz_key_load(app, furi_string_get_cstr(app->file_path), true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
furi_string_free(file_path);
|
furi_string_free(file_path);
|
||||||
|
|||||||
@@ -1,12 +1,12 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "helpers/subrem_types.h"
|
#include "helpers/subrem_types.h"
|
||||||
|
#include <subghz_remote_new_icons.h> // TODO:
|
||||||
|
|
||||||
#include "views/transmitter.h"
|
#include "views/remote.h"
|
||||||
|
|
||||||
#include "scenes/subrem_scene.h"
|
#include "scenes/subrem_scene.h"
|
||||||
|
|
||||||
#include <subghz_remote_new_icons.h> // TODO:
|
|
||||||
#include <gui/gui.h>
|
#include <gui/gui.h>
|
||||||
#include <gui/view_dispatcher.h>
|
#include <gui/view_dispatcher.h>
|
||||||
#include <gui/scene_manager.h>
|
#include <gui/scene_manager.h>
|
||||||
@@ -18,21 +18,16 @@
|
|||||||
#include <storage/storage.h>
|
#include <storage/storage.h>
|
||||||
#include <gui/modules/popup.h>
|
#include <gui/modules/popup.h>
|
||||||
|
|
||||||
|
#include <lib/subghz/protocols/raw.h>
|
||||||
|
|
||||||
#include <lib/subghz/subghz_setting.h>
|
#include <lib/subghz/subghz_setting.h>
|
||||||
#include <lib/subghz/receiver.h>
|
#include <lib/subghz/receiver.h>
|
||||||
#include <lib/subghz/transmitter.h>
|
#include <lib/subghz/transmitter.h>
|
||||||
|
|
||||||
#include <flipper_format/flipper_format_i.h> // FIXME:
|
#include <flipper_format/flipper_format_i.h> // FIXME:
|
||||||
|
|
||||||
// #include "views/subghz_remote_view_programmer.h"
|
#define SUBREM_APP_FOLDER ANY_PATH("subghz_remote")
|
||||||
// #include "views/subghz_remote_view_reader.h"
|
|
||||||
// #include "views/subghz_remote_view_writer.h"
|
|
||||||
// #include "views/subghz_remote_view_chip_detect.h"
|
|
||||||
|
|
||||||
#define SUBREM_APP_EXTENSION ".txt"
|
|
||||||
#define SUBREM_APP_FOLDER "/ext/subghz_remote"
|
|
||||||
#define SUBGHZ_REMOTE_MAX_LEN_NAME 64
|
#define SUBGHZ_REMOTE_MAX_LEN_NAME 64
|
||||||
#define SUBREM_MAX_SUB_KEY_COUNT (5U)
|
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
uint32_t frequency;
|
uint32_t frequency;
|
||||||
@@ -46,7 +41,7 @@ typedef struct {
|
|||||||
FuriString* file_path;
|
FuriString* file_path;
|
||||||
FuriString* protocaol_name;
|
FuriString* protocaol_name;
|
||||||
FuriString* label;
|
FuriString* label;
|
||||||
SubRemSubKeyType type;
|
SubGhzProtocolType type;
|
||||||
} SubRemSubFilePreset;
|
} SubRemSubFilePreset;
|
||||||
|
|
||||||
SubRemSubFilePreset* subrem_sub_file_preset_alloc();
|
SubRemSubFilePreset* subrem_sub_file_preset_alloc();
|
||||||
@@ -68,22 +63,25 @@ typedef struct {
|
|||||||
|
|
||||||
SubRemViewRemote* subrem_remote_view;
|
SubRemViewRemote* subrem_remote_view;
|
||||||
|
|
||||||
SubRemSubFilePreset* subs_preset[SUBREM_MAX_SUB_KEY_COUNT];
|
SubRemSubFilePreset* subs_preset[SubRemSubKeyNameMaxCount];
|
||||||
|
|
||||||
SubGhzSetting* setting;
|
SubGhzSetting* setting;
|
||||||
SubGhzEnvironment* environment;
|
SubGhzEnvironment* environment;
|
||||||
SubGhzReceiver* receiver;
|
SubGhzReceiver* receiver;
|
||||||
SubGhzTransmitter* transmitter;
|
SubGhzTransmitter* transmitter;
|
||||||
|
|
||||||
// AvrIspProgrammerView* subghz_remote_programmer_view;
|
bool tx_running;
|
||||||
// AvrIspReaderView* subghz_remote_reader_view;
|
|
||||||
// AvrIspWriterView* subghz_remote_writer_view;
|
|
||||||
// AvrIspChipDetectView* subghz_remote_chip_detect_view;
|
|
||||||
|
|
||||||
// AvrIspError error;
|
uint8_t chusen_sub;
|
||||||
|
|
||||||
|
// TODO: LoadFileError
|
||||||
} SubGhzRemoteApp;
|
} SubGhzRemoteApp;
|
||||||
|
|
||||||
bool subrem_load_from_file(SubGhzRemoteApp* app);
|
bool subrem_load_from_file(SubGhzRemoteApp* app);
|
||||||
|
|
||||||
bool subghz_tx_start_sub(SubGhzRemoteApp* app, SubRemSubFilePreset* sub_preset);
|
bool subghz_tx_start_sub(
|
||||||
void subghz_tx_stop_sub(SubGhzRemoteApp* app, SubRemSubFilePreset* sub_preset);
|
SubGhzRemoteApp* app,
|
||||||
|
SubRemSubFilePreset* sub_preset,
|
||||||
|
SubGhzProtocolEncoderRAWCallbackEnd callback);
|
||||||
|
|
||||||
|
bool subghz_tx_stop_sub(SubGhzRemoteApp* app, bool forced);
|
||||||
@@ -1,27 +1,18 @@
|
|||||||
#include "transmitter.h"
|
#include "remote.h"
|
||||||
#include "../subghz_remote_app_i.h"
|
#include "../subghz_remote_app_i.h"
|
||||||
|
|
||||||
#include <input/input.h>
|
#include <input/input.h>
|
||||||
#include <gui/elements.h>
|
#include <gui/elements.h>
|
||||||
|
|
||||||
#define SUBREM_VIEW_REMOTE_MAX_LABEL_LENGTH 16
|
#define SUBREM_VIEW_REMOTE_MAX_LABEL_LENGTH 16
|
||||||
|
|
||||||
struct SubRemViewRemote {
|
struct SubRemViewRemote {
|
||||||
View* view;
|
View* view;
|
||||||
SubRemViewRemoteCallback callback;
|
SubRemViewRemoteCallback callback;
|
||||||
void* context;
|
void* context;
|
||||||
};
|
};
|
||||||
// FIXME: drop
|
|
||||||
// static char* char_to_str(char* str, int i) {
|
|
||||||
// char* converted = malloc(sizeof(char) * i + 1);
|
|
||||||
// memcpy(converted, str, i);
|
|
||||||
|
|
||||||
// converted[i] = '\0';
|
|
||||||
|
|
||||||
// return converted;
|
|
||||||
// }
|
|
||||||
|
|
||||||
// TODO: model
|
// TODO: model
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
// FuriString* up_label;
|
// FuriString* up_label;
|
||||||
// FuriString* down_label;
|
// FuriString* down_label;
|
||||||
@@ -35,6 +26,8 @@ typedef struct {
|
|||||||
char* right_label;
|
char* right_label;
|
||||||
char* ok_label;
|
char* ok_label;
|
||||||
|
|
||||||
|
SubRemViewRemoteState state;
|
||||||
|
|
||||||
uint8_t pressed_btn;
|
uint8_t pressed_btn;
|
||||||
// bool show_button;
|
// bool show_button;
|
||||||
// FuriString* temp_button_id;
|
// FuriString* temp_button_id;
|
||||||
@@ -70,12 +63,6 @@ void subrem_view_remote_add_data_to_show(
|
|||||||
strncpy(model->right_label, right_label, SUBREM_VIEW_REMOTE_MAX_LABEL_LENGTH);
|
strncpy(model->right_label, right_label, SUBREM_VIEW_REMOTE_MAX_LABEL_LENGTH);
|
||||||
strncpy(model->ok_label, ok_label, SUBREM_VIEW_REMOTE_MAX_LABEL_LENGTH);
|
strncpy(model->ok_label, ok_label, SUBREM_VIEW_REMOTE_MAX_LABEL_LENGTH);
|
||||||
|
|
||||||
// model->up_label = char_to_str((char*)up_label, 16);
|
|
||||||
// model->down_label = char_to_str((char*)down_label, 16);
|
|
||||||
// model->left_label = char_to_str((char*)left_label, 16);
|
|
||||||
// model->right_label = char_to_str((char*)right_label, 16);
|
|
||||||
// model->ok_label = char_to_str((char*)ok_label, 16);
|
|
||||||
|
|
||||||
// furi_string_set(model->up_label, up_label);
|
// furi_string_set(model->up_label, up_label);
|
||||||
// furi_string_set(model->down_label, down_label);
|
// furi_string_set(model->down_label, down_label);
|
||||||
// furi_string_set(model->left_label, left_label);
|
// furi_string_set(model->left_label, left_label);
|
||||||
@@ -85,6 +72,23 @@ void subrem_view_remote_add_data_to_show(
|
|||||||
true);
|
true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void subrem_view_remote_set_presed_btn(SubRemViewRemote* subrem_view_remote, uint8_t presed_btn) {
|
||||||
|
furi_assert(subrem_view_remote);
|
||||||
|
with_view_model(
|
||||||
|
subrem_view_remote->view,
|
||||||
|
SubRemViewRemoteModel * model,
|
||||||
|
{ model->pressed_btn = presed_btn; },
|
||||||
|
true);
|
||||||
|
}
|
||||||
|
|
||||||
|
void subrem_view_remote_set_state(
|
||||||
|
SubRemViewRemote* subrem_view_remote,
|
||||||
|
SubRemViewRemoteState state) {
|
||||||
|
furi_assert(subrem_view_remote);
|
||||||
|
with_view_model(
|
||||||
|
subrem_view_remote->view, SubRemViewRemoteModel * model, { model->state = state; }, true);
|
||||||
|
}
|
||||||
|
|
||||||
void subrem_view_remote_draw(Canvas* canvas, SubRemViewRemoteModel* model) {
|
void subrem_view_remote_draw(Canvas* canvas, SubRemViewRemoteModel* model) {
|
||||||
canvas_clear(canvas);
|
canvas_clear(canvas);
|
||||||
canvas_set_color(canvas, ColorBlack);
|
canvas_set_color(canvas, ColorBlack);
|
||||||
@@ -126,29 +130,44 @@ void subrem_view_remote_draw(Canvas* canvas, SubRemViewRemoteModel* model) {
|
|||||||
canvas_draw_str_aligned(canvas, 11, 62, AlignLeft, AlignBottom, "Hold=Exit.");
|
canvas_draw_str_aligned(canvas, 11, 62, AlignLeft, AlignBottom, "Hold=Exit.");
|
||||||
|
|
||||||
//Status text and indicator
|
//Status text and indicator
|
||||||
// canvas_draw_str_aligned(canvas, 126, 10, AlignRight, AlignBottom, app->send_status);
|
|
||||||
|
//canvas_draw_str_aligned(canvas, 126, 10, AlignRight, AlignBottom, model->state);
|
||||||
|
|
||||||
canvas_draw_icon(canvas, 113, 15, &I_Pin_cell_13x13);
|
canvas_draw_icon(canvas, 113, 15, &I_Pin_cell_13x13);
|
||||||
switch(model->pressed_btn) {
|
|
||||||
case 0:
|
if(model->state == SubRemViewRemoteStateIdle) {
|
||||||
|
canvas_draw_str_aligned(canvas, 126, 10, AlignRight, AlignBottom, "Idle");
|
||||||
|
} else {
|
||||||
|
switch(model->state) {
|
||||||
|
case SubRemViewRemoteStateSending:
|
||||||
|
canvas_draw_str_aligned(canvas, 126, 10, AlignRight, AlignBottom, "Send");
|
||||||
break;
|
break;
|
||||||
case 1:
|
case SubRemViewRemoteStateLoading:
|
||||||
canvas_draw_icon(canvas, 116, 17, &I_Pin_arrow_up_7x9);
|
canvas_draw_str_aligned(canvas, 126, 10, AlignRight, AlignBottom, "Load");
|
||||||
break;
|
break;
|
||||||
case 2:
|
default:
|
||||||
canvas_draw_icon_ex(canvas, 116, 17, &I_Pin_arrow_up_7x9, IconRotation180);
|
canvas_draw_str_aligned(canvas, 126, 10, AlignRight, AlignBottom, "Idle");
|
||||||
break;
|
|
||||||
case 3:
|
|
||||||
canvas_draw_icon_ex(canvas, 115, 18, &I_Pin_arrow_up_7x9, IconRotation90);
|
|
||||||
break;
|
|
||||||
case 4:
|
|
||||||
canvas_draw_icon_ex(canvas, 115, 18, &I_Pin_arrow_up_7x9, IconRotation270);
|
|
||||||
break;
|
|
||||||
case 5:
|
|
||||||
canvas_draw_icon(canvas, 116, 18, &I_Pin_star_7x7);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
switch(model->pressed_btn) {
|
||||||
|
case SubRemSubKeyNameUp:
|
||||||
|
canvas_draw_icon(canvas, 116, 17, &I_Pin_arrow_up_7x9);
|
||||||
|
break;
|
||||||
|
case SubRemSubKeyNameDown:
|
||||||
|
canvas_draw_icon_ex(canvas, 116, 17, &I_Pin_arrow_up_7x9, IconRotation180);
|
||||||
|
break;
|
||||||
|
case SubRemSubKeyNameLeft:
|
||||||
|
canvas_draw_icon_ex(canvas, 115, 18, &I_Pin_arrow_up_7x9, IconRotation270);
|
||||||
|
break;
|
||||||
|
case SubRemSubKeyNameRight:
|
||||||
|
canvas_draw_icon_ex(canvas, 115, 18, &I_Pin_arrow_up_7x9, IconRotation90);
|
||||||
|
break;
|
||||||
|
case SubRemSubKeyNameOk:
|
||||||
|
canvas_draw_icon(canvas, 116, 18, &I_Pin_star_7x7);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
//Repeat indicator
|
//Repeat indicator
|
||||||
//canvas_draw_str_aligned(canvas, 125, 40, AlignRight, AlignBottom, "Repeat:");
|
//canvas_draw_str_aligned(canvas, 125, 40, AlignRight, AlignBottom, "Repeat:");
|
||||||
//canvas_draw_icon(canvas, 115, 39, &I_SubGHzRemote_Repeat_12x14);
|
//canvas_draw_icon(canvas, 115, 39, &I_SubGHzRemote_Repeat_12x14);
|
||||||
@@ -160,6 +179,7 @@ bool subrem_view_remote_input(InputEvent* event, void* context) {
|
|||||||
SubRemViewRemote* subrem_view_remote = context;
|
SubRemViewRemote* subrem_view_remote = context;
|
||||||
|
|
||||||
if(event->key == InputKeyBack && event->type == InputTypeLong) {
|
if(event->key == InputKeyBack && event->type == InputTypeLong) {
|
||||||
|
// TODO: remove reset Debug
|
||||||
with_view_model(
|
with_view_model(
|
||||||
subrem_view_remote->view,
|
subrem_view_remote->view,
|
||||||
SubRemViewRemoteModel * model,
|
SubRemViewRemoteModel * model,
|
||||||
@@ -177,28 +197,47 @@ bool subrem_view_remote_input(InputEvent* event, void* context) {
|
|||||||
// furi_string_reset(model->ok_label);
|
// furi_string_reset(model->ok_label);
|
||||||
},
|
},
|
||||||
false);
|
false);
|
||||||
return false;
|
subrem_view_remote->callback(SubRemCustomEventViewRemoteBack, subrem_view_remote->context);
|
||||||
} else if(event->key == InputKeyUp) {
|
|
||||||
if(event->type == InputTypePress) {
|
|
||||||
with_view_model(
|
|
||||||
subrem_view_remote->view,
|
|
||||||
SubRemViewRemoteModel * model,
|
|
||||||
{ model->pressed_btn = 1; },
|
|
||||||
true);
|
|
||||||
subrem_view_remote->callback(
|
|
||||||
SubRemCustomEventViewRemoteStartUP, subrem_view_remote->context);
|
|
||||||
return true;
|
return true;
|
||||||
} else if(event->type == InputTypeRelease) {
|
} else if(event->key == InputKeyBack && event->type == InputTypeShort) {
|
||||||
with_view_model(
|
with_view_model(
|
||||||
subrem_view_remote->view,
|
subrem_view_remote->view,
|
||||||
SubRemViewRemoteModel * model,
|
SubRemViewRemoteModel * model,
|
||||||
{ model->pressed_btn = 0; },
|
{ model->pressed_btn = 0; },
|
||||||
true);
|
true);
|
||||||
subrem_view_remote->callback(
|
subrem_view_remote->callback(
|
||||||
SubRemCustomEventViewRemoteStop, subrem_view_remote->context);
|
SubRemCustomEventViewRemoteForcedStop, subrem_view_remote->context);
|
||||||
|
return true;
|
||||||
|
} else if(event->key == InputKeyBack) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
// BACK button processing end
|
||||||
|
|
||||||
|
if(event->key == InputKeyUp && event->type == InputTypePress) {
|
||||||
|
subrem_view_remote->callback(
|
||||||
|
SubRemCustomEventViewRemoteStartUP, subrem_view_remote->context);
|
||||||
|
return true;
|
||||||
|
} else if(event->key == InputKeyDown && event->type == InputTypePress) {
|
||||||
|
subrem_view_remote->callback(
|
||||||
|
SubRemCustomEventViewRemoteStartDOWN, subrem_view_remote->context);
|
||||||
|
return true;
|
||||||
|
} else if(event->key == InputKeyLeft && event->type == InputTypePress) {
|
||||||
|
subrem_view_remote->callback(
|
||||||
|
SubRemCustomEventViewRemoteStartLEFT, subrem_view_remote->context);
|
||||||
|
return true;
|
||||||
|
} else if(event->key == InputKeyRight && event->type == InputTypePress) {
|
||||||
|
subrem_view_remote->callback(
|
||||||
|
SubRemCustomEventViewRemoteStartRIGHT, subrem_view_remote->context);
|
||||||
|
return true;
|
||||||
|
} else if(event->key == InputKeyOk && event->type == InputTypePress) {
|
||||||
|
subrem_view_remote->callback(
|
||||||
|
SubRemCustomEventViewRemoteStartOK, subrem_view_remote->context);
|
||||||
|
return true;
|
||||||
|
} else if(event->type == InputTypeRelease) {
|
||||||
|
subrem_view_remote->callback(SubRemCustomEventViewRemoteStop, subrem_view_remote->context);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -227,6 +266,8 @@ SubRemViewRemote* subrem_view_remote_alloc() {
|
|||||||
subrem_view_remote->view,
|
subrem_view_remote->view,
|
||||||
SubRemViewRemoteModel * model,
|
SubRemViewRemoteModel * model,
|
||||||
{
|
{
|
||||||
|
model->state = SubRemViewRemoteStateIdle;
|
||||||
|
|
||||||
model->up_label = malloc(sizeof(char) * SUBREM_VIEW_REMOTE_MAX_LABEL_LENGTH + 1);
|
model->up_label = malloc(sizeof(char) * SUBREM_VIEW_REMOTE_MAX_LABEL_LENGTH + 1);
|
||||||
model->down_label = malloc(sizeof(char) * SUBREM_VIEW_REMOTE_MAX_LABEL_LENGTH + 1);
|
model->down_label = malloc(sizeof(char) * SUBREM_VIEW_REMOTE_MAX_LABEL_LENGTH + 1);
|
||||||
model->left_label = malloc(sizeof(char) * SUBREM_VIEW_REMOTE_MAX_LABEL_LENGTH + 1);
|
model->left_label = malloc(sizeof(char) * SUBREM_VIEW_REMOTE_MAX_LABEL_LENGTH + 1);
|
||||||
@@ -3,6 +3,12 @@
|
|||||||
#include <gui/view.h>
|
#include <gui/view.h>
|
||||||
#include "../helpers/subrem_custom_event.h"
|
#include "../helpers/subrem_custom_event.h"
|
||||||
|
|
||||||
|
typedef enum {
|
||||||
|
SubRemViewRemoteStateIdle,
|
||||||
|
SubRemViewRemoteStateLoading,
|
||||||
|
SubRemViewRemoteStateSending,
|
||||||
|
} SubRemViewRemoteState;
|
||||||
|
|
||||||
typedef struct SubRemViewRemote SubRemViewRemote;
|
typedef struct SubRemViewRemote SubRemViewRemote;
|
||||||
|
|
||||||
typedef void (*SubRemViewRemoteCallback)(SubRemCustomEvent event, void* context);
|
typedef void (*SubRemViewRemoteCallback)(SubRemCustomEvent event, void* context);
|
||||||
@@ -25,3 +31,8 @@ void subrem_view_remote_add_data_to_show(
|
|||||||
const char* left_label,
|
const char* left_label,
|
||||||
const char* right_label,
|
const char* right_label,
|
||||||
const char* ok_label);
|
const char* ok_label);
|
||||||
|
|
||||||
|
void subrem_view_remote_set_presed_btn(SubRemViewRemote* subrem_view_remote, uint8_t presed_btn);
|
||||||
|
void subrem_view_remote_set_state(
|
||||||
|
SubRemViewRemote* subrem_view_remote,
|
||||||
|
SubRemViewRemoteState state);
|
||||||
Reference in New Issue
Block a user