2
2
The MIT License(MIT)
3
3
4
4
Cayenne Arduino Client Library
5
- Copyright © 2016 myDevices
5
+ Copyright © 2016 myDevices
6
6
7
7
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
8
8
documentation files(the "Software"), to deal in the Software without restriction, including without limitation
@@ -161,24 +161,13 @@ class VCNL4000
161
161
uint8_t data;
162
162
163
163
Wire.beginTransmission (VCNL4000_ADDRESS);
164
- #if ARDUINO >= 100
165
164
Wire.write (address);
166
- #else
167
- Wire.send (address);
168
- #endif
169
165
Wire.endTransmission ();
170
166
171
167
delayMicroseconds (170 ); // delay required
172
168
173
169
Wire.requestFrom (VCNL4000_ADDRESS, 1 );
174
- unsigned int start = millis ();
175
- while (!Wire.available () && (millis () - start < TIMEOUT));
176
-
177
- #if ARDUINO >= 100
178
170
return Wire.read ();
179
- #else
180
- return Wire.receive ();
181
- #endif
182
171
}
183
172
184
173
@@ -188,29 +177,13 @@ class VCNL4000
188
177
uint16_t data;
189
178
190
179
Wire.beginTransmission (VCNL4000_ADDRESS);
191
- #if ARDUINO >= 100
192
180
Wire.write (address);
193
- #else
194
- Wire.send (address);
195
- #endif
196
181
Wire.endTransmission ();
197
182
198
183
Wire.requestFrom (VCNL4000_ADDRESS, 2 );
199
- unsigned int start = millis ();
200
- while (!Wire.available () && (millis () - start < TIMEOUT));
201
- #if ARDUINO >= 100
202
184
data = Wire.read ();
203
185
data <<= 8 ;
204
- start = millis ();
205
- while (!Wire.available () && (millis () - start < TIMEOUT));
206
186
data |= Wire.read ();
207
- #else
208
- data = Wire.receive ();
209
- data <<= 8 ;
210
- start = millis ();
211
- while (!Wire.available () && (millis () - start < TIMEOUT));
212
- data |= Wire.receive ();
213
- #endif
214
187
215
188
return data;
216
189
}
@@ -219,13 +192,8 @@ class VCNL4000
219
192
void write8 (uint8_t address, uint8_t data)
220
193
{
221
194
Wire.beginTransmission (VCNL4000_ADDRESS);
222
- #if ARDUINO >= 100
223
195
Wire.write (address);
224
196
Wire.write (data);
225
- #else
226
- Wire.send (address);
227
- Wire.send (data);
228
- #endif
229
197
Wire.endTransmission ();
230
198
}
231
199
0 commit comments