time7segment 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- checksums.yaml.gz.sig +2 -0
- data/lib/time7segment.rb +62 -0
- data.tar.gz.sig +3 -0
- metadata +88 -0
- metadata.gz.sig +0 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: effa6ed1157c59eb5dc7ca8a0794d8630ea76e96
|
4
|
+
data.tar.gz: 101f2e2322ec2cf82375e740ea01e0739e75a3b8
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 8f473b79759b0ad0d5b5aabb974b790acf72fe5392c60ea8d9918053f3f62be16022ab19a3f6e103ff227b764ba7f3227f378ad253e1fb4843b37c3d479c9fac
|
7
|
+
data.tar.gz: 4e98536ad0005db29bc4f6fff92d671205e29672bc0af2e1153808efd6f8b499fe011e71e2c0850305f5caaf55973ccab0a8c788a6544b3207d8e684c84354f1
|
checksums.yaml.gz.sig
ADDED
data/lib/time7segment.rb
ADDED
@@ -0,0 +1,62 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'rpi'
|
4
|
+
|
5
|
+
|
6
|
+
# file: time7segment.rb
|
7
|
+
|
8
|
+
# Quick pin reference
|
9
|
+
# ===================
|
10
|
+
#
|
11
|
+
# index: 0 1 2 3 4 5 6 7
|
12
|
+
# segment: a b c d e f g dp
|
13
|
+
# 7 seg pin: 11 7 4 2 1 10 5 3
|
14
|
+
# GPIO pin: 11 4 23 8 20 10 18 25
|
15
|
+
|
16
|
+
|
17
|
+
class Time7Segment
|
18
|
+
|
19
|
+
# d1 d2 d3 d4 a b c d e f g dp
|
20
|
+
def initialize(gpio_pins=%w(22 27 17 24 11 4 23 8 20 10 18 25),
|
21
|
+
refresh: 0.0025)
|
22
|
+
|
23
|
+
pins = RPi.new(gpio_pins).pins
|
24
|
+
@digits, @segments = pins.take(4), pins.slice(4..-1)
|
25
|
+
@refresh = refresh
|
26
|
+
|
27
|
+
|
28
|
+
end
|
29
|
+
|
30
|
+
def start
|
31
|
+
|
32
|
+
loop do
|
33
|
+
|
34
|
+
Time.now.strftime("%H%M").chars.each.with_index do |x,i|
|
35
|
+
|
36
|
+
display(x.to_i)
|
37
|
+
@digits[i].on
|
38
|
+
@segments[7].method( i == 1 ? :off : :on).call
|
39
|
+
sleep @refresh
|
40
|
+
@digits[i].off
|
41
|
+
|
42
|
+
end
|
43
|
+
|
44
|
+
end
|
45
|
+
|
46
|
+
end
|
47
|
+
|
48
|
+
private
|
49
|
+
|
50
|
+
def display(c)
|
51
|
+
|
52
|
+
lookup = [0x7E, 0x30, 0x6D, 0x79, 0x33, 0x5B, 0x5F, 0x70, 0x7F, 0x7B]
|
53
|
+
a = lookup[c].to_s(2).rjust(7,'0').chars.map {|x| x == '1' ? :off : :on}
|
54
|
+
a.each.with_index {|x,i| @segments[i].method(x).call}
|
55
|
+
|
56
|
+
end
|
57
|
+
|
58
|
+
end
|
59
|
+
|
60
|
+
if __FILE__ == $0 then
|
61
|
+
Time7Segment.new(*ARGV).start
|
62
|
+
end
|
data.tar.gz.sig
ADDED
metadata
ADDED
@@ -0,0 +1,88 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: time7segment
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- James Robertson
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain:
|
11
|
+
- |
|
12
|
+
-----BEGIN CERTIFICATE-----
|
13
|
+
MIIDljCCAn6gAwIBAgIBATANBgkqhkiG9w0BAQUFADBIMRIwEAYDVQQDDAlnZW1t
|
14
|
+
YXN0ZXIxHjAcBgoJkiaJk/IsZAEZFg5qYW1lc3JvYmVydHNvbjESMBAGCgmSJomT
|
15
|
+
8ixkARkWAmV1MB4XDTE2MDIyNjIwMzkzMloXDTE3MDIyNTIwMzkzMlowSDESMBAG
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zIC/MmylyVjsvIYuDwB1fvLmWAW+GowwhmMWySWO
|
31
|
+
+hK+FacNWYYl7NLDoAQDnx8UxWfUl7WpWi7B/U09XsOHNwhaTJsZ6GeVkdVm1E//
|
32
|
+
W1B8FmCNgggaYQ==
|
33
|
+
-----END CERTIFICATE-----
|
34
|
+
date: 2016-02-26 00:00:00.000000000 Z
|
35
|
+
dependencies:
|
36
|
+
- !ruby/object:Gem::Dependency
|
37
|
+
name: rpi
|
38
|
+
requirement: !ruby/object:Gem::Requirement
|
39
|
+
requirements:
|
40
|
+
- - "~>"
|
41
|
+
- !ruby/object:Gem::Version
|
42
|
+
version: '0.4'
|
43
|
+
- - ">="
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: 0.4.5
|
46
|
+
type: :runtime
|
47
|
+
prerelease: false
|
48
|
+
version_requirements: !ruby/object:Gem::Requirement
|
49
|
+
requirements:
|
50
|
+
- - "~>"
|
51
|
+
- !ruby/object:Gem::Version
|
52
|
+
version: '0.4'
|
53
|
+
- - ">="
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
version: 0.4.5
|
56
|
+
description:
|
57
|
+
email: james@r0bertson.co.uk
|
58
|
+
executables: []
|
59
|
+
extensions: []
|
60
|
+
extra_rdoc_files: []
|
61
|
+
files:
|
62
|
+
- lib/time7segment.rb
|
63
|
+
homepage: https://github.com/jrobertson/time7segment
|
64
|
+
licenses:
|
65
|
+
- MIT
|
66
|
+
metadata: {}
|
67
|
+
post_install_message:
|
68
|
+
rdoc_options: []
|
69
|
+
require_paths:
|
70
|
+
- lib
|
71
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
77
|
+
requirements:
|
78
|
+
- - ">="
|
79
|
+
- !ruby/object:Gem::Version
|
80
|
+
version: '0'
|
81
|
+
requirements: []
|
82
|
+
rubyforge_project:
|
83
|
+
rubygems_version: 2.4.8
|
84
|
+
signing_key:
|
85
|
+
specification_version: 4
|
86
|
+
summary: Displays the time on a 4 digit 7 segment display connected to a Raspberry
|
87
|
+
Pi
|
88
|
+
test_files: []
|
metadata.gz.sig
ADDED
Binary file
|