SSD1306 0.2.1 → 0.2.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a8a40a8b9902a110c37e2d386ae73e54c436123f
4
- data.tar.gz: abe4bfe12d782ca5792a5f5d1ec559ff4261fe95
3
+ metadata.gz: 1516116688f72cffc1a7856402ff00ad7ebd9ffb
4
+ data.tar.gz: b345e88bdf2ce4a840478497bef54f379bf8c3c9
5
5
  SHA512:
6
- metadata.gz: 255f6d60ab5b2ac6bfb737e9b9ec8c599c3a9075e6908996aea7782619a15d9a154daca1f29740c6e98e1e044a762e972d5d312791b52533e9beb48a8c599500
7
- data.tar.gz: 57c33c6a12897b19254cde930bf8ef0ce0d85303bdea6b40af6e962df4c45688bcd33c0758e8dd74c46f3f7f227db2c71e84b6e6df31d560dc87d0eb077729f8
6
+ metadata.gz: 0ff7ce60231e94bb5b8055c4e4306819cf3132bc66c3c8f9f52eb0d94d51496c289006a1b360179e4a12ccf8610d580ba0428bbd158e2986cc9ae6df722fef48
7
+ data.tar.gz: 75c2527c3d4d53370a40c28c471ea1317b53b105f2c3c841b9bce1a362f191776650cdeb3c99059667eb5b93157eca0ba90c2b5724402df2cdf970bd3f2f0b59
data/SSD1306.gemspec CHANGED
@@ -32,4 +32,5 @@ Gem::Specification.new do |spec|
32
32
  spec.add_development_dependency "minitest", "~> 5.0"
33
33
 
34
34
  spec.add_runtime_dependency "i2c", ">= 0.4.0"
35
+ spec.add_runtime_dependency "rmagick", "~> 2.14"
35
36
  end
data/lib/SSD1306.rb CHANGED
@@ -1,4 +1,5 @@
1
1
  require "i2c"
2
+ require "rmagick"
2
3
 
3
4
  require "SSD1306/version"
4
5
  require "SSD1306/display"
@@ -1,43 +1,43 @@
1
1
  module SSD1306
2
- # Constants
3
- SSD1306_I2C_ADDRESS = 0x3C # 011110+SA0+RW - 0x3C or 0x3D
4
- SSD1306_SETCONTRAST = 0x81
5
- SSD1306_DISPLAYALLON_RESUME = 0xA4
6
- SSD1306_DISPLAYALLON = 0xA5
7
- SSD1306_NORMALDISPLAY = 0xA6
8
- SSD1306_INVERTDISPLAY = 0xA7
9
- SSD1306_DISPLAYOFF = 0xAE
10
- SSD1306_DISPLAYON = 0xAF
11
- SSD1306_SETDISPLAYOFFSET = 0xD3
12
- SSD1306_SETCOMPINS = 0xDA
13
- SSD1306_SETVCOMDETECT = 0xDB
14
- SSD1306_SETDISPLAYCLOCKDIV = 0xD5
15
- SSD1306_SETPRECHARGE = 0xD9
16
- SSD1306_SETMULTIPLEX = 0xA8
17
- SSD1306_SETLOWCOLUMN = 0x00
18
- SSD1306_SETHIGHCOLUMN = 0x10
19
- SSD1306_SETSTARTLINE = 0x40
20
- SSD1306_MEMORYMODE = 0x20
21
- SSD1306_COLUMNADDR = 0x21
22
- SSD1306_PAGEADDR = 0x22
23
- SSD1306_COMSCANINC = 0xC0
24
- SSD1306_COMSCANDEC = 0xC8
25
- SSD1306_SEGREMAP = 0xA0
26
- SSD1306_CHARGEPUMP = 0x8D
27
- SSD1306_EXTERNALVCC = 0x1
28
- SSD1306_SWITCHCAPVCC = 0x2
29
-
30
- # Scrolling constants
31
- SSD1306_ACTIVATE_SCROLL = 0x2F
32
- SSD1306_DEACTIVATE_SCROLL = 0x2E
33
- SSD1306_SET_VERTICAL_SCROLL_AREA = 0xA3
34
- SSD1306_RIGHT_HORIZONTAL_SCROLL = 0x26
35
- SSD1306_LEFT_HORIZONTAL_SCROLL = 0x27
36
- SSD1306_VERTICAL_AND_RIGHT_HORIZONTAL_SCROLL = 0x29
37
- SSD1306_VERTICAL_AND_LEFT_HORIZONTAL_SCROLL = 0x2A
2
+ # Constants
3
+ SSD1306_I2C_ADDRESS = 0x3C # 011110+SA0+RW - 0x3C or 0x3D
4
+ SSD1306_SETCONTRAST = 0x81
5
+ SSD1306_DISPLAYALLON_RESUME = 0xA4
6
+ SSD1306_DISPLAYALLON = 0xA5
7
+ SSD1306_NORMALDISPLAY = 0xA6
8
+ SSD1306_INVERTDISPLAY = 0xA7
9
+ SSD1306_DISPLAYOFF = 0xAE
10
+ SSD1306_DISPLAYON = 0xAF
11
+ SSD1306_SETDISPLAYOFFSET = 0xD3
12
+ SSD1306_SETCOMPINS = 0xDA
13
+ SSD1306_SETVCOMDETECT = 0xDB
14
+ SSD1306_SETDISPLAYCLOCKDIV = 0xD5
15
+ SSD1306_SETPRECHARGE = 0xD9
16
+ SSD1306_SETMULTIPLEX = 0xA8
17
+ SSD1306_SETLOWCOLUMN = 0x00
18
+ SSD1306_SETHIGHCOLUMN = 0x10
19
+ SSD1306_SETSTARTLINE = 0x40
20
+ SSD1306_MEMORYMODE = 0x20
21
+ SSD1306_COLUMNADDR = 0x21
22
+ SSD1306_PAGEADDR = 0x22
23
+ SSD1306_COMSCANINC = 0xC0
24
+ SSD1306_COMSCANDEC = 0xC8
25
+ SSD1306_SEGREMAP = 0xA0
26
+ SSD1306_CHARGEPUMP = 0x8D
27
+ SSD1306_EXTERNALVCC = 0x1
28
+ SSD1306_SWITCHCAPVCC = 0x2
29
+
30
+ # Scrolling constants
31
+ SSD1306_ACTIVATE_SCROLL = 0x2F
32
+ SSD1306_DEACTIVATE_SCROLL = 0x2E
33
+ SSD1306_SET_VERTICAL_SCROLL_AREA = 0xA3
34
+ SSD1306_RIGHT_HORIZONTAL_SCROLL = 0x26
35
+ SSD1306_LEFT_HORIZONTAL_SCROLL = 0x27
36
+ SSD1306_VERTICAL_AND_RIGHT_HORIZONTAL_SCROLL = 0x29
37
+ SSD1306_VERTICAL_AND_LEFT_HORIZONTAL_SCROLL = 0x2A
38
38
 
39
39
  class Display
40
- attr_accessor :protocol, :path, :address, :width, :height, :buffer, :vccstate
40
+ attr_accessor :protocol, :path, :address, :width, :height, :buffer, :vccstate, :interface
41
41
 
42
42
  def initialize(opts = {})
43
43
  default_options = {
@@ -142,9 +142,20 @@ SSD1306_VERTICAL_AND_LEFT_HORIZONTAL_SCROLL = 0x2A
142
142
  @interface.write @address, control, @buffer.pack('c*')
143
143
  end
144
144
 
145
- #TODO Complete image processing
146
145
  def image(image)
147
- raise "Image functionality not implemented yet"
146
+ image.image_type = BilevelType
147
+ pix = image.export_pixels
148
+ index = 0
149
+ for page in 0..(@pages - 1)
150
+ for x in 0..(@width - 1)
151
+ bits = 0
152
+ for bit in [0, 1, 2, 3, 4, 5, 6, 7]
153
+ bits = bits << 1
154
+ bits |= pix[(page*8*@width) + x + (bit*@width)] == 0 ? 0 : 1
155
+ @buffer[index] = bits
156
+ index += 1
157
+ end
158
+ end
148
159
  end
149
160
 
150
161
  def clear
@@ -1,3 +1,3 @@
1
1
  module SSD1306
2
- VERSION = "0.2.1"
2
+ VERSION = "0.2.2"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: SSD1306
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Xavier Bick
@@ -66,6 +66,20 @@ dependencies:
66
66
  - - ">="
67
67
  - !ruby/object:Gem::Version
68
68
  version: 0.4.0
69
+ - !ruby/object:Gem::Dependency
70
+ name: rmagick
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '2.14'
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '2.14'
69
83
  description: Use this library to interface to an SSD1306 OLED via I2C or SPI. It
70
84
  was developed with the Raspberry Pi in mind, but should work on any device with
71
85
  I2C or SPI.