Skip to content

Commit

Permalink
improve categorization (#370)
Browse files Browse the repository at this point in the history
Resolves #312 

- Add subcategorizations of Interface and EnvironmentalSensor
- Add MultipackDevice categorization, which replaces any prior
categorization - multipack devices should not be used in the context of
a normal block
  • Loading branch information
ducky64 authored Jul 25, 2024
1 parent 9a64eef commit 4d005cf
Show file tree
Hide file tree
Showing 16 changed files with 73 additions and 20 deletions.
2 changes: 1 addition & 1 deletion edg/abstract_parts/AbstractCapacitor.py
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,7 @@ def contents(self):
self.assign(self.actual_capacitance, self.capacitance) # fake it, since a combined capacitance is handwavey


class CombinedCapacitor(PassiveComponent, MultipackBlock, GeneratorBlock):
class CombinedCapacitor(MultipackDevice, MultipackBlock, GeneratorBlock):
"""A packed capacitor that combines multiple individual capacitors into a single component,
with the sum of or taking the max of the constituent capacitances."""
@init_in_parent
Expand Down
2 changes: 1 addition & 1 deletion edg/abstract_parts/AbstractLed.py
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ def __init__(self):
super().__init__(current_draw=RangeExpr())


class IndicatorSinkPackedRgbLed(Light, MultipackBlock):
class IndicatorSinkPackedRgbLed(MultipackDevice, MultipackBlock):
def __init__(self):
super().__init__()

Expand Down
4 changes: 2 additions & 2 deletions edg/abstract_parts/AbstractOpamp.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from typing import Mapping, Tuple, List, NamedTuple

from ..electronics_model import *
from .Categories import Analog
from .Categories import Analog, MultipackDevice


@abstract_block
Expand Down Expand Up @@ -32,7 +32,7 @@ class OpampElement(Opamp):


@abstract_block
class MultipackOpamp(Analog, MultipackBlock):
class MultipackOpamp(MultipackDevice, MultipackBlock):
"""Base class for packed opamps - devices that have multiple opamps in a single package,
with shared power and ground connections. Typically used with the multipack feature to
fit individual opamps across the design hierarchy into one of these."""
Expand Down
2 changes: 1 addition & 1 deletion edg/abstract_parts/AbstractResistorArray.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ def __init__(self):


@abstract_block
class ResistorArray(PassiveComponent, MultipackBlock):
class ResistorArray(MultipackDevice, MultipackBlock):
"""An n-element resistor array, where all resistors have the same resistance and power rating."""
@init_in_parent
def __init__(self, count: IntLike = 0) -> None: # 0 means 'size automatically'
Expand Down
50 changes: 50 additions & 0 deletions edg/abstract_parts/Categories.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,22 @@ class DigitalToAnalog(Interface):
pass


@abstract_block
class SpeakerDriver(Interface):
pass


@abstract_block
class IoExpander(Interface):
pass


@abstract_block
class BitBangAdapter(Interface):
"""Adapters that break out a structured Bundle to component wires, useful when bit-banging those protocols"""
pass


@abstract_block
class Radiofrequency(Block):
"""Radiofrequency devices."""
Expand Down Expand Up @@ -194,6 +210,28 @@ class EnvironmentalSensor(Sensor):
pass


@abstract_block
class TemperatureSensor(EnvironmentalSensor):
pass


@abstract_block
class HumiditySensor(EnvironmentalSensor):
pass


@abstract_block
class PressureSensor(EnvironmentalSensor):
"""Sensors measuring ambient pressure"""
pass


@abstract_block
class GasSensor(EnvironmentalSensor):
"""Sensors measuring gas concentration, including non-particle IAQ, TVOC, eCO2, and CO2 sensors."""
pass


@abstract_block
class LightSensor(Sensor):
pass
Expand All @@ -204,6 +242,11 @@ class Magnetometer(Sensor):
pass


@abstract_block
class Microphone(Sensor):
pass


@abstract_block
class Camera(Sensor):
"""Imaging sensors, including visible / RGB, IR, and thermal."""
Expand All @@ -227,6 +270,13 @@ class Testing(Block):
pass


@abstract_block
class MultipackDevice(Block):
"""A multipack device (e.g., dualpack opamp, quadpack resistor array) which blocks across the design
can be merged into."""
pass


@abstract_block
class ProgrammingConnector(Connector, Testing):
"""Programming / debug / JTAG connectors."""
Expand Down
2 changes: 1 addition & 1 deletion edg/abstract_parts/UsbBitBang.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from .AbstractResistor import Resistor


class UsbBitBang(Interface, Block):
class UsbBitBang(BitBangAdapter, Block):
"""Bit-bang circuit for USB, from the UPduino3.0 circuit and for 3.3v.
Presumably generalizes to any digital pin that can be driven fast enough.
Expand Down
8 changes: 5 additions & 3 deletions edg/abstract_parts/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,15 @@
from .Categories import Analog, OpampApplication
from .Categories import Filter, AnalogFilter, DigitalFilter
from .Categories import Microcontroller, Fpga, Memory, RealtimeClock, Radiofrequency
from .Categories import Interface, AnalogToDigital, DigitalToAnalog
from .Categories import Interface, AnalogToDigital, DigitalToAnalog, SpeakerDriver, IoExpander, BitBangAdapter
from .Categories import PowerConditioner, PowerSwitch, MotorDriver, BrushedMotorDriver, BldcDriver
from .Categories import PowerSource, Connector, ProgrammingConnector
from .Categories import HumanInterface, Display, Lcd, Oled, EInk, Light
from .Categories import Sensor, CurrentSensor, Accelerometer, Gyroscope, Magnetometer, DistanceSensor, Camera, \
EnvironmentalSensor, LightSensor
from .Categories import Sensor, CurrentSensor, Accelerometer, Gyroscope, Magnetometer, DistanceSensor, Microphone, \
Camera, LightSensor
from .Categories import EnvironmentalSensor, TemperatureSensor, HumiditySensor, PressureSensor, GasSensor
from .Categories import Label, Testing, TypedJumper, TypedTestPoint, InternalSubcircuit, DeprecatedBlock, Mechanical
from .Categories import MultipackDevice

from .ESeriesUtil import ESeriesUtil
from .SmdStandardPackage import SmdStandardPackage, SmdStandardPackageSelector
Expand Down
1 change: 1 addition & 0 deletions edg/core/Generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ def _generated_def_to_proto(self, generate_values: Iterable[Tuple[edgir.LocalPat
return self._def_to_proto()


@non_library
class DefaultExportBlock(GeneratorBlock):
"""EXPERIMENTAL UTILITY CLASS. There needs to be a cleaner way to address this eventually,
perhaps as a core compiler construct.
Expand Down
2 changes: 1 addition & 1 deletion edg/parts/EnvironmentalSensor_Bme680.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def contents(self) -> None:
self.assign(self.actual_basic_part, False)


class Bme680(EnvironmentalSensor, DefaultExportBlock):
class Bme680(TemperatureSensor, HumiditySensor, PressureSensor, GasSensor, DefaultExportBlock):
"""Gas (indoor air quality), pressure, temperature, and humidity sensor.
Humidity accuracy /-3% RH, pressure noise 0.12 Pa, temperature accuracy +/-0.5 C @ 25C"""
def __init__(self):
Expand Down
2 changes: 1 addition & 1 deletion edg/parts/EnvironmentalSensor_Sensirion.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def contents(self) -> None:
self.assign(self.actual_basic_part, False)


class Shtc3(EnvironmentalSensor, Block):
class Shtc3(TemperatureSensor, HumiditySensor, Block):
"""Humidity and temperature sensor with +/-2% RH and +/-0.2C"""
def __init__(self):
super().__init__()
Expand Down
4 changes: 2 additions & 2 deletions edg/parts/EnvironmentalSensor_Ti.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def contents(self) -> None:
self.assign(self.actual_basic_part, False)


class Hdc1080(EnvironmentalSensor, Block):
class Hdc1080(TemperatureSensor, HumiditySensor, Block):
"""Temperature and humidity sensor with +/- 0.2C and +/- 2% RH typical accuracy"""
def __init__(self):
super().__init__()
Expand Down Expand Up @@ -95,7 +95,7 @@ def generate(self) -> None:
self.assign(self.actual_basic_part, False)


class Tmp1075n(EnvironmentalSensor, Block):
class Tmp1075n(TemperatureSensor, Block):
"""Temperature sensor with 0.25C typical accuracy"""
@init_in_parent
def __init__(self, addr_lsb: IntLike = 0):
Expand Down
2 changes: 1 addition & 1 deletion edg/parts/IoExpander_Pca9554.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ def generate(self) -> None:
self.assign(self.lcsc_part, 'C86803')


class Pca9554(Interface, PinMappable):
class Pca9554(IoExpander, PinMappable):
"""8 bit I2C IO expander"""
@init_in_parent
def __init__(self, addr_lsb: IntLike = 0) -> None:
Expand Down
2 changes: 1 addition & 1 deletion edg/parts/IoExpander_Pcf8574.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ def generate(self) -> None:
self.assign(self.lcsc_part, "C86832")


class Pcf8574(Interface, PinMappable):
class Pcf8574(IoExpander, PinMappable):
"""8 bit I2C IO expander with 'quasi-bidirectional IOs'"""
@init_in_parent
def __init__(self, addr_lsb: IntLike = 0) -> None:
Expand Down
2 changes: 1 addition & 1 deletion edg/parts/Microphone_Sd18ob261.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def contents(self):
self.assign(self.actual_basic_part, False)


class Sd18ob261(Interface, GeneratorBlock):
class Sd18ob261(Microphone, GeneratorBlock):
"""SD18OB261-060 PDM microphone, probably footprint-compatible with similar Knowles devices.
Application circuit is not specified in the datasheet, this uses the one from SPH0655LM4H
(single 0.1uF decap)."""
Expand Down
6 changes: 3 additions & 3 deletions edg/parts/SpeakerDriver_Analog.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def contents(self):
)


class Lm4871(Interface, Block):
class Lm4871(SpeakerDriver, Block):
def __init__(self):
super().__init__()
# TODO should be a SpeakerDriver abstract part
Expand Down Expand Up @@ -128,7 +128,7 @@ def contents(self):
self.assign(self.actual_basic_part, False)


class Tpa2005d1(Interface, GeneratorBlock):
class Tpa2005d1(SpeakerDriver, GeneratorBlock):
"""TPA2005D1 configured in single-ended input mode.
Possible semi-pin-compatible with PAM8302AASCR (C113367), but which has internal resistor."""
@init_in_parent
Expand Down Expand Up @@ -232,7 +232,7 @@ def contents(self):
self.assign(self.actual_basic_part, False)


class Pam8302a(Interface):
class Pam8302a(SpeakerDriver, Block):
"""PAM8302A configured in single-ended input mode."""
@init_in_parent
def __init__(self):
Expand Down
2 changes: 1 addition & 1 deletion edg/parts/SpeakerDriver_Max98357a.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ def generate(self):
self.assign(self.lcsc_part, jlc_part)
self.assign(self.actual_basic_part, False)

class Max98357a(Interface, Block):
class Max98357a(SpeakerDriver, Block):
"""MAX98357A I2S speaker driver with default gain."""
@init_in_parent
def __init__(self):
Expand Down

0 comments on commit 4d005cf

Please sign in to comment.