Skip to content

Commit da626ed

Browse files
authored
Merge pull request #3 from sparkfun/bug_fixes
Bug fixes to support actual use.
2 parents 6ef3732 + fa3facb commit da626ed

File tree

4 files changed

+21
-10
lines changed

4 files changed

+21
-10
lines changed

library.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name=SparkFun STHS34PF80 Arduino Library
2-
version=1.0.0
2+
version=1.0.1
33
author=SparkFun Electronics <techsupport@sparkfun.com>
44
maintainer=SparkFun Electronics <sparkfun.com>
55
sentence=A library to drive the STMicroelectronics infrared sensor STHS34PF80.

src/SparkFun_STHS34PF80_Arduino_Library.cpp

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,22 @@
1+
2+
3+
4+
15
#include "SparkFun_STHS34PF80_Arduino_Library.h"
26

3-
int32_t STHS34PF80_I2C::begin(uint8_t devAddr, TwoWire& wirePort)
7+
8+
9+
bool STHS34PF80_I2C::begin(uint8_t devAddr, TwoWire& wirePort)
410
{
511
bus.init(devAddr, Wire);
612
sensor.read_reg = STHS34PF80_I2C::read;
713
sensor.write_reg = STHS34PF80_I2C::write;
814
sensor.mdelay = STHS34PF80_I2C::delayMS;
915
sensor.handle = &bus;
1016

11-
STHS34PF80::begin();
17+
// call super class begin -- it returns 0 on no error
18+
return STHS34PF80::begin() == 0;
1219

13-
return 0; // returns error code here
1420
}
1521

1622
int32_t STHS34PF80_I2C::read(void* bus, uint8_t addr, uint8_t* data, uint16_t numData)
@@ -32,17 +38,17 @@ void STHS34PF80_I2C::delayMS(uint32_t millisec)
3238
delay(millisec);
3339
}
3440

35-
int32_t STHS34PF80_SPI::begin(uint8_t chipSelect, SPIClass &spiPort)
41+
bool STHS34PF80_SPI::begin(uint8_t chipSelect, SPIClass &spiPort)
3642
{
3743
bus.init(chipSelect, spiPort, false);
3844
sensor.read_reg = STHS34PF80_SPI::read;
3945
sensor.write_reg = STHS34PF80_SPI::write;
4046
sensor.mdelay = STHS34PF80_SPI::delayMS;
4147
sensor.handle = &bus;
4248

43-
STHS34PF80::begin();
49+
// call super class begin -- it returns 0 on no error
50+
return STHS34PF80::begin() == 0;
4451

45-
return 0; // returns error code here
4652
}
4753

4854
int32_t STHS34PF80_SPI::read(void* bus, uint8_t addr, uint8_t* data, uint16_t numData)

src/SparkFun_STHS34PF80_Arduino_Library.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ Distributed as-is; no warranty is given.
1919

2020

2121
#include "sths34pf80_class.h"
22-
#include "SFE_Bus.h"
22+
#include "sfe_bus.h"
2323
#include <Arduino.h>
2424
#include <Wire.h>
2525
#include <SPI.h>
@@ -28,7 +28,7 @@ Distributed as-is; no warranty is given.
2828
class STHS34PF80_I2C : public STHS34PF80
2929
{
3030
public:
31-
int32_t begin(uint8_t devAddr = STHS34PF80_I2C_ADD >> 1, TwoWire& wirePort = Wire);
31+
bool begin(uint8_t devAddr = STHS34PF80_I2C_ADDRESS, TwoWire& wirePort = Wire);
3232
static int32_t read(void *, uint8_t, uint8_t *, uint16_t);
3333
static int32_t write(void *, uint8_t, const uint8_t *, uint16_t);
3434
static void delayMS(uint32_t millisec);
@@ -39,7 +39,7 @@ class STHS34PF80_I2C : public STHS34PF80
3939
class STHS34PF80_SPI : public STHS34PF80
4040
{
4141
public:
42-
int32_t begin(uint8_t chipSelect, SPIClass &spiPort=SPI);
42+
bool begin(uint8_t chipSelect, SPIClass &spiPort=SPI);
4343
static int32_t read(void *, uint8_t, uint8_t *, uint16_t);
4444
static int32_t write(void *, uint8_t, const uint8_t *, uint16_t);
4545
static void delayMS(uint32_t millisec);

src/sths34pf80_class.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@
44
#include "sths34pf80_api/sths34pf80_reg.h"
55
#include "sfe_bus.h"
66

7+
8+
// define a standard i2c address (7 bit) macro
9+
10+
#define STHS34PF80_I2C_ADDRESS (STHS34PF80_I2C_ADD >> 1)
11+
712
class STHS34PF80
813
{
914
public:

0 commit comments

Comments
 (0)