IRremote
Classes | Macros | Typedefs | Functions | Variables
MicroGirs.ino File Reference

This is a minimalistic Girs server. It only depends on (a subset of) IRremote. It can be used with IrScrutinizer (select Sending/Capturing hw = Girs Client) as well as Lirc version 0.9.4 and later, using the driver Girs). (Authors of similar software are encourage to implement support.) More...

#include <IRremote.h>
#include <limits.h>
Include dependency graph for MicroGirs.ino:

Go to the source code of this file.

Classes

class  Tokenizer
 Our own tokenizer class. More...
 

Macros

#define INPUTPIN   5
 Input Pin used by the receiver, can be arbitrary (almost...) More...
 
#define BAUDRATE   115200
 Baud rate for the serial/USB connection. More...
 
#define RECEIVE
 Define to support reception of IR. More...
 
#define TRANSMIT
 Define to support transmission of IR signals. More...
 
#define EOLCHAR   '\r'
 Character that ends the command lines. More...
 
#define modulesSupported   "base transmit receive"
 The modules supported, as given by the "modules" command. More...
 
#define PROGNAME   "MicroGirs"
 Name of program, as reported by the "version" command. More...
 
#define VERSION   "2020-07-05"
 Version of program, as reported by the "version" command. More...
 
#define okString   "OK"
 
#define errorString   "ERROR"
 
#define timeoutString   "."
 

Typedefs

typedef unsigned frequency_t
 Type used for modulation frequency in Hz (not kHz). More...
 
typedef unsigned microseconds_t
 Type used for durations in micro seconds. More...
 

Functions

static unsigned hz2khz (frequency_t hz)
 
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. More...
 
static void receive (Stream &stream)
 Reads a command from the stream given as argument. More...
 
static void dump (Stream &stream, decode_results *results)
 
void setup ()
 Initialization. More...
 
static String readCommand (Stream &stream)
 
static void processCommand (const String &line, Stream &stream)
 
void loop ()
 Reads a command from the serial line and executes it-. More...
 

Variables

static const microseconds_t DUMMYENDING = 40000U
 
static const frequency_t FREQUENCY_T_MAX = UINT16_MAX
 
static const frequency_t MICROSECONDS_T_MAX = UINT16_MAX
 
IRrecv irRecv (INPUTPIN)
 Instance of the IRremote class. More...
 
IRsend irSend
 

Detailed Description

This is a minimalistic Girs server. It only depends on (a subset of) IRremote. It can be used with IrScrutinizer (select Sending/Capturing hw = Girs Client) as well as Lirc version 0.9.4 and later, using the driver Girs). (Authors of similar software are encourage to implement support.)

It runs on all hardware on which IRemote runs.

It consists of an interactive IR server, taking one-line commands from the "user" (which is typically not a person but another program), and responds with a one-line response. In the language of the Girs specifications, the modules "base", receive, and transmit are implemented. (The two latter can be disabled by not defining two corresponding CPP symbols.)

It understands the following commands:

The "version" command returns the program name and version, The "modules" command returns the modules implemented, normally base, receive and transmit. The "receive" command reads an IR signal using the used, demodulating IR sensor. The "send" commands transmits a supplied raw signal the requested number of times.

Only the first character of the command is evaluated in this implementation.

The "receive" command returns the received IR sequence as a sequence of durations, including a (dummy) trailing silence. On-periods ("marks", "flashes") are prefixed by "+", while off-periods ("spaces", "gaps") are prefixed by "-". The present version never times out.

The send command takes the following parameters:

  send noSends frequencyHz introLength repeatLength endingLength durations...

where

Semantics: first the intro sequence will be sent once (i.e., the first repeatLength durations) (if non-empty). Then the repeat sequence will be sent (noSends-1) times, unless the intro sequence was empty, in which case it will be send noSends times. Finally, the ending sequence will be send once (if non-empty).

Weaknesses of the IRremote implementation:

For minimal footprint, undefine all DECODE* and SEND_* in IRremote.h.

For optimal results, try for example to set _GAP to 100000 (what a brilliant variable name!!) and RAW_BUFFER_LENGTH to 251 in IRremoteInt.h.

Definition in file MicroGirs.ino.

Macro Definition Documentation

◆ BAUDRATE

#define BAUDRATE   115200

Baud rate for the serial/USB connection.

(115200 is the default for IrScrutinizer and Lirc.)

Definition at line 83 of file MicroGirs.ino.

◆ EOLCHAR

#define EOLCHAR   '\r'

Character that ends the command lines.

Do not change unless you known what you are doing. IrScrutinizer and Lirc expects \r.

Definition at line 104 of file MicroGirs.ino.

◆ errorString

#define errorString   "ERROR"

Definition at line 136 of file MicroGirs.ino.

◆ INPUTPIN

#define INPUTPIN   5

Input Pin used by the receiver, can be arbitrary (almost...)

Definition at line 77 of file MicroGirs.ino.

◆ modulesSupported

#define modulesSupported   "base transmit receive"

The modules supported, as given by the "modules" command.

Definition at line 113 of file MicroGirs.ino.

◆ okString

#define okString   "OK"

Definition at line 135 of file MicroGirs.ino.

◆ PROGNAME

#define PROGNAME   "MicroGirs"

Name of program, as reported by the "version" command.

Definition at line 128 of file MicroGirs.ino.

◆ RECEIVE

#define RECEIVE

Define to support reception of IR.

Definition at line 91 of file MicroGirs.ino.

◆ timeoutString

#define timeoutString   "."

Definition at line 137 of file MicroGirs.ino.

◆ TRANSMIT

#define TRANSMIT

Define to support transmission of IR signals.

Definition at line 96 of file MicroGirs.ino.

◆ VERSION

#define VERSION   "2020-07-05"

Version of program, as reported by the "version" command.

Definition at line 133 of file MicroGirs.ino.

Typedef Documentation

◆ frequency_t

typedef unsigned frequency_t

Type used for modulation frequency in Hz (not kHz).

Definition at line 144 of file MicroGirs.ino.

◆ microseconds_t

typedef unsigned microseconds_t

Type used for durations in micro seconds.

Definition at line 149 of file MicroGirs.ino.

Function Documentation

◆ dump()

static void dump ( Stream &  stream,
decode_results results 
)
static

Definition at line 300 of file MicroGirs.ino.

◆ hz2khz()

static unsigned hz2khz ( frequency_t  hz)
inlinestatic

Definition at line 248 of file MicroGirs.ino.

◆ loop()

void loop ( )

Reads a command from the serial line and executes it-.

Definition at line 404 of file MicroGirs.ino.

◆ processCommand()

static void processCommand ( const String &  line,
Stream &  stream 
)
static

Definition at line 345 of file MicroGirs.ino.

◆ readCommand()

static String readCommand ( Stream &  stream)
static

Definition at line 336 of file MicroGirs.ino.

◆ receive()

static void receive ( Stream &  stream)
static

Reads a command from the stream given as argument.

Parameters
streamStream to read from, typically Serial.

Definition at line 288 of file MicroGirs.ino.

◆ sendRaw()

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 
)
static

Transmits the IR signal given as argument.

The intro sequence (possibly empty) is first sent. Then the repeat signal (also possibly empty) is sent, "times" times, except for the case of the intro signal being empty, in which case it is sent "times" times. Finally the ending sequence (possibly empty) is sent.

Parameters
introSequence to be sent exactly once at the start.
lengthIntroNumber of durations in intro sequence, must be even.
repeatSequence top possibly be sent multiple times
lengthRepeatNumber of durations in repeat sequence.
endingSequence to be sent at the end, possibly empty
lengthEndingNumber of durations in ending sequence
frequencyModulation frequency, in Hz (not kHz as normally in IRremote)
timesNumber of times to send the signal, in the sense above.

Definition at line 269 of file MicroGirs.ino.

◆ setup()

void setup ( )

Initialization.

Definition at line 318 of file MicroGirs.ino.

Variable Documentation

◆ DUMMYENDING

const microseconds_t DUMMYENDING = 40000U
static

Definition at line 151 of file MicroGirs.ino.

◆ FREQUENCY_T_MAX

const frequency_t FREQUENCY_T_MAX = UINT16_MAX
static

Definition at line 152 of file MicroGirs.ino.

◆ irRecv

IRrecv irRecv(INPUTPIN)

Instance of the IRremote class.

◆ irSend

IRsend irSend

Definition at line 166 of file MicroGirs.ino.

◆ MICROSECONDS_T_MAX

const frequency_t MICROSECONDS_T_MAX = UINT16_MAX
static

Definition at line 153 of file MicroGirs.ino.