mirror of
https://github.com/portapack-mayhem/mayhem-firmware.git
synced 2026-08-21 06:59:02 +00:00
Holtek HT6P20B support for SubGhzD (#2941)
This commit is contained in:
@@ -242,6 +242,8 @@ const char* SubGhzDView::getSensorTypeName(FPROTO_SUBGHZD_SENSOR type) {
|
||||
return "GangQi";
|
||||
case FPS_MARANTEC24:
|
||||
return "Marantec24";
|
||||
case FPS_HOLTEKHT6P20B:
|
||||
return "Holtek HT6P20B";
|
||||
case FPS_Invalid:
|
||||
default:
|
||||
return "Unknown";
|
||||
@@ -756,5 +758,11 @@ void SubGhzDRecentEntryDetailView::parseProtocol() {
|
||||
btn = entry_.data & 0xf;
|
||||
return;
|
||||
}
|
||||
|
||||
if (entry_.sensorType == FPS_HOLTEKHT6P20B) {
|
||||
serial = entry_.data >> 8;
|
||||
btn = (entry_.data >> 4) & 0xF;
|
||||
return;
|
||||
}
|
||||
}
|
||||
} // namespace ui
|
||||
} // namespace ui
|
||||
|
||||
@@ -0,0 +1,84 @@
|
||||
|
||||
#ifndef __FPROTO_HOLTEKHT6P20B_H__
|
||||
#define __FPROTO_HOLTEKHT6P20B_H__
|
||||
|
||||
#include "subghzdbase.hpp"
|
||||
|
||||
typedef enum : uint8_t {
|
||||
Holtek_HT6P20BDecoderStepReset = 0,
|
||||
Holtek_HT6P20BDecoderStepFoundStartBit,
|
||||
Holtek_HT6P20BDecoderStepSaveDuration,
|
||||
Holtek_HT6P20BDecoderStepCheckDuration,
|
||||
} Holtek_HT6P20BDecoderStep;
|
||||
|
||||
class FProtoSubGhzDHoltekHt6p20b : public FProtoSubGhzDBase {
|
||||
public:
|
||||
FProtoSubGhzDHoltekHt6p20b() {
|
||||
sensorType = FPS_HOLTEKHT6P20B;
|
||||
te_short = 450;
|
||||
te_long = 900;
|
||||
te_delta = 270;
|
||||
min_count_bit_for_found = 28;
|
||||
}
|
||||
|
||||
void feed(bool level, uint32_t duration) {
|
||||
switch (parser_step) {
|
||||
case Holtek_HT6P20BDecoderStepReset:
|
||||
if ((!level) && (DURATION_DIFF(duration, te_short * 23) < te_delta * 23)) {
|
||||
// Found Preambula
|
||||
parser_step = Holtek_HT6P20BDecoderStepFoundStartBit;
|
||||
}
|
||||
break;
|
||||
case Holtek_HT6P20BDecoderStepFoundStartBit:
|
||||
if ((level) && (DURATION_DIFF(duration, te_short) < te_delta)) {
|
||||
// Found StartBit
|
||||
parser_step = Holtek_HT6P20BDecoderStepSaveDuration;
|
||||
decode_data = 0;
|
||||
decode_count_bit = 0;
|
||||
} else {
|
||||
parser_step = Holtek_HT6P20BDecoderStepReset;
|
||||
}
|
||||
break;
|
||||
case Holtek_HT6P20BDecoderStepSaveDuration:
|
||||
// save duration
|
||||
if (!level) {
|
||||
if (duration >= ((uint32_t)te_short * 10 + te_delta)) {
|
||||
if (decode_count_bit == min_count_bit_for_found) {
|
||||
data_count_bit = decode_count_bit;
|
||||
if (callback) callback(this);
|
||||
}
|
||||
decode_data = 0;
|
||||
decode_count_bit = 0;
|
||||
parser_step = Holtek_HT6P20BDecoderStepFoundStartBit;
|
||||
break;
|
||||
} else {
|
||||
te_last = duration;
|
||||
parser_step = Holtek_HT6P20BDecoderStepCheckDuration;
|
||||
}
|
||||
} else {
|
||||
parser_step = Holtek_HT6P20BDecoderStepReset;
|
||||
}
|
||||
break;
|
||||
case Holtek_HT6P20BDecoderStepCheckDuration:
|
||||
if (level) {
|
||||
if ((DURATION_DIFF(te_last, te_long) < te_delta * 2) &&
|
||||
(DURATION_DIFF(duration, te_short) < te_delta)) {
|
||||
subghz_protocol_blocks_add_bit(1);
|
||||
parser_step = Holtek_HT6P20BDecoderStepSaveDuration;
|
||||
} else if (
|
||||
(DURATION_DIFF(te_last, te_short) < te_delta) &&
|
||||
(DURATION_DIFF(duration, te_long) < te_delta * 2)) {
|
||||
subghz_protocol_blocks_add_bit(0);
|
||||
parser_step = Holtek_HT6P20BDecoderStepSaveDuration;
|
||||
} else {
|
||||
parser_step = Holtek_HT6P20BDecoderStepReset;
|
||||
}
|
||||
} else {
|
||||
parser_step = Holtek_HT6P20BDecoderStepReset;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -54,6 +54,7 @@ So include here the .hpp, and add a new element to the protos vector in the cons
|
||||
#include "s-gangqi.hpp"
|
||||
#include "s-marantec24.hpp"
|
||||
// GENIE FROM PR
|
||||
#include "s-holtek_ht6p20b.hpp"
|
||||
|
||||
#ifndef __FPROTO_PROTOLISTSGZ_H__
|
||||
#define __FPROTO_PROTOLISTSGZ_H__
|
||||
@@ -107,6 +108,7 @@ class SubGhzDProtos : public FProtoListGeneral {
|
||||
protos[FPS_LEGRAND] = new FProtoSubGhzDLegrand();
|
||||
protos[FPS_GANGQI] = new FProtoSubGhzDGangqi();
|
||||
protos[FPS_MARANTEC24] = new FProtoSubGhzDMarantec24();
|
||||
protos[FPS_HOLTEKHT6P20B] = new FProtoSubGhzDHoltekHt6p20b();
|
||||
|
||||
for (uint8_t i = 0; i < FPS_COUNT; ++i) {
|
||||
if (protos[i] != NULL) protos[i]->setCallback(callbackTarget);
|
||||
|
||||
@@ -58,6 +58,7 @@ enum FPROTO_SUBGHZD_SENSOR : uint8_t {
|
||||
FPS_SOMIFY_TELIS,
|
||||
FPS_GANGQI,
|
||||
FPS_MARANTEC24,
|
||||
FPS_HOLTEKHT6P20B,
|
||||
FPS_COUNT
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user