-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
102 changed files
with
32,572 additions
and
16,988 deletions.
There are no files selected for viewing
This file contains 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,57 @@ | ||
# This is a basic workflow to help you get started with Actions | ||
|
||
name: Doxygen Action | ||
|
||
# Controls when the action will run. Triggers the workflow on push or pull request | ||
# events but only for the master branch | ||
on: | ||
push: | ||
branches: [ 3.0.0_prerelease ] | ||
|
||
|
||
|
||
# A workflow run is made up of one or more jobs that can run sequentially or in parallel | ||
jobs: | ||
# This workflow contains a single job called "build" | ||
build: | ||
# The type of runner that the job will run on | ||
runs-on: ubuntu-latest | ||
|
||
# Steps represent a sequence of tasks that will be executed as part of the job | ||
steps: | ||
|
||
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it | ||
- uses: actions/checkout@v2 | ||
|
||
- name: Doxygen Action_dev | ||
uses: mattnotmitt/[email protected] | ||
with: | ||
# Path to Doxyfile | ||
doxyfile-path: "./docs/deviceDoxyfile" # default is ./Doxyfile | ||
# Working directory | ||
working-directory: "." # default is . | ||
|
||
|
||
- name: Build_web | ||
uses: andstor/jsdoc-action@v1 | ||
with: | ||
source_dir: ./WebApp/src | ||
recurse: true | ||
output_dir: ./docs/web | ||
|
||
- name: Deploy | ||
uses: peaceiris/actions-gh-pages@v3 | ||
with: | ||
github_token: ${{ secrets.GITHUB_TOKEN }} | ||
# Default Doxyfile build documentation to html directory. | ||
# Change the directory if changes in Doxyfile | ||
publish_dir: ./docs | ||
|
||
- name: Deploy | ||
uses: peaceiris/actions-gh-pages@v3 | ||
with: | ||
github_token: ${{ secrets.GITHUB_TOKEN }} | ||
# Default Doxyfile build documentation to html directory. | ||
# Change the directory if changes in Doxyfile | ||
publish_dir: ./landing-page | ||
keep_files: true |
This file contains 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 |
---|---|---|
|
@@ -13,3 +13,7 @@ __pycache__/ | |
|
||
node_modules/ | ||
build/ | ||
act.exe | ||
docs/manual/mdpdf.log | ||
docs/manual/wkhtmltopdf.exe | ||
main/.DS_Store |
This file contains 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,6 @@ | ||
{ | ||
"files.associations": { | ||
"cmath": "cpp", | ||
"variant": "cpp" | ||
} | ||
} |
File renamed without changes.
File renamed without changes.
File renamed without changes.
Binary file not shown.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains 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
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file was deleted.
Oops, something went wrong.
This file contains 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,155 @@ | ||
import sim_constants as sc | ||
import numpy as np | ||
import PySimpleGUI as sg | ||
import sim_helpers as sim | ||
|
||
# Convert the logo's relative path to this file to an | ||
# absolute system path. | ||
logo_path = sim.get_absolute_path(sc.LOGO_RELATIVE_PATH) | ||
|
||
# Convert the Windows' icon relative path to a system path. | ||
icon_path = sim.get_absolute_path(sc.ICON_RELATIVE_PATH) | ||
|
||
old_serial_options = [sc.NO_SERIAL_PORT] + sim.ports_to_list() | ||
if "COM1" in old_serial_options: | ||
old_serial_options.remove("COM1") | ||
|
||
# Configure the GUI | ||
sg.theme(sc.APP_THEME) | ||
layout = [ | ||
[ | ||
sg.Image(logo_path, subsample=sc.LOGO_SCALE), | ||
sg.OptionMenu( | ||
values=old_serial_options, | ||
key=sc.COM_SELECTOR_KEY, | ||
default_value=sc.NO_SERIAL_PORT, | ||
), | ||
sg.Button(sc.RESCAN_BUTTON, key=sc.RESCAN_BUTTON), | ||
], | ||
sim.make_display_bar(sc.HSV_KEY), | ||
sim.make_display_bar(sc.RGB_KEY), | ||
sim.make_display_bar(sc.BGR_KEY), | ||
[ | ||
sg.Button(sc.CONNECT_BUTTON, key=sc.CONNECT_BUTTON), | ||
sg.Button(sc.DISCONNECT_BUTTON, key=sc.DISCONNECT_BUTTON), | ||
sg.Text(sc.state_to_string[sc.DEFAULT_STATE], key=sc.STATUS_FIELD) | ||
], | ||
] | ||
|
||
# Create the Window | ||
window = sg.Window( | ||
sc.APP_NAME, | ||
layout, | ||
icon=sim.path_to_png(icon_path), | ||
) | ||
|
||
# Ensure the openCV arrays are global variables | ||
bgr = np.zeros((sc.DEFAULT_LED_HEIGHT, sc.LED_BAR_TARGET_LENGTH, 3), np.uint8) | ||
hsv, rgb = bgr, bgr | ||
|
||
# Update the application window with new images. | ||
def update_bars(bgr, hsv, rgb): | ||
window[sc.RGB_KEY].update(data=sim.mat_to_png(rgb)) | ||
window[sc.BGR_KEY].update(data=sim.mat_to_png(bgr)) | ||
window[sc.HSV_KEY].update(data=sim.mat_to_png(hsv)) | ||
|
||
def update_selector_options(): | ||
options = [sc.NO_SERIAL_PORT] + sim.ports_to_list() | ||
if "COM1" in options: | ||
options.remove("COM1") | ||
window[sc.COM_SELECTOR_KEY].update(values=options, value=sc.NO_SERIAL_PORT) | ||
|
||
def disconnect_teardown(SER): | ||
SER.close() | ||
SER = None | ||
return sc.DISCONNECTED_STATE | ||
|
||
if __name__ == '__main__': | ||
|
||
# Application state setup | ||
app_state = sc.DEFAULT_STATE | ||
SER = None | ||
connection_attempted = False | ||
|
||
# Ensure that the bars are drawn at least once | ||
event, values = window.read(0) | ||
blank = np.zeros((sc.DEFAULT_LED_HEIGHT, sc.DEFAULT_LED_WIDTH, 3), np.uint8) # (B, G, R) | ||
blank = sim.resize_image(blank, 10, 30) | ||
update_bars(blank, blank, blank) | ||
|
||
# Main application loop | ||
while app_state != sc.EXITING_STATE: | ||
|
||
# Check for events from the UI. | ||
event, values = window.read(0) | ||
if event == sg.WIN_CLOSED: # if user closes window or clicks cancel | ||
app_state = sc.EXITING_STATE | ||
|
||
if event == sc.RESCAN_BUTTON: | ||
update_selector_options() | ||
|
||
# Reset the bgr image | ||
bgr = np.zeros((sc.DEFAULT_LED_HEIGHT, sc.LED_BAR_TARGET_LENGTH, 3), np.uint8) # (B, G, R) | ||
|
||
match app_state: | ||
case sc.CONNECTING_STATE: | ||
# Set the disable state of both buttons | ||
window[sc.CONNECT_BUTTON].update(disabled=True) | ||
window[sc.DISCONNECT_BUTTON].update(disabled=False) | ||
|
||
# If the connection button is pressed again, disconnect. | ||
if event == sc.DISCONNECT_BUTTON: | ||
app_state = sc.DISCONNECTED_STATE | ||
|
||
# Attempt to connect to serial. If serial_setup returns a value | ||
# that is not None, move to the connected state and give a | ||
# notification print. | ||
SER = sim.serial_setup(sc.NO_DEBUG, values[sc.COM_SELECTOR_KEY]) | ||
if SER != None: | ||
app_state = sc.CONNECTED_STATE | ||
print("Connected to NanoLux device.") | ||
connection_attempted = False | ||
|
||
case sc.CONNECTED_STATE: | ||
# Set the disable state of both buttons | ||
window[sc.CONNECT_BUTTON].update(disabled=True) | ||
window[sc.DISCONNECT_BUTTON].update(disabled=False) | ||
|
||
# Try to grab serial data and transform the blank image using the BGR | ||
# data from the AudioLux. | ||
# If this fails for whatever reason, move to the disconnected state and | ||
# disconnect from the AudioLux. | ||
try: | ||
# Read in data from serial and process it into a bgr image. | ||
serial_data = SER.readline().decode("utf-8").split() | ||
bgr = sim.update_image(bgr, serial_data) | ||
hsv, rgb = sim.bgr_to_hsv_rgb(bgr) | ||
update_bars(bgr, hsv, rgb) | ||
except: | ||
app_state = disconnect_teardown(SER) | ||
update_selector_options() | ||
|
||
# If the connection button is pressed again, disconnect. | ||
if event == sc.DISCONNECT_BUTTON: | ||
app_state = disconnect_teardown(SER) | ||
|
||
case sc.DISCONNECTED_STATE: | ||
|
||
# Set the disable state of both buttons | ||
window[sc.CONNECT_BUTTON].update(disabled=False) | ||
window[sc.DISCONNECT_BUTTON].update(disabled=True) | ||
|
||
# If we are in the disconnected state, wait until the connect button | ||
# is pressed before moving to the connecting state. | ||
if event == sc.CONNECT_BUTTON: | ||
app_state = sc.CONNECTING_STATE | ||
|
||
case _: | ||
# If we are in this state, there is an issue with state control. | ||
# If this print occurs, there is a code issue that must be resolved. | ||
app_state = sc.EXITING_STATE | ||
|
||
# Update the graphs on the UI that display the virtual LED strips | ||
# if not in the process of exiting. | ||
if app_state != sc.EXITING_STATE: | ||
window[sc.STATUS_FIELD].update(sc.state_to_string[app_state]) |
This file contains 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,39 @@ | ||
# State constants | ||
CONNECTING_STATE = 0 | ||
CONNECTED_STATE = 1 | ||
DISCONNECTED_STATE = 2 | ||
EXITING_STATE = 3 | ||
state_to_string = [ | ||
'Connecting', | ||
'Connected', | ||
'Disconnected', | ||
'Exiting' | ||
] | ||
DEFAULT_STATE = DISCONNECTED_STATE | ||
|
||
# UI Elements | ||
CONNECT_BUTTON = "Connect" | ||
DISCONNECT_BUTTON = "Disconnect" | ||
STATUS_FIELD = "-STATUS-" | ||
HSV_KEY = "HSV" | ||
BGR_KEY = "BGR" | ||
RGB_KEY = "RGB" | ||
LOGO_SCALE = 10 | ||
LOGO_RELATIVE_PATH = '\\assets\logo2.png' | ||
ICON_RELATIVE_PATH = '\\assets\icon.ico' | ||
APP_NAME = "Nanolux LED Strip Simulator" | ||
APP_THEME = 'SystemDefault' | ||
COM_SELECTOR_KEY = 'COMSelector' | ||
RESCAN_BUTTON = 'Rescan' | ||
|
||
# Numpy Constants | ||
DEFAULT_LED_HEIGHT = 1 | ||
DEFAULT_LED_WIDTH = 60 | ||
LED_BAR_TARGET_LENGTH = 600 | ||
|
||
# Debug | ||
NO_DEBUG = False | ||
DEBUG = True | ||
|
||
# Connection constants | ||
NO_SERIAL_PORT = 'No Serial' |
Oops, something went wrong.