denko-piboard 0.13.1 → 0.13.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/README.md +39 -31
- data/denko_piboard.gemspec +1 -1
- data/examples/pi_system_monitor.rb +14 -5
- data/lib/denko/piboard_core.rb +0 -3
- data/lib/denko/piboard_version.rb +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6bad42203be8c858270403900ba28c58f7a63eaf616151975e7b5d61a471a472
|
4
|
+
data.tar.gz: ad86f14e2d91a644ea1ccc8f7d599b4bbfa095d55b5f07fc734dd741447811ea
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
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
|
-
##
|
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
|
-
|
72
|
-
-
|
73
|
-
-
|
74
|
-
|
75
|
-
|
76
|
-
|
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
|
-
|
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
|
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
|
108
|
+
This automatically installs dependency gems: `denko` and `pigpio`.
|
101
109
|
|
102
|
-
**Note:** `sudo` may be needed before `gem install` if using the
|
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
|
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
|
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:
|
data/denko_piboard.gemspec
CHANGED
@@ -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
|
-
|
26
|
-
total_ram =
|
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
|
-
|
43
|
-
ram_usage =
|
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}
|
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]
|
data/lib/denko/piboard_core.rb
CHANGED
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.
|
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-
|
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:
|
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:
|
26
|
+
version: 0.1.12
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: denko
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|