-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathio_8574.h
59 lines (50 loc) · 1.42 KB
/
io_8574.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
47
48
49
50
51
52
53
54
55
56
57
58
#ifndef IO_PCF8591
#define IO_PCF8591
#include <iostream>
#include <string>
#include "I2C.h"
#include "connection.h"
using namespace std;
/**
* Class for the PCF8574 8-bit I/O I2C chip
*/
class Io_8574 : public I2c{
public:
/**
* Constructor for the PCF8574 I/O chip
* @param port [which sensor port to use]
* @param *connection [attach a connection]
* @param i2c_address [set the I2C address of the chip]
*/
Io_8574(Sensor_port port, Connection *connection, unsigned char i2c_address);
~Io_8574();
/**
* Initiate the sensor
* @param reply [true = require reply from NXT; false = no reply from NXT]
*/
void init(bool reply = false);
/**
* Read the sensor value
* (init method will be called if the sensor has not been initialized)
* @return a value between 0 and 255 that describes the state of the pins
* (remember to set input pins to high before reading)
*/
int read();
/**
* Sets the pins high (write to the sensor)
* @param value [sets the specified pins high (0xff all pins are set to input)]
*/
void set(unsigned int value);
/**
* Get the sensor type
* @return IO_8574_SENSOR
*/
Sensor_type get_type();
/**
* Get the sensor reading as a string
* (init method will be called if the sensor has not been initialized)
* @return sensor reading as a string
*/
string print();
};
#endif