Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to use setBatteryLevel function in the combo library #10

Open
deven322 opened this issue Aug 15, 2022 · 1 comment
Open

How to use setBatteryLevel function in the combo library #10

deven322 opened this issue Aug 15, 2022 · 1 comment

Comments

@deven322
Copy link

So I want to check the battery level and display it via a neopixel, The problem is in the normal library I could just create an instance of the class and call the function but here in this combo library, it's not working.

I tried using:
BleCombo.setBatteryLevel(percentage);

This is what the batteryLevel Function is like:

void batteryLevel() {
int sensorValue = analogRead(ADC);
float voltage = sensorValue * (5.12 / 4095.0);
Serial.print(voltage);
Serial.print("V ||");
int percentage = (voltage / 4.2) * 100;
Serial.print(percentage);
Serial.println("%");
BleCombo.setBatteryLevel(percentage);
if (percentage < 60) {
Serial.println("LOW battery");
for (uint8_t i = 30; i < 220; i++) {
for (int j = 0; j < 6; j++) {
leds[j] = CHSV( HUE_RED, 255, i);
}
FastLED.show();
delay(15);
}
for (uint8_t i = 220; i > 30; i--) {
for (int j = 0; j < 6; j++) {
leds[j] = CHSV( HUE_RED, 255, i);
}
FastLED.show();
delay(15);
}
}
}

It would be of great help if you help find me the solution!
Thanks!

@charleslck
Copy link

You can use Keyboard.setBatteryLevel(80);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants