Skip to content

Commit

Permalink
tm1637: Support LED modules requiring extra large (100 us) RC time co…
Browse files Browse the repository at this point in the history
…nstants
  • Loading branch information
bxparks committed Apr 30, 2023
1 parent c0ab359 commit 3caaa7a
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
14 changes: 13 additions & 1 deletion tm1637/registers.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,19 @@ const (
TM1637_CMD2 = 0xC0
TM1637_CMD3 = 0x80
TM1637_DSP_ON = 0x08
TM1637_DELAY = uint8(10)

// The black 4-digit and 6-digit TM1637 modules on Amazon and eBay (from
// robotdyn.com and diymore.cc) contain a 10nF capacitor with a 10kOhm pullup
// registor on each of the DIO and CLK lines. The RC time constant is 100
// microseconds, which forces the bit transition delay to be somewhere in
// the 100 microsecond range.
//
// The blue 4-digit TM1637 modules contain a much lower capacitor (220 or 470
// picofareds?), so the bit transition delay can be as low as 3-5
// microseconds.
//
// TODO: This should be an adjustable parameter.
TM1637_DELAY = uint8(100)
)

// 7-segment characters encoding for 0-9, A-Z, a-z, blank, dash, star
Expand Down
3 changes: 3 additions & 0 deletions tm1637/tm1637.go
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@ func (d *Device) start() {
pinMode(d.dio, false)
delaytm()
pinMode(d.clk, false)
delaytm()
}

func (d *Device) stop() {
Expand All @@ -172,6 +173,7 @@ func (d *Device) stop() {
pinMode(d.clk, true)
delaytm()
pinMode(d.dio, true)
delaytm()
}

func (d *Device) writeByte(data uint8) {
Expand All @@ -188,6 +190,7 @@ func (d *Device) writeByte(data uint8) {
pinMode(d.clk, true)
delaytm()
pinMode(d.clk, false)
delaytm()
}

func (d *Device) writeCmd() {
Expand Down

0 comments on commit 3caaa7a

Please sign in to comment.