From b601afb997ac2f14285105b4fed64eecedf414b5 Mon Sep 17 00:00:00 2001 From: r3df0xx Date: Sun, 3 Apr 2022 14:49:22 +0300 Subject: [PATCH] Update nice_flor_s.c --- lib/subghz/protocols/nice_flor_s.c | 29 ++++++++--------------------- 1 file changed, 8 insertions(+), 21 deletions(-) diff --git a/lib/subghz/protocols/nice_flor_s.c b/lib/subghz/protocols/nice_flor_s.c index ce6717034..54f8cd9d9 100644 --- a/lib/subghz/protocols/nice_flor_s.c +++ b/lib/subghz/protocols/nice_flor_s.c @@ -113,7 +113,7 @@ void subghz_protocol_encoder_nice_flor_s_free(void* context) { * @param instance Pointer to a SubGhzProtocolEncoderNiceFlorS instance * @return true On success */ -static bool +static void subghz_protocol_encoder_nice_flor_s_get_upload(SubGhzProtocolEncoderNiceFlorS* instance, uint8_t btn, const char* file_name) { furi_assert(instance); size_t index = 0; @@ -122,7 +122,6 @@ static bool size_t size_upload = (instance->generic.data_count_bit * 2) + ((35 + 2 + 2) * 2); if(size_upload > instance->encoder.size_upload) { FURI_LOG_E(TAG, "Size upload exceeds allocated encoder buffer."); - return false; } else { instance->encoder.size_upload = size_upload; } @@ -142,41 +141,29 @@ static bool for (int i = 0; i < 16; i++) { - static const uint64_t loops[4][32] = { - - { 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8, 0x9, 0xA, 0xB, 0xC, 0xD, 0xE, 0xF, 0x0, - 0xE, 0xF, 0xC, 0xD, 0xA, 0xB, 0x8, 0x9, 0x6, 0x7, 0x4, 0x5, 0x2, 0x3, 0x0, 0x1 }, - - { 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8, 0x9, 0xA, 0xB, 0xC, 0xD, 0xE, 0xF, 0x0, - 0xD, 0xC, 0xF, 0xE, 0x9, 0x8, 0xB, 0xA, 0x5, 0x4, 0x7, 0x6, 0x1, 0x0, 0x3, 0x2 }, - - { 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8, 0x9, 0xA, 0xB, 0xC, 0xD, 0xE, 0xF, 0x0, - 0xB, 0xA, 0x9, 0x8, 0xF, 0xE, 0xD, 0xC, 0x3, 0x2, 0x1, 0x0, 0x7, 0x6, 0x5, 0x4 }, - - { 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8, 0x9, 0xA, 0xB, 0xC, 0xD, 0xE, 0xF, 0x0, - 0x7, 0x6, 0x5, 0x4, 0x3, 0x2, 0x1, 0x0, 0xF, 0xE, 0xD, 0xC, 0xB, 0xA, 0x9, 0x8 } - }; + static const uint64_t loops[16] = { + 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8, 0x9, 0xA, 0xB, 0xC, 0xD, 0xE, 0xF, 0x0}; uint8_t byte; if (btn == 0x1) { //Button 1 - byte = btn << 4 | (0xF ^ btn ^ loops[0][i]); + byte = btn << 4 | (0xF ^ btn ^ loops[i]); instance->generic.data = (uint64_t)byte << 44 | enc_part; } if (btn == 0x2) { //Button 2 - byte = btn << 4 | (0xF ^ btn ^ loops[1][i]); + byte = btn << 4 | (0xF ^ btn ^ loops[i]); instance->generic.data = (uint64_t)byte << 44 | enc_part; } if (btn == 0x4) { //Button 3 - byte = btn << 4 | (0xF ^ btn ^ loops[2][i]); + byte = btn << 4 | (0xF ^ btn ^ loops[i]); instance->generic.data = (uint64_t)byte << 44 | enc_part; } if (btn == 0x8) { //Button 4 - byte = btn << 4 | (0xF ^ btn ^ loops[3][i]); + byte = btn << 4 | (0xF ^ btn ^ loops[i]); instance->generic.data = (uint64_t)byte << 44 | enc_part; } hi = instance->generic.data >> 32; @@ -216,7 +203,7 @@ static bool instance->encoder.upload[index++] = level_duration_make(false, (uint32_t)subghz_protocol_nice_flor_s_const.te_short * 3); } - return true; + instance->encoder.size_upload = index; } bool subghz_protocol_encoder_nice_flor_s_deserialize(void* context, FlipperFormat* flipper_format) {