-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMoreio_I2C.h
82 lines (57 loc) · 1.3 KB
/
Moreio_I2C.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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
#ifndef FDB_MOREIO_I2C_H
#define FDB_MOREIO_I2C_H
#include <Arduino.h>
class Moreio_I2C {
public:
Moreio_I2C(uint8_t lcd_addr);
void begin();
void digitalWrite(int pin, bool value);
void analogWrite(int pin, int value);
void pinMode(int pin, int value);
int analogRead(int pin);
int digitalRead(int pin);
private:
uint8_t _addr;
};
#endif // FDB_MOREIO_I2C_H
#ifndef FDB_MOREIO_I2C_H
#define FDB_MOREIO_I2C_H
#include <Arduino.h>
#include <Wire.h>
class Moreio_I2C {
public:
Moreio_I2C(uint8_t lcd_addr);
void begin();
void digitalWrite(int pin, bool value);
void analogWrite(int pin, int value);
void pinMode(int pin, int value);
int analogRead(int pin);
int digitalRead(int pin);
private:
typedef struct RecvData_t{
int A0;
int A1;
int A2;
int A3;
int io0; //PWM
int io1;
int io2;
int io3; //PWM
int io4; //PWM
int io5; //PWM
int io6;
int io7;
int io8; //Digital / Analog
int io9; //Digital / Analog
int io10; //Digital / Analog
int io11; //Digital / Analog
};
typedef union I2C_Packet_t{
RecvData_t data;
byte I2CPacket[sizeof(RecvData_t)];
};
#define PACKET_SIZE sizeof(RecvData_t)
I2C_Packet_t Packet;
uint8_t _addr;
};
#endif // FDB_MOREIO_I2C_H