ffi-wiring_pi 1.0.1 → 1.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/gemspec.yml +1 -1
- data/lib/ffi/wiring_pi.rb +1 -0
- data/lib/ffi/wiring_pi/lcd.rb +101 -0
- data/lib/ffi/wiring_pi/pcf8574.rb +10 -0
- metadata +3 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a70a4ff806ee1c320bdfc6072ca1c66367e22042879c2a1a4c1307f67e490cb6
|
4
|
+
data.tar.gz: 2037793244ebec75ba02ccf97093264f2f9dc15162c71b51698b6b93f7a1a5a0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 91dcf2995359cec012cf984d5de63a87d3288255863ca5487b64543ccf4985cd7264c54ae627e62bdbd3d5f69615e18b1a7a858634a7bf94cc96fe273d881fef
|
7
|
+
data.tar.gz: 72a73f4d037e10b0a0143f7beed66c7f7e07c16a438fee66b0d9126987e9c4e967e6c18d71f0ba723598d42f9858922fd8ac380cbfc69cca9242e42bb30d067a
|
data/gemspec.yml
CHANGED
data/lib/ffi/wiring_pi.rb
CHANGED
@@ -0,0 +1,101 @@
|
|
1
|
+
#frozen_string_literal: true
|
2
|
+
|
3
|
+
module FFI::WiringPi::LCD
|
4
|
+
extend FFI::Library
|
5
|
+
|
6
|
+
ffi_lib 'wiringPi'
|
7
|
+
# ws2811_return_t ws2811_init(ws2811_t *ws2811); //< Initialize buffers/hardware
|
8
|
+
# void ws2811_fini(ws2811_t *ws2811); //< Tear it all down
|
9
|
+
# ws2811_return_t ws2811_render(ws2811_t *ws2811); //< Send LEDs off to hardware
|
10
|
+
# ws2811_return_t ws2811_wait(ws2811_t *ws2811); //< Wait for DMA completion
|
11
|
+
# const char * ws2811_get_return_t_str(const ws2811_return_t state); //< Get string representation of the given return state
|
12
|
+
|
13
|
+
# attach_function :setup, :wiringPiSetup, [], :int
|
14
|
+
# int lcdInit (int rows, int cols, int bits, int rs, int strb,
|
15
|
+
# int d0, int d1, int d2, int d3, int d4, int d5, int d6, int d7) ;
|
16
|
+
|
17
|
+
attach_function :lcdInit, :lcdInit, [:int, :int, :int, :int, :int, :int, :int, :int, :int, :int, :int, :int, :int], :int
|
18
|
+
|
19
|
+
# lcdHome (int handle)
|
20
|
+
# lcdClear (int handle)
|
21
|
+
attach_function :lcdHome, :lcdHome, [:int], :void
|
22
|
+
attach_function :lcdClear, :lcdClear, [:int], :void
|
23
|
+
|
24
|
+
# lcdDisplay (int fd, int state)
|
25
|
+
attach_function :lcdDisplay, :lcdDisplay, [:int, :int], :void
|
26
|
+
# lcdCursor (int fd, int state)
|
27
|
+
attach_function :lcdCursor, :lcdClear, [:int, :int], :void
|
28
|
+
# lcdCursorBlink (int fd, int state)
|
29
|
+
attach_function :lcdCursorBlink, :lcdCursorBlink, [:int, :int], :void
|
30
|
+
|
31
|
+
# Set the position of the cursor for subsequent text entry.
|
32
|
+
# x is the column and 0 is the left-most edge. y is the line and 0 is the top line.
|
33
|
+
# lcdPosition (int handle, int x, int y) ;
|
34
|
+
attach_function :lcdPosition, :lcdPosition, [:int, :int, :int], :void
|
35
|
+
|
36
|
+
# This allows you to re-define one of the 8 user-definable chanracters in the display.
|
37
|
+
# The data array is 8 bytes which represent the character from the top-line to the bottom line.
|
38
|
+
# Note that the characters are actually 5×8, so only the lower 5 bits are used.
|
39
|
+
# The index is from 0 to 7 and you can subsequently print the character defined using the lcdPutchar() call.
|
40
|
+
#
|
41
|
+
# lcdCharDef (int handle, int index, unsigned char data[] [8]) ;
|
42
|
+
attach_function :lcdCharDef, :lcdCharDef, [:int, :int, :pointer], :void
|
43
|
+
|
44
|
+
# lcdPutchar (int handle, unsigned char data) ;
|
45
|
+
attach_function :lcdPutchar, :lcdPutchar, [:int, :pointer], :void
|
46
|
+
# lcdPuts (int handle, const char *string) ;
|
47
|
+
attach_function :lcdPuts, :lcdPuts, [:int, :string], :void
|
48
|
+
# lcdPrintf (int handle, const char *message, …) ;
|
49
|
+
attach_function :lcdPrintf, :lcdPrintf, [:int, :string, :varargs], :void
|
50
|
+
|
51
|
+
class Display
|
52
|
+
def initialize(params)
|
53
|
+
@handle = FFI::WiringPi::LCD.lcdInit(
|
54
|
+
params[:rows], params[:cols], params[:bits], params[:rs],
|
55
|
+
params[:strb], params[:d0], params[:d1], params[:d2], params[:d3],
|
56
|
+
params[:d4], params[:d5], params[:d6], params[:d7]
|
57
|
+
)
|
58
|
+
end
|
59
|
+
|
60
|
+
def home
|
61
|
+
FFI::WiringPi::LCD.lcdHome(@handle)
|
62
|
+
end
|
63
|
+
|
64
|
+
def clear
|
65
|
+
FFI::WiringPi::LCD.lcdClear @handle
|
66
|
+
end
|
67
|
+
|
68
|
+
def turn_display(state)
|
69
|
+
FFI::WiringPi::LCD.lcdDisplay(@handle, state ? 1 : 0)
|
70
|
+
end
|
71
|
+
|
72
|
+
def turn_cursor(state)
|
73
|
+
FFI::WiringPi::LCD.lcdCursor(@handle, state ? 1 : 0)
|
74
|
+
end
|
75
|
+
|
76
|
+
def turn_cursor_blink(state)
|
77
|
+
FFI::WiringPi::LCD.lcdCursorBlink(@handle, state ? 1 : 0)
|
78
|
+
end
|
79
|
+
|
80
|
+
def set_characters(index, data)
|
81
|
+
FFI::WiringPi::LCD.lcdCharDef(@handle, index, data[0...8])
|
82
|
+
end
|
83
|
+
|
84
|
+
def set_position(x, y)
|
85
|
+
FFI::WiringPi::LCD.lcdPosition(@handle, x, y)
|
86
|
+
end
|
87
|
+
|
88
|
+
def print(data)
|
89
|
+
FFI::WiringPi::LCD.lcdPutchar(@handle, data)
|
90
|
+
end
|
91
|
+
|
92
|
+
def puts(data)
|
93
|
+
FFI::WiringPi::LCD.lcdPuts(@handle, data)
|
94
|
+
end
|
95
|
+
|
96
|
+
def printf(format, *args)
|
97
|
+
FFI::WiringPi::LCD.lcdPuts(@handle, format, *args)
|
98
|
+
end
|
99
|
+
end
|
100
|
+
end
|
101
|
+
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ffi-wiring_pi
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mark Huk
|
@@ -105,7 +105,9 @@ files:
|
|
105
105
|
- gemspec.yml
|
106
106
|
- lib/ffi/wiring_pi.rb
|
107
107
|
- lib/ffi/wiring_pi/gpio.rb
|
108
|
+
- lib/ffi/wiring_pi/lcd.rb
|
108
109
|
- lib/ffi/wiring_pi/neopixel.rb
|
110
|
+
- lib/ffi/wiring_pi/pcf8574.rb
|
109
111
|
- lib/ffi/wiring_pi/pcf8591.rb
|
110
112
|
- lib/ffi/wiring_pi/soft_pwm.rb
|
111
113
|
- lib/ffi/wiring_pi/soft_tone.rb
|