- 
                Notifications
    You must be signed in to change notification settings 
- Fork 18
Initial completion of ViaGridBoard to best of ability w current tsc functionality #42
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
          
     Open
      
      
            raykholo
  wants to merge
  15
  commits into
  tscircuit:main
  
    
      
        
          
  
    
      Choose a base branch
      
     
    
      
        
      
      
        
          
          
        
        
          
            
              
              
              
  
           
        
        
          
            
              
              
           
        
       
     
  
        
          
            
          
            
          
        
       
    
      
from
raykholo:ViaGridBoard
  
      
      
   
  
    
  
  
  
 
  
      
    base: main
Could not load branches
            
              
  
    Branch not found: {{ refName }}
  
            
                
      Loading
              
            Could not load tags
            
            
              Nothing to show
            
              
  
            
                
      Loading
              
            Are you sure you want to change the base?
            Some commits from the old base branch may be removed from the timeline,
            and old review comments may become outdated.
          
          
  
     Open
                    Changes from all commits
      Commits
    
    
            Show all changes
          
          
            15 commits
          
        
        Select commit
          Hold shift + click to select a range
      
      d2dcf44
              
                Initial completion of ViaGridBoard to best of ability w current tsc f…
              
              
                raykholo 6021468
              
                format!
              
              
                raykholo 115ea9e
              
                rm phantom code
              
              
                raykholo 2f3187c
              
                severe cleanup of corner pacmans with OutlineBuilder and arcTo, pcbRo…
              
              
                raykholo 433bcde
              
                format
              
              
                raykholo 2b14e32
              
                more cleanup
              
              
                raykholo 6a3ce18
              
                fix .map -> keys
              
              
                raykholo 47cc0cd
              
                all vias now have unique names!
              
              
                raykholo 79c980f
              
                Added GND net to fix errors!  snapshots work now!
              
              
                raykholo e51797c
              
                cleanup
              
              
                raykholo 653773e
              
                 hide the pacmans and top rect in the schematic
              
              
                raykholo f0c87e5
              
                Update ViaGridBoard.circuit-schematic.snap.svg
              
              
                raykholo 92b439b
              
                Update index.tsx
              
              
                raykholo 4f3bac4
              
                Update index.tsx
              
              
                raykholo 727ed53
              
                comment out copperpour per seve
              
              
                raykholo File filter
Filter by extension
Conversations
          Failed to load comments.   
        
        
          
      Loading
        
  Jump to
        
          Jump to file
        
      
      
          Failed to load files.   
        
        
          
      Loading
        
  Diff view
Diff view
There are no files selected for viewing
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              | Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -0,0 +1,156 @@ | ||
| import { splitBoardAndChipProps } from "../../util/splitBoardAndChipProps" | ||
| import { ChipProps, BoardProps } from "@tscircuit/props" | ||
| import { grid } from "@tscircuit/math-utils" | ||
| import { | ||
| ViaGridVia, | ||
| ViaGridPlus, | ||
| pacmanPolygonOutline, | ||
| } from "./viaGridElements" | ||
|  | ||
| type ViaGridBoardProps = ChipProps & | ||
| BoardProps & { children?: any; boardName?: string } | ||
|  | ||
| export const ViaGridBoard = ({ children, ...rest }: ViaGridBoardProps) => { | ||
| const { boardProps, chipProps = {} } = splitBoardAndChipProps({ | ||
| ...rest, | ||
| }) as { | ||
| boardProps: any | ||
| chipProps: Record<string, any> | ||
| } | ||
|  | ||
| const resolvedName = `${chipProps.name}_chip` | ||
| const { name: _, ...chipRest } = chipProps | ||
|  | ||
| return ( | ||
| <board | ||
| {...boardProps} | ||
| width="100mm" | ||
| height="65mm" | ||
| boardAnchorPosition={{ x: 0, y: 0 }} | ||
| boardAnchorAlignment="bottom_left" | ||
| > | ||
| <pcbnoterect //User.1 kicad rect shows outer bounds of usable area | ||
| pcbX={50} | ||
| pcbY={32.5} | ||
| width={90} | ||
| height={55} | ||
| strokeWidth={0.3} | ||
| color="blue" | ||
| /> | ||
|  | ||
| {["BL", "TL", "TR", "BR"].map((cornerPositionName, index) => { | ||
| const x = (cornerPositionName.includes("R") ? 90 : 0) + 5 | ||
| const y = (cornerPositionName.includes("T") ? 55 : 0) + 5 | ||
| const rotation = index * 90 | ||
| return ( | ||
| <chip | ||
| key={"pacman_" + cornerPositionName} | ||
| name={cornerPositionName} | ||
| pcbX={x} | ||
| pcbY={y} | ||
| noSchematicRepresentation={true} | ||
| pcbRotation={-rotation} //{(cell.index-1)*90} | ||
| footprint={ | ||
| <footprint> | ||
| <smtpad | ||
| pcbX="0mm" | ||
| pcbY="0mm" | ||
| layer="top" | ||
| shape="polygon" | ||
| portHints={["pin1"]} | ||
| points={pacmanPolygonOutline} | ||
| /> | ||
| </footprint> | ||
| } | ||
| /> | ||
| ) | ||
| })} | ||
|  | ||
| <ViaGridPlus pcbX={30} pcbY={25} startIndex={0} /> | ||
| <ViaGridPlus pcbX={70} pcbY={25} startIndex={5} /> | ||
| <ViaGridPlus pcbX={30} pcbY={40} startIndex={10} /> | ||
| <ViaGridPlus pcbX={70} pcbY={40} startIndex={15} /> | ||
|  | ||
| {horizontalEdgeViaGridCells.map((cell) => ( | ||
| <ViaGridVia | ||
| pcbX={cell.center.x} | ||
| pcbY={cell.center.y} | ||
| key={cell.index} | ||
| viaIndex={cell.index + 20} | ||
| /> | ||
| ))} | ||
|  | ||
| {verticalEdgeViaGridCells.map((cell) => ( | ||
| <ViaGridVia | ||
| pcbX={cell.center.x} | ||
| pcbY={cell.center.y} | ||
| key={cell.index} | ||
| viaIndex={cell.index + 54} | ||
| /> | ||
| ))} | ||
|  | ||
| <chip | ||
| name="TOP_RECT" | ||
| noSchematicRepresentation={true} | ||
| footprint={ | ||
| <footprint> | ||
| <smtpad | ||
| pcbX="50mm" | ||
| pcbY="62.5mm" | ||
| layer="top" | ||
| shape="rect" | ||
| width="40mm" | ||
| height="3mm" | ||
| portHints={["pin1"]} | ||
| cornerRadius={0.5} | ||
| /> | ||
| </footprint> | ||
| } | ||
| /> | ||
|  | ||
| <silkscreentext | ||
| text="VIAGRID TOP" | ||
| fontSize="1.5mm" | ||
| pcbX={50} | ||
| pcbY={2.5} | ||
| /> | ||
| <net name="GND" /> | ||
| {/* <copperpour | ||
| connectsTo="net.GND" | ||
| layer="top" | ||
| // outline=[ | ||
| // { x: 5, y: 5 }, | ||
| // { x: 5, y: 60 }, | ||
| // { x: 95, y: 60 }, | ||
| // { x: 95, y: 5 } | ||
| // ] | ||
| There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. CC @ShiboSoftwareDev we should get this working! | ||
| /> */} | ||
| </board> | ||
| ) | ||
| } | ||
|  | ||
| const horizontalEdgeViaGridCells = grid({ | ||
| rows: 2, | ||
| cols: 17, | ||
| // width: 80, | ||
| // height: 45, | ||
| xSpacing: 5, // if you want to provide the spacing instead of width | ||
| ySpacing: 45, // if you want to provide the spacing instead of height | ||
| offsetX: 90 / 2 + 5, // optional | ||
| offsetY: 55 / 2 + 5, // optional | ||
| yDirection: "up-is-negative", // optional, default: "cartesian" | ||
| // centered: true // optional, default: true | ||
| }) | ||
|  | ||
| const verticalEdgeViaGridCells = grid({ | ||
| rows: 8, | ||
| cols: 2, | ||
| // width: 80, | ||
| // height: 45, | ||
| xSpacing: 80, // if you want to provide the spacing instead of width | ||
| ySpacing: 5, // if you want to provide the spacing instead of height | ||
| offsetX: 90 / 2 + 5, // optional | ||
| offsetY: 55 / 2 + 5, // optional | ||
| yDirection: "up-is-negative", // optional, default: "cartesian" | ||
| // centered: true // optional, default: true | ||
| }) | ||
      
      Loading
      
  Sorry, something went wrong. Reload?
      Sorry, we cannot display this file.
      Sorry, this file is invalid so it cannot be displayed.
      
    
        
          
  
    
      
          
            1 change: 1 addition & 0 deletions
          
          1 
        
  lib/ViaGridBoard/__snapshots__/ViaGridBoard.circuit-pcb.snap.svg
  
  
      
      
   
        
      
      
    
      
      Loading
      
  Sorry, something went wrong. Reload?
      Sorry, we cannot display this file.
      Sorry, this file is invalid so it cannot be displayed.
      
    
        
          
  
    
      
          
            25 changes: 25 additions & 0 deletions
          
          25 
        
  lib/ViaGridBoard/__snapshots__/ViaGridBoard.circuit-schematic.snap.svg
  
  
      
      
   
        
      
      
    
      
      Loading
      
  Sorry, something went wrong. Reload?
      Sorry, we cannot display this file.
      Sorry, this file is invalid so it cannot be displayed.
      
    
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              | Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -0,0 +1,41 @@ | ||
| import { CommonLayoutProps, GroupProps } from "@tscircuit/props" | ||
| import { OutlineBuilder } from "../../util/outlineBuilder" | ||
|  | ||
| export const ViaGridVia = (props: CommonLayoutProps & { viaIndex: number }) => { | ||
| const { viaIndex, ...restProps } = props | ||
| return ( | ||
| <via | ||
| name={`via_${viaIndex}`} | ||
| fromLayer="top" | ||
| toLayer="bottom" | ||
| outerDiameter="1.5mm" | ||
| holeDiameter="0.3mm" | ||
| // pcbX={0} | ||
| // pcbY={0} | ||
| {...restProps} | ||
| /> | ||
| ) | ||
| } | ||
|  | ||
| export const ViaGridPlus = (props: GroupProps & { startIndex: number }) => { | ||
| const { startIndex, ...restProps } = props | ||
| return ( | ||
| <group {...restProps}> | ||
| <ViaGridVia pcbX={0} pcbY={0} viaIndex={startIndex} /> | ||
| <ViaGridVia pcbX={2.5} pcbY={0} viaIndex={startIndex + 1} /> | ||
| <ViaGridVia pcbX={0} pcbY={2.5} viaIndex={startIndex + 2} /> | ||
| <ViaGridVia pcbX={-2.5} pcbY={0} viaIndex={startIndex + 3} /> | ||
| <ViaGridVia pcbX={0} pcbY={-2.5} viaIndex={startIndex + 4} /> | ||
| </group> | ||
| ) | ||
| } | ||
|  | ||
| export default ViaGridPlus | ||
|  | ||
| export const pacmanPolygonOutline = new OutlineBuilder(-0.2, -0.2) | ||
| .lineTo(-0.2, 2.5) | ||
| .arcTo(-2.5, 0, { radius: 2.5, sweep: true }) | ||
| .arcTo(0, -2.5, { radius: 2.5, sweep: true }) | ||
| .arcTo(2.5, -0.2, { radius: 2.5, sweep: true }) | ||
| .lineTo(-0.2, -0.2) | ||
| .toArray() | 
      
      Oops, something went wrong.
        
    
  
  Add this suggestion to a batch that can be applied as a single commit.
  This suggestion is invalid because no changes were made to the code.
  Suggestions cannot be applied while the pull request is closed.
  Suggestions cannot be applied while viewing a subset of changes.
  Only one suggestion per line can be applied in a batch.
  Add this suggestion to a batch that can be applied as a single commit.
  Applying suggestions on deleted lines is not supported.
  You must change the existing code in this line in order to create a valid suggestion.
  Outdated suggestions cannot be applied.
  This suggestion has been applied or marked resolved.
  Suggestions cannot be applied from pending reviews.
  Suggestions cannot be applied on multi-line comments.
  Suggestions cannot be applied while the pull request is queued to merge.
  Suggestion cannot be applied right now. Please check back later.
  
    
  
    
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is this type casting necessary? (CC @Abse2001 if so we should patch this)
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@seveibar lines 14 through 27 are a direct copy from the Arduino Shield in this repo. You said "there's an existing pattern in that tscircuit/common repo" which I interpreted as this so I copied it over directly. I don't use anything like this in the similar "userland" stuff I have been doing, but I defer to you to determine what is ultimately necessary or not for everything to work properly. However, it is important to deal with passing BoardProps and children into the that ViaGridBoard encompasses. So some variation of all this seems necessary.