working pi detection, stub out Chip a bit further
This commit is contained in:
parent
32dffc8a58
commit
686bc57a28
5 changed files with 47 additions and 54 deletions
|
|
@ -1,39 +1,5 @@
|
|||
# Pi revision codes:
|
||||
# 0002 | B | 1.0 | 256 MB | Egoman
|
||||
# 0003 | B | 1.0 | 256 MB | Egoman
|
||||
# 0004 | B | 2.0 | 256 MB | Sony UK
|
||||
# 0005 | B | 2.0 | 256 MB | Qisda
|
||||
# 0006 | B | 2.0 | 256 MB | Egoman
|
||||
# 0007 | A | 2.0 | 256 MB | Egoman
|
||||
# 0008 | A | 2.0 | 256 MB | Sony UK
|
||||
# 0009 | A | 2.0 | 256 MB | Qisda
|
||||
# 000d | B | 2.0 | 512 MB | Egoman
|
||||
# 000e | B | 2.0 | 512 MB | Sony UK
|
||||
# 000f | B | 2.0 | 512 MB | Egoman
|
||||
# 0010 | B+ | 1.0 | 512 MB | Sony UK
|
||||
# 0011 | CM1 | 1.0 | 512 MB | Sony UK
|
||||
# 0012 | A+ | 1.1 | 256 MB | Sony UK
|
||||
# 0013 | B+ | 1.2 | 512 MB | Embest
|
||||
# 0014 | CM1 | 1.0 | 512 MB | Embest
|
||||
# 0015 | A+ | 1.1 | 256 MB / 512 MB | Embest
|
||||
# 900021 | A+ | 1.1 | 512 MB | Sony UK
|
||||
# 900032 | B+ | 1.2 | 512 MB | Sony UK
|
||||
# 900092 | Zero | 1.2 | 512 MB | Sony UK
|
||||
# 920092 | Zero | 1.2 | 512 MB | Embest
|
||||
# 900093 | Zero | 1.3 | 512 MB | Sony UK
|
||||
# 9000c1 | Zero W | 1.1 | 512 MB | Sony UK
|
||||
# 920093 | Zero | 1.3 | 512 MB | Embest
|
||||
# a01040 | 2B | 1.0 | 1 GB | Sony UK
|
||||
# a01041 | 2B | 1.1 | 1 GB | Sony UK
|
||||
# a02082 | 3B | 1.2 | 1 GB | Sony UK
|
||||
# a020a0 | CM3 | 1.0 | 1 GB | Sony UK
|
||||
# a21041 | 2B | 1.1 | 1 GB | Embest
|
||||
# a22042 | 2B (w/BCM2837) | 1.2 | 1 GB | Embest
|
||||
# a22082 | 3B | 1.2 | 1 GB | Embest
|
||||
# a32082 | 3B | 1.2 | 1 GB | Sony Japan
|
||||
# a52082 | 3B | 1.2 | 1 GB | Stadium
|
||||
# a020d3 | 3B+ | 1.3 | 1 GB | Sony UK
|
||||
# 9020e0 | 3A+ | 1.0 | 512 MB | Sony UK
|
||||
# Pi revision codes from:
|
||||
# https://www.raspberrypi.org/documentation/hardware/raspberrypi/revision-codes/README.md
|
||||
|
||||
RASPBERRY_PI_B = "raspberry_pi_b"
|
||||
RASPBERRY_PI_B_PLUS = "raspberry_pi_b_plus"
|
||||
|
|
@ -71,17 +37,20 @@ class Board:
|
|||
# Check Raspberry Pi values:
|
||||
if attr in _PI_REV_CODES:
|
||||
return self.pi_rev_code in _PI_REV_CODES[attr]
|
||||
|
||||
raise AttributeError(attr + " is not a defined board")
|
||||
|
||||
@property
|
||||
def name(self):
|
||||
pi_rev_code = self.pi_rev_code
|
||||
name = None
|
||||
|
||||
pi_rev_code = self.pi_rev_code
|
||||
if pi_rev_code:
|
||||
for model, codes in _PI_REV_CODES:
|
||||
for model, codes in _PI_REV_CODES.items():
|
||||
if pi_rev_code in codes:
|
||||
name = model
|
||||
break
|
||||
|
||||
return name
|
||||
|
||||
@property
|
||||
|
|
@ -98,4 +67,4 @@ class Board:
|
|||
if self.detect.cpuinfo_field('Hardware') not in ('BCM2708', 'BCM2709', 'BCM2835'):
|
||||
# Something else, not a Pi.
|
||||
return None
|
||||
return self.cpuinfo_field('Revision')
|
||||
return self.detect.cpuinfo_field('Revision')
|
||||
|
|
|
|||
|
|
@ -1,3 +1,28 @@
|
|||
import sys
|
||||
|
||||
ESP8266 = "esp8266",
|
||||
SAMD21 = "samd21",
|
||||
STM32 = "stm32",
|
||||
|
||||
class Chip:
|
||||
def __init__(self, detect):
|
||||
self.detect = detect
|
||||
|
||||
@property
|
||||
def name(self):
|
||||
name = None
|
||||
|
||||
platform = sys.platform
|
||||
if platform is not None:
|
||||
if platform == "esp8266":
|
||||
name = ESP8266
|
||||
elif platform == "samd21":
|
||||
name = SAMD21
|
||||
elif platform == "pyboard":
|
||||
name = STM32
|
||||
elif platform == "linux":
|
||||
# XXX: Here is where some work to detect ARM / x86 stuff for
|
||||
# real needs to happen.
|
||||
name = self.detect.cpuinfo_field("Hardware")
|
||||
|
||||
return name
|
||||
|
|
|
|||
13
bin/detect.py
Normal file
13
bin/detect.py
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
#!/usr/bin/env python3
|
||||
|
||||
import adafruit_platformdetect
|
||||
|
||||
detect = adafruit_platformdetect.PlatformDetect()
|
||||
|
||||
print("Chip name: ", detect.chip.name)
|
||||
|
||||
print("Board name: ", detect.board.name)
|
||||
|
||||
if detect.board.any_raspberry_pi:
|
||||
print("Raspberry Pi detected.")
|
||||
print("Revision code: ", detect.board.pi_rev_code)
|
||||
2
setup.py
2
setup.py
|
|
@ -30,7 +30,7 @@ setup(
|
|||
url='https://github.com/adafruit/Adafruit_Python_PlatformDetect',
|
||||
|
||||
# If your package is a single module, use this instead of 'packages':
|
||||
py_modules=['adafruit_platformdetect'],
|
||||
packages=['adafruit_platformdetect'],
|
||||
|
||||
install_requires=[],
|
||||
license='MIT',
|
||||
|
|
|
|||
|
|
@ -1,14 +0,0 @@
|
|||
import adafruit_platformdetect
|
||||
|
||||
detect = adafruit_platformdetect.PlatformDetect()
|
||||
print(detect.board.name)
|
||||
|
||||
# print(adafruit_platformdetect.board.RASPBERRY_PI_B)
|
||||
|
||||
print(detect.board.pi_rev_code)
|
||||
print(detect.board.any_raspberry_pi)
|
||||
|
||||
print(detect.board.raspberry_pi_3b_plus)
|
||||
print(detect.board.raspberry_pi_a)
|
||||
print(detect.board.raspberry_pi_3b_plus)
|
||||
print(detect.board.raspberry_pi_a)
|
||||
Loading…
Reference in a new issue