Skip to content

Commit

Permalink
Merge pull request #654 from ohmtech-rdi/erbui-guitar-pedal-base-support
Browse files Browse the repository at this point in the history
Erbui guitar pedal base support
  • Loading branch information
ohmtech-rdi authored Jan 22, 2024
2 parents 905e280 + 20858dc commit 7a6ac9e
Show file tree
Hide file tree
Showing 31 changed files with 5,094 additions and 37 deletions.
4 changes: 4 additions & 0 deletions build-system/build-system.gyp
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,10 @@
'erbui/generators/perf/code_template.cpp',
'erbui/generators/perf/code.py',

# generators/tayda
'erbui/generators/tayda/drill.py',
'erbui/generators/tayda/drill_template.py',

# generators/ui
'erbui/generators/ui/code_template.h',
'erbui/generators/ui/code.py',
Expand Down
14 changes: 14 additions & 0 deletions build-system/erbui/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
from .generators.front_pcb.centroid import Centroid as front_pcbCentroid
from .generators.max.code import Code as maxCode
from .generators.faust.code import Code as faustCode
from .generators.tayda.drill import Drill as taydaDrill

PATH_THIS = os.path.abspath (os.path.dirname (__file__))
PATH_ROOT = os.path.abspath (os.path.dirname (os.path.dirname (PATH_THIS)))
Expand Down Expand Up @@ -194,6 +195,7 @@ def generate_hardware (path, ast):
generate_front_pcb_kicad_pcb (path_hardware, ast)
generate_front_pcb_bom (path_hardware, ast)
generate_front_pcb_centroid (path_hardware, ast)
generate_tayda_drill (path_hardware, ast)



Expand Down Expand Up @@ -282,3 +284,15 @@ def generate_front_pcb_gerber (path, ast):

generator = kicad_pcbKicadPcb ()
generator.generate_gerber (path_hardware, ast)



"""
==============================================================================
Name: generate_tayda_drill
==============================================================================
"""

def generate_tayda_drill (path, ast):
generator = taydaDrill ()
generator.generate (path, ast)
19 changes: 17 additions & 2 deletions build-system/erbui/analyser.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ def analyse_module (self, module):

self.exclude_pins (module)

self.set_auto_board_width (module)
self.set_auto_board_width_height (module)

for control in module.controls:
self.update_pools (module, control)
Expand Down Expand Up @@ -128,7 +128,22 @@ def exclude_pins (self, module):

#--------------------------------------------------------------------------

def set_auto_board_width (self, module):
def set_auto_board_width_height (self, module):
entities = [e for e in module.board.entities if e.is_format]
if len (entities) == 0:
module.board.add (ast.Format (adapter.BuiltIn ('3u')))

module.add (module.board.format)

if module.board.format.is_3u:
module.board.add (ast.Height (ast.DistanceLiteral (adapter.LiteralSynthesized ('128.5mm'), 'mm')))
elif module.board.format.is_1590bb2_portrait:
module.board.add (ast.Width (ast.DistanceLiteral (adapter.LiteralSynthesized ('94.0mm'), 'mm')))
module.board.add (ast.Height (ast.DistanceLiteral (adapter.LiteralSynthesized ('119.5mm'), 'mm')))

if module.board.height != None:
module.add (module.board.height)

if module.board.width == None:
return # board doesn't support fixed width

Expand Down
50 changes: 47 additions & 3 deletions build-system/erbui/analysers/style.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,18 @@ def analyse_module (self, global_namespace, module):
if module.board.pcb:
module.sch_symbols = self.collect_symbols (module)

if module.board.pcb_side ('left'):
module.pcb_left = pcb.Root.read (os.path.abspath (module.board.pcb_side ('left').path))

if module.board.pcb_side ('top'):
module.pcb_top = pcb.Root.read (os.path.abspath (module.board.pcb_side ('top').path))

if module.board.pcb_side ('right'):
module.pcb_right = pcb.Root.read (os.path.abspath (module.board.pcb_side ('right').path))

if module.board.pcb_side ('bottom'):
module.pcb_bottom = pcb.Root.read (os.path.abspath (module.board.pcb_side ('bottom').path))


#--------------------------------------------------------------------------

Expand Down Expand Up @@ -227,7 +239,7 @@ def analyse_control (self, module, control, manufacturer_style_set):
component_list = cur_styles_parts ['parts']

for component_name in component_list:
kicad_pcb, kicad_sch = self.load_kicad_pcb_sch (
kicad_pcb, kicad_pcb_side, kicad_sch = self.load_kicad_pcb_sch (
module, module.manufacturer_base_path, component_name
)
self.rename_normalling_to (kicad_pcb, control)
Expand All @@ -237,8 +249,11 @@ def analyse_control (self, module, control, manufacturer_style_set):
self.relink_nets (kicad_pcb, module, control)
self.rotate (kicad_pcb, control)
self.translate (kicad_pcb, control)
side = None
if kicad_pcb_side:
side = self.translate_side (kicad_pcb_side, control)

control.parts.append (ast.Control.Part (kicad_pcb, kicad_sch))
control.parts.append (ast.Control.Part (kicad_pcb, kicad_pcb_side, side, kicad_sch))


#--------------------------------------------------------------------------
Expand All @@ -251,6 +266,12 @@ def load_kicad_pcb_sch (self, module, base_path, component_name):
kicad_sch_path = os.path.abspath (os.path.join (base_path, component_name, '%s.kicad_sch' % component_name))
kicad_sch = sch.Root.read (kicad_sch_path)

kicad_pcb_side_path = os.path.abspath (os.path.join (base_path, component_name, '%s.side.kicad_pcb' % component_name))

kicad_pcb_side = None
if os.path.exists (kicad_pcb_side_path):
kicad_pcb_side = pcb.Root.read (kicad_pcb_side_path)

ref_map = self.make_ref_map (module, kicad_pcb)

for footprint in kicad_pcb.footprints:
Expand All @@ -266,7 +287,7 @@ def load_kicad_pcb_sch (self, module, base_path, component_name):
if symbol_instance.reference [0] != '#': # eg. #PWRxxx
symbol_instance.reference = ref_map [symbol_instance.reference]

return (kicad_pcb, kicad_sch)
return (kicad_pcb, kicad_pcb_side, kicad_sch)


#--------------------------------------------------------------------------
Expand Down Expand Up @@ -411,6 +432,29 @@ def translate (self, kicad_pcb, control):
kicad_pcb.translate (control.position.x.mm, control.position.y.mm)


#--------------------------------------------------------------------------
# Translate top level objects to their new side position
# Returns the detected side

def translate_side (self, kicad_pcb, control):
rotation_degree = (control.rotation.degree + 360) % 360 if control.rotation else 0

if rotation_degree == 0:
side = 'top'
kicad_pcb.translate (control.position.x.mm, 0)
elif rotation_degree == 90:
side = 'left'
kicad_pcb.translate (control.position.y.mm, 0)
elif rotation_degree == 180:
side = 'bottom'
kicad_pcb.translate (control.position.x.mm, 0)
elif rotation_degree == 270:
side = 'right'
kicad_pcb.translate (control.position.y.mm, 0)

return side


#--------------------------------------------------------------------------

def collect_symbols (self, module):
Expand Down
146 changes: 143 additions & 3 deletions build-system/erbui/ast.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,9 @@ def is_board_include (self): return isinstance (self, BoardInclude)
@property
def is_board_pcb (self): return isinstance (self, BoardPcb)

@property
def is_board_pcb_side (self): return isinstance (self, BoardPcbSide)

@property
def is_board_sch (self): return isinstance (self, BoardSch)

Expand Down Expand Up @@ -113,6 +116,12 @@ def is_board_header (self): return isinstance (self, BoardHeader)
@property
def is_width (self): return isinstance (self, Width)

@property
def is_height (self): return isinstance (self, Height)

@property
def is_format (self): return isinstance (self, Format)

@property
def is_material (self): return isinstance (self, Material)

Expand Down Expand Up @@ -425,6 +434,10 @@ def __init__ (self, identifier, super_identifier):
self.identifier = identifier
self.super_identifier = super_identifier
self.pcb = None
self.pcb_left = None
self.pcb_top = None
self.pcb_right = None
self.pcb_bottom = None
self.sch = None
self.sch_symbols = None # board, hierarchical sheets, controls
self.references = []
Expand Down Expand Up @@ -476,6 +489,18 @@ def width (self):
assert (len (entities) == 1)
return entities [0]

@property
def height (self):
entities = [e for e in self.entities if e.is_height]
assert (len (entities) == 1)
return entities [0]

@property
def format (self):
entities = [e for e in self.entities if e.is_format]
assert (len (entities) == 1)
return entities [0]

@property
def material (self):
entities = [e for e in self.entities if e.is_material]
Expand Down Expand Up @@ -658,7 +683,15 @@ def include (self):

@property
def pcb (self):
entities = [e for e in self.entities if e.is_board_pcb]
entities = [e for e in self.entities if e.is_board_pcb and e.side_name == 'face']
assert (len (entities) <= 1)
if entities:
return entities [0]
else:
return None

def pcb_side (self, name):
entities = [e for e in self.entities if e.is_board_pcb and e.side_name == name]
assert (len (entities) <= 1)
if entities:
return entities [0]
Expand All @@ -683,6 +716,24 @@ def width (self):
else:
return None

@property
def height (self):
entities = [e for e in self.entities if e.is_height]
assert (len (entities) <= 1)
if entities:
return entities [0]
else:
return None

@property
def format (self):
entities = [e for e in self.entities if e.is_format]
assert (len (entities) <= 1)
if entities:
return entities [0]
else:
return None

def pin (self, name):
entities = [e for e in self.entities if e.is_board_pin and e.name == name]
assert (len (entities) == 1)
Expand Down Expand Up @@ -767,7 +818,7 @@ def path (self): return self.filepath

# -- BoardPcb ----------------------------------------------------------------

class BoardPcb (Node):
class BoardPcb (Scope):
def __init__ (self, filepath, string_literal):
assert isinstance (filepath, str)
assert isinstance (string_literal, StringLiteral)
Expand All @@ -778,6 +829,51 @@ def __init__ (self, filepath, string_literal):
@property
def path (self): return self.filepath

@property
def side (self):
entities = [e for e in self.entities if e.is_board_pcb_side]
assert (len (entities) <= 1)
if entities:
return entities [0]
else:
return None

@property
def side_name (self):
return self.side.name if self.side else 'face'


# -- BoardPcbSide ------------------------------------------------------------

class BoardPcbSide (Node):
def __init__ (self, keyword_name):
assert isinstance (keyword_name, adapter.Keyword)
super (BoardPcbSide, self).__init__ ()
self.keyword_name = keyword_name

@property
def name (self): return self.keyword_name.value

@property
def is_face (self):
return self.name == 'face'

@property
def is_left (self):
return self.name == 'left'

@property
def is_top (self):
return self.name == 'top'

@property
def is_right (self):
return self.name == 'right'

@property
def is_bottom (self):
return self.name == 'bottom'


# -- BoardSch ----------------------------------------------------------------

Expand Down Expand Up @@ -1384,8 +1480,10 @@ def value (self):

class Control (Scope):
class Part:
def __init__ (self, pcb, sch):
def __init__ (self, pcb, pcb_side, side, sch):
self.pcb = pcb
self.pcb_side = pcb_side
self.side = side
self.sch = sch

def __init__ (self, identifier_name, keyword_kind):
Expand Down Expand Up @@ -1803,6 +1901,48 @@ def pt (self):



# -- Height ------------------------------------------------------------------

class Height (Node):
def __init__ (self, literal):
assert isinstance (literal, DistanceLiteral)
super (Height, self).__init__ ()
self.literal = literal

@staticmethod
def typename (): return 'height'

@property
def mm (self):
return self.literal.mm

@property
def pt (self):
return self.literal.pt



# -- Format ------------------------------------------------------------------

class Format (Node):
def __init__ (self, keyword_name):
assert isinstance (keyword_name, adapter.Keyword)
super (Format, self).__init__ ()
self.keyword_name = keyword_name

@staticmethod
def typename (): return 'format'

@property
def is_3u (self):
return self.keyword_name.value == '3u'

@property
def is_1590bb2_portrait (self):
return self.keyword_name.value == '1590bb2_portrait'



# -- Positioning -------------------------------------------------------------

class Positioning (Node):
Expand Down
Loading

0 comments on commit 7a6ac9e

Please sign in to comment.