Hacker News new | ask | show | jobs
by salex89 2555 days ago
Was a pinhole reset button so hard to implement?
1 comments

Yeah, it would be. You want the user to stick their hand up in a lamp, with the power on? And try to poke a button with a sharp metal object?

I suppose you could add a big capacitor or battery so that it could be reset when not in the lamp, but that is non-trivial.

Perhaps you could use an on/off switch, and do something like this.

    function power_on() {
        bool sw_pos_last = eeprom_read(SWITCH_LASTBOOT);
        bool sw_pos_now = input_read(SWITCH);
        if (sw_pos_last != sw_pos_now) {
            eeprom_write(SWITCH_LASTBOOT, sw_pos_now);
            factory_reset();
        }
    }
To reset, simply turn it off, press the switch, turn it on, done!

No power is needed to latch a reset request when the bulb is disconnected. Seems easy and straightforward, at worst you need to power the bulb on/off several times.

> I suppose you could add a big capacitor or battery so that it could be reset when not in the lamp, but that is non-trivial.

Even if you go this way with only a momentary switch, it's not trivial, but I don't think it's rocket science either, just an example to make the point: using a flip-flop and a 100 uF capacitor, with an isolated Vcc supply (can be supplied by the MCU). The flip-flop draws 1 mA of current at 5 volt, you press a reset switch to invert the flip-flop, when the bulb is turned on later, the MCU would read a different state and trigger the factory reset. 100 uF would give the user at least 2 minutes to react, assuming the worst capacitor. To detect the power loss of the flip-flop, use a comparator before MCU reapplies the power, the cost is less than 1 USD, and I bet the electronics engineers can come up with a even better solution.

Well that's a very good design.