You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

55 lines
1.3 KiB

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

class AtmegaMcu():
# Словарь с ВСЕМИ МК (сделаем его атрибутом класса)
ATMEGA_MCUS = {}
def __init__(self, name, BlockSize, FlashSize, BootSize, SpecialInfoSizeInPages):
self.name = name
self.BlockSize = BlockSize
self.FlashSize = FlashSize
self.BootSize = BootSize
self.SpecialInfoSizeInPages = SpecialInfoSizeInPages
# Автоматически добавляем в словарь при создании
AtmegaMcu.ATMEGA_MCUS[name] = self
@classmethod
def get_all_names(cls):
"""Получить список всех имен МК"""
return list(cls.ATMEGA_MCUS.keys())
@classmethod
def get_by_name(cls, name):
"""Получить МК по имени"""
return cls.ATMEGA_MCUS.get(name)
@classmethod
def get_all(cls):
"""Получить все МК"""
return list(cls.ATMEGA_MCUS.values())
# Теперь создаем МК - они автоматически добавятся в словарь
ATmega328PB = AtmegaMcu(
"ATmega328PB",
128,
32 * 1024,
4 * 1024,
1,
)
ATmega1280 = AtmegaMcu(
"ATmega1280",
256,
128 * 1024,
8 * 1024,
1,
)
ATmega2560 = AtmegaMcu(
"ATmega2560",
256,
256 * 1024,
8 * 1024,
1,
)