eBoard ๐
โ โงโจ
Written for SIA 2017/2018
Main Page
Pages
Tutorials
Namespaces
Classes
Files
File List
File Members
eagle_PinCtrl.h
Go to the documentation of this file.
1
#ifndef EAGLE_EBOARD_HELPLIB_PINCTRL
2
#define EAGLE_EBOARD_HELPLIB_PINCTRL
3
12
//=====================================================================================================================================================
13
// Pin control
14
//=====================================================================================================================================================
15
16
//-------------------------------------------------------------------------------------------------------------------------------------------------
17
// variables
18
//-------------------------------------------------------------------------------------------------------------------------------------------------
19
21
optVAL_t
_pwmValue
= 0x0,
_OpwmValue
= 0x0;
22
23
//-------------------------------------------------------------------------------------------------------------------------------------------------
24
// PWM
25
//-------------------------------------------------------------------------------------------------------------------------------------------------
26
34
inline
void
writePWM
(
optVAL_t
val);
35
37
inline
void
writePWM
(
optVAL_t
val){
38
val = min(val,0xFF); val = max(0x0,val);
39
_pwmValue
= val;
40
}
42
43
//-------------------------------------------------------------------------------------------------------------------------------------------------
44
// write
45
//-------------------------------------------------------------------------------------------------------------------------------------------------
46
56
inline
void
writePin
(
optVAL_t
idx,
bool
val);
57
59
inline
void
writePin
(
optVAL_t
idx,
bool
val){
60
#if EBOARD_SHIFT_REGISTER > 0x0
61
if
(idx>0x63) {
62
idx -= 0x64;
63
shiftSingle
(idx,val);
64
return
;
65
}
66
#endif
67
#if EBOARD_CHECK_PINS > 0x0
68
checkIdx
(idx);
69
if
(!checkPin(idx))
70
#endif
71
#if EBOARD_COPY_AND_PASTE > 0x0
72
setPin(idx);
73
#else
74
pinMode(idx,OUTPUT);
75
#endif
76
digitalWrite(idx,val);
77
}
78
79
//-------------------------------------------------------------------------------------------------------------------------------------------------
80
// read1
81
//-------------------------------------------------------------------------------------------------------------------------------------------------
82
84
94
inline
optVAL_t
readPin
(
optVAL_t
idx,
bool
dig =
true
);
95
97
inline
optVAL_t
readPin
(
optVAL_t
idx,
bool
dig){
98
#if EBOARD_CHECK_PINS > 0x0
99
if
(dig)
checkIdx
(idx);
100
#if defined (__AVR_ATmega2560__)
101
else
if
(idx<0||idx>0xF){
//use I2C? change => Wire
102
#else
103
else
if
(idx<0||idx>0x7){
//use I2C? change => Wire
104
#endif
105
#if EBOARD_DEBUG_MODE > 0x0
106
assert(
false
);
107
#endif
108
return
0;
109
}
110
if
(dig && !checkPin(idx,INPUT))
111
#endif
112
#if EBOARD_COPY_AND_PASTE > 0x0
113
setPin(idx,INPUT);
114
#else
115
pinMode(idx,INPUT);
116
#endif
117
return
((dig)? digitalRead(idx) : analogRead(idx));
118
}
120
#endif
writePWM
void writePWM(optVAL_t val)
write a clamped pwm value to an output pin
checkIdx
void checkIdx(optVAL_t idx)
[DEBUG_MODE] used to check if a pin index is in bounds
writePin
void writePin(optVAL_t idx, bool val)
write a boolean state to an output pin
_pwmValue
optVAL_t _pwmValue
Definition:
eagle_PinCtrl.h:21
readPin
optVAL_t readPin(optVAL_t idx, bool dig=true)
read a digital state from an INPUTpin
_OpwmValue
optVAL_t _OpwmValue
Definition:
eagle_PinCtrl.h:21
shiftSingle
void shiftSingle(optVAL_t idx, bool val)
[SHIFT] Changes a single output Pin
optVAL_t
int optVAL_t
Definition:
eBoard.h:132
eBoard
source
eagle_PinCtrl.h
[WIP-BUILD]
EagleoutIce
03.05.2018 22:22:29