|
5 | 5 | Date: 2021-04-01 |
6 | 6 | Description: Detects the board type |
7 | 7 | """ |
8 | | -import sys |
9 | 8 | import os |
10 | 9 |
|
11 | 10 | class Board: |
12 | 11 | class BoardType: |
13 | 12 | PICO_W = 'Raspberry Pi Pico W' |
14 | 13 | PICO = 'Raspberry Pi Pico' |
| 14 | + PICO_2_W = 'Raspberry Pi Pico 2 W' |
| 15 | + PICO_2 = 'Raspberry Pi Pico 2' |
15 | 16 | ESP8266 = 'ESP8266' |
| 17 | + ESP32_C3 = 'ESP32-C3' |
16 | 18 | ESP32 = 'ESP32' |
17 | 19 | UNKNOWN = 'Unknown' |
18 | 20 |
|
| 21 | + FAMILY_PICO = (PICO, PICO_W, PICO_2, PICO_2_W) |
| 22 | + |
19 | 23 | def __init__(self): |
20 | 24 | self.type = self.detect_board_type() |
21 | 25 |
|
22 | 26 | def detect_board_type(self): |
23 | 27 | sysname = os.uname().sysname.lower() |
24 | 28 | machine = os.uname().machine.lower() |
25 | 29 |
|
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 |
30 | 41 | elif sysname == 'esp8266': |
31 | 42 | 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 |
32 | 48 | # Add more conditions for other boards here |
33 | 49 | else: |
34 | 50 | return self.BoardType.UNKNOWN |
0 commit comments