Skip to content

Commit 0c4b2eb

Browse files
committed
Implement encoder and expander
1 parent d852db5 commit 0c4b2eb

File tree

1 file changed

+20
-2
lines changed

1 file changed

+20
-2
lines changed

src/AutomationCarrier.h

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
#include "utility/Adafruit_MAX31865/Adafruit_MAX31865.h"
55
#include "utility/Arduino_MKRTHERM/src/MKRTHERM.h"
66
#include "utility/ArduinoRS485/src/ArduinoRS485.h"
7+
#include "utility/QEI/QEI.h"
8+
#include "utility/ioexpander/TCA6424A.h"
79

810
#include "mbed.h"
911

@@ -138,24 +140,40 @@ extern AnalogOutClass analog_out;
138140
Use QEI library for mbed since it implements index pin
139141
*/
140142

143+
static QEI _enc_0(PJ_8, PH_12, PH_11, 0);
144+
static QEI _enc_1(PC_13, PK_1, PJ_10, 0);
145+
141146
class EncoderClass {
142147
public:
148+
QEI& operator[](int index) {
149+
switch (index) {
150+
case 0:
151+
return enc_0;
152+
case 1:
153+
return enc_1;
154+
}
155+
}
143156
private:
157+
QEI& enc_0 = _enc_0;
158+
QEI& enc_1 = _enc_1;
144159
};
145160

146161
extern EncoderClass encoders;
147162

148163
/*
149-
TODO: writeme
150164
using gpio expander class https://www.i2cdevlib.com/devices/tca6424a#source
151165
Ask Giampaolo for proper porting
152166
Expander interrupt is PI_5
153167
prog_latch_retry (AKA TERM ? ) is PH_14
168+
169+
TODO: check if Wire and address are correct
154170
*/
155171

156-
class ProgrammableDIOClass {
172+
class ProgrammableDIOClass : public TCA6424A {
157173
public:
174+
mbed::DigitalOut prog_latch_retry = mbed::DigitalOut(PH_14);
158175
private:
176+
159177
};
160178

161179
extern ProgrammableDIOClass programmable_digital_io;

0 commit comments

Comments
 (0)