I just built a hilt and blade plug charger. Normally the TP4056 charge module in the plug lights red while charging and turns blue when charged. However in this instance, both LEDs light up together.
Battery is new and is moderately charged (3.7 volts) so should be able to accept more. I can’t see anything in the config that I haven’t used for the same feature before.
But then it occurred to me that for this hilt, I’ve wired the switch commons to batt+ at the back of the neo connector, instead of the more usual Gnd, in order to save a bit of wiring space, with the button setup modded accordingly in the config.
Could that be tripping up the charge module? And if so, I assume there isn’t a software fix and I’ll need to rewire it?
As always, thoughts welcome.
Short answer is no, it should not matter how you wired switches and LEDs.
… unless there is a short somewhere.
Ah interesting. I felt sure that was it. Will have to dig some more tomorrow then. It’s weird because other than the charge issue, the saber works fine.
Will report back when I figure it out…
Update to this:
It seems that ChargingStylePtr doesn’t work quite as expected…
As I understand it, this bladestyle:
ChargingStylePtr<Black>(),
should keep the pins powered for blade plug charging without any other code required. Unfortunately it doesn’t appear to do it. I tested with fresh downloads of 7.15 and GitHub Master, but both were the same.
But if I add this code to the top of my config:
#ifdef CONFIG_STYLES
class BlackPower {
public:
LayerRunResult run(BladeBase* base) {
return LayerRunResult::UNKNOWN;
}
SimpleColor getColor(int led) {
return SimpleColor(Color16(0,0,0));
}
};
#endif
and then use this for the blade style:
ChargingStylePtr<BlackPower>(),
everything works as it should.
To be honest, I was doing the extra code thing for ages until quite recently when I learned that ChargingStyePtr alone should take care of it. I guess that’s why I never spotted this sooner despite doing quite a few installs with blade plug charging.
1 Like
How did you test it?
Can you post your full config?
With the config below, as mentioned above, I Initially I had both red and blue LEDs on the charge plug lighting up together. I tried both GitHub Master and 7.15, but both were the same. So I tried the plug in another hilt that I knew worked with a plug charger, and it worked fine, which confirmed that the plug itself was OK.
So I then tried going onto a normal preset, igniting the blade with no blade fitted, shutting off, then immediately shoving the live plug charger into the emitter. Since the pins stay live for a second or two after shutoff, expected behaviour was the charger turning red (charging) while the pins were live then turning blue once they shut off and the charge module in effect was no longer connected, and this did indeed prove to be the case. This suggested that when pins were correctly live, there was no issue with charging, but something about the charging style wasn’t keeping them live, or was doing something else at the same time that was tripping up the charge module.
So I tried resinstating the code above along with the BlackPower blade style, and hey presto - everything started working again.
Anyway here’s the config that displayed the issue. The charge preset is the very last one.
I checked in a fix on github master, let me know if ChargingStylePtr works better now…
Interesting - that won’t compile for me:
Yep, that’s cracked it! 
Thanks Prof. 
Worth a bugfix to 7.16, or just leave it as an 8.x thing?
It’s a fairly minor bug, and not that many people use it I think.
If I make another 7.x zip, I will definitely include it though.
2 Likes