Fixing MAX17048 usermod

I would love to use the MAX17048 mod to monitor the battery charge, which I could use in my project powered by 18650 cells.

Unfortunately, the mod was last updated a year ago and for some reason it is not visible after installing it in Visual Studio.

[env:esp32dev]
board = esp32dev
platform = ${esp32.platform}
platform_packages = ${esp32.platform_packages}
upload_speed = 921600
custom_usermods = audioreactive deep_sleep EXAMPLE MAX17048_v2
build_unflags = ${common.build_unflags}
build_flags = ${common.build_flags} ${esp32.build_flags}
    -D WLED_RELEASE_NAME=\"ESP32_MULTI_USREMODS\"
    -D WLED_ENABLE_USERMOD_PAGE # if created
    -D USERMOD_MAX17048_v2
lib_deps = 
  ${esp32.lib_deps}
  https://github.com/adafruit/Adafruit_BusIO @ 1.17
  https://github.com/adafruit/Adafruit_MAX1704X @ 1.0.3

I thought that the method of adding mods to the project had probably changed, but the logic and code for reading the charge value would be identical. Theoretically, using the example mod, I could create a working mod by copying code fragments from the MAX17048 mod.
Especially since the libraries seem to be added correctly:

Dependency Graph
|-- LittleFS_esp32 @ 1.0.6+sha.f0817ca
|-- AsyncTCP @ 1.3.1
|-- AnimatedGIF @ 1.4.7
|-- GifDecoder @ 1.1.0+sha.bc3af18
|-- FastLED @ 3.6.0
|-- IRremoteESP8266 @ 2.8.2
|-- NeoPixelBus @ 2.8.3
|-- ESPAsyncWebServerWLED @ 2.4.0+sha.2d3af2c
|-- QuickEspNow @ 0.8.1+sha.193e991
|-- Adafruit BusIO @ 1.17.0+sha.055013b
|-- Adafruit MAX1704X @ 1.0.3+sha.4953d76
|-- audioreactive
|-- deep_sleep
|-- Wire @ 1.0.1
|-- EEPROM @ 1.0.3
|-- ArduinoOTA @ 1.0
|-- DNSServer @ 1.1.0
|-- ESPmDNS @ 1.0
|-- WiFi @ 1.0
|-- SPI @ 1.0
|-- ESP32 Async UDP @ 1.0.0
|-- WebServer @ 1.0
Building in release mode

Additionally, if it was not too complicated, I would like to add the ability to configure LED outputs 1, 2, 3 or 4, which would signal the battery level and display a charging animation.

Unfortunately, the problem turned out to be just running the Example code.
Nothing appears in the usermods tab

I guess I’ll have to use another mod as a base.

DeepSleep seems to add correctly.

usermods are now libraries, check how others are done.

I copied the folder with the v2 project and made changes based on the working libraries, mainly changing the names in several places. Somehow it worked :smiley: (I don’t know exactly why yet)

Unfortunately, the MAX17048 dev board I have doesn’t seem to work, so I’ll have to wait for the second one

MAX17048_v3.zip (4.8 KB)

The new MAX17048 chip arrived and it works. I will write what needs to be changed so that the mod can be copied correctly in the new version and I will let the author know to update the files

or submit a PR