OMOTE/Platformio/hardware/ESP32/keyboard_ble_hal_esp32.cpp
Max a13418b035 Hardware Revision 4 Initial Commit
Changes in hardware:
- MAX17048 for battery monitoring instead of ESP32 ADC
- Onboard LiPo protection for overvoltage, undervoltage and overcurrent (DW01A) (issue #53)
- Testpoints added for critical signals
- Capacitor on ESP32_EN changed from 100nF to 1uF ( issue #62)
- Easier to source LiPo charger (TP4056)
- LiPo charger status input fixed(issue #55)
Changes in software:
- MAX17048G added as source for battery stats (enabled by defining board revision 4 in Platformio.ini)
2024-05-25 17:08:23 +02:00

55 lines
1.2 KiB
C++

#if (ENABLE_KEYBOARD_BLE == 1)
#include "lib/ESP32-BLE-Keyboard/BleKeyboard.h"
#include "battery_hal_esp32.h"
BleKeyboard bleKeyboard("OMOTE Keyboard", "CoretechR");
void init_keyboardBLE_HAL() {
int battery_voltage;
int battery_percentage;
boolean battery_ischarging;
get_battery_status_HAL(&battery_voltage, &battery_percentage, &battery_ischarging);
bleKeyboard.setBatteryLevel(battery_percentage);
bleKeyboard.begin();
}
bool keyboardBLE_isConnected_HAL() {
return bleKeyboard.isConnected();
}
void keyboardBLE_end_HAL() {
bleKeyboard.end();
}
void keyboardBLE_write_HAL(uint8_t c) {
bleKeyboard.write(c);
}
void keyboardBLE_longpress_HAL(uint8_t c) {
bleKeyboard.press(c);
delay(1000);
bleKeyboard.release(c);
}
void keyboardBLE_home_HAL() {
bleKeyboard.press(KEY_LEFT_ALT);
bleKeyboard.press(KEY_ESC);
bleKeyboard.releaseAll();
}
void keyboardBLE_sendString_HAL(const std::string &s) {
bleKeyboard.print(s.c_str());
}
void consumerControlBLE_write_HAL(const MediaKeyReport value) {
bleKeyboard.write(value);
}
void consumerControlBLE_longpress_HAL(const MediaKeyReport value) {
bleKeyboard.press(value);
delay(1000);
bleKeyboard.release(value);
}
#endif