repl_gpio.h 1.55 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
/*-----------------------------------------------------------------------------
 *  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

#define CMD_REPL_DWRITE {\
    "dwrite", REPL_DWRITE, "dwrite <pin> <value>",\
11
12
13
14
15
    "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)."}
16
17
18

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

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

25
26
27
28
#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."}
29

30
31
32
33
34
35
36
37
38
39
40
41
#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."}

#define ALLCMD_REPL_GPIO \
    CMD_REPL_DWRITE, \
    CMD_REPL_AWRITE, \
    CMD_REPL_AREAD, \
    CMD_REPL_DREAD, \
    CMD_REPL_LOG, \
    CMD_REPL_BLINK
42
43

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

#endif