mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-02-13 18:57:12 +08:00
more directionalThreshold...
This commit is contained in:
parent
16b494fa71
commit
998d752bd5
2 changed files with 33 additions and 27 deletions
|
@ -2397,6 +2397,33 @@ int CmdScale(const char *Cmd)
|
||||||
RepaintGraphWindow();
|
RepaintGraphWindow();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
int directionalThreshold(const int* in, int *out, size_t len, int8_t up, int8_t down)
|
||||||
|
{
|
||||||
|
int lastValue = in[0];
|
||||||
|
out[0] = 0; // Will be changed at the end, but init 0 as we adjust to last samples value if no threshold kicks in.
|
||||||
|
|
||||||
|
for (size_t i = 1; i < len; ++i) {
|
||||||
|
// Apply first threshold to samples heading up
|
||||||
|
if (in[i] >= up && in[i] > lastValue)
|
||||||
|
{
|
||||||
|
lastValue = out[i]; // Buffer last value as we overwrite it.
|
||||||
|
out[i] = 1;
|
||||||
|
}
|
||||||
|
// Apply second threshold to samples heading down
|
||||||
|
else if (in[i] <= down && in[i] < lastValue)
|
||||||
|
{
|
||||||
|
lastValue = out[i]; // Buffer last value as we overwrite it.
|
||||||
|
out[i] = -1;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
lastValue = out[i]; // Buffer last value as we overwrite it.
|
||||||
|
out[i] = out[i-1];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
out[0] = out[1]; // Align with first edited sample.
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
int CmdDirectionalThreshold(const char *Cmd)
|
int CmdDirectionalThreshold(const char *Cmd)
|
||||||
{
|
{
|
||||||
|
@ -2405,29 +2432,7 @@ int CmdDirectionalThreshold(const char *Cmd)
|
||||||
|
|
||||||
printf("Applying Up Threshold: %d, Down Threshold: %d\n", upThres, downThres);
|
printf("Applying Up Threshold: %d, Down Threshold: %d\n", upThres, downThres);
|
||||||
|
|
||||||
int lastValue = GraphBuffer[0];
|
directionalThreshold(GraphBuffer, GraphBuffer,GraphTraceLen, upThres, downThres);
|
||||||
GraphBuffer[0] = 0; // Will be changed at the end, but init 0 as we adjust to last samples value if no threshold kicks in.
|
|
||||||
|
|
||||||
for (int i = 1; i < GraphTraceLen; ++i) {
|
|
||||||
// Apply first threshold to samples heading up
|
|
||||||
if (GraphBuffer[i] >= upThres && GraphBuffer[i] > lastValue)
|
|
||||||
{
|
|
||||||
lastValue = GraphBuffer[i]; // Buffer last value as we overwrite it.
|
|
||||||
GraphBuffer[i] = 1;
|
|
||||||
}
|
|
||||||
// Apply second threshold to samples heading down
|
|
||||||
else if (GraphBuffer[i] <= downThres && GraphBuffer[i] < lastValue)
|
|
||||||
{
|
|
||||||
lastValue = GraphBuffer[i]; // Buffer last value as we overwrite it.
|
|
||||||
GraphBuffer[i] = -1;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
lastValue = GraphBuffer[i]; // Buffer last value as we overwrite it.
|
|
||||||
GraphBuffer[i] = GraphBuffer[i-1];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
GraphBuffer[0] = GraphBuffer[1]; // Aline with first edited sample.
|
|
||||||
RepaintGraphWindow();
|
RepaintGraphWindow();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,9 +16,6 @@
|
||||||
#include <stdbool.h> //bool
|
#include <stdbool.h> //bool
|
||||||
#include "cmdparser.h" // for command_t
|
#include "cmdparser.h" // for command_t
|
||||||
|
|
||||||
#define MAX_DEMOD_BUF_LEN (1024*128)
|
|
||||||
#define BIGBUF_SIZE 40000
|
|
||||||
|
|
||||||
command_t * CmdDataCommands();
|
command_t * CmdDataCommands();
|
||||||
|
|
||||||
int CmdData(const char *Cmd);
|
int CmdData(const char *Cmd);
|
||||||
|
@ -80,11 +77,15 @@ void printEM410x(uint32_t hi, uint64_t id);
|
||||||
int getSamples(const char *Cmd, bool silent);
|
int getSamples(const char *Cmd, bool silent);
|
||||||
|
|
||||||
void setGrid_Clock(uint8_t clock);
|
void setGrid_Clock(uint8_t clock);
|
||||||
|
int directionalThreshold(const int* in, int *out, size_t len, int8_t up, int8_t down);
|
||||||
int CmdDataIIR(const char *Cmd);
|
int CmdDataIIR(const char *Cmd);
|
||||||
|
|
||||||
|
#define MAX_DEMOD_BUF_LEN (1024*128)
|
||||||
|
#define BIGBUF_SIZE 40000
|
||||||
extern uint8_t DemodBuffer[MAX_DEMOD_BUF_LEN];
|
extern uint8_t DemodBuffer[MAX_DEMOD_BUF_LEN];
|
||||||
extern size_t DemodBufferLen;
|
extern size_t DemodBufferLen;
|
||||||
|
extern int g_DemodStartIdx;
|
||||||
|
extern int g_DemodClock;
|
||||||
extern uint8_t g_debugMode;
|
extern uint8_t g_debugMode;
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in a new issue