Skip to content

Commit e26f025

Browse files
author
神农民
authored
Merge pull request #29 from hxming123456/update_items_based_on_ide
Update items based on ide
2 parents 6a61466 + 5f65df5 commit e26f025

File tree

966 files changed

+73322
-676
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

966 files changed

+73322
-676
lines changed

NexGpio.cpp

+105
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
/**
2+
* @file NexGpio.cpp
3+
*
4+
* The implementation of class NexGpio.
5+
*
6+
* @author Wu Pengfei (email:<[email protected]>)
7+
* @date 2015/8/13
8+
* @copyright
9+
* Copyright (C) 2014-2015 ITEAD Intelligent Systems Co., Ltd. \n
10+
* This program is free software; you can redistribute it and/or
11+
* modify it under the terms of the GNU General Public License as
12+
* published by the Free Software Foundation; either version 2 of
13+
* the License, or (at your option) any later version.
14+
*/
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.h

+102
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
/**
2+
* @file NexGpio.h
3+
*
4+
* The definition of class NexGpio.
5+
*
6+
* @author Wu Pengfei (email:<[email protected]>)
7+
* @date 2015/8/13
8+
*
9+
* @copyright
10+
* Copyright (C) 2014-2015 ITEAD Intelligent Systems Co., Ltd. \n
11+
* This program is free software; you can redistribute it and/or
12+
* modify it under the terms of the GNU General Public License as
13+
* published by the Free Software Foundation; either version 2 of
14+
* the License, or (at your option) any later version.
15+
*/
16+
17+
#ifndef _NEXGPIO_H
18+
#define _NEXGPIO_H
19+
20+
#include "NexTouch.h"
21+
#include "NexHardware.h"
22+
/**
23+
* @addtogroup Component
24+
* @{
25+
*/
26+
27+
/**
28+
* NexGpio component.
29+
*/
30+
31+
class NexGpio
32+
{
33+
public:
34+
/**
35+
* Set gpio mode
36+
*
37+
* @param port - the gpio port number
38+
* @param mode - set gpio port mode(0--Pull on the input
39+
* 1--the control input binding
40+
* 2--Push-pull output
41+
* 3--pwm output
42+
* 4--open mode leakage)
43+
* @param control_id - nextion controls id ,when the modeel is 1 to be valid
44+
* @return true if success, false for failure
45+
*/
46+
47+
bool pin_mode(uint32_t port,uint32_t mode,uint32_t control_id);
48+
49+
/**
50+
* write a HIGH or a LOW value to a digital pin
51+
*
52+
* @param port - the gpio port number
53+
* @param value - HIGH or LOW
54+
* @return true if success, false for failure
55+
*/
56+
57+
bool digital_write(uint32_t port,uint32_t value);
58+
59+
/**
60+
* read a HIGH or a LOW value to a digital pin
61+
*
62+
* @param port - the gpio port number
63+
* @return the value from a specified digital pin, either high or low
64+
*/
65+
66+
uint32_t digital_read(uint32_t port);
67+
68+
/**
69+
* writes an analog value (PWM wave) to a pin
70+
*
71+
* @param port - the gpio port number
72+
* @param value - the duty cycle: between 0 (always off) and 100 (always on).
73+
* @return true if success, false for failure
74+
*/
75+
76+
bool analog_write(uint32_t port,uint32_t value);
77+
78+
/**
79+
* writes pwm output frequency
80+
*
81+
* @param value - the frequency: between 1 and 65535
82+
* @return true if success, false for failure
83+
*/
84+
85+
bool set_pwmfreq(uint32_t value);
86+
87+
/**
88+
* read pwm output frequency
89+
*
90+
* @param number - the frequency
91+
* @return true if success, false for failure
92+
*/
93+
94+
uint32_t get_pwmfreq(uint32_t *number);
95+
96+
};
97+
98+
/**
99+
* @}
100+
*/
101+
102+
#endif /* #ifndef __NEXGPIO_H__ */

0 commit comments

Comments
 (0)