seth10 / watch Goto Github PK
View Code? Open in Web Editor NEWI'm making a watch with an Adafruit Trinket and an 4-digit alphanumeric or 128x64 OLED display
I'm making a watch with an Adafruit Trinket and an 4-digit alphanumeric or 128x64 OLED display
The Trinket has an ATtiny85, which has just 8K of flash and 512 bytes of SRAM. Can we get the Adafruit_SSD1306 library (including the Adafruit-GFX-Library) to run on this little guy?
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.
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
and HIGH
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 the RISING
or FALLING
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 calls loop
again (need to test it), as seen in the video linked earlier (note ISR (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.
"I wonder if you can oscillate it fast enough to make greys" @pimlu
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.