denko-piboard 0.13.1 → 0.13.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
  SHA256:
3
- metadata.gz: 5677a479b94e8352c42dee06a389339b95fe1adcf897fa7ce871a0d7ca394aaf
4
- data.tar.gz: 355ce56cafe97d3511cd60b3cc7f91d75167b3485d06f1e162308347d11471c2
3
+ metadata.gz: 6bad42203be8c858270403900ba28c58f7a63eaf616151975e7b5d61a471a472
4
+ data.tar.gz: ad86f14e2d91a644ea1ccc8f7d599b4bbfa095d55b5f07fc734dd741447811ea
5
5
  SHA512:
6
- metadata.gz: d9010b4a8acd2172d1f19c8c666b76c1240b79b9f9cb814d495138235433a588e35e3b3e262d95875e5baedd84f13c40274913adb882cb968bb5637fad811390
7
- data.tar.gz: 3dfc780aa00dbae71df4308f7e73aa721e5fd6cbcc4b70159206115166f21ece1827a337920fead04b6892ab7283378facaed7d0eeae450d6dfa1da0f2e7bc25
6
+ metadata.gz: aceaac910ced26a348b5a22da0d3729c6cf0b91c66c7bac417d0a96877b531407a2ff56e7fa1aa1c30cde3b8709eea7d9a44b2d07cd1628f315591b0c7477594
7
+ data.tar.gz: ea5a92edc491447c75417b3e9787fcd785a86e7f15e27c18b92e97b4969ff30dcb1c913bc4fc10b81c09ecbe079859b7a5cd10d9cd744865680d1fd643b842fe
data/README.md CHANGED
@@ -9,8 +9,6 @@ This gem adds support for the Raspberry Pi GPIO interface to the [`denko`](https
9
9
  **Note:** This is not for the Raspberry Pi Pico (W) / RP2040. That microcontroller works with the main gem.
10
10
 
11
11
  ## Example
12
- Create a script, `led_button.rb`:
13
-
14
12
  ```ruby
15
13
  require 'denko/piboard'
16
14
 
@@ -39,13 +37,8 @@ end
39
37
  sleep
40
38
  ```
41
39
 
42
- Run it:
43
- ```shell
44
- ruby led_button.rb
45
- ```
46
-
47
40
  #### More Examples
48
- Pi-specific examples will be in this gem's [examples](examples) folder, but most examples are in the [main gem](https://github.com/denko-rb/denko/tree/master/examples). They must be modified to work with the Pi's GPIO:
41
+ Pi-specific examples are in this gem's [examples](examples) folder, but examples from the [main gem](https://github.com/denko-rb/denko/tree/master/examples) can be modified to work on the Pi:
49
42
 
50
43
  1. Replace setup code:
51
44
  ```ruby
@@ -66,57 +59,72 @@ Pi-specific examples will be in this gem's [examples](examples) folder, but most
66
59
 
67
60
  **Note:** Not all features from all examples are implemented yet, nor can be implemented. See [Features](#features) below.
68
61
 
69
- ## Installation
62
+ ## Support
63
+
64
+ #### Hardware
65
+
66
+ :green_heart: Support verified
67
+ :question: Should work, but not verified
68
+
69
+ | Chip | Status | Products | Notes |
70
+ | :-------- | :------: | :--------------- |------ |
71
+ | BCM2835 | :green_heart: | Pi 1, Pi Zero (W) |
72
+ | BCM2836/7 | :question: | Pi 2 |
73
+ | BCM2837A0/B0 | :green_heart: | Pi 3 |
74
+ | BCM2711 | :green_heart: | Pi 4, Pi 400 |
75
+ | BCM2710A1 | :question: | Pi Zero 2W |
76
+
77
+ #### Software
70
78
 
71
- #### System Requirements
72
- - Tested on a Pi Zero W and Pi 3B, but should work on others.
73
- - Tested on DietPi and Raspberry Pi OS, both based on Debian 11 (Bullseye), with kernel version 6.1 or higher.
74
- - Tested Ruby versions:
75
- - Ruby 2.7.4 (incldued with OS)
76
- - Ruby 3.2.2+YJIT
79
+ - Operating Systems:
80
+ - Raspberry Pi OS
81
+ - DietPi
82
+
83
+ Note: Both with kernel version 6.1 or higher.
84
+
85
+ - Rubies:
86
+ - Ruby 2.7.4 (system Ruby on some Raspberry Pi OS installs)
87
+ - Ruby 3.2.2 (with and without YJIT)
77
88
  - TruffleRuby 22.3.1 :man_shrugging: (Not available on ARMv6 Pis: Zero W, Pi 1. Not recommended in general)
78
89
 
79
90
  #### Dependencies
80
- This gem depends on [pigpio](https://github.com/joan2937/pigpio), the [pigpio gem](https://github.com/nak1114/ruby-extension-pigpio) to provide Ruby bindings, and [libgpiod](https://git.kernel.org/pub/scm/libs/libgpiod/libgpiod.git).
91
+
92
+ - [pigpio](https://github.com/joan2937/pigpio)
93
+ - [libgpiod](https://git.kernel.org/pub/scm/libs/libgpiod/libgpiod.git)
94
+ - [pigpio gem](https://github.com/nak1114/ruby-extension-pigpio) (Ruby bindings for pigpio)
95
+ - [denko](https://github.com/denko-rb/denko) (peripheral implementations from main gem)
96
+
97
+ ## Installation
81
98
 
82
99
  #### 1. Install pigpio and libgpiod packages
83
100
  ```shell
84
101
  sudo apt install pigpio libgpiod-dev
85
102
  ```
86
103
 
87
- #### 2. Install pigpio gem
88
- A bug in the current `pigpio` gem release prevents it from installing on Ruby 3.2+. You can safely ignore this step if using a lower Ruby version, or install it from [this fork](https://github.com/vickash/ruby-extension-pigpio) until fixes are merged and released:
89
- ```shell
90
- git clone https://github.com/denko-rb/ruby-extension-pigpio.git
91
- cd ruby-extension-pigpio
92
- gem build
93
- gem install ruby-extension-pigpio-0.1.11.gem
94
- ```
95
-
96
- #### 3. Install denko-piboard gem
104
+ #### 2. Install denko-piboard gem
97
105
  ```shell
98
106
  gem install denko-piboard
99
107
  ```
100
- This will automatically install the main `denko` gem and any other dependencies.
108
+ This automatically installs dependency gems: `denko` and `pigpio`.
101
109
 
102
- **Note:** `sudo` may be needed before `gem install` if using the preinstalled Ruby on a Pi.
110
+ **Note:** `sudo` may be needed before `gem install` if using the Pi's system ruby.
103
111
 
104
112
  ## Pi Setup
105
113
 
106
114
  #### pigpiod
107
- The `pigpio` package installs `pigpiod`, which needs to be running in the background as root for Ruby scripts to work. You should only need to start it once per boot. Automate it, or start manually with:
115
+ The `pigpio` package installs `pigpiod`, which must run in the background (as root) for Ruby scripts to work. You should only need to start it once per boot. Automate it, or start manually with:
108
116
  ```shell
109
117
  sudo pigpiod -s 10
110
118
  ```
111
119
  **Note:** `-s 10` sets tick interval to 10 microseconds, lowering CPU use. Valid values are: 1, 2, 4, 5, 8, 10 (5 default).
112
120
 
113
121
  #### libgpiod
114
- Depending on your Pi and OS, `libgpiod` may limit GPIO access. If this is the case, some scripts will fail with a `libgpiod` error. It is only used for low-level digital read/write operations, so check using a simple script like blinking an LED. To get `libgpiod` permission, add your user account to the `gpio` group:
122
+ Depending on your Pi and OS, `libgpiod` may limit GPIO access. If this happens, some scripts will fail. It is only used for digital read/write operations, so test with a simple script like blinking an LED. To get permission, add your user account to the `gpio` group:
115
123
  ```
116
124
  sudo usermod -a -G gpio $(whoami)
117
125
  ```
118
126
 
119
- #### Features
127
+ #### Enable Features
120
128
  I2C, SPI and the hardware UART may be disabled on the Pi by default. Enable them with the built-in utility:
121
129
  ```shell
122
130
  # On Raspberry Pi OS:
@@ -16,6 +16,6 @@ Gem::Specification.new do |s|
16
16
  # libgpio C extension
17
17
  s.extensions = %w[ext/gpiod/extconf.rb]
18
18
 
19
- s.add_dependency 'pigpio', '~> 0.1'
19
+ s.add_dependency 'pigpio', '~> 0.1.12'
20
20
  s.add_dependency 'denko', '~> 0.13'
21
21
  end
@@ -21,9 +21,18 @@ i2c = Denko::I2C::Bus.new(board: board, pin: :SDA)
21
21
  oled = Denko::Display::SSD1306.new(bus: i2c, rotate: true)
22
22
  canvas = oled.canvas
23
23
 
24
+ # Helper to convert free output to nearest integer in MiB units.
25
+ def ram_integer_from_string(string)
26
+ if string.match("Gi")
27
+ return (string.gsub("Gi", "").to_f * 1024).round
28
+ else
29
+ return string.gsub("Mi", "").to_i
30
+ end
31
+ end
32
+
24
33
  # Only do this once since total RAM won't change.
25
- total_ram = `free -h | awk 'NR==2 {gsub("Mi", "", $2); print $2}'`
26
- total_ram = total_ram.to_i
34
+ total_ram_string = `free -h | awk 'NR==2 {print $2}'`
35
+ total_ram = ram_integer_from_string(total_ram_string)
27
36
  ram_bar_factor = total_ram / 25.0
28
37
 
29
38
  loop do
@@ -39,11 +48,11 @@ loop do
39
48
  (cpu_percent / 4).ceil.times { canvas.raw_char(BAR_ELEMENT) }
40
49
 
41
50
  # RAM Usage
42
- ram_usage = `free -h | awk 'NR==2 {gsub("Mi", "", $3); print $3}'`
43
- ram_usage = ram_usage.to_i
51
+ ram_string = `free -h | awk 'NR==2 {print $3}'`
52
+ ram_usage = ram_string.to_i
44
53
 
45
54
  canvas.text_cursor = [0, 40]
46
- ram_string = "#{ram_usage}/#{total_ram}MB"
55
+ ram_string = "#{ram_usage}/#{total_ram}M"
47
56
  canvas.print "RAM Usage:#{ram_string.rjust(11, ' ')}"
48
57
 
49
58
  canvas.text_cursor = [0, 48]
@@ -2,9 +2,6 @@ module Denko
2
2
  class PiBoard
3
3
  # CMD = 0
4
4
  def set_pin_mode(pin, mode=:input, glitch_time=nil)
5
- # Validate pin
6
- # Validate output type
7
-
8
5
  # Close the line in libgpiod, if was already open.
9
6
  Denko::GPIOD.close_line(pin)
10
7
 
@@ -1,5 +1,5 @@
1
1
  module Denko
2
2
  class PiBoard
3
- VERSION = '0.13.1'
3
+ VERSION = '0.13.2'
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: denko-piboard
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.13.1
4
+ version: 0.13.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - vickash
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-06-20 00:00:00.000000000 Z
11
+ date: 2023-09-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: pigpio
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '0.1'
19
+ version: 0.1.12
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '0.1'
26
+ version: 0.1.12
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: denko
29
29
  requirement: !ruby/object:Gem::Requirement