-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
148 additions
and
7 deletions.
There are no files selected for viewing
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
import Jetson.GPIO as GPIO | ||
import time | ||
''' | ||
TM1640 driver and demo, ported from Arduino | ||
''' | ||
alphabet = [ | ||
[0x7F, 0x09, 0x19, 0x29, 0x46, 0x00, 0x00, 0x00, 0x7F, 0x09, 0x19, 0x29, 0x46, 0x00, 0x00, 0x00], | ||
[0x00, 0x42, 0x7F, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x42, 0x7F, 0x40, 0x00, 0x00, 0x00, 0x00], | ||
[0x42, 0x61, 0x51, 0x49, 0x46, 0x00, 0x00, 0x00, 0x42, 0x61, 0x51, 0x49, 0x46, 0x00, 0x00, 0x00], | ||
[0x22, 0x41, 0x49, 0x49, 0x36, 0x00, 0x00, 0x00, 0x22, 0x41, 0x49, 0x49, 0x36, 0x00, 0x00, 0x00], | ||
|
||
[0x18, 0x14, 0x12, 0x7F, 0x10, 0x00, 0x00, 0x00, 0x18, 0x14, 0x12, 0x7F, 0x10, 0x00, 0x00, 0x00], | ||
[0x4F, 0x49, 0x49, 0x49, 0x31, 0x00, 0x00, 0x00, 0x4F, 0x49, 0x49, 0x49, 0x31, 0x00, 0x00, 0x00], | ||
[0x3E, 0x49, 0x49, 0x49, 0x32, 0x00, 0x00, 0x00, 0x3E, 0x49, 0x49, 0x49, 0x32, 0x00, 0x00, 0x00], | ||
[0x01, 0x01, 0x71, 0x09, 0x07, 0x00, 0x00, 0x00, 0x01, 0x01, 0x71, 0x09, 0x07, 0x00, 0x00, 0x00], | ||
|
||
[0x36, 0x49, 0x49, 0x49, 0x36, 0x00, 0x00, 0x00, 0x36, 0x49, 0x49, 0x49, 0x36, 0x00, 0x00, 0x00], | ||
[0x26, 0x49, 0x49, 0x49, 0x3E, 0x00, 0x00, 0x00, 0x26, 0x49, 0x49, 0x49, 0x3E, 0x00, 0x00, 0x00], | ||
[0x7F, 0x04, 0x08, 0x10, 0x7F, 0x00, 0x00, 0x00, 0x7F, 0x04, 0x08, 0x10, 0x7F, 0x00, 0x00, 0x00], | ||
[0xff, 0x00, 0xff, 0x00, 0xff, 0x00, 0xff, 0x00, 0x00, 0xff, 0x00, 0xff, 0x00, 0xff, 0x00, 0xff]] | ||
|
||
din=13 | ||
clk=11 | ||
|
||
def start(): | ||
GPIO.output(clk, GPIO.HIGH) | ||
GPIO.output(din, GPIO.HIGH) | ||
GPIO.output(din, GPIO.LOW) | ||
GPIO.output(clk, GPIO.LOW) | ||
def stop(): | ||
GPIO.output(clk, GPIO.HIGH) | ||
GPIO.output(din, GPIO.LOW) | ||
GPIO.output(din, GPIO.HIGH) | ||
def write_byte(byte): | ||
GPIO.output(clk, GPIO.LOW) | ||
for i in range(8): | ||
if byte & 0x01 == 0x01: | ||
GPIO.output(din, GPIO.HIGH) | ||
else: | ||
GPIO.output(din, GPIO.LOW) | ||
GPIO.output(clk, GPIO.HIGH) | ||
GPIO.output(clk, GPIO.LOW) | ||
byte>>=1 | ||
|
||
def cmd(byte): | ||
start() | ||
write_byte(byte) | ||
stop() | ||
def write_block(idx): | ||
start() | ||
write_byte(0xc0) | ||
for i in range(16): | ||
write_byte(alphabet[idx][i]) | ||
stop() | ||
|
||
def init(): | ||
GPIO.setmode(GPIO.BOARD) | ||
GPIO.setup(din, GPIO.OUT, initial=GPIO.HIGH) | ||
GPIO.setup(clk, GPIO.OUT, initial=GPIO.HIGH) | ||
cmd(0x40) | ||
cmd(0x8c) | ||
init() | ||
|
||
for i in range(12): | ||
write_block(i) | ||
time.sleep(0.3) | ||
|
||
GPIO.cleanup() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
#!/bin/bash | ||
I2C=0 | ||
SET="i2cset -y $I2C" | ||
declare -a dz=("0x3f" "0x30" "0x5b" "0x79" "0x74" "0x6d" "0x6f" "0x38" "0xff" "0x7d") | ||
echo "start at iic bus $I2C" | ||
|
||
$SET 0x24 0x01 | ||
|
||
while true | ||
do | ||
DATE4=$( date "+%H%M" ) | ||
echo $DATE4 | ||
|
||
$SET 0x34 ${dz[${DATE4:0:1}]} | ||
$SET 0x35 ${dz[${DATE4:1:1}]} | ||
$SET 0x36 ${dz[${DATE4:2:1}]} | ||
$SET 0x37 ${dz[${DATE4:3:1}]} | ||
sleep 1 | ||
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters