Simple clock using TM1637 4-digit display #883
harshkc03
started this conversation in
Show and tell
Replies: 1 comment 2 replies
-
Nice. The data pin needs to be open-drain (as it's both input and output). However, for that it should also have a pull-up. However, currently, there is no way to set the pull-up flag with a Here is, what I mean: diff --git a/examples/clock.toit b/examples/clock.toit
index 0ee7c95..7bd287f 100644
--- a/examples/clock.toit
+++ b/examples/clock.toit
@@ -5,7 +5,7 @@ main:
// Set clock and data pins as output
pinCLK := gpio.Pin 22 --output
- pinDIO := gpio.Pin 23 --output
+ pinDIO := gpio.Pin 23 --output --pull_up
// Initialize display and set the brightness as 7 (max)
disp := tm1637.Tm1637 pinCLK pinDIO
diff --git a/src/tm1637.toit b/src/tm1637.toit
index 43b52e5..3e9cf63 100644
--- a/src/tm1637.toit
+++ b/src/tm1637.toit
@@ -43,27 +43,27 @@ class Tm1637:
// Configure clock and data pins as output
clock_.config --output
- data_.config --output
+ data_.config --input --output --open_drain
// Clear the display
clear
@@ -76,14 +76,12 @@ class Tm1637:
data_.set bit
clock_.set 1
// Receive the ackownledgement, although we won't use it
clock_.set 0
- data_.config --input
clock_.set 1
ack := data_.get
- data_.config --output
// Set the values of the 4 digits individually
write first second third fourth --show_dots/bool = false: I will try to add the functionality today. Also: if you use 2-space indentation, then vscode is much better with syntax highlighting. |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I wrote the driver for the TM1637-based 4-digit 7-segment display and built a really simple clock with it.
Package available here: https://pkg.toit.io/package/github.com%2Fharshkc03%2Ftoit-tm1637@v1.0.0
I'm planning to add support for negative numbers, alphabets, and symbols.
tm1637-demo.mp4
Beta Was this translation helpful? Give feedback.
All reactions