Skip to content

Commit 66da591

Browse files
committed
Merge remote-tracking branch 'upstream/master'
2 parents cfccf74 + 3948cf9 commit 66da591

File tree

6 files changed

+44
-18
lines changed

6 files changed

+44
-18
lines changed

docs/cli_pinout.rst

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ Synopsis
88

99
::
1010

11-
pinout [-h] [-r REVISION] [-c] [-m]
11+
pinout [-h] [-r REVISION] [-c] [-m] [-x]
1212

1313
Description
1414
-----------
@@ -41,6 +41,10 @@ Options
4141

4242
Force monochrome output. See also :option:`--color`
4343

44+
.. option:: -x, --xyz
45+
46+
Open `pinout.xyz`_ in the default web browser
47+
4448
Examples
4549
--------
4650

@@ -172,4 +176,5 @@ PIGPIO_PORT
172176

173177
:manpage:`remote-gpio(7)`
174178

175-
.. _revision codes: http://elinux.org/RPi_HardwareHistory
179+
.. _pinout.xyz: https://pinout.xyz/
180+
.. _revision codes: https://www.raspberrypi.org/documentation/hardware/raspberrypi/revision-codes/README.md

docs/development.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ command should install all required dependencies:
9090
.. code-block:: console
9191
9292
$ sudo apt install texlive-latex-recommended texlive-latex-extra \
93-
texlive-fonts-recommended graphviz inkscape
93+
texlive-fonts-recommended graphviz inkscape python-sphinx
9494
9595
Once these are installed, you can use the "doc" target to build the
9696
documentation:

gpiozero/boards.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1602,6 +1602,10 @@ def __repr__(self):
16021602
except DeviceClosed:
16031603
return "<gpiozero.Energenie object closed>"
16041604

1605+
@property
1606+
def socket(self):
1607+
return self._socket
1608+
16051609
@property
16061610
def value(self):
16071611
return self._value

gpiozero/pins/data.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@
122122
{style:white on green}| {J8:{style} col2}{style:white on green} J8 {style:black on white}+===={style:reset}
123123
{style:white on green}| {J8:{style} col1}{style:white on green} {style:black on white}| USB{style:reset}
124124
{style:white on green}| {style:black on white}+===={style:reset}
125-
{style:white on green}| {style:bold}Pi Model {model:3s}V{pcb_revision:3s}{style:normal} |{style:reset}
125+
{style:white on green}| {style:bold}Pi Model {model:4s}V{pcb_revision:3s}{style:normal} |{style:reset}
126126
{style:white on green}| {style:on black}+----+{style:on green} {style:black on white}+===={style:reset}
127127
{style:white on green}| {style:on black}|D|{style:on green} {style:on black}|SoC |{style:on green} {style:black on white}| USB{style:reset}
128128
{style:white on green}| {style:on black}|S|{style:on green} {style:on black}| |{style:on green} {style:black on white}+===={style:reset}
@@ -841,7 +841,7 @@ def from_revision(cls, revision):
841841
# CCCC - Manufacturer (0=Sony, 1=Egoman, 2=Embest, 3=Sony Japan)
842842
# PPPP - Processor (0=2835, 1=2836, 2=2837)
843843
# TTTTTTTT - Type (0=A, 1=B, 2=A+, 3=B+, 4=2B, 5=Alpha (??), 6=CM,
844-
# 8=3B, 9=Zero, 10=CM3, 12=Zero W)
844+
# 8=3B, 9=Zero, 10=CM3, 12=Zero W, 13=3B+)
845845
# RRRR - Revision (0, 1, 2, etc.)
846846
revcode_memory = (revision & 0x700000) >> 20
847847
revcode_manufacturer = (revision & 0xf0000) >> 16
@@ -860,6 +860,7 @@ def from_revision(cls, revision):
860860
9: 'Zero',
861861
10: 'CM3',
862862
12: 'Zero W',
863+
13: '3B+',
863864
}.get(revcode_type, '???')
864865
if model in ('A', 'B'):
865866
pcb_revision = {
@@ -896,6 +897,7 @@ def from_revision(cls, revision):
896897
'Zero': '2015Q4' if pcb_revision == '1.2' else '2016Q2',
897898
'CM3': '2017Q1',
898899
'Zero W': '2017Q1',
900+
'3B+': '2018Q1',
899901
}.get(model, 'Unknown')
900902
storage = {
901903
'A': 'SD',
@@ -923,10 +925,12 @@ def from_revision(cls, revision):
923925
wifi = {
924926
'3B': True,
925927
'Zero W': True,
928+
'3B+': True,
926929
}.get(model, False)
927930
bluetooth = {
928931
'3B': True,
929932
'Zero W': True,
933+
'3B+': True,
930934
}.get(model, False)
931935
csi = {
932936
'Zero': 0 if pcb_revision == '1.0' else 1,

gpiozerocli/pinout.py

Lines changed: 24 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
import sys
1414
import textwrap
1515
import warnings
16+
import webbrowser
1617

1718
class PinoutTool(object):
1819
def __init__(self):
@@ -38,6 +39,12 @@ def __init__(self):
3839
action='store_false',
3940
help='Force monochrome output. See also --color'
4041
)
42+
self.parser.add_argument(
43+
'-x', '--xyz',
44+
dest='xyz',
45+
action='store_true',
46+
help='Open pinout.xyz in the default web browser'
47+
)
4148

4249
def __call__(self, args=None):
4350
if args is None:
@@ -69,23 +76,27 @@ def main(self, args):
6976
"remotely access your Pi."
7077
)
7178
formatter.add_text(
72-
"* https://gpiozero.readthedocs.io/en/latest/remote_gpio.html"
79+
"* https://gpiozero.readthedocs.io/en/stable/remote_gpio.html"
7380
)
7481
sys.stderr.write(formatter.format_help())
7582
else:
76-
if args.revision == '':
77-
try:
78-
pi_info().pprint(color=args.color)
79-
except IOError:
80-
raise IOError('This device is not a Raspberry Pi')
83+
if args.xyz:
84+
webbrowser.open('https://pinout.xyz')
8185
else:
82-
pi_info(args.revision).pprint(color=args.color)
83-
formatter = self.parser._get_formatter()
84-
formatter.add_text(
85-
"For further information, please refer to https://pinout.xyz/"
86-
)
87-
sys.stdout.write('\n')
88-
sys.stdout.write(formatter.format_help())
86+
if args.revision == '':
87+
try:
88+
pi_info().pprint(color=args.color)
89+
except IOError:
90+
raise IOError('This device is not a Raspberry Pi')
91+
else:
92+
pi_info(args.revision).pprint(color=args.color)
93+
formatter = self.parser._get_formatter()
94+
formatter.add_text(
95+
"For further information, please refer to "
96+
"https://pinout.xyz/"
97+
)
98+
sys.stdout.write('\n')
99+
sys.stdout.write(formatter.format_help())
89100

90101

91102
main = PinoutTool()

tests/test_boards.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -935,6 +935,8 @@ def test_energenie():
935935
assert repr(device2) == '<gpiozero.Energenie object on socket 2>'
936936
assert device1.value
937937
assert not device2.value
938+
assert device1.socket == 1
939+
assert device2.socket == 2
938940
[pin.clear_states() for pin in pins]
939941
device1.on()
940942
assert device1.value

0 commit comments

Comments
 (0)