Thanx a lot for the latest versions. It looks really promising. You fixed two problems (missing last pulse, chopping signals too much (e.g. a NEC1 signal with repeats was chopped, every repeat turned into a separate sequence)) before I had the time to report it.
It appears as (most?) captures end with a pulse, not with a gap. Possibly this is somewhat of a philosophical question: LIRC always end with a pulse, in the JP1/IRP world, the signals always end with a gap of well-defined length. Of course, when capturing, there is no way to reproduce this well-defined length, unless the signal is immediately followed by another signal, which we do not want to assume, and introduces the new problem of splitting the two. The solution I prefer and I have implemented in IrScrutinizer is to have the user specify an "endTimeout" , and consider the capture ended when a silence of this length has been detected (cf. the pseudo code in my last message). Any chance?
I do not think you have to discard the duty cycle computation when not storing the negative edges: Just add up all the "small" gaps (one variable!) and compare it to the sum of all the pulses.
I see the "aggregateThreshold" as an a-priori parameter the user supplies, as a price for not having to store all edges. For practical uses, say up to 60kHz, the value is probably rather uncritical, so that a default values should serve well in almost all cases. There are alternatives, either a learning phase (I think LIRC does something like this), or some adaptation, but it has its disadvantages.
Which of the three capture modes is useful? Should all three be supported and should there be a command to switch between the modes?
From a practical (users) point of view, it should "just work", and produce frequency, "aggregated timing", optionally duty cycle. I also thing it is reasonable to require a "production" solution to run on a 2k SRAM Arduino (like Uno, Leonardo, nano,...). Which is to say the "aggregating" mode. When that does not suffice, I do not think it is reasonable to search a universal solution.
The ICT output format has changed a bit:
My suggestion: remove it. IMHO, software for measuring devices need only produce data in one format; it is the task of the host computer to convert it.
// TODO: automatically determine if the sensor is inverting:
// wait for a long period without level changes (e.g. 1ms) and use the value as the low value
(comment in code) Good idea. You might want to peek into lirc_serial.c, init_port().
It is "Arduino.h" (captalized). Relying to the file system to forgive is non-portable.
Code: Select all
#if USE_AGG_CAPTURE
#undef USE_PULSE_AGGREGATION
#define USE_PULSE_AGGREGATION 0
#undef CAPTURE_RISING_EDGE_ONLY
#define CAPTURE_RISING_EDGE_ONLY 1
#endif
I consider it a bad idea just to quietly "fix" contradictory input data without telling the user. Better just to barf, and have the user fix it. Suggestion:
Code: Select all
#if USE_AGG_CAPTURE & USE_PULSE_AGGREGATION
#error these options are exclusive
#endif
End of setup():
Code: Select all
for(uint16_t i = 0; i < captureCount; i++)
captureData[i] = 0;
Problem 1: captureCount is here uninitialized (you mean bufSize?). Problem 2: If initialization is needed, it is needed for every capture.
The sensor I am presently using QSE159 has open collector, i.e. requiring a pull-up resistor. Do you know if there are internal pull-up resistors, per SW controllable, on some pins, like in the Raspberry Pi? Would that be feasible?