Function bodies 879 total
createInstance method · cpp · L19-L25 (7 LOC)firmware/boards/diy_smoochie/core/Device.cpp
Device* Device::createInstance() {
pinMode(LCD_BL, OUTPUT);
digitalWrite(LCD_BL, HIGH);
return new Device(display, power, &navigation, nullptr,
&storageSD, &storageLFS, &sdSpi, nullptr);
}DisplayImpl class · c · L5-L33 (29 LOC)firmware/boards/diy_smoochie/core/Display.h
class DisplayImpl : public IDisplay
{
public:
void setBrightness(uint8_t pct) override {
if (pct > 100) pct = 100;
static bool _ready = false;
if (!_ready) {
// Match M5GFX Light_PWM: GPIO38, ch7, 256 Hz, 9-bit (core 2.x API)
ledcSetup(7, 256, 9);
ledcAttachPin(LCD_BL, 7);
_ready = true;
}
// Convert 0-100% → 0-255, then apply M5GFX offset formula
// (freq=256, bits=9, offset=16, invert=false)
uint8_t brightness = (uint8_t)((uint32_t)pct * 255 / 100);
uint32_t duty = 0;
if (brightness) {
static constexpr uint32_t ofs = (16u * 259u) >> 8u; // = 16
duty = (uint32_t)brightness * (257u - ofs);
duty += ofs * 255u;
duty += 1u << 6u; // 1 << (15 - PWM_BITS)
duty >>= 7u; // >> (16 - PWM_BITS)
}
ledcWrite(7, duty);
}
};setBrightness method · c · L8-L32 (25 LOC)firmware/boards/diy_smoochie/core/Display.h
public:
void setBrightness(uint8_t pct) override {
if (pct > 100) pct = 100;
static bool _ready = false;
if (!_ready) {
// Match M5GFX Light_PWM: GPIO38, ch7, 256 Hz, 9-bit (core 2.x API)
ledcSetup(7, 256, 9);
ledcAttachPin(LCD_BL, 7);
_ready = true;
}
// Convert 0-100% → 0-255, then apply M5GFX offset formula
// (freq=256, bits=9, offset=16, invert=false)
uint8_t brightness = (uint8_t)((uint32_t)pct * 255 / 100);
uint32_t duty = 0;
if (brightness) {
static constexpr uint32_t ofs = (16u * 259u) >> 8u; // = 16
duty = (uint32_t)brightness * (257u - ofs);
duty += ofs * 255u;
duty += 1u << 6u; // 1 << (15 - PWM_BITS)
duty >>= 7u; // >> (16 - PWM_BITS)
}
ledcWrite(7, duty);
}NavigationImpl class · c · L5-L16 (12 LOC)firmware/boards/diy_smoochie/core/Navigation.h
class NavigationImpl : public INavigation
{
public:
void begin() override {}
void update() override {
}
private:
Direction _heldDir = DIR_NONE;
};update method · c · L10-L12 (3 LOC)firmware/boards/diy_smoochie/core/Navigation.h
void update() override {
}PowerImpl class · c · L7-L34 (28 LOC)firmware/boards/diy_smoochie/core/Power.h
class PowerImpl : public IPower
{
public:
void begin() override {
pinMode(BAT_ADC_PIN, INPUT);
analogReadMilliVolts(BAT_ADC_PIN); // warm up ADC calibration (first call is slow)
}
uint8_t getBatteryPercentage() override {
// analogReadMilliVolts uses factory ADC calibration (much more accurate than raw analogRead)
float mv = (float)analogReadMilliVolts(BAT_ADC_PIN) * 2.0f; // voltage divider x2
float pct = (mv - 3300.0f) / (4150.0f - 3350.0f) * 100.0f;
if (pct < 0.0f) pct = 0.0f;
if (pct > 100.0f) pct = 100.0f;
return (uint8_t)pct;
}
bool isCharging() override {
// No charger IC — not detectable
return false;
}
void powerOff() override {
// No power IC — use deep sleep
esp_deep_sleep_start();
}
};begin method · c · L10-L14 (5 LOC)firmware/boards/diy_smoochie/core/Power.h
public:
void begin() override {
pinMode(BAT_ADC_PIN, INPUT);
analogReadMilliVolts(BAT_ADC_PIN); // warm up ADC calibration (first call is slow)
}Repobility — the code-quality scanner for AI-generated software · https://repobility.com
getBatteryPercentage method · c · L15-L23 (9 LOC)firmware/boards/diy_smoochie/core/Power.h
uint8_t getBatteryPercentage() override {
// analogReadMilliVolts uses factory ADC calibration (much more accurate than raw analogRead)
float mv = (float)analogReadMilliVolts(BAT_ADC_PIN) * 2.0f; // voltage divider x2
float pct = (mv - 3300.0f) / (4150.0f - 3350.0f) * 100.0f;
if (pct < 0.0f) pct = 0.0f;
if (pct > 100.0f) pct = 100.0f;
return (uint8_t)pct;
}isCharging method · c · L24-L28 (5 LOC)firmware/boards/diy_smoochie/core/Power.h
bool isCharging() override {
// No charger IC — not detectable
return false;
}powerOff method · c · L29-L33 (5 LOC)firmware/boards/diy_smoochie/core/Power.h
void powerOff() override {
// No power IC — use deep sleep
esp_deep_sleep_start();
}createInstance method · cpp · L22-L36 (15 LOC)firmware/boards/m5_cardputer_adv/core/Device.cpp
Device* Device::createInstance() {
pinMode(LCD_BL, OUTPUT);
digitalWrite(LCD_BL, HIGH);
pinMode(SD_CS, OUTPUT);
digitalWrite(SD_CS, HIGH);
sdSpi.begin(SPI_SCK_PIN, SPI_MISO_PIN, SPI_MOSI_PIN, -1);
storageLFS.begin();
bool sdOk = storageSD.begin(SD_CS, sdSpi);
Serial.printf("[DEV] SD init %s (CS=%d SCK=%d MOSI=%d MISO=%d)\n",
sdOk ? "OK" : "FAILED", SD_CS, SPI_SCK_PIN, SPI_MOSI_PIN, SPI_MISO_PIN);
return new Device(display, power, &navigation, &keyboard,
&storageSD, &storageLFS, nullptr, &speaker);
}DisplayImpl class · c · L5-L33 (29 LOC)firmware/boards/m5_cardputer_adv/core/Display.h
class DisplayImpl : public IDisplay
{
public:
void setBrightness(uint8_t pct) override {
if (pct > 100) pct = 100;
static bool _ready = false;
if (!_ready) {
// Match M5GFX Light_PWM: GPIO38, ch7, 256 Hz, 9-bit
ledcSetup(7, 256, 9);
ledcAttachPin(LCD_BL, 7);
_ready = true;
}
// Convert 0-100% → 0-255, then apply M5GFX offset formula
// (freq=256, bits=9, offset=16, invert=false)
uint8_t brightness = (uint8_t)((uint32_t)pct * 255 / 100);
uint32_t duty = 0;
if (brightness) {
static constexpr uint32_t ofs = (16u * 259u) >> 8u; // = 16
duty = (uint32_t)brightness * (257u - ofs);
duty += ofs * 255u;
duty += 1u << 6u; // 1 << (15 - PWM_BITS)
duty >>= 7u; // >> (16 - PWM_BITS)
}
ledcWrite(7, duty);
}
};setBrightness method · c · L8-L32 (25 LOC)firmware/boards/m5_cardputer_adv/core/Display.h
public:
void setBrightness(uint8_t pct) override {
if (pct > 100) pct = 100;
static bool _ready = false;
if (!_ready) {
// Match M5GFX Light_PWM: GPIO38, ch7, 256 Hz, 9-bit
ledcSetup(7, 256, 9);
ledcAttachPin(LCD_BL, 7);
_ready = true;
}
// Convert 0-100% → 0-255, then apply M5GFX offset formula
// (freq=256, bits=9, offset=16, invert=false)
uint8_t brightness = (uint8_t)((uint32_t)pct * 255 / 100);
uint32_t duty = 0;
if (brightness) {
static constexpr uint32_t ofs = (16u * 259u) >> 8u; // = 16
duty = (uint32_t)brightness * (257u - ofs);
duty += ofs * 255u;
duty += 1u << 6u; // 1 << (15 - PWM_BITS)
duty >>= 7u; // >> (16 - PWM_BITS)
}
ledcWrite(7, duty);
}KeyboardImpl class · c · L28-L117 (90 LOC)firmware/boards/m5_cardputer_adv/core/Keyboard.h
class KeyboardImpl : public IKeyboard, public Adafruit_TCA8418
{
public:
void begin() override {
Wire1.begin(KB_I2C_SDA, KB_I2C_SCL);
Wire1.setClock(400000);
delay(100);
if (!Adafruit_TCA8418::begin(KB_I2C_ADDR, &Wire1)) return;
this->matrix(7, 8);
this->flush();
this->enableInterrupts();
_ready = true;
_shift = false;
_key = 0;
_available = false;
}
void update() override {
if (!_ready || _available) return;
if (Adafruit_TCA8418::available() == 0) return;
int raw = this->getEvent();
if (raw == 0) return;
bool pressed = (raw & 0x80) != 0;
uint8_t value = (raw & 0x7F);
uint8_t u = value % 10;
uint8_t t = value / 10;
if (u < 1 || u > 8 || t > 6) return;
uint8_t u0 = u - 1;
uint8_t row = u0 & 0x03;
uint8_t col = (t << 1) | (u0 >> 2);
if (row >= 4 || col >= 14) return;
char n = _ADV_KB_MAP[row][col].n;
if (row == 2 && col == 0) { _fn = pressed; rebegin method · c · L31-L47 (17 LOC)firmware/boards/m5_cardputer_adv/core/Keyboard.h
public:
void begin() override {
Wire1.begin(KB_I2C_SDA, KB_I2C_SCL);
Wire1.setClock(400000);
delay(100);
if (!Adafruit_TCA8418::begin(KB_I2C_ADDR, &Wire1)) return;
this->matrix(7, 8);
this->flush();
this->enableInterrupts();
_ready = true;
_shift = false;
_key = 0;
_available = false;
}Provenance: Repobility (https://repobility.com) — every score reproducible from /scan/
update method · c · L48-L86 (39 LOC)firmware/boards/m5_cardputer_adv/core/Keyboard.h
void update() override {
if (!_ready || _available) return;
if (Adafruit_TCA8418::available() == 0) return;
int raw = this->getEvent();
if (raw == 0) return;
bool pressed = (raw & 0x80) != 0;
uint8_t value = (raw & 0x7F);
uint8_t u = value % 10;
uint8_t t = value / 10;
if (u < 1 || u > 8 || t > 6) return;
uint8_t u0 = u - 1;
uint8_t row = u0 & 0x03;
uint8_t col = (t << 1) | (u0 >> 2);
if (row >= 4 || col >= 14) return;
char n = _ADV_KB_MAP[row][col].n;
if (row == 2 && col == 0) { _fn = pressed; return; }
if (row == 2 && col == 1) { _shift = pressed; return; }
if (row == 3 && col == 0) { _ctrl = pressed; return; }
if (row == 3 && col == 1) { _opt = pressed; return; }
if (row == 3 && col == 2) { _alt = pressed; return; }
if (!pressed) {
if (n != '\0') _keyHeld = false; // non-modifier released
return;
}
if (n == '\0') return;
_key = _shift ? _ADV_KB_MAP[modifiers method · c · L90-L98 (9 LOC)firmware/boards/m5_cardputer_adv/core/Keyboard.h
uint8_t modifiers() override {
uint8_t m = MOD_NONE;
if (_shift) m |= MOD_SHIFT;
if (_fn) m |= MOD_FN;
if (_ctrl) m |= MOD_CTRL;
if (_alt) m |= MOD_ALT;
if (_opt) m |= MOD_OPT;
return m;
}getKey method · c · L99-L103 (5 LOC)firmware/boards/m5_cardputer_adv/core/Keyboard.h
char getKey() override {
_available = false;
return _key;
}NavigationImpl class · c · L5-L54 (50 LOC)firmware/boards/m5_cardputer_adv/core/Navigation.h
class NavigationImpl : public INavigation
{
public:
NavigationImpl(IKeyboard* kb) : _kb(kb) {}
void begin() override {}
void update() override {
if (suppressKeys()) {
updateState(DIR_NONE);
return;
}
if (_kb && _kb->available()) {
char c = _kb->peekKey();
Direction dir = DIR_NONE;
if (c == ';') dir = DIR_UP;
else if (c == '.') dir = DIR_DOWN;
else if (c == '\n') dir = DIR_PRESS;
else if (c == '\b') dir = DIR_BACK;
else if (c == ',') dir = DIR_LEFT;
else if (c == '/') dir = DIR_RIGHT;
if (dir != DIR_NONE) {
_kb->getKey();
_heldDir = dir;
updateState(dir);
return;
}
}
// While the physical key is still held, keep the press active so
// pressDuration() accumulates real hold time.
if (_heldDir != DIR_NONE) {
if (_kb && _kb->isKeyHeld()) {
updateState(_heldDir);
} else {
_heldDir = DIR_NONE;
updateState(DIupdate method · c · L12-L49 (38 LOC)firmware/boards/m5_cardputer_adv/core/Navigation.h
void update() override {
if (suppressKeys()) {
updateState(DIR_NONE);
return;
}
if (_kb && _kb->available()) {
char c = _kb->peekKey();
Direction dir = DIR_NONE;
if (c == ';') dir = DIR_UP;
else if (c == '.') dir = DIR_DOWN;
else if (c == '\n') dir = DIR_PRESS;
else if (c == '\b') dir = DIR_BACK;
else if (c == ',') dir = DIR_LEFT;
else if (c == '/') dir = DIR_RIGHT;
if (dir != DIR_NONE) {
_kb->getKey();
_heldDir = dir;
updateState(dir);
return;
}
}
// While the physical key is still held, keep the press active so
// pressDuration() accumulates real hold time.
if (_heldDir != DIR_NONE) {
if (_kb && _kb->isKeyHeld()) {
updateState(_heldDir);
} else {
_heldDir = DIR_NONE;
updateState(DIR_NONE);
}
return;
}
updateState(DIR_NONE);
}PowerImpl class · c · L7-L34 (28 LOC)firmware/boards/m5_cardputer_adv/core/Power.h
class PowerImpl : public IPower
{
public:
void begin() override {
pinMode(BAT_ADC_PIN, INPUT);
analogReadMilliVolts(BAT_ADC_PIN); // warm up ADC calibration (first call is slow)
}
uint8_t getBatteryPercentage() override {
// analogReadMilliVolts uses factory ADC calibration (much more accurate than raw analogRead)
float mv = (float)analogReadMilliVolts(BAT_ADC_PIN) * 2.0f; // voltage divider x2
float pct = (mv - 3300.0f) / (4150.0f - 3350.0f) * 100.0f;
if (pct < 0.0f) pct = 0.0f;
if (pct > 100.0f) pct = 100.0f;
return (uint8_t)pct;
}
bool isCharging() override {
// No charger IC — not detectable
return false;
}
void powerOff() override {
// No power IC — use deep sleep
esp_deep_sleep_start();
}
};begin method · c · L10-L14 (5 LOC)firmware/boards/m5_cardputer_adv/core/Power.h
public:
void begin() override {
pinMode(BAT_ADC_PIN, INPUT);
analogReadMilliVolts(BAT_ADC_PIN); // warm up ADC calibration (first call is slow)
}getBatteryPercentage method · c · L15-L23 (9 LOC)firmware/boards/m5_cardputer_adv/core/Power.h
uint8_t getBatteryPercentage() override {
// analogReadMilliVolts uses factory ADC calibration (much more accurate than raw analogRead)
float mv = (float)analogReadMilliVolts(BAT_ADC_PIN) * 2.0f; // voltage divider x2
float pct = (mv - 3300.0f) / (4150.0f - 3350.0f) * 100.0f;
if (pct < 0.0f) pct = 0.0f;
if (pct > 100.0f) pct = 100.0f;
return (uint8_t)pct;
}Repobility's GitHub App fixes findings like these · https://github.com/apps/repobility-bot
isCharging method · c · L24-L28 (5 LOC)firmware/boards/m5_cardputer_adv/core/Power.h
bool isCharging() override {
// No charger IC — not detectable
return false;
}powerOff method · c · L29-L33 (5 LOC)firmware/boards/m5_cardputer_adv/core/Power.h
void powerOff() override {
// No power IC — use deep sleep
esp_deep_sleep_start();
}SpeakerADV class · c · L11-L38 (28 LOC)firmware/boards/m5_cardputer_adv/core/Speaker.h
class SpeakerADV : public SpeakerI2S {
public:
void begin() override {
SpeakerI2S::begin();
_initES8311();
}
private:
void _initES8311() {
static constexpr uint8_t regs[][2] = {
{0x00, 0x80}, // RESET / CSM POWER ON
{0x01, 0xB5}, // CLOCK_MANAGER / MCLK=BCLK
{0x02, 0x18}, // CLOCK_MANAGER / MULT_PRE=3
{0x0D, 0x01}, // SYSTEM / Power up analog circuitry
{0x12, 0x00}, // SYSTEM / Power-up DAC
{0x13, 0x10}, // SYSTEM / Enable output to HP drive
{0x32, 0xBF}, // DAC / Volume ±0 dB
{0x37, 0x08}, // DAC / Bypass DAC equalizer
};
for (const auto& r : regs) {
Wire1.beginTransmission(0x18);
Wire1.write(r[0]);
Wire1.write(r[1]);
Wire1.endTransmission();
}
}
};begin method · c · L13-L17 (5 LOC)firmware/boards/m5_cardputer_adv/core/Speaker.h
public:
void begin() override {
SpeakerI2S::begin();
_initES8311();
}_initES8311 method · c · L18-L37 (20 LOC)firmware/boards/m5_cardputer_adv/core/Speaker.h
private:
void _initES8311() {
static constexpr uint8_t regs[][2] = {
{0x00, 0x80}, // RESET / CSM POWER ON
{0x01, 0xB5}, // CLOCK_MANAGER / MCLK=BCLK
{0x02, 0x18}, // CLOCK_MANAGER / MULT_PRE=3
{0x0D, 0x01}, // SYSTEM / Power up analog circuitry
{0x12, 0x00}, // SYSTEM / Power-up DAC
{0x13, 0x10}, // SYSTEM / Enable output to HP drive
{0x32, 0xBF}, // DAC / Volume ±0 dB
{0x37, 0x08}, // DAC / Bypass DAC equalizer
};
for (const auto& r : regs) {
Wire1.beginTransmission(0x18);
Wire1.write(r[0]);
Wire1.write(r[1]);
Wire1.endTransmission();
}
}createInstance method · cpp · L22-L36 (15 LOC)firmware/boards/m5_cardputer/core/Device.cpp
Device* Device::createInstance() {
pinMode(LCD_BL, OUTPUT);
digitalWrite(LCD_BL, HIGH);
pinMode(SD_CS, OUTPUT);
digitalWrite(SD_CS, HIGH);
sdSpi.begin(SPI_SCK_PIN, SPI_MISO_PIN, SPI_MOSI_PIN, -1);
storageLFS.begin();
bool sdOk = storageSD.begin(SD_CS, sdSpi);
Serial.printf("[DEV] SD init %s (CS=%d SCK=%d MOSI=%d MISO=%d)\n",
sdOk ? "OK" : "FAILED", SD_CS, SPI_SCK_PIN, SPI_MOSI_PIN, SPI_MISO_PIN);
return new Device(display, power, &navigation, &keyboard,
&storageSD, &storageLFS, nullptr, &speaker);
}DisplayImpl class · c · L5-L33 (29 LOC)firmware/boards/m5_cardputer/core/Display.h
class DisplayImpl : public IDisplay
{
public:
void setBrightness(uint8_t pct) override {
if (pct > 100) pct = 100;
static bool _ready = false;
if (!_ready) {
// Match M5GFX Light_PWM: GPIO38, ch7, 256 Hz, 9-bit (core 2.x API)
ledcSetup(7, 256, 9);
ledcAttachPin(LCD_BL, 7);
_ready = true;
}
// Convert 0-100% → 0-255, then apply M5GFX offset formula
// (freq=256, bits=9, offset=16, invert=false)
uint8_t brightness = (uint8_t)((uint32_t)pct * 255 / 100);
uint32_t duty = 0;
if (brightness) {
static constexpr uint32_t ofs = (16u * 259u) >> 8u; // = 16
duty = (uint32_t)brightness * (257u - ofs);
duty += ofs * 255u;
duty += 1u << 6u; // 1 << (15 - PWM_BITS)
duty >>= 7u; // >> (16 - PWM_BITS)
}
ledcWrite(7, duty);
}
};setBrightness method · c · L8-L32 (25 LOC)firmware/boards/m5_cardputer/core/Display.h
public:
void setBrightness(uint8_t pct) override {
if (pct > 100) pct = 100;
static bool _ready = false;
if (!_ready) {
// Match M5GFX Light_PWM: GPIO38, ch7, 256 Hz, 9-bit (core 2.x API)
ledcSetup(7, 256, 9);
ledcAttachPin(LCD_BL, 7);
_ready = true;
}
// Convert 0-100% → 0-255, then apply M5GFX offset formula
// (freq=256, bits=9, offset=16, invert=false)
uint8_t brightness = (uint8_t)((uint32_t)pct * 255 / 100);
uint32_t duty = 0;
if (brightness) {
static constexpr uint32_t ofs = (16u * 259u) >> 8u; // = 16
duty = (uint32_t)brightness * (257u - ofs);
duty += ofs * 255u;
duty += 1u << 6u; // 1 << (15 - PWM_BITS)
duty >>= 7u; // >> (16 - PWM_BITS)
}
ledcWrite(7, duty);
}Repobility analyzer · published findings · https://repobility.com
KeyboardImpl class · c · L32-L164 (133 LOC)firmware/boards/m5_cardputer/core/Keyboard.h
class KeyboardImpl : public IKeyboard
{
public:
void begin() override {
for (uint8_t p : _KB_OUT) {
gpio_reset_pin((gpio_num_t)p);
gpio_set_direction((gpio_num_t)p, GPIO_MODE_OUTPUT);
gpio_set_pull_mode((gpio_num_t)p, GPIO_PULLUP_PULLDOWN);
gpio_set_level((gpio_num_t)p, 0);
}
for (uint8_t p : _KB_IN) {
gpio_reset_pin((gpio_num_t)p);
gpio_set_direction((gpio_num_t)p, GPIO_MODE_INPUT);
gpio_set_pull_mode((gpio_num_t)p, GPIO_PULLUP_ONLY);
}
}
void update() override {
if (_available) return;
// wait for all non-modifier keys released before accepting next key
if (_waitRelease) {
bool anyNonMod = false;
for (int i = 0; i < 8; i++) {
_setOutput(i);
uint8_t bits = _readInput();
if (!bits) continue;
uint8_t yf = 3 - ((i > 3) ? (i - 4) : i);
bool x1 = (i > 3);
for (int j = 0; j < 7; j++) {
if (!(bits & (1 << j))) continue;
uint8_t x = begin method · c · L35-L48 (14 LOC)firmware/boards/m5_cardputer/core/Keyboard.h
public:
void begin() override {
for (uint8_t p : _KB_OUT) {
gpio_reset_pin((gpio_num_t)p);
gpio_set_direction((gpio_num_t)p, GPIO_MODE_OUTPUT);
gpio_set_pull_mode((gpio_num_t)p, GPIO_PULLUP_PULLDOWN);
gpio_set_level((gpio_num_t)p, 0);
}
for (uint8_t p : _KB_IN) {
gpio_reset_pin((gpio_num_t)p);
gpio_set_direction((gpio_num_t)p, GPIO_MODE_INPUT);
gpio_set_pull_mode((gpio_num_t)p, GPIO_PULLUP_ONLY);
}
}update method · c · L49-L118 (70 LOC)firmware/boards/m5_cardputer/core/Keyboard.h
void update() override {
if (_available) return;
// wait for all non-modifier keys released before accepting next key
if (_waitRelease) {
bool anyNonMod = false;
for (int i = 0; i < 8; i++) {
_setOutput(i);
uint8_t bits = _readInput();
if (!bits) continue;
uint8_t yf = 3 - ((i > 3) ? (i - 4) : i);
bool x1 = (i > 3);
for (int j = 0; j < 7; j++) {
if (!(bits & (1 << j))) continue;
uint8_t x = x1 ? _KB_X1[j] : _KB_X2[j];
if (_KB_MAP[yf][x].n != '\0') anyNonMod = true;
}
}
_setOutput(0);
if (anyNonMod) return;
_waitRelease = false;
}
bool shiftSeen = false, fnSeen = false, ctrlSeen = false, altSeen = false, optSeen = false;
// first pass: detect modifiers
for (int i = 0; i < 8; i++) {
_setOutput(i);
uint8_t bits = _readInput();
if (!bits) continue;
uint8_t yf = 3 - ((i > 3) ? (i - 4) : i);
bool x1 = (modifiers method · c · L122-L130 (9 LOC)firmware/boards/m5_cardputer/core/Keyboard.h
uint8_t modifiers() override {
uint8_t m = MOD_NONE;
if (_shift) m |= MOD_SHIFT;
if (_fn) m |= MOD_FN;
if (_ctrl) m |= MOD_CTRL;
if (_alt) m |= MOD_ALT;
if (_opt) m |= MOD_OPT;
return m;
}getKey method · c · L131-L136 (6 LOC)firmware/boards/m5_cardputer/core/Keyboard.h
char getKey() override {
_available = false;
_waitRelease = true;
return _key;
}_setOutput method · c · L149-L154 (6 LOC)firmware/boards/m5_cardputer/core/Keyboard.h
void _setOutput(int i) {
gpio_set_level((gpio_num_t)_KB_OUT[0], (i >> 0) & 1);
gpio_set_level((gpio_num_t)_KB_OUT[1], (i >> 1) & 1);
gpio_set_level((gpio_num_t)_KB_OUT[2], (i >> 2) & 1);
}_readInput method · c · L155-L163 (9 LOC)firmware/boards/m5_cardputer/core/Keyboard.h
uint8_t _readInput() {
uint8_t bits = 0;
for (int j = 0; j < 7; j++) {
if (!gpio_get_level((gpio_num_t)_KB_IN[j]))
bits |= (1 << j);
}
return bits;
}NavigationImpl class · c · L5-L54 (50 LOC)firmware/boards/m5_cardputer/core/Navigation.h
class NavigationImpl : public INavigation
{
public:
NavigationImpl(IKeyboard* kb) : _kb(kb) {}
void begin() override {}
void update() override {
if (suppressKeys()) {
updateState(DIR_NONE);
return;
}
if (_kb && _kb->available()) {
char c = _kb->peekKey();
Direction dir = DIR_NONE;
if (c == ';') dir = DIR_UP;
else if (c == '.') dir = DIR_DOWN;
else if (c == '\n') dir = DIR_PRESS;
else if (c == '\b') dir = DIR_BACK;
else if (c == ',') dir = DIR_LEFT;
else if (c == '/') dir = DIR_RIGHT;
if (dir != DIR_NONE) {
_kb->getKey();
_heldDir = dir;
updateState(dir);
return;
}
}
// While the physical key is still held, keep the press active so
// pressDuration() accumulates real hold time.
if (_heldDir != DIR_NONE) {
if (_kb && _kb->isKeyHeld()) {
updateState(_heldDir);
} else {
_heldDir = DIR_NONE;
updateState(DIRepobility — the code-quality scanner for AI-generated software · https://repobility.com
update method · c · L12-L49 (38 LOC)firmware/boards/m5_cardputer/core/Navigation.h
void update() override {
if (suppressKeys()) {
updateState(DIR_NONE);
return;
}
if (_kb && _kb->available()) {
char c = _kb->peekKey();
Direction dir = DIR_NONE;
if (c == ';') dir = DIR_UP;
else if (c == '.') dir = DIR_DOWN;
else if (c == '\n') dir = DIR_PRESS;
else if (c == '\b') dir = DIR_BACK;
else if (c == ',') dir = DIR_LEFT;
else if (c == '/') dir = DIR_RIGHT;
if (dir != DIR_NONE) {
_kb->getKey();
_heldDir = dir;
updateState(dir);
return;
}
}
// While the physical key is still held, keep the press active so
// pressDuration() accumulates real hold time.
if (_heldDir != DIR_NONE) {
if (_kb && _kb->isKeyHeld()) {
updateState(_heldDir);
} else {
_heldDir = DIR_NONE;
updateState(DIR_NONE);
}
return;
}
updateState(DIR_NONE);
}PowerImpl class · c · L7-L34 (28 LOC)firmware/boards/m5_cardputer/core/Power.h
class PowerImpl : public IPower
{
public:
void begin() override {
pinMode(BAT_ADC_PIN, INPUT);
analogReadMilliVolts(BAT_ADC_PIN); // warm up ADC calibration (first call is slow)
}
uint8_t getBatteryPercentage() override {
// analogReadMilliVolts uses factory ADC calibration (much more accurate than raw analogRead)
float mv = (float)analogReadMilliVolts(BAT_ADC_PIN) * 2.0f; // voltage divider x2
float pct = (mv - 3300.0f) / (4150.0f - 3350.0f) * 100.0f;
if (pct < 0.0f) pct = 0.0f;
if (pct > 100.0f) pct = 100.0f;
return (uint8_t)pct;
}
bool isCharging() override {
// No charger IC — not detectable
return false;
}
void powerOff() override {
// No power IC — use deep sleep
esp_deep_sleep_start();
}
};begin method · c · L10-L14 (5 LOC)firmware/boards/m5_cardputer/core/Power.h
public:
void begin() override {
pinMode(BAT_ADC_PIN, INPUT);
analogReadMilliVolts(BAT_ADC_PIN); // warm up ADC calibration (first call is slow)
}getBatteryPercentage method · c · L15-L23 (9 LOC)firmware/boards/m5_cardputer/core/Power.h
uint8_t getBatteryPercentage() override {
// analogReadMilliVolts uses factory ADC calibration (much more accurate than raw analogRead)
float mv = (float)analogReadMilliVolts(BAT_ADC_PIN) * 2.0f; // voltage divider x2
float pct = (mv - 3300.0f) / (4150.0f - 3350.0f) * 100.0f;
if (pct < 0.0f) pct = 0.0f;
if (pct > 100.0f) pct = 100.0f;
return (uint8_t)pct;
}isCharging method · c · L24-L28 (5 LOC)firmware/boards/m5_cardputer/core/Power.h
bool isCharging() override {
// No charger IC — not detectable
return false;
}powerOff method · c · L29-L33 (5 LOC)firmware/boards/m5_cardputer/core/Power.h
void powerOff() override {
// No power IC — use deep sleep
esp_deep_sleep_start();
}createInstance method · cpp · L24-L33 (10 LOC)firmware/boards/m5stickcplus_11/core/Device.cpp
Device* Device::createInstance() {
pinMode(BTN_B, INPUT_PULLUP);
pinMode(BTN_A, INPUT_PULLUP);
Wire1.begin(INTERNAL_SDA, INTERNAL_SCL); // Wire1: AXP192 + BM8563 share same internal I2C bus
storageLFS.begin();
return new Device(display, power, &navigation, nullptr,
nullptr, &storageLFS, nullptr, &speaker);
}applyNavMode method · cpp · L34-L42 (9 LOC)firmware/boards/m5stickcplus_11/core/Device.cpp
void Device::applyNavMode() {
String mode = Config.get(APP_CONFIG_NAV_MODE, APP_CONFIG_NAV_MODE_DEFAULT);
if (mode == "encoder") {
switchNavigation(&encoderNavigation);
} else {
switchNavigation(&navigation);
}
}Provenance: Repobility (https://repobility.com) — every score reproducible from /scan/
boardHook method · cpp · L43-L57 (15 LOC)firmware/boards/m5stickcplus_11/core/Device.cpp
void Device::boardHook() {
static unsigned long _btnAHeld = 0;
if (digitalRead(BTN_A) == LOW) {
if (_btnAHeld == 0) _btnAHeld = millis();
else if (millis() - _btnAHeld >= 3000) {
Config.set(APP_CONFIG_NAV_MODE, APP_CONFIG_NAV_MODE_DEFAULT);
Config.save(Storage);
applyNavMode();
_btnAHeld = 0;
}
} else {
_btnAHeld = 0;
}
}DisplayImpl class · c · L8-L27 (20 LOC)firmware/boards/m5stickcplus_11/core/Display.h
class DisplayImpl : public IDisplay
{
public:
DisplayImpl(AXP192* axp) : _axp(axp) {}
void setBrightness(uint8_t pct) override
{
if (pct > 100) pct = 100;
if (pct == 0) {
_axp->SetLDO2(false); // cut LDO2 power → display off
} else {
_axp->SetLDO2(true); // ensure LDO2 is enabled
_axp->ScreenBreath(pct);
}
}
private:
AXP192* _axp;
};setBrightness method · c · L13-L23 (11 LOC)firmware/boards/m5stickcplus_11/core/Display.h
void setBrightness(uint8_t pct) override
{
if (pct > 100) pct = 100;
if (pct == 0) {
_axp->SetLDO2(false); // cut LDO2 power → display off
} else {
_axp->SetLDO2(true); // ensure LDO2 is enabled
_axp->ScreenBreath(pct);
}
}page 1 / 18next ›