Skip to content
Open
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
63 changes: 63 additions & 0 deletions boards/_boards_json/xk404.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
{
"build": {
"arduino": {
"ldscript": "esp32s3_out.ld",
"partitions": "default_16MB.csv",
"memory_type": "qio_opi"
},
"core": "esp32",
"extra_flags": [
"-DXK404",
"-DBOARD_HAS_PSRAM",
"-DARDUINO_RUNNING_CORE=1",
"-DARDUINO_EVENT_RUNNING_CORE=1",
"-DARDUINO_USB_MODE=1",
"-DARDUINO_USB_CDC_ON_BOOT"
],
"f_cpu": "240000000L",
"f_flash": "80000000L",
"flash_mode": "qio",
"hwids": [
[
"0x239A",
"0x811B"
],
[
"0x239A",
"0x011B"
],
[
"0x239A",
"0x811C"
]
],
"mcu": "esp32s3",
"variant": "pinouts"
},
"connectivity": [
"bluetooth",
"wifi",
"lora"
],
"debug": {
"default_tool": "esp-builtin",
"onboard_tools": [
"esp-builtin"
],
"openocd_target": "esp32s3.cfg"
},
"frameworks": [
"arduino",
"espidf"
],
"name": "xk404",
"upload": {
"flash_size": "16MB",
"maximum_ram_size": 327680,
"maximum_size": 16777216,
"require_upload_port": true,
"speed": 460800
},
"url": "https://bruce.computer/",
"vendor": "SMOOCHIEE"
}
2 changes: 2 additions & 0 deletions boards/pinouts/pins_arduino.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@
#include "../ESP-General/pins_arduino.h"
#elif SMOOCHIEE_BOARD
#include "../smoochiee-board/pins_arduino.h"
#elif XK404
#include "../xk404/pins_arduino.h"
#elif T_WATCH_S3
#include "../lilygo-t-watch-s3/pins_arduino.h"
#elif T_DISPLAY_S3_PRO
Expand Down
52 changes: 27 additions & 25 deletions boards/smoochiee-board/interface.cpp
Original file line number Diff line number Diff line change
@@ -1,20 +1,17 @@
#include "core/powerSave.h"

#include <driver/adc.h>
#include <esp_adc_cal.h>
#include <soc/adc_channel.h>
#include <soc/soc_caps.h>

/***************************************************************************************
** Function name: _setup_gpio()
** Location: main.cpp
** Description: initial setup for the device
***************************************************************************************/

// Power handler for battery detection
#ifdef XPOWERS_CHIP_BQ25896
#include <Wire.h>
#include <XPowersLib.h>
XPowersPPM PPM;
#endif

void _setup_gpio() {

Expand All @@ -34,9 +31,9 @@ void _setup_gpio() {
bruceConfig.rfModule = CC1101_SPI_MODULE;
bruceConfig.irRx = RXLED;
Wire.setPins(GROVE_SDA, GROVE_SCL);
Wire.begin();
// Wire.begin();
bool pmu_ret = false;

Wire.begin(GROVE_SDA, GROVE_SCL);
pmu_ret = PPM.init(Wire, GROVE_SDA, GROVE_SCL, BQ25896_SLAVE_ADDRESS);
if (pmu_ret) {
PPM.setSysPowerDownVoltage(3300);
Expand All @@ -48,25 +45,37 @@ void _setup_gpio() {
PPM.setChargerConstantCurr(832);
PPM.getChargerConstantCurr();
Serial.printf("getChargerConstantCurr: %d mA\n", PPM.getChargerConstantCurr());
PPM.enableADCMeasure();
PPM.enableCharge();
PPM.enableOTG();
PPM.enableMeasure(PowersBQ25896::CONTINUOUS);
PPM.disableOTG();
PPM.enableCharge();
}
}
bool isCharging() {
//PPM.disableBatterPowerPath();
return PPM.isCharging();
}


/***************************************************************************************
** Function name: getBattery()
** location: display.cpp
** Description: Delivers the battery value from 1-100+
***************************************************************************************/
int getBattery() {
int8_t percent = 0;
percent = (PPM.getSystemVoltage() - 3300) * 100 / (float)(4150 - 3350);
int voltage = PPM.getBattVoltage();
int percent = (voltage - 3300) * 100 / (float)(4150 - 3350);

if (percent < 0) return 0;
if (percent > 100) percent = 100;

return (percent < 0) ? 0 : (percent >= 100) ? 100 : percent;
if (PPM.isCharging() && percent >= 97) {
PPM.disableBatLoad();
percent = 95; // estimate still charging
}

if (PPM.isChargeDone()) { percent = 100; }

return percent;
}




/*********************************************************************
** Function: setBrightness
** location: settings.cpp
Expand Down Expand Up @@ -160,10 +169,3 @@ void checkReboot() {
tft.fillRect(60, 12, tftWidth - 60, tft.fontHeight(1), bruceConfig.bgColor);
}
}
/***************************************************************************************
** Function name: isCharging()
** Description: Determines if the device is charging
***************************************************************************************/
bool isCharging() {
return PPM.isCharging(); // Return the charging status from BQ27220
}
Loading