Skip to content

Current ADC and more - #18

Open
mooiweertje wants to merge 48 commits into
void-spark:masterfrom
mooiweertje:master
Open

Current ADC and more#18
mooiweertje wants to merge 48 commits into
void-spark:masterfrom
mooiweertje:master

Conversation

@mooiweertje

Copy link
Copy Markdown
Contributor

Current ADC and more, NOT GENERIC.

@void-spark

Copy link
Copy Markdown
Owner

I think I merged all your previous PRs, which probably includes everything in here?
The history had become very messy though, so I redid everything grouping it in a few clean commits :)

You're probably better off creating a new branch and checking if there's anything missing, adding that on top again :)

If you look at the files changes in this specific PR, according to GitHub, it's very messy now, and lots of stuff that doesn't make sense. Also I think it's confused about the history and misreporting what it would actually create as PR merge.

@mooiweertje

mooiweertje commented Jul 31, 2026

Copy link
Copy Markdown
Contributor Author

this is much more than what you have. but it is what I use for my LIFEPO4 bikes and not generic. You can't just merge it.
I gave you this to consider making it generic/configurable.

@void-spark

Copy link
Copy Markdown
Owner

Ok, the GitHub PR doesn't show any changes I don't already have :)
Can you tell me which branch you build your firmware from, and give a super short summary of functions that are added?
I should be able to work out from there what the relevant code is :)

@void-spark

Copy link
Copy Markdown
Owner

What I do have already from you is:

  • Use NVS instead of spiffs
  • Add health-check / keepalive
  • Improve battery percentage/voltage smoothing algorithm
  • Clean up GitHub Actions main.yml
  • Reset distance on mode long press
  • Add supermini and tesla configuration

@mooiweertje

Copy link
Copy Markdown
Contributor Author

Here is says that 30 files changed. Most important change is Current ADC next to voltage. So the display shows Ah used in stead of an estimate based on voltage.

@void-spark

Copy link
Copy Markdown
Owner

Yes, 30 files here too, actually, it might be mostly actual differences, just also reverts several changes that should stay :)
And gitmodules are gone :)

Ok, for current, I guess it's the config:
config ION_CURR_ADC
bool "Enable ADC for current measurement"
default n

config ION_CURR_ADC_CHAN
    int "ADC channel to use for current measurement"
    default 6

config ION_BAT_CHARGE
    int "Full battery charge in mAh."
    default 10000

Some changes in display.h, just for CU2:

#if CONFIG_ION_CU2
uint16_t numTop = digits(state->speed, 3, 2);
// uint16_t numTop = digits(getChargePercentage(), 3, 2);
//uint16_t numTop = digits(getBatMv(), 3, 2);
uint32_t numBottom = digits(getTrip1() / 100, 5, 1);
// uint32_t numBottom = digits(getBatMa(), 5, 1);
// uint32_t numBottom = digits(getMah() / 1000, 5, 1);
uint8_t batPercentage = getChargePercentage();
displayUpdateCu2(false, // setDefault
(assist_level)state->level, // assistLevel
BLNK_SOLID, // assistBlink
BLNK_SOLID, // top
BLNK_SOLID, // bottom
false, // miles
batPercentage, // batPercentage
numTop, // topVal
numBottom); // bottomVal

And a new charge.h and charge.cpp

Some changes in main.cpp also, and in bat.cpp / bat.h

And some other smaller calls, a cu2 update in calibration it seems

And I see 3 new sdkconfigs I think :)

What is needed on the circuit side? I see it uses a second ADC channel/pin :)

I think it could be included, but it would take some time to do it cleanly, and I will never have the hardware to test it :)

@mooiweertje

mooiweertje commented Jul 31, 2026

Copy link
Copy Markdown
Contributor Author

It needs a powermodule like this: https://nl.aliexpress.com/item/1005005831224524.html

To make it generic will take some efford still. It works on my bicycles.

To make it generic some configuration stuff needs to be added. Not to much I think but requires some insight on how whings are made configurable now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants