repl_gpio.h 1.55 KB
Newer Older
1 2 3 4 5 6 7 8
/*-----------------------------------------------------------------------------
 *  Author: Nelso G. Jost (nelsojost@gmail.com)
 *  License: GPLv2
 *  Purpose: Provide basic GPIO control commands for the REPL.
 *---------------------------------------------------------------------------*/
#ifndef REPL_GPIO_H
#define REPL_GPIO_H

9

10 11
#define CMD_REPL_DWRITE {\
    "dwrite", REPL_DWRITE, "dwrite <pin> <value>",\
12 13 14 15 16
    "Perform pinMode(pin, OUTPUT) and digitalWrite(pin, value)."}

#define CMD_REPL_AWRITE {\
    "awrite", REPL_AWRITE, "awrite <pin> <value>",\
    "Perform analogWrite(pin, value) with 0 <= PWM value <= 255 (duty cycle)."}
17 18 19

#define CMD_REPL_AREAD {\
    "aread", REPL_AREAD, "aread <pin>", \
20
    "Perform analogRead(pin)"}
21

22 23 24
#define CMD_REPL_DREAD {\
    "dread", REPL_DREAD, "dread <pin>", \
    "Perform digitalRead(pin)"}
25

26 27 28 29
#define CMD_REPL_LOG {\
    "log", REPL_LOG, "log <pin> <interval>", \
    "Start logging a pin reading with given interval (in seconds). " \
    "Pin must be aX (analog) or dX (digital) where X is an integer."}
30

31 32 33 34 35
#define CMD_REPL_BLINK {\
    "blink", REPL_BLINK, "blink <interval>", \
    "Blink builtin led (pin 2) with given <interval> in seconds (int|float). " \
    "Use \"blink 0\" to stop it."}

36

37 38 39 40 41 42 43
#define ALLCMD_REPL_GPIO \
    CMD_REPL_DWRITE, \
    CMD_REPL_AWRITE, \
    CMD_REPL_AREAD, \
    CMD_REPL_DREAD, \
    CMD_REPL_LOG, \
    CMD_REPL_BLINK
44

45

46
void REPL_DWRITE(REPL * repl);
47
void REPL_AWRITE(REPL * repl);
48
void REPL_AREAD(REPL * repl);
49 50 51
void REPL_DREAD(REPL * repl);
void REPL_LOG(REPL * repl);
void REPL_BLINK(REPL * repl);
52

53

54
#endif