Skip to content

Commit f0a3477

Browse files
committed
Load driver update
1 parent 4ab3be6 commit f0a3477

2 files changed

Lines changed: 38 additions & 20 deletions

File tree

demos/LoadDemo/src/MCP23008T/MCP23008T.hpp

Lines changed: 28 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,17 @@
55
* @author Noah (@BobSaidHi <https://github.com/bobsaidhi>) for
66
* @CalPolyWindPower <https://github.com/calpolywindpower>
77
* @since 20260207 (@07507a)
8-
* @version 0.2.0
8+
* @version 0.3.0
99
*/
1010
#pragma once
1111

1212
// MARK: Includes
1313
#include <Adafruit_BusIO_Register.h>
1414
#include <Adafruit_I2CDevice.h>
1515
#include <cstdint>
16-
#include <etl/format_spec.h>
17-
#include <etl/string.h>
18-
#include <etl/to_string.h>
16+
// #include <etl/format_spec.h>
17+
// #include <etl/string.h>
18+
// #include <etl/to_string.h>
1919

2020
/**
2121
* @brief Class to interface with the MCP23008T I2C 8-Bit I/O Expander
@@ -251,26 +251,35 @@ class MCP23008T {
251251
return device.address();
252252
}
253253

254-
static constexpr uint_fast8_t LOG_STRING_SIZE = 3 + 5 + 2 + (3 * 2) + 1;
255254
/**
256-
* @brief Get at string that describes the current state of the actuator
257-
* @returns the current state of the actuator as a string
255+
* @details The GPIO register reflects the value on the port. Reading from
256+
* this register reads the port. Writing to this register modifies the
257+
* Output Latch (OLAT) register.
258+
*
259+
* @returns Returns the value of the GPIO register, or 0xFFFFFFFF on failure
258260
*/
259-
etl::string<LOG_STRING_SIZE> getLogString() {
260-
etl::string<LOG_STRING_SIZE> logString(TAG); // 3 chars
261-
logString.append(": @ox"); // 5 chars
261+
inline uint32_t readGPIO() { return regGPIO.read(); }
262262

263-
etl::format_spec format2;
264-
format2.hex().width(2).fill('0'); // [2 chars]
265-
etl::to_string(getAddress(), logString, format2, true); // 2 chars
263+
// static constexpr uint_fast8_t LOG_STRING_SIZE = 3 + 5 + 2 + (3 * 2) + 1;
264+
// /**
265+
// * @brief Get at string that describes the current state of the actuator
266+
// * @returns the current state of the actuator as a string
267+
// */
268+
// etl::string<LOG_STRING_SIZE> getLogString() {
269+
// etl::string<LOG_STRING_SIZE> logString(TAG); // 3 chars
270+
// logString.append(": @ox"); // 5 chars
266271

267-
etl::format_spec format3;
268-
format3.hex().width(3).fill('0'); // [3 chars]
269-
etl::to_string(readIntCap(), logString, format3, true); // 3 chars
270-
etl::to_string(readIntFlag(), logString, format3, true); // 3 chars
272+
// etl::format_spec format2;
273+
// format2.hex().width(2).fill('0'); // [2 chars]
274+
// etl::to_string(getAddress(), logString, format2, true); // 2 chars
271275

272-
return logString;
273-
}
276+
// etl::format_spec format3;
277+
// format3.hex().width(3).fill('0'); // [3 chars]
278+
// etl::to_string(readIntCap(), logString, format3, true); // 3 chars
279+
// etl::to_string(readIntFlag(), logString, format3, true); // 3 chars
280+
281+
// return logString;
282+
// }
274283

275284
private: // MARK: Private
276285
Adafruit_I2CDevice device;

lib/MCP23008T/MCP23008T.hpp

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* @author Noah (@BobSaidHi <https://github.com/bobsaidhi>) for
66
* @CalPolyWindPower <https://github.com/calpolywindpower>
77
* @since 20260207 (@07507a)
8-
* @version 0.2.0
8+
* @version 0.3.0
99
*/
1010
#pragma once
1111

@@ -251,6 +251,15 @@ class MCP23008T {
251251
return device.address();
252252
}
253253

254+
/**
255+
* @details The GPIO register reflects the value on the port. Reading from
256+
* this register reads the port. Writing to this register modifies the
257+
* Output Latch (OLAT) register.
258+
*
259+
* @returns Returns the value of the GPIO register, or 0xFFFFFFFF on failure
260+
*/
261+
inline uint32_t readGPIO() { return regGPIO.read(); }
262+
254263
static constexpr uint_fast8_t LOG_STRING_SIZE = 3 + 5 + 2 + (3 * 2) + 1;
255264
/**
256265
* @brief Get at string that describes the current state of the actuator

0 commit comments

Comments
 (0)