Skip to content

Commit d24ca1d

Browse files
committed
fixed the digitalPin class
1 parent 550c215 commit d24ca1d

File tree

3 files changed

+9
-25
lines changed

3 files changed

+9
-25
lines changed

api/Common.h

-5
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,6 @@
22
#include <stdint.h>
33
#include <stdbool.h>
44

5-
#ifdef __cplusplus
6-
#define pHIGH ((bool)0x1)
7-
#define pLOW ((bool)0x0)
8-
#endif
9-
105
#ifdef __cplusplus
116
extern "C"{
127
#endif

api/digitalPin.cpp

+4-9
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,12 @@ digitalPin::digitalPin(const digitalPin& dig_pin)
1111
: pin(dig_pin.pin), sat(dig_pin.sat) {}
1212

1313

14-
int digitalPin::get()
14+
PinStatus digitalPin::get()
1515
{
1616
return digitalRead(pin);
1717
}
1818

19-
void digitalPin::set(bool sat)
19+
void digitalPin::set(PinStatus sat)
2020
{
2121
digitalWrite(pin, (PinStatus)sat);
2222
}
@@ -26,7 +26,7 @@ digitalPin::operator bool()
2626
return get();
2727
}
2828

29-
digitalPin::operator int()
29+
digitalPin::operator PinStatus()
3030
{
3131
return get();
3232
}
@@ -46,12 +46,7 @@ void digitalPin::PWMset(int val)
4646
analogWrite(pin, val);
4747
}
4848

49-
void digitalPin::operator()(bool v)
49+
void digitalPin::operator()(PinStatus v)
5050
{
5151
set(v);
52-
}
53-
54-
void digitalPin::operator()(int av)
55-
{
56-
PWMset(av);
5752
}

api/digitalPin.hpp

+5-11
Original file line numberDiff line numberDiff line change
@@ -3,33 +3,27 @@
33
#define DIG_PIN_H
44
#include <stdint.h>
55

6-
/*enum class PIN_SAT : bool
7-
{
8-
pHIGH = 1,
9-
pLOW = 0
10-
};*/
11-
126
class digitalPin
137
{
148
private:
159
uint8_t pin;
1610
bool sat;
17-
void operator()(int av);
11+
//void operator()(int av);
1812
public:
1913
digitalPin(uint8_t pin);
2014
digitalPin(const digitalPin& dig_pin);
2115

2216
__inline digitalPin(){}
23-
void set(bool sat);
24-
int get();
17+
void set(PinStatus sat);
18+
PinStatus get();
2519
bool toggle();
2620
void PWMset(int val);
2721

28-
void operator()(bool v);
22+
void operator()(PinStatus v);
2923

3024
digitalPin operator=(uint8_t pin);
3125
operator bool();
32-
operator int();
26+
operator PinStatus();
3327

3428

3529
__inline ~digitalPin(){}

0 commit comments

Comments
 (0)