Open seth10 opened 7 years ago
Update on idea 3: I just desoldered the wires and soldered on some pins so I could play with the trinket and display on a mini breadboard. With Vcc connected to 5V the sketch writes some characters to the display. If is disconnect Vcc from 5V the characters remain, but are very dim. Reconnecting Vcc to 5V brings the display back to full brightness, retaining the characters without any additional I2C data being transmitted.
Now I connect Vcc to pin 4. In the first line of the sketch I set it to an OUTPUT
and then HIGH
. When I programmatically set it LOW
, the display completely shuts off. When I return the state of pin 4 to HIGH
, the display remains blank. After pausing a moment then calling .begin
once again, the display shows some random characters. After calling .writeDisplay
again the characters return, but this means an I2C transmission was required to restore the buffer from the trinket to the display.
I need to programmatically emulate my pulling out the Vcc wire. Setting pin 4 LOW
grounds the display and completely shuts it off. If I instead set pin 4 an INPUT
, the display still shuts off, but when I restore the pin to an OUTPUT
and set it HIGH
, the characters return.
OOPS just realized this is not what I was trying to achieve
Idea 3 and 4 will work, I just tested it on a breadboard. The display does remain dim when the switch is off or the button is not pressed. It may be worthwhile to time the battery in the half-on state. Also check if software brightness makes a difference. Doing so does not have any visible effect, and I'd guess it doesn't have an effect on battery either.. Further note that disconnecting Vi2c has no effect (besides cutting off any updates), the display remains on at full brightness.
TODO: Look at the HT16K33 datasheet for how to use a software standby mode. Or maybe just call .clear()
I had to repair the bootloader. Eventually I was able to get it working again. After more toying around it broke again, and I have not been able to repair the bootloader since. It felt so great when I fixed it the first time though. When I was doing some testing I did run into issue that I had Vcc connected to pin 4, which is used for USB programming. I had to either disconnect and reconnect the USB cable, or disconnect pin 4 then hit reset to program. However, with pin 4 connected it did skip the bootloader, which could actually be useful in the final implementation.
The 4-digit 14-segment alphanumeric display lasts 6 hours at full brightness (default). Lowering it to the minimum brightness lets it last 9 hours. These tests were done with a 105mAh battery. Still a 9 hour watch isn't that useful. To save power, only turn on the screen with a user's input.
Ideas
Put a switch between the battery and trinket. This was my first idea, but without a real-time clock the "watch" wouldn't be able to keep track of how much time has passed.
Turn on the screen for a few seconds when a button is pressed. Even better, because we can control the brightness, I can fade the screen on, pause a few moment, then fade it out. For this idea I would need to unbridge Vcc and Vi2c, leaving Vi2c connected but now connecting Vcc to a pin, say pin 3. There's no reason to ever need to disconnect Vi2c, so leave that connected. Pin 0 and 2 are used for I2C data and clock, so that leaves pins 1, 3 and 4 open. Pins 3 and 4 are used for programming the ATtiny85, but unfortunately we'll have to use one of them. We need two pins: one for [conditionally] powering the display, and one for the button. I wanted to keep these new functions on the other side of the board and noise away from the I2C lines, hence pins 3 and 4, but the trinket pinout page recommends using them for output, if unavoidable. So we'll save pin 1 for the button input and use pin 3 for powering the display. Setting this pin to an
OUTPUT
andHIGH
should end up being no different than if we had just connected it to power. Instead of constantly polling the button, we'll use an interrupt to handle it. This video greatly helped me see how to do this with the trinket. This would be great if we could actually even put the Attiny85 to sleep and use the pin change interrupt to wake it up. This would save even more power. We don't need to worry about only listening for theRISING
orFALLING
edge or debouncing, because (hopefully) this would just make the display stay on for a moment longer before it falls back asleep. Waking the processor with a pin change interrupt either resumes execution from where it went to sleep or just callsloop
again (need to test it), as seen in the video linked earlier (noteISR (PCINT0_vect)
is left empty). So after setting pin 3 to high, we'll probably have to send the.begin
command each time we power on the display.Use a switch to turn on the display. Similar to above, but instead of dealing with all of that added complexity, just put a switch between Vcc and 5V on the trinket. Unfortunately, then the trinket wouldn't be able to know when the display gets turned on. If the display doesn't remember the digits it was last displaying, the trinket would need to constantly be sending I2C data. I'm not sure how much power this would take as I have not tested it. I have also not tested if the display remembers its state when it loses and regains Vcc. Vi2c will remain on, if that makes any difference. I also wouldn't be able to fade in the display with this method.
Same as the previous idea, but use a button. The display would be on as the push button is held. The advantage is that it's a simple button press, the disadvantage is that you have to hold it. However, you wouldn't have to remember to turn it off like the switch. The button has a reasonable, satisfying click, while the switch is quite firm. I would be concerned of it snapping off.