-
Notifications
You must be signed in to change notification settings - Fork 0
/
multiplexer.h
46 lines (31 loc) · 991 Bytes
/
multiplexer.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#ifndef MULTIPLEXER_H
#define MULTIPLEXER_H
#include "global_includes.h"
#include <ADC.h>
class analogManager {
public:
const ADC *adc = new ADC();
analogManager();
};
extern analogManager * analog_manager;
// Instantiated for each chain of multiplexers connected to the control board. Can be used as input or output (though should use I2C port expanders for digital input or output)
class Multiplexer {
int selectPins[4] = MUX_SELECT_PINS;
int enablePins[4] = MUX_ENABLE_PINS;
int numOfMux;
int IOpin;
bool input;
//bool pullup;
bool continuous;
std::vector<bool> pullups;
void writeBinary(int pins[4], int value);
void prepare(int pin);
public:
Multiplexer(bool _input, bool _continuous, int number, int _IOpin);
void selectMuxAndPin(int index);
void setPullup(int pin, bool pullup);
int AnalogReadSingle(int pin);
int DigitalRead(int pin);
};
//extern Multiplexer testMux;
#endif