#!/bin/bash

# SPDX-FileCopyrightText: 2023 - 2024 Thomas Buck <thomas@xythobuz.de>
# SPDX-License-Identifier: CERN-OHL-S-2.0+
#
#  ------------------------------------------------------------------------------
# | Copyright (c) 2023 - 2024 Thomas Buck <thomas@xythobuz.de>                   |
# |                                                                              |
# | This source describes Open Hardware and is licensed under the CERN-OHL-S v2  |
# | or any later version.                                                        |
# |                                                                              |
# | You may redistribute and modify this source and make products using it under |
# | the terms of the CERN-OHL-S v2 (https://ohwr.org/cern_ohl_s_v2.txt)          |
# | or any later version.                                                        |
# |                                                                              |
# | This source is distributed WITHOUT ANY EXPRESS OR IMPLIED WARRANTY,          |
# | INCLUDING OF MERCHANTABILITY, SATISFACTORY QUALITY AND FITNESS FOR A         |
# | PARTICULAR PURPOSE. Please see the CERN-OHL-S v2 (or any later version)      |
# | for applicable conditions.                                                   |
# |                                                                              |
# | Source location: https://github.com/drinkrobotics/dispensy                   |
# |                                                                              |
# | As per CERN-OHL-S v2 section 4, should You produce hardware based on this    |
# | source, You must where practicable maintain the Source Location visible      |
# | on the external case of the Gizmo or other products you make using this      |
# | source.                                                                      |
#  ------------------------------------------------------------------------------

# Depends on:
# https://github.com/TousstNicolas/JLC2KiCad_lib
# (or https://github.com/Xyntexx/JLC2KiCad_lib/tree/footprint_alignment_workarounds)

# enter directory of script
cd "$(dirname "$0")"

# create output directory
mkdir -p jlc_lib

# fetch / update parts libs
JLC2KiCadLib \
    C713613  `# BC547B Transistor` \
    C713617  `# BC557B Transistor` \
    C179555  `# 1N4148S Diode` \
    C18080   `# RCA Video Connector female` \
    C410695  `# THT Resistor 10k 1%` \
    C172965  `# THT Resistor 100k 1%` \
    C410631  `# THT Resistor 3k3 1%` \
    C410657  `# THT Resistor 220 1%` \
    C119302  `# THT Resistor 82 1%` \
    C713997  `# THT Resistor 1k 1%` \
    C410615  `# THT Resistor 470 1%` \
    C433604  `# THT Resistor 22 1%` \
    C2896897 `# THT Resistor 75 5%` \
    C2761733 `# THT Capacitor 10u 25V Ceramic` \
    C263180  `# THT Capacitor 10n 50V Ceramic` \
    C409817  `# THT Capacitor 4n7 50V Ceramic` \
    C6718390 `# THT Capacitor 100u 50V Electrolytic` \
    C503219  `# THT Capacitor 10u 50V Electrolytic` \
    C1651069 `# THT Capacitor 1u 450V Electrolytic` \
    C557648  `# 1x2P 10A 300V 5mm Screw terminal` \
    -dir jlc_lib \
    -symbol_lib jlc_schematics \
    -symbol_lib_dir Schematic \
    -footprint_lib jlc_footprints \
    --skip_existing