Go to the documentation of this file.
82 #define BAUDRATE 115200
112 #define modulesSupported "base transmit receive"
114 #define modulesSupported "base transmit"
118 #define modulesSupported "base receive"
120 #error At lease one of TRANSMIT and RECEIVE must be defined
127 #define PROGNAME "MicroGirs"
132 #define VERSION "2020-07-05"
134 #define okString "OK"
135 #define errorString "ERROR"
136 #define timeoutString "."
175 static const int invalidIndex = -1;
178 const String& payload;
202 String result = index == invalidIndex ? String(
"") : payload.substring(index);
203 index = invalidIndex;
208 if (index == invalidIndex)
211 int i = payload.indexOf(
'\n', index);
212 String s = (i > 0) ? payload.substring(index, i) : payload.substring(index);
213 index = (i > 0) ? i+1 : invalidIndex;
221 int i = payload.indexOf(
' ', index);
222 String s = (i > 0) ? payload.substring(index, i) : payload.substring(index);
223 index = (i > 0) ? i : invalidIndex;
224 if (index != invalidIndex)
225 if (index != invalidIndex)
226 while (payload.charAt(index) ==
' ')
233 return token ==
"" ? (long)
invalid : token.toInt();
249 return (hz + 500)/1000;
273 if (lengthIntro > 0U)
275 if (lengthRepeat > 0U)
276 for (
unsigned i = 0U; i < times - (lengthIntro > 0U); i++)
278 if (lengthEnding > 0U)
297 dump(stream, &results);
301 unsigned int count = results->
rawlen;
305 for (
unsigned int i = 1; i < count; i++) {
306 stream.write(i & 1 ?
'+' :
'-');
337 while (stream.available() == 0) {
340 String line = stream.readStringUntil(
EOLCHAR);
350 if (cmd.length() == 0) {
373 unsigned noSends = (unsigned) tokenizer.
getInt();
375 unsigned introLength = (unsigned) tokenizer.
getInt();
376 unsigned repeatLength = (unsigned) tokenizer.
getInt();
377 unsigned endingLength = (unsigned) tokenizer.
getInt();
381 for (
unsigned i = 0; i < introLength; i++)
383 for (
unsigned i = 0; i < repeatLength; i++)
385 for (
unsigned i = 0; i < endingLength; i++)
387 sendRaw(intro, introLength, repeat, repeatLength, ending, endingLength, frequency, noSends);
void loop()
Reads a command from the serial line and executes it-.
void resume()
Called to re-enable IR reception.
void disableIRIn()
Disable IR reception.
void enableIRIn()
Enable IR reception.
static const frequency_t FREQUENCY_T_MAX
Main class for receiving IR.
Results returned from the decoder.
unsigned frequency_t
Type used for modulation frequency in Hz (not kHz).
volatile unsigned int * rawbuf
Raw intervals in 50uS ticks.
Tokenizer(const String &str)
Main class for sending IR.
unsigned microseconds_t
Type used for durations in micro seconds.
static unsigned hz2khz(frequency_t hz)
#define EOLCHAR
Character that ends the command lines.
static String readCommand(Stream &stream)
#define PROGNAME
Name of program, as reported by the "version" command.
IRrecv irRecv(INPUTPIN)
Instance of the IRremote class.
#define BAUDRATE
Baud rate for the serial/USB connection.
static void sendRaw(const microseconds_t intro[], unsigned lengthIntro, const microseconds_t repeat[], unsigned lengthRepeat, const microseconds_t ending[], unsigned lengthEnding, frequency_t frequency, unsigned times)
Transmits the IR signal given as argument.
#define INPUTPIN
Input Pin used by the receiver, can be arbitrary (almost...)
int decode(decode_results *results)
Attempt to decode the recently receive IR signal.
static void dump(Stream &stream, decode_results *results)
#define modulesSupported
The modules supported, as given by the "modules" command.
Public API to the library.
static const frequency_t MICROSECONDS_T_MAX
microseconds_t getMicroseconds()
static const microseconds_t DUMMYENDING
static void processCommand(const String &line, Stream &stream)
frequency_t getFrequency()
static void receive(Stream &stream)
Reads a command from the stream given as argument.
#define VERSION
Version of program, as reported by the "version" command.
void setup()
Initialization.
unsigned int rawlen
Number of records in rawbuf.
void sendRaw(const unsigned int buf[], unsigned int len, unsigned int hz)