Skip to content

Commit

Permalink
Merge b42f036 into 38955aa
Browse files Browse the repository at this point in the history
  • Loading branch information
eeintech committed Feb 21, 2023
2 parents 38955aa + b42f036 commit ed0e9b0
Show file tree
Hide file tree
Showing 26 changed files with 4,138 additions and 1,930 deletions.
5 changes: 1 addition & 4 deletions .coveragerc
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,11 @@ omit =
# Do not run coverage on virtual environment files
env-kintree/*
.venv/*
# Skip KiCad library tool
kintree/kicad/lib_utils/*
# Skip UI coverage
kintree/kintree_gui.py
kintree/common/progress.py
kintree/gui/*
# Skip wrapt_timeout_decorator
kintree/wrapt_timeout_decorator/*
# Skip LCSC supplier search
kintree/search/lcsc_api.py
# Skip test script
run_tests.py
6 changes: 3 additions & 3 deletions kintree/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@

# VERSION INFORMATION
version_info = {
'MAJOR_REVISION': 0,
'MINOR_REVISION': 6,
'RELEASE_STATUS': 99, # Dev = 99
'MAJOR_REVISION': 1,
'MINOR_REVISION': 0,
'RELEASE_STATUS': '0a1',
}

__version__ = '.'.join([str(v) for v in version_info.values()])
94 changes: 28 additions & 66 deletions kintree/common/progress.py
Original file line number Diff line number Diff line change
@@ -1,93 +1,55 @@
import time

# PySimpleGUI
import PySimpleGUI as sg
CREATE_PART_PROGRESS: float
MAX_PROGRESS = 1.0
DEFAULT_PROGRESS = 0.1

CREATE_PART_PROGRESS: int
MAX_PROGRESS = 100
DEFAULT_PROGRESS = 5


def create_progress_bar_window(font=None, location=None) -> bool:
''' Create window for part creation progress '''
global CREATE_PART_PROGRESS, MAX_PROGRESS
global progress_window

progress_layout = [
[sg.Text('Creating part...')],
[sg.ProgressBar(MAX_PROGRESS, orientation='h', size=(20, 30), key='progressbar')],
[sg.Cancel()]
]
progress_window = sg.Window('Part Creation Progress', progress_layout, font=font, location=location)
# progress_bar = progress_window['progressbar']

event, values = progress_window.read(timeout=10)
def reset_progress_bar(progress_bar) -> bool:
''' Reset progress bar '''
global CREATE_PART_PROGRESS

# Reset progress
CREATE_PART_PROGRESS = 0
update_progress_bar_window()

if progress_window:
return True

return False

progress_bar.color = None
progress_bar.value = 0
progress_bar.update()
time.sleep(0.1)

def close_progress_bar_window():
''' Close progress bar window after part creation '''
global progress_window
return True

try:
if progress_window:
progress_window.close()
except NameError:
return


def progress_increment():
def progress_increment(inc):
''' Increment progress '''
global CREATE_PART_PROGRESS, MAX_PROGRESS

if CREATE_PART_PROGRESS + 1 < MAX_PROGRESS:
CREATE_PART_PROGRESS += 1
if CREATE_PART_PROGRESS + inc < MAX_PROGRESS:
CREATE_PART_PROGRESS += inc
else:
CREATE_PART_PROGRESS = MAX_PROGRESS

return CREATE_PART_PROGRESS

def update_progress_bar_window(increment=0) -> bool:
''' Update progress bar during part creation '''
global CREATE_PART_PROGRESS, MAX_PROGRESS, DEFAULT_PROGRESS
global progress_window

on_going_progress = True
def update_progress_bar(progress_bar, increment=0) -> bool:
''' Update progress bar during part creation '''
global DEFAULT_PROGRESS

try:
if not progress_window:
return False
except NameError:
return False
if not progress_bar:
return True

if increment:
inc = increment
else:
# Default
inc = DEFAULT_PROGRESS

progress_bar = progress_window['progressbar']

event, values = progress_window.read(timeout=10)

if event in ['Cancel', sg.WIN_CLOSED]:
on_going_progress = False
close_progress_bar_window()
else:
# Smooth effect
for i in range(inc):
progress_increment()
progress_bar.update(CREATE_PART_PROGRESS, MAX_PROGRESS)
if inc < MAX_PROGRESS:
time.sleep(0.02)
else:
time.sleep(0.005)
current_value = progress_bar.value * 100
new_value = progress_increment(inc) * 100
# Smooth progress
for i in range(int(new_value - current_value)):
progress_bar.value += i / 100
progress_bar.update()
time.sleep(0.05)

return on_going_progress
return True
3 changes: 1 addition & 2 deletions kintree/common/tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,9 @@ def cprint(*args, **kwargs):

def create_library(library_path: str, symbol: str, template_lib: str):
''' Create library files if they don\'t exist '''

if not os.path.exists(library_path):
os.mkdir(library_path)
new_kicad_sym_file = os.path.join(library_path, symbol + '.kicad_sym')
new_kicad_sym_file = os.path.join(library_path, f'{symbol}.kicad_sym')
if not os.path.exists(new_kicad_sym_file):
copyfile(template_lib, new_kicad_sym_file)

Expand Down
2 changes: 1 addition & 1 deletion kintree/config/digikey/digikey_categories.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ Integrated Circuits:
- Logic - Translators, Level Shifters
- Clock/Timing - Clock Generators, PLLs, Frequency Synthesizers
- Logic - Buffers, Drivers, Receivers, Transceivers
MCU:
Microcontroller:
- Embedded - Microcontrollers
Memory:
- Memory
Expand Down
24 changes: 19 additions & 5 deletions kintree/config/inventree/categories.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,25 @@ CATEGORIES:
- Printed-Circuit Board Assembly
- Product
Capacitors:
- Ceramic
- Aluminium
- Tantalum
- Polymer
- Super Capacitors
Ceramic:
'0603':
10V:
- X5R
- X7R
16V:
- X5R
- X7R
'0402':
10V:
- X5R
- X7R
16V:
- X5R
- X7R
Aluminium:
Tantalum:
Polymer:
Super Capacitors:
Circuit Protections:
- TVS
- Fuses
Expand Down
Loading

0 comments on commit ed0e9b0

Please sign in to comment.