Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Devices/m5stack-papers3/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ file(GLOB_RECURSE SOURCE_FILES Source/*.c*)

idf_component_register(SRCS ${SOURCE_FILES}
INCLUDE_DIRS "Source"
REQUIRES FastEpdDisplay GT911 TactilityCore
REQUIRES EPDiyDisplay GT911 TactilityCore driver EstimatedPower
)
9 changes: 6 additions & 3 deletions Devices/m5stack-papers3/Source/Configuration.cpp
Original file line number Diff line number Diff line change
@@ -1,19 +1,22 @@
#include "devices/Display.h"
#include "devices/SdCard.h"
#include "devices/Power.h"

#include <Tactility/hal/Configuration.h>

using namespace tt::hal;

bool initBoot();

static DeviceVector createDevices() {
auto touch = createTouch();
return {
createPower(),
createDisplay(),
createSdCard(),
createDisplay(touch)
};
}

extern const Configuration hardwareConfiguration = {
.initBoot = nullptr,
.initBoot = initBoot,
.createDevices = createDevices
};
48 changes: 48 additions & 0 deletions Devices/m5stack-papers3/Source/Init.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
#include <Tactility/Logger.h>
#include <driver/gpio.h>

static const auto LOGGER = tt::Logger("Paper S3");

constexpr gpio_num_t VBAT_PIN = GPIO_NUM_3;
constexpr gpio_num_t CHARGE_STATUS_PIN = GPIO_NUM_4;
constexpr gpio_num_t USB_DETECT_PIN = GPIO_NUM_5;

static bool powerOn() {
if (gpio_reset_pin(CHARGE_STATUS_PIN) != ESP_OK) {
LOGGER.error("Failed to reset CHARGE_STATUS_PIN");
return false;
}

if (gpio_set_direction(CHARGE_STATUS_PIN, GPIO_MODE_INPUT) != ESP_OK) {
LOGGER.error("Failed to set direction for CHARGE_STATUS_PIN");
return false;
}

if (gpio_reset_pin(USB_DETECT_PIN) != ESP_OK) {
LOGGER.error("Failed to reset USB_DETECT_PIN");
return false;
}

if (gpio_set_direction(USB_DETECT_PIN, GPIO_MODE_INPUT) != ESP_OK) {
LOGGER.error("Failed to set direction for USB_DETECT_PIN");
return false;
}

// VBAT_PIN is used as ADC input; only reset it here to clear any previous
// configuration. The ADC driver (ChargeFromAdcVoltage) configures it for ADC use.
if (gpio_reset_pin(VBAT_PIN) != ESP_OK) {
LOGGER.error("Failed to reset VBAT_PIN");
return false;
}
return true;
}

bool initBoot() {
LOGGER.info("Power on");
if (!powerOn()) {
LOGGER.error("Power on failed");
return false;
}

return true;
}
27 changes: 8 additions & 19 deletions Devices/m5stack-papers3/Source/devices/Display.cpp
Original file line number Diff line number Diff line change
@@ -1,34 +1,23 @@
#include "Display.h"
#include <Gt911Touch.h>
#include <FastEpdDisplay.h>
#include <Tactility/lvgl/LvglSync.h>
#include <EpdiyDisplayHelper.h>

std::shared_ptr<tt::hal::touch::TouchDevice> createTouch() {
auto configuration = std::make_unique<Gt911Touch::Configuration>(
I2C_NUM_0,
540,
960,
false, // swapXy
false, // mirrorX
true, // swapXy
true, // mirrorX
false, // mirrorY
GPIO_NUM_NC, // pinReset
GPIO_NUM_NC // pinInterrupt
GPIO_NUM_NC //48 pinInterrupt
);

auto touch = std::make_shared<Gt911Touch>(std::move(configuration));
return std::static_pointer_cast<tt::hal::touch::TouchDevice>(touch);
return std::make_shared<Gt911Touch>(std::move(configuration));
}

std::shared_ptr<tt::hal::display::DisplayDevice> createDisplay(std::shared_ptr<tt::hal::touch::TouchDevice> touch) {
FastEpdDisplay::Configuration configuration = {
.horizontalResolution = 540,
.verticalResolution = 960,
.touch = std::move(touch),
.busSpeedHz = 20000000,
.rotationDegrees = 90,
.use4bppGrayscale = false,
.fullRefreshEveryNFlushes = 40,
};

return std::make_shared<FastEpdDisplay>(configuration, tt::lvgl::getSyncLock());
std::shared_ptr<tt::hal::display::DisplayDevice> createDisplay() {
auto touch = createTouch();
return EpdiyDisplayHelper::createM5PaperS3Display(touch);
}
5 changes: 2 additions & 3 deletions Devices/m5stack-papers3/Source/devices/Display.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#pragma once

#include <memory>
#include <Tactility/hal/display/DisplayDevice.h>
#include <Tactility/hal/touch/TouchDevice.h>

std::shared_ptr<tt::hal::touch::TouchDevice> createTouch();
std::shared_ptr<tt::hal::display::DisplayDevice> createDisplay(std::shared_ptr<tt::hal::touch::TouchDevice> touch);
std::shared_ptr<tt::hal::display::DisplayDevice> createDisplay();
Loading