Tactiliest/Boards/UnPhone/Source/UnPhoneFeatures.h
Ken Van Hoeylandt c87200a80d
Project restructuring (fixes macOS builds) (#198)
- Create `Include/` folder for all main projects
- Fix some issues here and there (found while moving things)
- All includes are now in `Tactility/` subfolder and must be included with that prefix. This fixes issues with clashing POSIX headers (e.g. `<semaphore.h>` versus Tactility's `Semaphore.h`)
2025-02-01 18:13:20 +01:00

52 lines
1.1 KiB
C++

#pragma once
#include "bq24295/Bq24295.h"
#include <Tactility/Thread.h>
#include <esp_io_expander_tca95xx_16bit.h>
/**
* Easy access to GPIO pins
*/
class UnPhoneFeatures {
private:
esp_io_expander_handle_t ioExpander = nullptr;
Bq24295 batteryManagement = Bq24295(I2C_NUM_0);
tt::Thread buttonHandlingThread;
bool buttonHandlingThreadInterruptRequest = false;
bool initNavButtons();
static bool initOutputPins();
static bool initPowerSwitch();
bool initGpioExpander();
public:
UnPhoneFeatures() = default;
~UnPhoneFeatures();
bool init();
bool setBacklightPower(bool on) const;
bool getBacklightPower(bool& on) const;
bool setIrPower(bool on) const;
bool setVibePower(bool on) const;
bool setExpanderPower(bool on) const;
bool isPowerSwitchOn() const;
void turnPeripheralsOff() const;
/** Battery management (BQ24295) will stop supplying power until USB connects */
bool setShipping(bool on) const;
void wakeOnPowerSwitch() const;
bool isUsbPowerConnected() const;
bool setRgbLed(bool red, bool green, bool blue) const;
void printInfo() const;
};