Last post I said that in the dark, ATLAS would bring the frontlight up automagically.
And it did! It came up automagically. Then it went off automagically. Then on. Then off. Then on. lol
Let me back up.

The screen and the glass
Short recap. ATLAS is running the Sharp Memory-In-Pixel now, 400x240 mono. Every pixel holds its own state, so once a screen is drawn the panel just sits there holding it for basically nothing. No backlight to feed. A GPS page parked on a 3D fix does not need 60fps, it needs to still be there in eight hours with battery left.
The catch, and I knew this going in, is that it's fully reflective. Gorgeous in sunlight!, gets better the brighter it is out. In the dark it's a mirror. Nothing to see.
Hence the frontlight. You can't light one of these from behind (the back IS the reflector) so it has to come in from the bezel and wash across the face.
One correction from last time, I said Gorilla glass. It's now 1.75mm Borofloat 33 now. Nothing wrong with Gorilla, but go try and order 50 custom-cut pieces of it and let me know how that goes. (not great) Borofloat comes in 1.75mm as a stock thickness, so I get fire-polished cuts with ground edges from a normal supplier on a normal lead time. Also does not care about going from a hot car into a 14C cave, which matters.
For the lamp itself, warm Edison-style filaments around the bezel. Yes, partly because amber doesn't wreck your night vision.
Then I wrote about three lines of code...
Read the light sensor. Dark? Lamp on. Bright? Lamp off.
Three lines. I felt pretty good about those three lines.
Took it into a dim room. The sensor reads low, so ATLAS goes "it's dark in here" and fires up the lamp. Lamp comes on. And the TSL2591 is sitting on the front face about 9mm away from a lamp that is now on. Reads a TON of light. ATLAS goes "oh, plenty bright, we're good" and shuts it off. Room is dim again...
You see where this is going. It sat on my bench flashing at me like a squad car.
Now here's the part I'm not proud of. I checked the wiring first. Of course I did. Went looking for a cold joint, a flaky sensor, something in the mux. Twenty years of this and my first instinct is still "the hardware betrayed me." It hadn't. The firmware was doing exactly what I told it to do, which is the worst kind of bug there is.
I built a positive feedback loop into a device whose entire job is measuring the world around it. It was measuring itself. In three lines. I stood there watching it blink for a good minute before I touched anything because it was, and still is, hilarious. Congratulations Apollo, you've invented a $200 candle. Battery powered. Speaks English.
Fixing it
First instinct is hysteresis. Split the on and off thresholds, add a dwell timer, flashing stops. Except that doesn't actually fix anything, it just makes it fail quietly. The reading still has the lamp in it, so now the lamp latches on and sits there forever in a dim room instead of blinking. Traded a loud bug for a quiet one.
What it needs is the room with the lamp taken out of it. So I taught it what its own light looks like.
Every time the frontlight switches, it grabs a reading right before, flips, waits for the sensor to settle, grabs another. The difference between them is what the lamp is contributing through this exact stack of bezel, glass and panel. Average that over time (it wanders a bit with duty cycle, and with however dusty the bezel got this month) and from then on the logic runs on measured-minus-lamp instead of raw lux. Hysteresis and a dwell timer still go on top, belt and suspenders. And one fast path, if the raw reading jumps way past anything the lamp could possibly account for, somebody opened a door or you walked out of the treeline, kill it now, don't wait on a timer.
One thing worth stealing if you're building something like this: save that lamp number to flash and load it at boot. Start it at zero and the first switch after a cold boot still hiccups once before it converges. Same exact thing bit me on the magnetometer alignment seeding. A filter that starts at zero will lie to you on its first sample, every single time.
So now it knows what it looks like to itself and subtracts itself out before it decides anything. Which is a weirdly philosophical thing to have to write into a flashlight.
I kept the video of it blinking. Obviously.
Meramec Caverns
A dim lab is not a test. I wanted actual zero, where the only photons in the room are the ones ATLAS is making, because that's the nightmare case for that loop. No ambient at all means nothing to swamp it. The old code wouldn't have flickered down there, it would have gone full square wave.
Meramec is about an hour southwest of the lab. Missouri is not short on holes in the ground.

Held rock steady the entire walk through. Not one flicker.
Everything else did about what you'd hope. GPS is gone a few meters past the entrance and stays gone, which is the whole reason the HOME page runs on logged crumbs plus BNO085 dead reckoning, arrow keeps pointing with zero satellites. Need more testing here though, more caves. A way to see the conf or error rate on the screen. Light sensor pinned at the bottom of its range the whole time. That last one is the reading I actually drove out there for. CO2 was not fitted this round. And it and a better pressure sensor is still on its way.
And standing in there with it lit up in my hand, warm amber on a mono screen, water dripping somewhere off in the dark... yeah. That's the thing I set out to build. Still get me sometimes.
Where it's at now...
Panel, glass and frontlight are locked for the first 50 Founders Edition units. Lamp calibration gets written per-unit at test since bezel tolerance and LED binning move that number around more than you'd think.
Enjoy the pics. More soon, probably the speech path, since that's that's a key feature.
Apollo Timbers
Discussions
Become a Hackaday.io Member
Create an account to leave a comment. Already have an account? Log In.