16x2 easyC LCD Library
1.0.0
This is a library for the 16x2 easyC LCD Module
Toggle main menu visibility
Loading...
Searching...
No Matches
easyC.hpp
Go to the documentation of this file.
1
11
12
#ifndef __EASYC__
13
#define __EASYC__
14
15
#include "Arduino.h"
16
#include "Wire.h"
17
18
#define ANALOG_READ_REG 0
19
#define DIGITAL_READ_REG 1
20
21
class
EasyC
22
{
23
public
:
28
EasyC
()
29
{
30
native
= 0;
31
}
32
36
void
begin
()
37
{
38
if
(
native
)
39
initializeNative
();
40
else
41
begin
(
defaultAddress
);
42
beginDone
= 1;
43
}
44
50
void
begin
(uint8_t _address)
51
{
52
address
= _address;
53
54
Wire.begin();
55
56
beginDone
= 1;
57
}
58
59
int
native
= 0;
60
bool
beginDone
= 0;
61
62
virtual
void
initializeNative
() = 0;
63
64
int
err
;
65
66
char
address
;
67
const
char
defaultAddress
= 0x30;
68
76
int
sendAddress
(
char
regAddr)
77
{
78
Wire.beginTransmission(
address
);
79
Wire.write(regAddr);
80
81
return
err
= Wire.endTransmission();
82
}
83
92
int
readData
(
char
a[],
int
n)
93
{
94
Wire.requestFrom(
address
, n);
95
Wire.readBytes(a, n);
96
97
return
0;
98
}
99
109
int
readRegister
(
char
regAddr,
char
a[],
size_t
n)
110
{
111
if
(
sendAddress
(regAddr))
112
return
err
;
113
114
if
(
readData
(a, n))
115
return
err
;
116
117
return
0;
118
}
119
128
int
sendData
(
const
uint8_t *a,
int
n)
129
{
130
Wire.beginTransmission(
address
);
131
Wire.write(a, n);
132
133
return
err
= Wire.endTransmission();
134
}
135
};
136
137
#endif
EasyC::sendAddress
int sendAddress(char regAddr)
Private function to send a single byte to sensor.
Definition
easyC.hpp:76
EasyC::begin
void begin()
Initializes sensors on native or easyC on default address.
Definition
easyC.hpp:36
EasyC::EasyC
EasyC()
Main constructor for easyC version.
Definition
easyC.hpp:28
EasyC::beginDone
bool beginDone
Definition
easyC.hpp:60
EasyC::readRegister
int readRegister(char regAddr, char a[], size_t n)
Private function to send over i2c and then read n bytes.
Definition
easyC.hpp:109
EasyC::initializeNative
virtual void initializeNative()=0
EasyC::address
char address
Definition
easyC.hpp:66
EasyC::err
int err
Definition
easyC.hpp:64
EasyC::defaultAddress
const char defaultAddress
Definition
easyC.hpp:67
EasyC::readData
int readData(char a[], int n)
Private function to read n bytes over i2c.
Definition
easyC.hpp:92
EasyC::begin
void begin(uint8_t _address)
Initializes sensors on supplied i2c address.
Definition
easyC.hpp:50
EasyC::native
int native
Definition
easyC.hpp:59
EasyC::sendData
int sendData(const uint8_t *a, int n)
Private function to write n bytes over i2c.
Definition
easyC.hpp:128
src
libs
Generic-easyC
easyC.hpp
Generated on
for 16x2 easyC LCD Library by
1.17.0. Dark theme by
Tilen Majerle
. All rights reserved. Copyright:
Soldered