mirror of
https://github.com/eried/portapack-mayhem.git
synced 2024-10-01 01:26:06 -04:00
2ccda5aebd
* Initial commit - wip
* Half part of the transition of baseband processor.
* More SGD
* WIP, Weather refactor, UI improv
* Rename
* Added 4msps, and fixes
* Fixes
* princeton working
* Renamed proc_weather, bc now multifunctional
* Proto: bett
* FPS_CAME = 4,
FPS_PRASTEL = 5,
FPS_AIRFORCE = 6,
* Came Atomo, fixes
* Separate weather and sgd, bc of baseband size limit
* Fix display
* Save space
* More protos
* Dooya proto added
* More protos
* add protos
* More protos
* Move weather to ext app
* nw
* Revert "Move weather to ext app"
This reverts commit 8a84aac2f5
.
* revert
* Fix merge
* Better naming
* More protos
* More protos
* Add protos
* Fix warning
* Add NeroRadio
* more protos
* more protos
* More protos
* Shrink a bit
* fixes
* More protos
* Nicer code
* Fix naming
* Fix format
* Remove unused
* Fix some protos, that needs a LOOOONG part with the same lo/high
* Modify key calculation
87 lines
3.3 KiB
C++
87 lines
3.3 KiB
C++
|
|
#ifndef __FPROTO_MARANTEC_H__
|
|
#define __FPROTO_MARANTEC_H__
|
|
|
|
#include "subghzdbase.hpp"
|
|
|
|
typedef enum : uint8_t {
|
|
MarantecDecoderStepReset = 0,
|
|
MarantecDecoderFoundHeader,
|
|
MarantecDecoderStepDecoderData,
|
|
} MarantecDecoderStep;
|
|
|
|
class FProtoSubGhzDMarantec : public FProtoSubGhzDBase {
|
|
public:
|
|
FProtoSubGhzDMarantec() {
|
|
sensorType = FPS_MARANTEC;
|
|
te_short = 1000;
|
|
te_long = 2000;
|
|
te_delta = 200;
|
|
min_count_bit_for_found = 49;
|
|
}
|
|
|
|
void feed(bool level, uint32_t duration) {
|
|
ManchesterEvent event = ManchesterEventReset;
|
|
|
|
switch (parser_step) {
|
|
case MarantecDecoderStepReset:
|
|
if ((!level) && (DURATION_DIFF(duration, te_long * 5) < te_delta * 8)) {
|
|
// Found header marantec
|
|
parser_step = MarantecDecoderStepDecoderData;
|
|
decode_data = 1;
|
|
decode_count_bit = 1;
|
|
FProtoGeneral::manchester_advance(manchester_saved_state, ManchesterEventReset, &manchester_saved_state, NULL);
|
|
}
|
|
break;
|
|
case MarantecDecoderStepDecoderData:
|
|
if (!level) {
|
|
if (DURATION_DIFF(duration, te_short) < te_delta) {
|
|
event = ManchesterEventShortLow;
|
|
} else if (
|
|
DURATION_DIFF(duration, te_long) < te_delta) {
|
|
event = ManchesterEventLongLow;
|
|
} else if (
|
|
duration >= ((uint32_t)te_long * 2 + te_delta)) {
|
|
if (decode_count_bit == min_count_bit_for_found) {
|
|
data = decode_data;
|
|
data_count_bit = decode_count_bit;
|
|
// controller
|
|
btn = (data >> 16) & 0xF;
|
|
serial = ((data >> 12) & 0xFFFFFF00) | ((data >> 8) & 0xFF);
|
|
if (callback) callback(this);
|
|
}
|
|
decode_data = 1;
|
|
decode_count_bit = 1;
|
|
FProtoGeneral::manchester_advance(manchester_saved_state, ManchesterEventReset, &manchester_saved_state, NULL);
|
|
} else {
|
|
parser_step = MarantecDecoderStepReset;
|
|
}
|
|
} else {
|
|
if (DURATION_DIFF(duration, te_short) < te_delta) {
|
|
event = ManchesterEventShortHigh;
|
|
} else if (
|
|
DURATION_DIFF(duration, te_long) < te_delta) {
|
|
event = ManchesterEventLongHigh;
|
|
} else {
|
|
parser_step = MarantecDecoderStepReset;
|
|
}
|
|
}
|
|
if (event != ManchesterEventReset) {
|
|
bool bitstate;
|
|
bool data_ok = FProtoGeneral::manchester_advance(manchester_saved_state, event, &manchester_saved_state, &bitstate);
|
|
|
|
if (data_ok) {
|
|
decode_data = (decode_data << 1) | bitstate;
|
|
decode_count_bit++;
|
|
}
|
|
}
|
|
break;
|
|
}
|
|
}
|
|
|
|
protected:
|
|
ManchesterState manchester_saved_state = ManchesterStateMid1;
|
|
};
|
|
|
|
#endif
|