D.I.Y. Illuminated Tailcap - gChart Editions

I assembled another smart tailcap and put it in a S41S (stainless, not colored).

New firmware this time: when starting up, it “dials up” the battery readout and displays it for 3 seconds. Then it goes into a slow rotate animation.

Hmm… I wonder how a pseudo-random “twinkling” animation would look?

I always thought it might look neat to do sort of a roulette wheel animation while waiting for voltage to settle, then take a reading and slow down the animation until it stops at a point representing the current charge. After that, I figured I would have it go into a low-power beacon mode which blinks the result periodically.

That was for a RGB tailcap though. I guess on a 8-of-the-same-color design it would display based on how many LEDs are illuminated.

As designed, I could use multiple colors of LEDs (perhaps 4 each of 2 different colors). I’m not sure how that would work for a roulette animation, but it could be a start. And I considered having this rotating animation pause occasionally to display the battery level… not sure yet. Or perhaps just stop the animation and switch to a beacon once it hits a low-batt threshold? Dunno yet.

PS - thoughts on how to efficiently do an 8-bit pseudo-random pattern? Bitshifting a predefined pattern? Using int rand() from <stdlib.h>?

Pull the code bytes out of flash with an incrementing pointer and output them. When your through, bend it back to the beginning.

Here’s a dancing/twinkling version. After seeing it, I’m not sure if it’s my cup of tea, but it was fun to make.

It should be pretty simple. The battery status is displayed based on how many LEDs are illuminated. Just rotate that same pattern. They’d still spin around, but the number lit up at any time would indicate the charge level.

The library rand() function would work, and you probably have plenty of space to include it. Or you could roll your own. For example, combine the contents of ROM with a random seed, and do things to make the seed more volatile. I force bits to rotate each time it’s accessed, and I also add real-world entropy to it from each ADC measurement, so it ends up being a true random instead of just pseudo-random. It’s not crypto-grade randomness, but it’s not bad for a cheap chip in a flashlight.

Thanks TK. Nice idea on rotating the battery level.

I went ahead a precalculated a ~250 value array of values the randomly switched one bit on, then one bit off. I probably could have just called rand() from the attinys. But for now I think I’ll keep your tip in my back pocket for later.

Very creative gc. I could not work out on the video above the dancing light how the voltage was read from the light sequence.

Thanks! The voltage readout on that one happens right as it’s turning on. You’ll notice it initially ’spin up” to a certain number of LEDs (1 thru 8) indicating voltage level. It displays that for 3 seconds, then starts a non-informative dance.

I also have it checking the voltage every couple of minutes. If it detects <3.0 volts, it’ll stop dancing and will start flashing a single LED.

There are probably several fun things to do with an 8-pixel tail ring like that, especially if it can use the internal resistor to get more than one brightness level. Most of what comes to mind would require a relatively high frame rate though, so probably not ideal for a low-power tailcap. Perhaps it could underclock the MCU to the kHz range and/or run the WDT in sleep mode at a fairly quick rate.

I could see using it to do something similar to candle mode, except it’d also change the position, not just the brightness. Or maybe a couple simultaneous random spinners with erratic motion.

Simply spinning the battery status is probably the most useful mode though.

I’m currently running the main clock using the internal ultra low power oscillator, no prescaler (so 32.768 kHz). Using the real time counter interrupt to wake up as needed to move the LEDs.

I haven’t tried adding the internal pull-ups into the mix, but I bet that would work.

Also, it wouldn’t satisfy the anti-PWM crowd, but even with the main clock at 32 kHz, low-resolution PWM could be used for some fading effects. Something like a 16-level (2 kHz) or 8-level (4 kHz) PWM could work, and still be pretty low current draw. Ohh, the possibilities :slight_smile:

I know the feeling. I got a keyboard with RGB LEDs under each key, individually addressable. I was pretty excited… I had 64 pixels! So of course I immediately modified the firmware to make it run a physics simulation which responds to keypresses. It simulates the surface of a swimming pool, and each keystroke acts like a raindrop which causes waves.

While eight pixels may not be quite as flexible, it’s still plenty to have a good time. After being limited to just one pixel for so long, eight sounds like a vast playground of possibilities.

New “smart” tailcap today. This one is mini for AA sized lights. Swapped out a friend’s Booster Tail for this one since he always uses his Sofirn SF14 with li-ions (with AA/NiMH the flashlight will still work of course, just not the tailcap now). It has 6 LEDs uses them to display battery status.

First battery in the video was at 4.07 V, the second was at 3.55 V.

I currently have the breakdown as such:

  • 6 LEDs: 4.0 V +
  • 5 LEDs: 3.8 - 4.0 V
  • 4 LEDs: 3.6 - 3.8 V
  • 3 LEDs: 3.4 - 3.6 V
  • 2 LEDs: 3.2 - 3.4 V
  • 1 LED: 3.0 - 3.2 V
  • Below 3.0 V, it shuts off

This new smart tail cap is a cool idea! reminds me of the new Olight battery status indicators, just in a better location?

Sweet! Glad to see that they arrived. Everything go smoothly?

For my Convoy M1 with L4P driver, yes. Pretty straightforward, just 2 pin to solder between your board and the omten switch and that’s it !
For the Tool AA, unfortunately I didn’t think about it before but I use a Biscotti 5*7135 driver… so the bleeder resistor is tricky to define. I used a 332 (3,3Kohms) but now it’s “next mode” memory…
I have to try a smaller value maybe ? Anyway, I put the tailcap in the lathe at work to accommodate a 14mm clear tailcap :slight_smile:

I pretty much always just use a ~840 Ohm bleeder for Bicotti-type drivers. As long as you’re not using an OTC, they usually don’t seem too picky (unless you’ve got the FX-12 type… I’ve never had good luck with those)

I'd love something like this on some of my lights. It's often bothered me on my simpler lights that I don't have built-in charge indication. My ideal operation would probably be to tell me battery voltage when I first turn on the light... possibly even stay lit during use (and live-update the display periodically). I'm worried I'd have trouble counting the pixels, which makes me lean towards someone else's earlier suggestion of using like two red, two yellow, and four green LEDs. So 100% would be all of them, 50% just the red and yellow, and 25% just the red.

Because of how illuminated tailcaps work, they only light up while the flashlight is off. Aside from that, what you’re proposing is very easy with the existing hardware. I’d just need to play around with balancing the colors and tweak the code a little bit. I usually don’t get too much into color mixing due to color blindness, but I could definitely make one for someone else… and have the wife verify that I got the colors right. If you’re interested in something like that, hit me up on PM.