Skip to content
This repository has been archived by the owner on May 26, 2024. It is now read-only.

Commit

Permalink
cleaned up code
Browse files Browse the repository at this point in the history
  • Loading branch information
generationmake committed Feb 9, 2022
1 parent 151f960 commit f828d7d
Show file tree
Hide file tree
Showing 8 changed files with 10 additions and 39 deletions.
3 changes: 0 additions & 3 deletions .github/workflows/compile-examples.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,6 @@ jobs:
LIBRARIES: |
# Install the library from the local path.
- source-path: ./
- name: 107-Arduino-Debug
- name: 107-Arduino-Sensor
- name: 107-Arduino-BoostUnits
strategy:
fail-fast: false
Expand Down
3 changes: 1 addition & 2 deletions examples/TCS3472-Basic/TCS3472-Basic.ino
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ void i2c_generic_read (uint8_t const i2c_slave_addr, uint8_t const reg_addr, uin

ArduinoTCS3472 tcs3472(i2c_generic_write,
i2c_generic_read,
// delay,
TCS3472::DEFAULT_I2C_ADDR);

/**************************************************************************************
Expand All @@ -42,7 +41,7 @@ void setup()
if (!tcs3472.begin())
{
Serial.print("ArduinoTCS3472::begin(...) failed, error code ");
Serial.print((int)tcs3472.error());
Serial.print(static cast<int>(tcs3472.error()));
for(;;) { }
}

Expand Down
14 changes: 7 additions & 7 deletions keywords.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ write KEYWORD2
# Constants (LITERAL1)
#######################################

TCS3472_ClearErrorFlag LITERAL1
TCS3472_ProgrammingControl LITERAL1
TCS3472_OTP_RegisterZeroPosition_HIGH LITERAL1
TCS3472_OTP_RegisterZeroPosition_LOW LITERAL1
TCS3472_Diagnostics_AutomaticGainControl LITERAL1
TCS3472_Magnitude LITERAL1
TCS3472_Angle LITERAL1
ClearErrorFlag LITERAL1
ProgrammingControl LITERAL1
OTP_RegisterZeroPosition_HIGH LITERAL1
OTP_RegisterZeroPosition_LOW LITERAL1
Diagnostics_AutomaticGainControl LITERAL1
Magnitude LITERAL1
Angle LITERAL1
2 changes: 1 addition & 1 deletion library.properties
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ category=Sensors
url=https://github.com/107-systems/107-Arduino-TCS3472
architectures=samd,mbed,mbed_nano,mbed_portenta,mbed_edge,esp8266
includes=107-Arduino-TCS3472.h
depends=107-Arduino-Sensor
depends=
1 change: 0 additions & 1 deletion src/107-Arduino-TCS3472.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ using namespace TCS3472;

ArduinoTCS3472::ArduinoTCS3472(TCS3472::I2cWriteFunc write,
TCS3472::I2cReadFunc read,
// TCS3472::DelayFunc delay,
uint8_t const i2c_slave_addr)
: _error{TCS3472::Error::None}
, _io{write, read, i2c_slave_addr}
Expand Down
2 changes: 0 additions & 2 deletions src/107-Arduino-TCS3472.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
**************************************************************************************/

#include "TCS3472/TCS3472_Io.h"
#include "Arduino.h"

/**************************************************************************************
* CLASS DECLARATION
Expand All @@ -34,7 +33,6 @@ class ArduinoTCS3472

ArduinoTCS3472(TCS3472::I2cWriteFunc write,
TCS3472::I2cReadFunc read,
// TCS3472::DelayFunc delay,
uint8_t const i2c_slave_addr);

bool begin();
Expand Down
17 changes: 0 additions & 17 deletions src/TCS3472/TCS3472_Io.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,23 +69,6 @@ void TCS3472_Io::write(Register const reg, uint8_t const * buf, size_t const byt
_write(_i2c_slave_addr, to_integer(reg), buf, bytes);
}

void TCS3472_Io::modify(Register const reg, uint8_t const bitmask, uint8_t const val)
{
uint8_t reg_val = read(reg);
reg_val &= ~(bitmask);
reg_val |= (val & bitmask);
write(reg, reg_val);
}

bool TCS3472_Io::isBitSet(Register const reg, uint8_t const bitpos)
{
uint8_t const reg_val = read(reg);
if (reg_val & (1<<bitpos))
return true;
else
return false;
}

/**************************************************************************************
* NAMESPACE
**************************************************************************************/
Expand Down
7 changes: 1 addition & 6 deletions src/TCS3472/TCS3472_Io.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,25 +43,20 @@ class TCS3472_Io
TCS3472_Io(I2cWriteFunc write, I2cReadFunc read, uint8_t const i2c_slave_addr);


inline void set_i2c_slace_addr(uint8_t const i2c_slave_addr) { _i2c_slave_addr = i2c_slave_addr; }


void write (Register const reg);
uint8_t read (Register const reg);
uint16_t read16 (Register const reg);
void write (Register const reg, uint8_t const val);
void read (Register const reg, uint8_t * buf, size_t const bytes);
void write (Register const reg, uint8_t const * buf, size_t const bytes);
void modify (Register const reg, uint8_t const bitmask, uint8_t const val);
bool isBitSet(Register const reg, uint8_t const bitpos);


private:

I2cWriteFunc _write;
I2cReadFunc _read;

uint8_t _i2c_slave_addr;
uint8_t const _i2c_slave_addr;
};

/**************************************************************************************
Expand Down

0 comments on commit f828d7d

Please sign in to comment.