prettier names in mesh view

This commit is contained in:
Laura Klünder 2023-10-20 15:04:36 +02:00
parent 6a35c6767b
commit 7f7ea64fd3
6 changed files with 33 additions and 14 deletions

View file

@ -1,3 +1,4 @@
import re
from dataclasses import dataclass, field
from enum import IntEnum, unique
@ -21,6 +22,10 @@ class LedType(IntEnum):
SERIAL = 1
MULTIPIN = 2
@property
def pretty_name(self):
return self.name.lower()
@unique
class SerialLedType(IntEnum):
@ -83,6 +88,18 @@ class BoardType(IntEnum):
C3NAV_LOCATION_PCB_REV_0_1 = 0x11
C3NAV_LOCATION_PCB_REV_0_2 = 0x12
@property
def pretty_name(self):
if self.name.startswith('ESP32'):
return self.name.replace('_', '-').replace('DEVKIT-', 'DevKit')
if self.name.startswith('C3NAV'):
name = self.name.replace('_', ' ').lower()
name = name.replace('uwb', 'UWB').replace('pcb', 'PCB')
name = re.sub(r'[0-9]+( [0-9+])+', lambda s: s[0].replace(' ', '.'), name)
name = re.sub(r'rev.*', lambda s: s[0].replace(' ', ''), name)
return name
return self.name
@dataclass
class BoardConfig(StructType, union_type_field="board"):