- Add setChargeCurrentLimitA() and getChargeCurrentLimitA() functions * Range: 0.04A-2.0A in 0.04A steps (register 0x02, bits 10:5) - Add setChargeVoltageLimitV() and getChargeVoltageLimitV() functions * Range: 3.5V-4.8V in 0.01V steps (register 0x04, bits 11:3) - Add setInputCurrentLimitA() and getInputCurrentLimitA() functions * Range: 0.1A-3.2A in 0.02A steps (register 0x06, 8 bits shifted by 4) - Add setInputVoltageLimitV() and getInputVoltageLimitV() functions * Range: 3.8V-16.8V in 0.04V steps (register 0x08, 9 bits shifted by 5) - Add setMinimalSystemVoltageV() and getMinimalSystemVoltageV() functions * Range: 2.56V-3.84V in 0.08V steps (register 0x0E, 6 bits shifted by 6) - Update test example with all register functions and F() strings for SRAM optimization - All functions verified working with hardware showing correct default values 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
76 lines
No EOL
2 KiB
C++
76 lines
No EOL
2 KiB
C++
/*!
|
|
* Test sketch for the Adafruit BQ25628E I2C Battery Charger library
|
|
*
|
|
* Designed specifically to work with the Adafruit BQ25628E Breakout
|
|
* Pick one up today in the adafruit shop!
|
|
*
|
|
* Author: Limor 'ladyada' Fried with assistance from Claude Code
|
|
* License: MIT
|
|
*/
|
|
|
|
#include "Adafruit_BQ25628E.h"
|
|
|
|
Adafruit_BQ25628E bq;
|
|
|
|
void setup() {
|
|
Serial.begin(115200);
|
|
while (!Serial) delay(10);
|
|
|
|
Serial.println(F("Adafruit BQ25628E Test!"));
|
|
|
|
if (!bq.begin()) {
|
|
Serial.println(F("Failed to find BQ25628E chip"));
|
|
while (1) delay(10);
|
|
}
|
|
|
|
Serial.println(F("BQ25628E Found!"));
|
|
|
|
// Uncomment to set charge current limit to 1.0A
|
|
// bq.setChargeCurrentLimitA(1.0);
|
|
|
|
// Test charge current limit functions
|
|
float current = bq.getChargeCurrentLimitA();
|
|
Serial.print(F("Current charge limit: "));
|
|
Serial.print(current);
|
|
Serial.println(F(" A"));
|
|
|
|
// Uncomment to set charge voltage limit to 4.1V
|
|
// bq.setChargeVoltageLimitV(4.1);
|
|
|
|
// Test charge voltage limit functions
|
|
float voltage = bq.getChargeVoltageLimitV();
|
|
Serial.print(F("Current voltage limit: "));
|
|
Serial.print(voltage);
|
|
Serial.println(F(" V"));
|
|
|
|
// Uncomment to set input current limit to 2.0A
|
|
// bq.setInputCurrentLimitA(2.0);
|
|
|
|
// Test input current limit functions
|
|
float input_current = bq.getInputCurrentLimitA();
|
|
Serial.print(F("Current input limit: "));
|
|
Serial.print(input_current);
|
|
Serial.println(F(" A"));
|
|
|
|
// Uncomment to set input voltage limit to 5.0V
|
|
// bq.setInputVoltageLimitV(5.0);
|
|
|
|
// Test input voltage limit functions
|
|
float input_voltage = bq.getInputVoltageLimitV();
|
|
Serial.print(F("Current input voltage limit: "));
|
|
Serial.print(input_voltage);
|
|
Serial.println(F(" V"));
|
|
|
|
// Uncomment to set minimal system voltage to 3.0V
|
|
// bq.setMinimalSystemVoltageV(3.0);
|
|
|
|
// Test minimal system voltage functions
|
|
float min_sys_voltage = bq.getMinimalSystemVoltageV();
|
|
Serial.print(F("Current minimal system voltage: "));
|
|
Serial.print(min_sys_voltage);
|
|
Serial.println(F(" V"));
|
|
}
|
|
|
|
void loop() {
|
|
delay(1000);
|
|
} |