| Documentation For Arduino users

- Main Page
- Related Pages
- Modules
- Classes
- Files
- Examples

- File List
- File Members

NexGpio.cpp
Go to the documentation of this file.
1
15 #include "NexGpio.h"
16
17 bool NexGpio::pin_mode(uint32_t port,uint32_t mode,uint32_t control_id)
18 {
19 char buf;
20 String cmd;
21
22 cmd += "cfgpio ";
23 buf = port + '0';
24 cmd += buf;
25 cmd += ',';
26 buf = mode + '0';
27 cmd += buf;
28 cmd += ',';
29 buf = control_id = '0';
30 cmd += buf;
31
32 sendCommand(cmd.c_str());
33 return recvRetCommandFinished();
34
35 }
36
37 bool NexGpio::digital_write(uint32_t port,uint32_t value)
38 {
39 String cmd;
40 char buf;
41
42 cmd += "pio";
43 buf = port + '0';
44 cmd += buf;
45 cmd += '=';
46 buf = value + '0';
47 cmd += buf;
48
49 sendCommand(cmd.c_str());
50 return recvRetCommandFinished();
51 }
52
53 uint32_t NexGpio::digital_read(uint32_t port)
54 {
55 uint32_t number;
56 char buf;
57
58 String cmd = String("get ");
59 cmd += "pio";
60 buf = port + '0';
61 cmd += buf;
62
63 sendCommand(cmd.c_str());
64 recvRetNumber(&number);
65 return number;
66 }
67
68 bool NexGpio::analog_write(uint32_t port,uint32_t value)
69 {
70 char buf[10] = {0};
71 char c;
72 String cmd;
73
74 utoa(value, buf, 10);
75 cmd += "pwm";
76 c = port + '0';
77 cmd += c;
78 cmd += '=';
79 cmd += buf;
80
81 Serial.print(cmd);
82 sendCommand(cmd.c_str());
83 return recvRetCommandFinished();
84 }
85
86 bool NexGpio::set_pwmfreq(uint32_t value)
87 {
88 char buf[10] = {0};
89 String cmd;
90
91 utoa(value, buf, 10);
92 cmd += "pwmf";
93 cmd += '=';
94 cmd += buf;
95
96 sendCommand(cmd.c_str());
97 return recvRetCommandFinished();
98 }
99
100 uint32_t NexGpio::get_pwmfreq(uint32_t *number)
101 {
102 String cmd = String("get pwmf");
103 sendCommand(cmd.c_str());
104 return recvRetNumber(number);
105 }
NexGpio::digital_write
bool digital_write(uint32_t port, uint32_t value)
write a HIGH or a LOW value to a digital pin
Definition: NexGpio.cpp:37
NexGpio::set_pwmfreq
bool set_pwmfreq(uint32_t value)
writes pwm output frequency
Definition: NexGpio.cpp:86
NexGpio::pin_mode
bool pin_mode(uint32_t port, uint32_t mode, uint32_t control_id)
Set gpio mode.
Definition: NexGpio.cpp:17
NexGpio::get_pwmfreq
uint32_t get_pwmfreq(uint32_t *number)
read pwm output frequency
Definition: NexGpio.cpp:100
NexGpio.h
The definition of class NexGpio.
NexGpio::analog_write
bool analog_write(uint32_t port, uint32_t value)
writes an analog value (PWM wave) to a pin
Definition: NexGpio.cpp:68
NexGpio::digital_read
uint32_t digital_read(uint32_t port)
read a HIGH or a LOW value to a digital pin
Definition: NexGpio.cpp:53