lgpio 0.1.0 → 0.1.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3694843b060710d0fdf63c790b2857cd00bb37943fb80b52b4bb0e884c9eac63
4
- data.tar.gz: 5749c5dbcaca251af6f5b2c6c3d189bcf1226f67ebabfc0dd418dee49361da77
3
+ metadata.gz: 4bb351b8041dc3f5e78ed92128c3c971cf3f9e35d247a71e8d4ce56acec87f32
4
+ data.tar.gz: a4df4836decc51de97ad16093bbd19e649cd02b675d6511c601feddde0cded66
5
5
  SHA512:
6
- metadata.gz: e7cd82024168e24f5a776a39b364a7c9f2432de7de6d1966517c686d04acaddf338186074b7b7597051e9521bc93115292223e66a7fa34b2fcf7bb02090ae0ae
7
- data.tar.gz: 6855f0811581f7c50803cf1372a9d3927399e547b9d3b9f05dd6162106949d3793d9ea40ee50d5253b9d3c252ed137bfe0859cf7bc38d00a3a2686e64d4be82e
6
+ metadata.gz: f94daeeaba65d22c4ee2e0205a9399f18f886cc5f42e15f53a4991381756b7a33d97d29113918b809b6ff96d7900a327ee26d441d9249e86020cee7c21c34765
7
+ data.tar.gz: 367559fcd9750f88e728b80836c3dfa7d9273dcb2c734bc67faed29b23e177fc03e9e18df9678533907f3ddbe85be5d4d443a5d45404a03322ac09e586827e11
data/README.md CHANGED
@@ -7,10 +7,10 @@ Ruby bindings for the [lgpio (lg)](https://github.com/joan2937/lg) C library, wh
7
7
  ### Progress:
8
8
 
9
9
  - [x] GPIO Read/Write
10
- - [ ] GPIO Group Read/Write
11
- - [ ] GPIO Callbacks
12
- - [ ] PWM
13
- - [ ] Wave
10
+ - [x] GPIO Group Read/Write
11
+ - [x] GPIO Alerts / Callbacks (read from a queue)
12
+ - [x] PWM (software-timed)
13
+ - [x] Wave (software-timed)
14
14
  - [ ] I2C
15
15
  - [ ] SPI
16
16
  - [ ] Serial
data/examples/bench_in.rb CHANGED
@@ -1,8 +1,8 @@
1
1
  require 'lgpio'
2
2
 
3
3
  GPIO_CHIP = 0
4
- PIN = 258
5
- COUNT = 1000000
4
+ PIN = 258
5
+ COUNT = 1000000
6
6
 
7
7
  chip_handle = LGPIO.chip_open(GPIO_CHIP)
8
8
  LGPIO.gpio_claim_input(chip_handle, LGPIO::SET_PULL_UP, PIN)
@@ -14,3 +14,6 @@ end
14
14
  t2 = Time.now
15
15
 
16
16
  puts "Reads per second: #{COUNT.to_f / (t2 - t1).to_f}"
17
+
18
+ LGPIO.gpio_free(chip_handle, PIN)
19
+ LGPIO.chip_close(chip_handle)
@@ -1,8 +1,8 @@
1
1
  require 'lgpio'
2
2
 
3
3
  GPIO_CHIP = 0
4
- PIN = 260
5
- COUNT = 1000000
4
+ PIN = 260
5
+ COUNT = 1000000
6
6
 
7
7
  chip_handle = LGPIO.chip_open(GPIO_CHIP)
8
8
  LGPIO.gpio_claim_output(chip_handle, LGPIO::SET_PULL_NONE, PIN, LGPIO::LOW)
@@ -15,3 +15,6 @@ end
15
15
  t2 = Time.now
16
16
 
17
17
  puts "Toggles per second: #{COUNT.to_f / (t2 - t1).to_f}"
18
+
19
+ LGPIO.gpio_free(chip_handle, PIN)
20
+ LGPIO.chip_close(chip_handle)
data/examples/blink.rb CHANGED
@@ -1,8 +1,8 @@
1
1
  require 'lgpio'
2
2
 
3
3
  GPIO_CHIP = 0
4
- LED = 260
5
- INTERVAL = 0.25
4
+ LED = 260
5
+ INTERVAL = 0.25
6
6
 
7
7
  chip_handle = LGPIO.chip_open(GPIO_CHIP)
8
8
  LGPIO.gpio_claim_output(chip_handle, LGPIO::SET_PULL_NONE, LED, LGPIO::LOW)
@@ -0,0 +1,18 @@
1
+
2
+ require 'lgpio'
3
+
4
+ GPIO_CHIP = 0
5
+ BUTTONS = [258, 256]
6
+ LEDS = [260, 267]
7
+ INIT_STATE = [0, 0]
8
+
9
+ chip_handle = LGPIO.chip_open(GPIO_CHIP)
10
+ LGPIO.group_claim_input(chip_handle, LGPIO::SET_PULL_UP, BUTTONS)
11
+ LGPIO.group_claim_output(chip_handle, LGPIO::SET_PULL_NONE, LEDS, INIT_STATE)
12
+
13
+ # The inverted (active-low) state of each button controls the corresponding LED.
14
+ loop do
15
+ output_bits = LGPIO.group_read(chip_handle, BUTTONS[0]) ^ 0b11
16
+ LGPIO.group_write(chip_handle, LEDS[0], output_bits, 0b11)
17
+ sleep 0.001
18
+ end
@@ -0,0 +1,27 @@
1
+ require 'lgpio'
2
+
3
+ GPIO_CHIP = 0
4
+ LEDS = [260, 267]
5
+ INIT_STATE = [0, 0]
6
+ INTERVAL = 250_000 # 250ms
7
+ TIMES = 10
8
+
9
+ chip_handle = LGPIO.chip_open(GPIO_CHIP)
10
+ LGPIO.group_claim_output(chip_handle, LGPIO::SET_PULL_NONE, LEDS, INIT_STATE)
11
+
12
+ # Convert us interval to seconds.
13
+ interval = INTERVAL.to_f / 1_000_000
14
+
15
+ # Alternate the LEDs each INTERVAL.
16
+ TIMES.times do
17
+ # Last 2 args are bits to write, and write mask respectively.
18
+ LGPIO.group_write(chip_handle, LEDS[0], 0b01, 0b11)
19
+ sleep interval
20
+ LGPIO.group_write(chip_handle, LEDS[0], 0b10, 0b11)
21
+ sleep interval
22
+ end
23
+
24
+ # Turn them off and cleanup.
25
+ LGPIO.group_write(chip_handle, LEDS[0], 0b00, 0b11)
26
+ LGPIO.group_free(chip_handle, LEDS[0])
27
+ LGPIO.chip_close(chip_handle)
data/examples/pwm.rb ADDED
@@ -0,0 +1,19 @@
1
+ require 'lgpio'
2
+
3
+ GPIO_CHIP = 0
4
+ LED = 260
5
+ PWM_FREQ = 500
6
+ PWM_OFFSET = 0
7
+ PWM_CYCLES = 0 # 0 = infinite
8
+
9
+ chip_handle = LGPIO.chip_open(GPIO_CHIP)
10
+ LGPIO.gpio_claim_output(chip_handle, LGPIO::SET_PULL_NONE, LED, LGPIO::LOW)
11
+
12
+ # Seamless loop from 0-100 and back.
13
+ duty_cycles = (0..100).to_a + (1..99).to_a.reverse
14
+
15
+ # Pulse the LED up and down.
16
+ duty_cycles.cycle do |d|
17
+ LGPIO.tx_pwm(chip_handle, LED, PWM_FREQ, d, PWM_OFFSET, PWM_CYCLES)
18
+ sleep 0.020
19
+ end
@@ -0,0 +1,18 @@
1
+ require 'lgpio'
2
+
3
+ GPIO_CHIP = 0
4
+ PIN = 76
5
+
6
+ chip_handle = LGPIO.chip_open(GPIO_CHIP)
7
+
8
+ LGPIO.gpio_claim_input(chip_handle, LGPIO::SET_PULL_NONE, PIN)
9
+ LGPIO.gpio_claim_alert(chip_handle, 0, LGPIO::BOTH_EDGES, PIN)
10
+ LGPIO.gpio_start_reporting
11
+
12
+ loop do
13
+ report = LGPIO.gpio_get_report
14
+ report ? puts(report) : sleep(0.001)
15
+ end
16
+
17
+ LGPIO.gpio_free(chip_handle, PIN)
18
+ LGPIO.chip_close(chip_handle)
@@ -0,0 +1,51 @@
1
+ #
2
+ # Demo of a simple 30-detent rotary encoder.
3
+ # PIN_A = CLK/CLOCK, PIN_B = DT/DATA, PIN_SW = SWITCH
4
+ #
5
+ require 'lgpio'
6
+
7
+ GPIO_CHIP = 0
8
+ PIN_A = 76
9
+ PIN_B = 228
10
+ PIN_SW = 226
11
+
12
+ # Encoder state
13
+ position = 0
14
+ state_a = 0
15
+ state_b = 0
16
+
17
+ chip_handle = LGPIO.chip_open(GPIO_CHIP)
18
+
19
+ # Encoder pin setup
20
+ LGPIO.gpio_claim_input(chip_handle, LGPIO::SET_PULL_NONE, PIN_A)
21
+ LGPIO.gpio_claim_alert(chip_handle, 0, LGPIO::BOTH_EDGES, PIN_A)
22
+ LGPIO.gpio_claim_input(chip_handle, LGPIO::SET_PULL_NONE, PIN_B)
23
+ LGPIO.gpio_claim_alert(chip_handle, 0, LGPIO::BOTH_EDGES, PIN_B)
24
+
25
+ # Switch pin setup
26
+ LGPIO.gpio_claim_input(chip_handle, LGPIO::SET_PULL_UP, PIN_SW)
27
+ LGPIO.gpio_claim_alert(chip_handle, 0, LGPIO::FALLING_EDGE, PIN_SW)
28
+
29
+ # Start generating reports for GPIO level changes.
30
+ LGPIO.gpio_start_reporting
31
+
32
+ # Get and reports to update state.
33
+ loop do
34
+ report = LGPIO.gpio_get_report
35
+ if report
36
+ if report[:gpio] == PIN_A
37
+ # Half quadrature, so we count every detent.
38
+ state_a = report[:level]
39
+ elsif report[:gpio] == PIN_B
40
+ delta = (report[:level] == state_a) ? -1 : 1
41
+ position += delta
42
+ state_b = report[:level]
43
+ puts "Position: #{position}"
44
+ elsif report[:gpio] == PIN_SW
45
+ position = 0
46
+ puts "Position: 0"
47
+ end
48
+ else
49
+ sleep(0.001)
50
+ end
51
+ end
data/examples/wave.rb ADDED
@@ -0,0 +1,32 @@
1
+ require 'lgpio'
2
+
3
+ GPIO_CHIP = 0
4
+ LEDS = [260, 267]
5
+ INIT_STATE = [0, 0]
6
+ INTERVAL = 250_000 # 250ms
7
+ TIMES = 10
8
+
9
+ chip_handle = LGPIO.chip_open(GPIO_CHIP)
10
+ LGPIO.group_claim_output(chip_handle, LGPIO::SET_PULL_NONE, LEDS, INIT_STATE)
11
+
12
+ # Generic pulse that updates both LED states (first element) each INTERVAL.
13
+ generic_pulse = [ nil, 0b11, INTERVAL ]
14
+
15
+ # Alternate the LEDs each INTERVAL.
16
+ pulses = []
17
+ TIMES.times do
18
+ pulses << generic_pulse.clone
19
+ pulses.last[0] = 0b01
20
+ pulses << generic_pulse.clone
21
+ pulses.last[0] = 0b10
22
+ end
23
+ # Turn them off at the end.
24
+ pulses << [0b00, 0b11, 1000]
25
+
26
+ # Add to wave queue.
27
+ LGPIO.tx_wave(chip_handle, LEDS[0], pulses)
28
+
29
+ # Wait for it to complete, then cleanup.
30
+ sleep 0.010 while LGPIO.tx_busy(chip_handle, LEDS[0], LGPIO::TX_WAVE) == 1
31
+ LGPIO.group_free(chip_handle, LEDS[0])
32
+ LGPIO.chip_close(chip_handle)
data/ext/lgpio/lgpio.c CHANGED
@@ -1,13 +1,20 @@
1
1
  #include <lgpio.h>
2
2
  #include <ruby.h>
3
3
 
4
+ // Set up a queue for up to 2**16 GPIO reports.
5
+ static pthread_mutex_t queueLock;
6
+ #define QUEUE_LENGTH UINT16_MAX + 1
7
+ static lgGpioReport_t reportQueue[QUEUE_LENGTH];
8
+ static uint16_t qWritePos = 1;
9
+ static uint16_t qReadPos = 0;
10
+
4
11
  static VALUE chip_open(VALUE self, VALUE gpio_dev) {
5
12
  int result = lgGpiochipOpen(NUM2INT(gpio_dev));
6
13
  return INT2NUM(result);
7
14
  }
8
15
 
9
- static VALUE chip_close(VALUE self, VALUE gpio_dev) {
10
- int result = lgGpiochipClose(NUM2INT(gpio_dev));
16
+ static VALUE chip_close(VALUE self, VALUE handle) {
17
+ int result = lgGpiochipClose(NUM2INT(handle));
11
18
  return INT2NUM(result);
12
19
  }
13
20
 
@@ -21,6 +28,11 @@ static VALUE gpio_claim_input(VALUE self, VALUE handle, VALUE flags, VALUE gpio)
21
28
  return INT2NUM(result);
22
29
  }
23
30
 
31
+ static VALUE gpio_free(VALUE self, VALUE handle, VALUE gpio) {
32
+ int result = lgGpioFree(NUM2INT(handle), NUM2INT(gpio));
33
+ return INT2NUM(result);
34
+ }
35
+
24
36
  static VALUE gpio_read(VALUE self, VALUE handle, VALUE gpio) {
25
37
  int result = lgGpioRead(NUM2INT(handle), NUM2INT(gpio));
26
38
  return INT2NUM(result);
@@ -31,23 +43,174 @@ static VALUE gpio_write(VALUE self, VALUE handle, VALUE gpio, VALUE level) {
31
43
  return INT2NUM(result);
32
44
  }
33
45
 
46
+ static VALUE group_claim_input(VALUE self, VALUE handle, VALUE flags, VALUE gpios) {
47
+ int count = rb_array_len(gpios);
48
+ int lgGpios[count];
49
+ int i;
50
+ for(i=0; i<count; i++) {
51
+ lgGpios[i] = NUM2INT(rb_ary_entry(gpios, i));
52
+ }
53
+ int result = lgGroupClaimInput(NUM2INT(handle), NUM2INT(flags), count, lgGpios);
54
+ return INT2NUM(result);
55
+ }
56
+
57
+ static VALUE group_claim_output(VALUE self, VALUE handle, VALUE flags, VALUE gpios, VALUE levels) {
58
+ int count = rb_array_len(gpios);
59
+ int lgGpios[count];
60
+ int lgLevels[count];
61
+ int i;
62
+ for(i=0; i<count; i++) {
63
+ lgGpios[i] = NUM2INT(rb_ary_entry(gpios, i));
64
+ lgLevels[i] = NUM2INT(rb_ary_entry(levels, i));
65
+ }
66
+ int result = lgGroupClaimOutput(NUM2INT(handle), NUM2INT(flags), count, lgGpios, lgLevels);
67
+ return INT2NUM(result);
68
+ }
69
+
70
+ static VALUE group_free(VALUE self, VALUE handle, VALUE gpio) {
71
+ int result = lgGroupFree(NUM2INT(handle), NUM2INT(gpio));
72
+ return INT2NUM(result);
73
+ }
74
+
75
+ static VALUE group_read(VALUE self, VALUE handle, VALUE gpio) {
76
+ uint64_t result;
77
+ lgGroupRead(NUM2INT(handle), NUM2INT(gpio), &result);
78
+ return UINT2NUM(result);
79
+ }
80
+
81
+ static VALUE group_write(VALUE self, VALUE handle, VALUE gpio, VALUE bits, VALUE mask) {
82
+ int result = lgGroupWrite(NUM2INT(handle), NUM2INT(gpio), NUM2UINT(bits), NUM2UINT(mask));
83
+ return INT2NUM(result);
84
+ }
85
+
86
+ static VALUE gpio_claim_alert(VALUE self, VALUE handle, VALUE flags, VALUE eFlags, VALUE gpio) {
87
+ int result = lgGpioClaimAlert(NUM2INT(handle), NUM2INT(flags), NUM2INT(eFlags), NUM2INT(gpio), -1);
88
+ return INT2NUM(result);
89
+ }
90
+
91
+ void queue_gpio_reports(int count, lgGpioAlert_p events, void *data){
92
+ pthread_mutex_lock(&queueLock);
93
+ for(int i=0; i<count; i++) {
94
+ memcpy(&reportQueue[qWritePos], &events[i].report, sizeof(lgGpioReport_t));
95
+ qWritePos += 1;
96
+ // qReadPos is the LAST report read. If passing by 1, increment it too. Lose oldest data first.
97
+ if (qWritePos - qReadPos == 1) qReadPos += 1;
98
+ }
99
+ pthread_mutex_unlock(&queueLock);
100
+ }
101
+
102
+ static VALUE gpio_start_reporting(VALUE self) {
103
+ lgGpioSetSamplesFunc(queue_gpio_reports, NULL);
104
+ }
105
+
106
+ static VALUE gpio_get_report(VALUE self){
107
+ VALUE hash = rb_hash_new();
108
+ bool popped = false;
109
+
110
+ pthread_mutex_lock(&queueLock);
111
+ // qWritePos is where the NEXT report will go. Always trail it by 1.
112
+ if (qWritePos - qReadPos != 1){
113
+ qReadPos += 1;
114
+ rb_hash_aset(hash, ID2SYM(rb_intern("timestamp")), ULL2NUM(reportQueue[qReadPos].timestamp));
115
+ rb_hash_aset(hash, ID2SYM(rb_intern("chip")), UINT2NUM(reportQueue[qReadPos].chip));
116
+ rb_hash_aset(hash, ID2SYM(rb_intern("gpio")), UINT2NUM(reportQueue[qReadPos].gpio));
117
+ rb_hash_aset(hash, ID2SYM(rb_intern("level")), UINT2NUM(reportQueue[qReadPos].level));
118
+ rb_hash_aset(hash, ID2SYM(rb_intern("flags")), UINT2NUM(reportQueue[qReadPos].flags));
119
+ popped = true;
120
+ }
121
+ pthread_mutex_unlock(&queueLock);
122
+
123
+ if (popped){
124
+ return hash;
125
+ } else {
126
+ return Qnil;
127
+ }
128
+ }
129
+
130
+ static VALUE tx_busy(VALUE self, VALUE handle, VALUE gpio, VALUE kind) {
131
+ int result = lgTxBusy(NUM2INT(handle), NUM2INT(gpio), NUM2INT(kind));
132
+ return INT2NUM(result);
133
+ }
134
+
135
+ static VALUE tx_room(VALUE self, VALUE handle, VALUE gpio, VALUE kind) {
136
+ int result = lgTxRoom(NUM2INT(handle), NUM2INT(gpio), NUM2INT(kind));
137
+ return INT2NUM(result);
138
+ }
139
+
140
+ static VALUE tx_pulse(VALUE self, VALUE handle, VALUE gpio, VALUE on, VALUE off, VALUE offset, VALUE cycles) {
141
+ int result = lgTxPulse(NUM2INT(handle), NUM2INT(gpio), NUM2INT(on), NUM2INT(off), NUM2INT(offset), NUM2INT(cycles));
142
+ return INT2NUM(result);
143
+ }
144
+
145
+ static VALUE tx_pwm(VALUE self, VALUE handle, VALUE gpio, VALUE freq, VALUE duty, VALUE offset, VALUE cycles) {
146
+ int result = lgTxPwm(NUM2INT(handle), NUM2INT(gpio), NUM2INT(freq), NUM2INT(duty), NUM2INT(offset), NUM2INT(cycles));
147
+ return INT2NUM(result);
148
+ }
149
+
150
+ static VALUE tx_servo(VALUE self, VALUE handle, VALUE gpio, VALUE width, VALUE freq, VALUE offset, VALUE cycles) {
151
+ int result = lgTxServo(NUM2INT(handle), NUM2INT(gpio), NUM2INT(width), NUM2INT(freq), NUM2INT(offset), NUM2INT(cycles));
152
+ return INT2NUM(result);
153
+ }
154
+
155
+ static VALUE tx_wave(VALUE self, VALUE handle, VALUE lead_gpio, VALUE pulses) {
156
+ // Copy Ruby array to array of lgPulse_t.
157
+ int pulseCount = rb_array_len(pulses);
158
+ lgPulse_t pulsesOut[pulseCount];
159
+ VALUE rbPulse;
160
+ int i;
161
+ for(i=0; i<pulseCount; i++) {
162
+ rbPulse = rb_ary_entry(pulses, i);
163
+ pulsesOut[i].bits = NUM2UINT(rb_ary_entry(rbPulse, 0));
164
+ pulsesOut[i].mask = NUM2UINT(rb_ary_entry(rbPulse, 1));
165
+ pulsesOut[i].delay = NUM2INT (rb_ary_entry(rbPulse, 2));
166
+ }
167
+
168
+ // Add it to wave queue.
169
+ int result = lgTxWave(NUM2INT(handle), NUM2INT(lead_gpio), pulseCount, pulsesOut);
170
+ return INT2NUM(result);
171
+ }
172
+
34
173
  void Init_lgpio(void) {
35
174
  // Modules
36
175
  VALUE mLGPIO = rb_define_module("LGPIO");
37
176
 
38
- // Constants
177
+ // Basics
39
178
  rb_define_const(mLGPIO, "SET_ACTIVE_LOW", INT2NUM(LG_SET_ACTIVE_LOW));
40
179
  rb_define_const(mLGPIO, "SET_OPEN_DRAIN", INT2NUM(LG_SET_OPEN_DRAIN));
41
180
  rb_define_const(mLGPIO, "SET_OPEN_SOURCE", INT2NUM(LG_SET_OPEN_SOURCE));
42
181
  rb_define_const(mLGPIO, "SET_PULL_UP", INT2NUM(LG_SET_PULL_UP));
43
182
  rb_define_const(mLGPIO, "SET_PULL_DOWN", INT2NUM(LG_SET_PULL_DOWN));
44
183
  rb_define_const(mLGPIO, "SET_PULL_NONE", INT2NUM(LG_SET_PULL_NONE));
45
-
46
- // Methods
47
- rb_define_singleton_method(mLGPIO, "chip_open", chip_open, 1);
48
- rb_define_singleton_method(mLGPIO, "chip_close", chip_close, 1);
49
- rb_define_singleton_method(mLGPIO, "gpio_claim_input", gpio_claim_input, 3);
184
+ rb_define_const(mLGPIO, "RISING_EDGE", INT2NUM(LG_RISING_EDGE));
185
+ rb_define_const(mLGPIO, "FALLING_EDGE", INT2NUM(LG_FALLING_EDGE));
186
+ rb_define_const(mLGPIO, "BOTH_EDGES", INT2NUM(LG_BOTH_EDGES));
187
+ rb_define_singleton_method(mLGPIO, "chip_open", chip_open, 1);
188
+ rb_define_singleton_method(mLGPIO, "chip_close", chip_close, 1);
189
+ rb_define_singleton_method(mLGPIO, "gpio_free", gpio_free, 2);
190
+ rb_define_singleton_method(mLGPIO, "gpio_claim_input", gpio_claim_input, 3);
50
191
  rb_define_singleton_method(mLGPIO, "gpio_claim_output", gpio_claim_output, 4);
51
- rb_define_singleton_method(mLGPIO, "gpio_read", gpio_read, 2);
52
- rb_define_singleton_method(mLGPIO, "gpio_write", gpio_write, 3);
192
+ rb_define_singleton_method(mLGPIO, "gpio_read", gpio_read, 2);
193
+ rb_define_singleton_method(mLGPIO, "gpio_write", gpio_write, 3);
194
+
195
+ // Grouped
196
+ rb_define_singleton_method(mLGPIO, "group_claim_input", group_claim_input, 3);
197
+ rb_define_singleton_method(mLGPIO, "group_claim_output", group_claim_output, 4);
198
+ rb_define_singleton_method(mLGPIO, "group_free", group_free, 2);
199
+ rb_define_singleton_method(mLGPIO, "group_read", group_read, 2);
200
+ rb_define_singleton_method(mLGPIO, "group_write", group_write, 4);
201
+
202
+ // Alerts / Reports
203
+ rb_define_singleton_method(mLGPIO, "gpio_claim_alert", gpio_claim_alert, 4);
204
+ rb_define_singleton_method(mLGPIO, "gpio_start_reporting", gpio_start_reporting, 0);
205
+ rb_define_singleton_method(mLGPIO, "gpio_get_report", gpio_get_report, 0);
206
+
207
+ // PWM / Servo / Wave
208
+ rb_define_const(mLGPIO, "TX_PWM", INT2NUM(LG_TX_PWM));
209
+ rb_define_const(mLGPIO, "TX_WAVE",INT2NUM(LG_TX_WAVE));
210
+ rb_define_singleton_method(mLGPIO, "tx_busy", tx_busy, 3);
211
+ rb_define_singleton_method(mLGPIO, "tx_room", tx_room, 3);
212
+ rb_define_singleton_method(mLGPIO, "tx_pulse", tx_pulse, 6);
213
+ rb_define_singleton_method(mLGPIO, "tx_pwm", tx_pwm, 6);
214
+ rb_define_singleton_method(mLGPIO, "tx_servo", tx_servo, 6);
215
+ rb_define_singleton_method(mLGPIO, "tx_wave", tx_wave, 3);
53
216
  }
data/lib/lgpio/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module LGPIO
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.2"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lgpio
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - vickash
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-04-24 00:00:00.000000000 Z
11
+ date: 2024-07-31 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Use GPIO / PWM / I2C / SPI / UART on Linux SBCs in Ruby
14
14
  email: mail@vickash.com
@@ -24,7 +24,13 @@ files:
24
24
  - examples/bench_in.rb
25
25
  - examples/bench_out.rb
26
26
  - examples/blink.rb
27
+ - examples/group_in.rb
28
+ - examples/group_out.rb
27
29
  - examples/momentary.rb
30
+ - examples/pwm.rb
31
+ - examples/reports.rb
32
+ - examples/rotary_encoder.rb
33
+ - examples/wave.rb
28
34
  - ext/lgpio/extconf.rb
29
35
  - ext/lgpio/lgpio.c
30
36
  - lgpio.gemspec
@@ -50,7 +56,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
50
56
  - !ruby/object:Gem::Version
51
57
  version: '0'
52
58
  requirements: []
53
- rubygems_version: 3.5.9
59
+ rubygems_version: 3.5.16
54
60
  signing_key:
55
61
  specification_version: 4
56
62
  summary: lgpio (lg) bindings for Ruby