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
optVAL_t
_pwmValue
= 0x0,
_OpwmValue
= 0x0;
5
13
inline
void
writePWM
(
optVAL_t
val);
15
inline
void
writePWM
(
optVAL_t
val){
16
val = min(val,0xFF); val = max(0x0,val);
17
_pwmValue
= val;
18
}
20
29
inline
void
writePin
(
optVAL_t
idx,
bool
val);
31
inline
void
writePin
(
optVAL_t
idx,
bool
val){
32
#if EBOARD_SHIFT_REGISTER > 0x0
33
if
(idx>0x63) {
34
idx -= 0x64;
35
shiftSingle
(idx,val);
36
return
;
37
}
38
#endif
39
#if EBOARD_CHECK_PINS > 0x0
40
checkIdx
(idx);
41
if
(!checkPin(idx))
42
#endif
43
#if EBOARD_COPY_AND_PASTE > 0x0
44
setPin(idx);
45
#else
46
pinMode(idx,OUTPUT);
47
#endif
48
digitalWrite(idx,val);
49
}
51
61
inline
optVAL_t
readPin
(
optVAL_t
idx,
bool
dig =
true
);
63
inline
optVAL_t
readPin
(
optVAL_t
idx,
bool
dig){
64
#if EBOARD_CHECK_PINS > 0x0
65
if
(dig)
checkIdx
(idx);
66
#if defined (__AVR_ATmega2560__)
67
else
if
(idx<0||idx>0xF){
//use I2C? change => Wire
68
#else
69
else
if
(idx<0||idx>0x7){
//use I2C? change => Wire
70
#endif
71
#if EBOARD_DEBUG_MODE > 0x0
72
assert(
false
);
73
#endif
74
return
0;
75
}
76
if
(dig && !checkPin(idx,INPUT))
77
#endif
78
#if EBOARD_COPY_AND_PASTE > 0x0
79
setPin(idx,INPUT);
80
#else
81
pinMode(idx,INPUT);
82
#endif
83
return
((dig)? digitalRead(idx) : analogRead(idx));
84
}
86
#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:4
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:4
shiftSingle
void shiftSingle(optVAL_t idx, bool val)
[SHIFT] Changes a single output Pin
optVAL_t
int optVAL_t
Definition:
eBoard.h:196
eBoard
source
eagle_PinCtrl.h
[WIP-BUILD]
EagleoutIce
19.04.2018 16:49:12