mirror of
https://github.com/Next-Flip/Momentum-Firmware.git
synced 2026-05-22 05:14:46 -07:00
updated protoview
This commit is contained in:
@@ -13,17 +13,19 @@ void raw_sampling_worker_start(ProtoViewApp *app);
|
||||
void raw_sampling_worker_stop(ProtoViewApp *app);
|
||||
|
||||
ProtoViewModulation ProtoViewModulations[] = {
|
||||
{"OOK 650Khz", FuriHalSubGhzPresetOok650Async, NULL},
|
||||
{"OOK 270Khz", FuriHalSubGhzPresetOok270Async, NULL},
|
||||
{"2FSK 2.38Khz", FuriHalSubGhzPreset2FSKDev238Async, NULL},
|
||||
{"2FSK 47.6Khz", FuriHalSubGhzPreset2FSKDev476Async, NULL},
|
||||
{"MSK", FuriHalSubGhzPresetMSK99_97KbAsync, NULL},
|
||||
{"GFSK", FuriHalSubGhzPresetGFSK9_99KbAsync, NULL},
|
||||
{"TPMS 1 (FSK)", 0, (uint8_t*)protoview_subghz_tpms1_fsk_async_regs},
|
||||
{"TPMS 2 (OOK)", 0, (uint8_t*)protoview_subghz_tpms2_ook_async_regs},
|
||||
{"TPMS 3 (FSK)", 0, (uint8_t*)protoview_subghz_tpms3_fsk_async_regs},
|
||||
{"TPMS 4 (FSK)", 0, (uint8_t*)protoview_subghz_tpms4_fsk_async_regs},
|
||||
{NULL, 0, NULL} /* End of list sentinel. */
|
||||
{"OOK 650Khz", "FuriHalSubGhzPresetOok650Async",
|
||||
FuriHalSubGhzPresetOok650Async, NULL},
|
||||
{"OOK 270Khz", "FuriHalSubGhzPresetOok270Async",
|
||||
FuriHalSubGhzPresetOok270Async, NULL},
|
||||
{"2FSK 2.38Khz", "FuriHalSubGhzPreset2FSKDev238Async",
|
||||
FuriHalSubGhzPreset2FSKDev238Async, NULL},
|
||||
{"2FSK 47.6Khz", "FuriHalSubGhzPreset2FSKDev476Async",
|
||||
FuriHalSubGhzPreset2FSKDev476Async, NULL},
|
||||
{"TPMS 1 (FSK)", NULL, 0, (uint8_t*)protoview_subghz_tpms1_fsk_async_regs},
|
||||
{"TPMS 2 (OOK)", NULL, 0, (uint8_t*)protoview_subghz_tpms2_ook_async_regs},
|
||||
{"TPMS 3 (FSK)", NULL, 0, (uint8_t*)protoview_subghz_tpms3_fsk_async_regs},
|
||||
{"TPMS 4 (FSK)", NULL, 0, (uint8_t*)protoview_subghz_tpms4_fsk_async_regs},
|
||||
{NULL, NULL, 0, NULL} /* End of list sentinel. */
|
||||
};
|
||||
|
||||
/* Called after the application initialization in order to setup the
|
||||
@@ -35,17 +37,26 @@ void radio_begin(ProtoViewApp* app) {
|
||||
furi_hal_subghz_reset();
|
||||
furi_hal_subghz_idle();
|
||||
|
||||
/* Power circuits are noisy. Suppressing the charge while we use
|
||||
* ProtoView will improve the RF performances. */
|
||||
furi_hal_power_suppress_charge_enter();
|
||||
|
||||
/* The CC1101 preset can be either one of the standard presets, if
|
||||
* the modulation "custom" field is NULL, or a custom preset we
|
||||
* defined in custom_presets.h. */
|
||||
if (ProtoViewModulations[app->modulation].custom == NULL)
|
||||
furi_hal_subghz_load_preset(ProtoViewModulations[app->modulation].preset);
|
||||
else
|
||||
furi_hal_subghz_load_custom_preset(ProtoViewModulations[app->modulation].custom);
|
||||
if (ProtoViewModulations[app->modulation].custom == NULL) {
|
||||
furi_hal_subghz_load_preset(
|
||||
ProtoViewModulations[app->modulation].preset);
|
||||
} else {
|
||||
furi_hal_subghz_load_custom_preset(
|
||||
ProtoViewModulations[app->modulation].custom);
|
||||
}
|
||||
furi_hal_gpio_init(&gpio_cc1101_g0, GpioModeInput, GpioPullNo, GpioSpeedLow);
|
||||
app->txrx->txrx_state = TxRxStateIDLE;
|
||||
}
|
||||
|
||||
/* ================================= Reception ============================== */
|
||||
|
||||
/* Setup subghz to start receiving using a background worker. */
|
||||
uint32_t radio_rx(ProtoViewApp* app) {
|
||||
furi_assert(app);
|
||||
@@ -76,6 +87,7 @@ uint32_t radio_rx(ProtoViewApp* app) {
|
||||
/* Stop subghz worker (if active), put radio on idle state. */
|
||||
void radio_rx_end(ProtoViewApp* app) {
|
||||
furi_assert(app);
|
||||
|
||||
if (app->txrx->txrx_state == TxRxStateRx) {
|
||||
if (!app->txrx->debug_timer_sampling) {
|
||||
if(subghz_worker_is_running(app->txrx->worker)) {
|
||||
@@ -100,6 +112,33 @@ void radio_sleep(ProtoViewApp* app) {
|
||||
}
|
||||
furi_hal_subghz_sleep();
|
||||
app->txrx->txrx_state = TxRxStateSleep;
|
||||
furi_hal_power_suppress_charge_exit();
|
||||
}
|
||||
|
||||
/* =============================== Transmission ============================= */
|
||||
|
||||
/* This function suspends the current RX state, switches to TX mode,
|
||||
* transmits the signal provided by the callback data_feeder, and later
|
||||
* restores the RX state if there was one. */
|
||||
void radio_tx_signal(ProtoViewApp *app, FuriHalSubGhzAsyncTxCallback data_feeder, void *ctx) {
|
||||
TxRxState oldstate = app->txrx->txrx_state;
|
||||
|
||||
if (oldstate == TxRxStateRx) radio_rx_end(app);
|
||||
radio_begin(app);
|
||||
|
||||
furi_hal_subghz_idle();
|
||||
uint32_t value = furi_hal_subghz_set_frequency_and_path(app->frequency);
|
||||
FURI_LOG_E(TAG, "Switched to frequency: %lu", value);
|
||||
furi_hal_gpio_write(&gpio_cc1101_g0, false);
|
||||
furi_hal_gpio_init(&gpio_cc1101_g0, GpioModeOutputPushPull, GpioPullNo, GpioSpeedLow);
|
||||
|
||||
furi_hal_subghz_start_async_tx(data_feeder, ctx);
|
||||
while(!furi_hal_subghz_is_async_tx_complete()) furi_delay_ms(10);
|
||||
furi_hal_subghz_stop_async_tx();
|
||||
furi_hal_subghz_idle();
|
||||
|
||||
radio_begin(app);
|
||||
if (oldstate == TxRxStateRx) radio_rx(app);
|
||||
}
|
||||
|
||||
/* ============================= Raw sampling mode =============================
|
||||
|
||||
Reference in New Issue
Block a user