Divide pulse length by 4 to handle longer pulses
This commit is contained in:
parent
6326dc3a06
commit
31f4e21feb
|
@ -15,9 +15,11 @@ void loop() {
|
|||
if(RFControl::hasData()) {
|
||||
unsigned int *timings;
|
||||
unsigned int timings_size;
|
||||
unsigned int pulse_length_divider = RFControl::getPulseLengthDivider();
|
||||
RFControl::getRaw(&timings, &timings_size);
|
||||
for(int i=0; i < timings_size; i++) {
|
||||
Serial.print(timings[i]);
|
||||
unsigned long timing = timings[i] * pulse_length_divider;
|
||||
Serial.print(timing);
|
||||
Serial.write('\t');
|
||||
if((i+1)%16 == 0) {
|
||||
Serial.write('\n');
|
||||
|
|
|
@ -17,8 +17,10 @@
|
|||
#define STATUS_RECORDING_3 4
|
||||
#define STATUS_RECORDING_END 5
|
||||
|
||||
#define MIN_FOOTER_LENGTH 3500
|
||||
#define MIN_PULSE_LENGTH 100
|
||||
#define PULSE_LENGTH_DIVIDER 4
|
||||
|
||||
#define MIN_FOOTER_LENGTH (3500 / PULSE_LENGTH_DIVIDER)
|
||||
#define MIN_PULSE_LENGTH (100 / PULSE_LENGTH_DIVIDER)
|
||||
|
||||
unsigned int footer_length;
|
||||
unsigned int timings[MAX_RECORDINGS];
|
||||
|
@ -39,6 +41,10 @@ bool skip = false;
|
|||
bool new_duration = false;
|
||||
void handleInterrupt();
|
||||
|
||||
unsigned int RFControl::getPulseLengthDivider() {
|
||||
return PULSE_LENGTH_DIVIDER;
|
||||
}
|
||||
|
||||
void RFControl::startReceiving(int _interruptPin) {
|
||||
footer_length = 0;
|
||||
state = STATUS_WAITING;
|
||||
|
@ -287,7 +293,7 @@ void verification(int package) {
|
|||
void handleInterrupt() {
|
||||
//digitalWrite(9, HIGH);
|
||||
unsigned long currentTime = micros();
|
||||
duration = currentTime - lastTime;
|
||||
duration = (currentTime - lastTime) / PULSE_LENGTH_DIVIDER;
|
||||
//lastTime = currentTime;
|
||||
if (skip) {
|
||||
skip = false;
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
class RFControl
|
||||
{
|
||||
public:
|
||||
static unsigned int getPulseLengthDivider();
|
||||
static void startReceiving(int interruptPin);
|
||||
static void stopReceiving();
|
||||
static bool hasData();
|
||||
|
|
Loading…
Reference in New Issue