@RH64 Well the main original goal, OTSM, has some problems still, and it's a mystery at the moment that I'm a bit stumped on. The debugging required to get the bottom of it is maybe not lightweight at all either (maybe needs custom hardware to time triggered shutdowns for example, a bunch just to debug).
@Lexel I think I misunderstood where you're coming from. You're trying to port the e-switch into Bistro-TA. That's your mistake. Bistro-HD is a not a specialty release like some previous ones. It fully includes bistro-TA, as well as bistro-trippledown and plain bistro, and I may even get a BLFA6 emulation build into it. It's just a matter of selecting the right config options. I'm presently working on separating pre-set configs out into separate files so we can just have configs like this laid out for custom lights and ready to go. It will be part of the next release. I don't know much about biscotti, but ideally that would be config options too. That may be unrealistic, not sure.
Anyway, what you need is just to go to fr-tk-attiny.h
Go to the trippledown layout section.
Uncomment this:
//#define ESWITCH_PIN PB3
That defines the eswitch as being on the traditional CAP pin.
Actually there should be no problem with me leaving that uncommented by default, but it wasn't. You don't need to uncomment the CAP_PIN either (if everything works right), and in fact you can use it for both.
Then go to bistro-HD.c In the top section the #define statements turn options on and off, until line 209.
then enable USE_ESWITCH. (un-comment #define USE_ESWITCH)
You will want to go down and look at the first boot options and set them how you like too. Memory is turned on by default I think which wasn't actually my intent, probably happened during testing (another reason to have custom config files).
Now comes the complicated stuff. Is it a 1S light? Does it have an LDO, a protection diode? If it's 1-S with no LDO, I would set READ_VOLTAGE_FROM_VCC and comment out READ_VOLTAGE_FROM_DIVIDER This frees up the voltage pin from complication. This only works if Vcc sees the battery voltage (minus possibly a small diode drop).
Now, what about your clicky switch? We can have it use the tk noinit method that requires no cap. gchart and I have been working on an upgrade for that in BLFA6 to address a fairly serious reliability issue. It's working there. It's not in here yet, but could be soon. You can USE OTSM, but it's not working right yet, and may never be low parasitic drain. You could use OTC actually. You would just put both a cap and a switch on the OTC pads. The switch will short the cap and bring it down. Might want a small series resistance in line with the switch to reduce the cap discharge current. I think this is a good option for now.
If you want OTSM, and you're using READ_VOLTAGE_FROM_VCC you'll want R1 to be 1/3 (no more, less is ok) of R2. And the total bleed resistance (R1+R2 is part of that, parallel to bleeder) is still a mystery. It should work with a total of 4k but there are question marks still.
If you're using READ_VOLTAGE_FROM_DIVIDER and OTSM you'll want the max divider voltage to correspond to Vcc, or maybe 5% less. If it drops too low it will trigger OTSM. In that case you'd also need to reference the ADC off Vcc and I think the option for that only exists in my un-released version.
Anyway, either enable USE_OTSM or USE_OTC, or neither to revert to the noinit method. I wouldn't go with OTSM at the moment unless you want to help fix it. Even OTC or noinit in combination with E_SWITCH are still very alpha and you should approach it that initialliy it can be a lockout and get the e-switch working. If it does more on first try, that's a bonus. These combinations were tricky to work out and still untested.
At some point maybe I can work up a config for your case and all you'll need to do is select the right config file. The danger with doing too much of this is it's more baggage to maintain if the configs all need some re-working. Oh well, if they weren't there, they'd need to be reworked too, just not by the programmer who broke them. It puts more responsibility on the development side.