Skip to content

Commit ff305a4

Browse files
author
Kevin J Walters
committed
Picking up new board.py from pico-web-server-control.
See gurgleapps/pico-web-server-control#11 and gurgleapps/pico-web-server-control#12
1 parent d32939f commit ff305a4

File tree

1 file changed

+21
-5
lines changed

1 file changed

+21
-5
lines changed

src/board.py

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,30 +5,46 @@
55
Date: 2021-04-01
66
Description: Detects the board type
77
"""
8-
import sys
98
import os
109

1110
class Board:
1211
class BoardType:
1312
PICO_W = 'Raspberry Pi Pico W'
1413
PICO = 'Raspberry Pi Pico'
14+
PICO_2_W = 'Raspberry Pi Pico 2 W'
15+
PICO_2 = 'Raspberry Pi Pico 2'
1516
ESP8266 = 'ESP8266'
17+
ESP32_C3 = 'ESP32-C3'
1618
ESP32 = 'ESP32'
1719
UNKNOWN = 'Unknown'
1820

21+
FAMILY_PICO = (PICO, PICO_W, PICO_2, PICO_2_W)
22+
1923
def __init__(self):
2024
self.type = self.detect_board_type()
2125

2226
def detect_board_type(self):
2327
sysname = os.uname().sysname.lower()
2428
machine = os.uname().machine.lower()
2529

26-
if sysname == 'rp2' and 'pico w' in machine:
27-
return self.BoardType.PICO_W
28-
elif sysname == 'rp2' and 'pico' in machine:
29-
return self.BoardType.PICO
30+
if sysname == 'rp2':
31+
if 'pico 2 w' in machine:
32+
return self.BoardType.PICO_2_W
33+
elif 'pico 2' in machine:
34+
return self.BoardType.PICO_2
35+
elif 'pico w' in machine:
36+
return self.BoardType.PICO_W
37+
elif 'pico' in machine:
38+
return self.BoardType.PICO
39+
else:
40+
return self.BoardType.UNKNOWN
3041
elif sysname == 'esp8266':
3142
return self.BoardType.ESP8266
43+
elif sysname == 'esp32':
44+
if 'esp32c3' in machine:
45+
return self.BoardType.ESP32_C3
46+
else:
47+
return self.BoardType.ESP32
3248
# Add more conditions for other boards here
3349
else:
3450
return self.BoardType.UNKNOWN

0 commit comments

Comments
 (0)