Pretty much at least. I've added an EEPROM variable for storing the magazine capacity and I've added support for programming the magazine capacity and for resetting the rounds remaining counter without turning off the entire device.
The device can be in two modes: run and program. Run is the normal count-down-when-a-round-is-fired mode and the PRG/RST button will reset the counter (for when you put in a fresh magazine).
To enter program mode, press the PRG/RST switch while powering on the device. The display will show "PrG" for a second (as opposed to "run" in run mode) and then the counter will show 000. Pressing the PRG/RST button will increase the counter which is the magazine capacity. If the PRG/RST button is held down for a second, the counter will increase quickly. The capacity is saved in EEPROM every time is it increased so simply turn off and back on the device to use the new capacity.
Download the code here: firmware_rev2
Points of note:
- Both the photo interrupter and the reset switch work as external interrupts (INT0 and INT1, respectively)
- In programming mode, a 1 second timer compare match interrupt is used for hold-to-count-quickly
- Magazine capacity is stored in EEPROM