mirror of
https://github.com/crosspoint-reader/crosspoint-reader.git
synced 2026-04-29 10:26:52 -07:00
Initial support for the x3
This commit is contained in:
@@ -9,6 +9,16 @@ HalDisplay::~HalDisplay() {}
|
||||
|
||||
void HalDisplay::begin() { einkDisplay.begin(); }
|
||||
|
||||
void HalDisplay::setDcPin(int8_t pin) { einkDisplay.setDcPin(pin); }
|
||||
|
||||
void HalDisplay::setBusyActiveHigh(bool activeHigh) { einkDisplay.setBusyActiveHigh(activeHigh); }
|
||||
|
||||
void HalDisplay::setBwOnly(bool bwOnly) { einkDisplay.setBwOnly(bwOnly); }
|
||||
|
||||
void HalDisplay::setControllerType(EInkDisplay::ControllerType type) { einkDisplay.setControllerType(type); }
|
||||
|
||||
void HalDisplay::setDisplayDimensions(uint16_t width, uint16_t height) { einkDisplay.setDisplayDimensions(width, height); }
|
||||
|
||||
void HalDisplay::clearScreen(uint8_t color) const { einkDisplay.clearScreen(color); }
|
||||
|
||||
void HalDisplay::drawImage(const uint8_t* imageData, uint16_t x, uint16_t y, uint16_t w, uint16_t h,
|
||||
@@ -51,3 +61,11 @@ void HalDisplay::copyGrayscaleMsbBuffers(const uint8_t* msbBuffer) { einkDisplay
|
||||
void HalDisplay::cleanupGrayscaleBuffers(const uint8_t* bwBuffer) { einkDisplay.cleanupGrayscaleBuffers(bwBuffer); }
|
||||
|
||||
void HalDisplay::displayGrayBuffer(bool turnOffScreen) { einkDisplay.displayGrayBuffer(turnOffScreen); }
|
||||
|
||||
uint16_t HalDisplay::getDisplayWidth() const { return einkDisplay.getDisplayWidth(); }
|
||||
|
||||
uint16_t HalDisplay::getDisplayHeight() const { return einkDisplay.getDisplayHeight(); }
|
||||
|
||||
uint16_t HalDisplay::getDisplayWidthBytes() const { return einkDisplay.getDisplayWidthBytes(); }
|
||||
|
||||
uint32_t HalDisplay::getBufferSize() const { return einkDisplay.getBufferSize(); }
|
||||
|
||||
@@ -20,6 +20,13 @@ class HalDisplay {
|
||||
// Initialize the display hardware and driver
|
||||
void begin();
|
||||
|
||||
// Pre-begin display config passthroughs (used by X3 setup path)
|
||||
void setDcPin(int8_t pin);
|
||||
void setBusyActiveHigh(bool activeHigh);
|
||||
void setBwOnly(bool bwOnly);
|
||||
void setControllerType(EInkDisplay::ControllerType type);
|
||||
void setDisplayDimensions(uint16_t width, uint16_t height);
|
||||
|
||||
// Display dimensions
|
||||
static constexpr uint16_t DISPLAY_WIDTH = EInkDisplay::DISPLAY_WIDTH;
|
||||
static constexpr uint16_t DISPLAY_HEIGHT = EInkDisplay::DISPLAY_HEIGHT;
|
||||
@@ -47,6 +54,12 @@ class HalDisplay {
|
||||
|
||||
void displayGrayBuffer(bool turnOffScreen = false);
|
||||
|
||||
// Runtime geometry passthrough
|
||||
uint16_t getDisplayWidth() const;
|
||||
uint16_t getDisplayHeight() const;
|
||||
uint16_t getDisplayWidthBytes() const;
|
||||
uint32_t getBufferSize() const;
|
||||
|
||||
private:
|
||||
EInkDisplay einkDisplay;
|
||||
};
|
||||
|
||||
+13
-2
@@ -5,7 +5,14 @@
|
||||
void HalGPIO::begin() {
|
||||
inputMgr.begin();
|
||||
SPI.begin(EPD_SCLK, SPI_MISO, EPD_MOSI, EPD_CS);
|
||||
pinMode(BAT_GPIO0, INPUT);
|
||||
|
||||
// X3 boards bias GPIO4 (EPD DC) around ~700 ADC counts at boot in our setup.
|
||||
// X4 boards do not, and use GPIO0 for battery ADC.
|
||||
_detectAdcValue = analogRead(4);
|
||||
_deviceType = (_detectAdcValue > 500 && _detectAdcValue < 1200) ? DeviceType::X3 : DeviceType::X4;
|
||||
_batteryPin = (_deviceType == DeviceType::X3) ? 4 : BAT_GPIO0;
|
||||
|
||||
pinMode(_batteryPin, INPUT);
|
||||
pinMode(UART0_RXD, INPUT);
|
||||
}
|
||||
|
||||
@@ -36,6 +43,10 @@ void HalGPIO::startDeepSleep() {
|
||||
}
|
||||
|
||||
int HalGPIO::getBatteryPercentage() const {
|
||||
if (_deviceType == DeviceType::X3) {
|
||||
// X3 battery telemetry is not on ADC in stock fw; avoid fighting EPD DC on GPIO4.
|
||||
return 0;
|
||||
}
|
||||
static const BatteryMonitor battery = BatteryMonitor(BAT_GPIO0);
|
||||
return battery.readPercentage();
|
||||
}
|
||||
@@ -61,4 +72,4 @@ HalGPIO::WakeupReason HalGPIO::getWakeupReason() const {
|
||||
return WakeupReason::AfterUSBPower;
|
||||
}
|
||||
return WakeupReason::Other;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,6 +23,14 @@ class HalGPIO {
|
||||
InputManager inputMgr;
|
||||
#endif
|
||||
|
||||
public:
|
||||
enum class DeviceType : uint8_t { X4, X3 };
|
||||
|
||||
private:
|
||||
DeviceType _deviceType = DeviceType::X4;
|
||||
int _detectAdcValue = 0;
|
||||
int _batteryPin = BAT_GPIO0;
|
||||
|
||||
public:
|
||||
HalGPIO() = default;
|
||||
|
||||
@@ -47,6 +55,11 @@ class HalGPIO {
|
||||
// Check if USB is connected
|
||||
bool isUsbConnected() const;
|
||||
|
||||
// Device detection helpers
|
||||
DeviceType getDeviceType() const { return _deviceType; }
|
||||
int getDetectAdcValue() const { return _detectAdcValue; }
|
||||
int getBatteryPin() const { return _batteryPin; }
|
||||
|
||||
enum class WakeupReason { PowerButton, AfterFlash, AfterUSBPower, Other };
|
||||
|
||||
WakeupReason getWakeupReason() const;
|
||||
|
||||
Reference in New Issue
Block a user