This repository was archived by the owner on May 7, 2019. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +27
-3
lines changed
Expand file tree Collapse file tree 2 files changed +27
-3
lines changed Original file line number Diff line number Diff line change 3636/* *************************************************************************/
3737
3838#include < avr/pgmspace.h>
39- #include < WProgram.h>
4039#include < util/delay.h>
4140#include < stdlib.h>
42- #include < Wire.h>
4341
4442#include " TSL2561.h"
4543
@@ -57,10 +55,18 @@ boolean TSL2561::begin(void) {
5755
5856 // Initialise I2C
5957 Wire.beginTransmission (_addr);
58+ #if ARDUINO >= 100
59+ Wire.write (TSL2561_REGISTER_ID);
60+ #else
6061 Wire.send (TSL2561_REGISTER_ID);
62+ #endif
6163 Wire.endTransmission ();
6264 Wire.requestFrom (_addr, 1 );
65+ #if ARDUINO >= 100
66+ int x = Wire.read ();
67+ #else
6368 int x = Wire.receive ();
69+ #endif
6470 // Serial.print("0x"); Serial.println(x, HEX);
6571 if (x & 0x0A ) {
6672 // Serial.println("Found TSL2561");
@@ -256,12 +262,21 @@ uint16_t TSL2561::read16(uint8_t reg)
256262 uint16_t x; uint16_t t;
257263
258264 Wire.beginTransmission (_addr);
265+ #if ARDUINO >= 100
266+ Wire.write (reg);
267+ #else
259268 Wire.send (reg);
269+ #endif
260270 Wire.endTransmission ();
261271
262272 Wire.requestFrom (_addr, 2 );
273+ #if ARDUINO >= 100
274+ t = Wire.read ();
275+ x = Wire.read ();
276+ #else
263277 t = Wire.receive ();
264278 x = Wire.receive ();
279+ #endif
265280 x <<= 8 ;
266281 x |= t;
267282 return x;
@@ -272,7 +287,12 @@ uint16_t TSL2561::read16(uint8_t reg)
272287void TSL2561::write8 (uint8_t reg, uint8_t value)
273288{
274289 Wire.beginTransmission (_addr);
290+ #if ARDUINO >= 100
291+ Wire.write (reg);
292+ Wire.write (value);
293+ #else
275294 Wire.send (reg);
276295 Wire.send (value);
296+ #endif
277297 Wire.endTransmission ();
278298}
Original file line number Diff line number Diff line change 3838#ifndef _TSL2561_H_
3939#define _TSL2561_H_
4040
41+ #if ARDUINO >= 100
42+ #include < Arduino.h>
43+ #else
44+ #include < WProgram.h>
45+ #endif
4146#include < Wire.h>
42- #include < WProgram.h>
4347
4448#define TSL2561_VISIBLE 2 // channel 0 - channel 1
4549#define TSL2561_INFRARED 1 // channel 1
You can’t perform that action at this time.
0 commit comments