Skip to content
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

Getting recent updates, specifically video demo #47

Merged
merged 34 commits into from
Sep 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
405d073
hook test
christopolise Aug 18, 2022
51db9c1
restart sss rtfd
christopolise Aug 18, 2022
d0e58ce
Update to incorporate sss rtfd
christopolise Aug 18, 2022
48c030a
Merge branch 'dev' of github.com:NET-BYU/sss into docs
christopolise Jun 9, 2023
03ba567
Added new link and removed site folder tracking
christopolise Jun 9, 2023
7605bee
Clarify virtual environment indicator
christopolise Aug 24, 2023
9c7a565
Fix internal link #33
christopolise Aug 24, 2023
da6c94b
Emphasis on install guides #37
christopolise Aug 24, 2023
1ae6fb0
Fix comments to be compatible with mkdocstring #34
christopolise Aug 24, 2023
1f7967d
Fix git URL issue #31
christopolise Aug 25, 2023
ff372de
Add some new comments
christopolise Aug 25, 2023
8a714b2
More detailed and formatted docs for broadcasters and controllers
christopolise Aug 28, 2023
8f9d94e
Reformat with black
christopolise Aug 28, 2023
d45a2a2
Merge branch 'remove-asdf' of github.com:NET-BYU/sss into csv_npy
christopolise Aug 30, 2023
d282703
Uses NPY (actually NPZ) instead of CSV to address #8
christopolise Aug 30, 2023
9c8375c
Fix format issue
christopolise Aug 30, 2023
e1a7e15
Added shrek and better formatting
christopolise Aug 30, 2023
526137e
Debug
christopolise Aug 30, 2023
98e97ba
Debug again
christopolise Aug 30, 2023
2744c8a
Found the bugger
christopolise Aug 30, 2023
09ea1b1
Remove unnecessary print
christopolise Aug 30, 2023
4c4223f
Hot mess
byu-netlab Aug 31, 2023
ceb6dd7
Debug drawing speed
byu-netlab Aug 31, 2023
36b98b4
Runs faster now
byu-netlab Aug 31, 2023
c17cce8
Fix formatting
byu-netlab Aug 31, 2023
8cb0692
Fix formatting ++
byu-netlab Aug 31, 2023
99e6fcf
init
christopolise Aug 31, 2023
3f0f5eb
Merge pull request #44 from NET-BYU/csv_npy
christopolise Aug 31, 2023
19b50f0
Update issue templates
christopolise Aug 31, 2023
cbaba5d
Update README.md
christopolise Aug 31, 2023
ec7ef4d
Update README.md
christopolise Aug 31, 2023
ac49461
Update README.md
christopolise Aug 31, 2023
ebb3c0e
Update README.md
christopolise Aug 31, 2023
07dc639
Merge pull request #46 from NET-BYU/readme
apal6981 Aug 31, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
---
name: Bug report
about: Create a report to help us improve
title: ''
labels: bug
assignees: ''

---

**Describe the bug**
A clear and concise description of what the bug is.

**To Reproduce**
Steps to reproduce the behavior:
1. Go to '...'
2. Click on '....'
3. Scroll down to '....'
4. See error

**Expected behavior**
A clear and concise description of what you expected to happen.

**Screenshots**
If applicable, add screenshots to help explain your problem.

**Desktop (please complete the following information):**
- OS: [e.g. Ubuntu]
- Browser [e.g. chrome, firefox]
- Version [e.g. 22]

**Additional context**
Add any other context about the problem here.
17 changes: 17 additions & 0 deletions .github/ISSUE_TEMPLATE/documentation-issue.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
---
name: Documentation issue
about: Describe this issue template's purpose here.
title: ''
labels: documentation
assignees: ''

---

## Location
[Link](provide link to the affected page here)

## Issue
Provide a concise description of where you think the documentation is incomplete, ambiguous, erroneous, etc

## Suggested Fix
How do you think the documentation should look instead? What could be done to improve upon the issue?
20 changes: 20 additions & 0 deletions .github/ISSUE_TEMPLATE/feature_request.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
---
name: Feature request
about: Suggest an idea for this project
title: ''
labels: enhancement
assignees: ''

---

**Is your feature request related to a problem? Please describe.**
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]

**Describe the solution you'd like**
A clear and concise description of what you want to happen.

**Describe alternatives you've considered**
A clear and concise description of any alternative solutions or features you've considered.

**Additional context**
Add any other context or screenshots about the feature request here.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,4 @@ __pycache__
*.yaml
*high_score*
chocolate-doom
site
48 changes: 48 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# Seven Segment Sign

![Black formatter](https://github.com/NET-BYU/sss/actions/workflows/black.yml/badge.svg) ![Black Formatter 2](https://github.com/NET-BYU/sss/actions/workflows/formatting.yml/badge.svg) ![Docs](https://github.com/NET-BYU/sss/actions/workflows/pages/pages-build-deployment/badge.svg) ![Test](https://github.com/NET-BYU/sss/actions/workflows/test.yaml/badge.svg) ![Raspberry Pi](https://github.com/NET-BYU/sss/actions/workflows/raspberry_pi.yml/badge.svg)

## Welcome to the Seven Segment Sign! (SSS)
![ricky](docs/assets/doom_video.GIF)

## Getting Started
Here are some helpful links to get you up and running!
- [API Docs](https://sss.readthedocs.io/en/latest/API/Display/)
- [Install on Linux/Mac](https://sss.readthedocs.io/en/latest/Installation/Install%20SSS%20on%20Mac%20or%20Linux/)
- [Install on Windows](https://sss.readthedocs.io/en/latest/Installation/Install%20SSS%20on%20Windows/)
- [Create your first demo](https://sss.readthedocs.io/en/latest/Tutorials/Creating%20a%20demo/)

## Common Commands
Although thorough information on how to [get started](https://sss.readthedocs.io/en/latest/Overview/Get%20started/) is in the docs, here are some quick commands you can run in order to get rolling **once you have everything installed**:

- Run the PyGame Simulator for the SSS
```bash
python3 main.py simulator
```
- Run a specific demo in the simulator
```bash
python3 main.py demo <demo_name> -s
```
- Start the SSS in kiosk mode
```bash
python3 main.py kiosk
```
- To view log output of varying degrees, use the `-v` option (the more `v`'s the more `v`erbose the output becomes

For any other help or a list of comprehensive commands, run
```bash
python3 main.py --help
```

## Reporting an Issue
We love feedback! As the SSS codespace expands and acquires new features, we realize that some bugs will fall through the cracks. Please feel free to open a new issue if you notice any bugs in the code, mistakes or missing information in the documentation, or if you want a new feature to be added to the project.

You can go to the **Issues** tab to create a new issue. Please be mindful to choose the correct template for the right type of question. Apart from the currently open issues from before this writing, any **issue that does not conform to the template may become stale or be closed without warning.**

## Submitting a PR
If you are feeling creative and you would like to contribute a demo but you are outside of our organization, you are more than welcome to submit a pull request and we will look it over!

In order for a pull request to be merged, we have the following three policies:
1. Your code must have adequate, meaningful comments. Don't feel like you have to explain every statement, but also don't write comments like `# This a loop that goes over all the values`.
2. Your PR will need approval from **at least 2 org members**. Users who respond to these the most are @apal6981, @christopolise, and @philipbl
3. Your code **MUST** be formatted with `black`. This is as simple as adding the [Black Formatter](https://marketplace.visualstudio.com/items?itemName=ms-python.black-formatter) to VS/OSS Code or running `python3 -m black <your py files>`
8 changes: 7 additions & 1 deletion broadcasters/mqtt.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,13 @@


def start_processing_output(system_queue, mqtt_q):
"""Called by the broadcaster module to initialize a connection to the desired MQTT broker."""
"""
Called by the broadcaster module to initialize a connection to the desired MQTT broker.

Args:
system_queue (Queue): The queue to put system output events in.
mqtt_q (Queue): The queue to put MQTT messages in.
"""

def on_connect(client, userdata, flags, rc):
"""Callback function executed upon the successful connection to the desired broker"""
Expand Down
7 changes: 6 additions & 1 deletion broadcasters/utils.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
def get_all_from_queue(queue):
"""Helper function that gets all items from a given queue."""
"""
Helper function that gets all items from a given queue.

Args:
queue (Queue): The queue to get all items from.
"""
while not queue.empty():
yield queue.get()
13 changes: 13 additions & 0 deletions controllers/gamepad.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@


def get_input_from_gamepad(queue):
"""
Reads input from the gamepad and puts it in the queue.

Args:
queue (Queue): The queue to put the input events in.
"""
while True:
# See if the gamepad is plugged in
try:
Expand All @@ -25,6 +31,13 @@ def get_input_from_gamepad(queue):


def start_processing_input(system_queue, demo_input_queue):
"""
Listens to input on the device and puts it into the appropriate queue.

Args:
system_queue (Queue): The queue to put system input events in.
demo_input_queue (Queue): The queue to put demo input events in.
"""
queue = Queue()

thread = threading.Thread(target=get_input_from_gamepad, args=(queue,), daemon=True)
Expand Down
7 changes: 7 additions & 0 deletions controllers/keyboard.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,13 @@ def check_if_sim():


def start_processing_input(system_queue, demo_input_queue):
"""
Listens to input on the device and puts it into the appropriate queue.

Args:
system_queue (Queue): The queue to put system input events in.
demo_input_queue (Queue): The queue to put demo input events in.
"""
while True:
events = pygame.event.get()

Expand Down
8 changes: 8 additions & 0 deletions controllers/mqtt.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,14 @@


def start_processing_input(system_queue, demo_input_queue):
"""
Listens to input on the device and puts it into the appropriate queue.

Args:
system_queue (Queue): The queue to put system input events in.
demo_input_queue (Queue): The queue to put demo input events in.
"""

def on_message(client, userdata, message):
logger.debug("on_message triggered")
try:
Expand Down
2 changes: 1 addition & 1 deletion demos/breakout/high_score.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
375
400
88 changes: 53 additions & 35 deletions demos/video/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,16 @@ def __init__(self, input_queue, output_queue, screen):
self.screen = screen

# init demo/game specific variables here
self.path = "./demos/video/resorces/pre-processed/"
self.path = "./demos/video/resources/pre-processed/"
self.targets = os.listdir(self.path)
self.address = random.randint(0, len(self.targets) - 1)
self.target = self.targets[self.address]
self.pause = False
self.new_video = False
self.next_frame = False
self.previous_frame = np.full((2353), 0)
self.previous_frame = np.zeros((self.screen.x_width, self.screen.y_height))

# Get the next video in the list
def get_next_video(self):
if self.address < (len(self.targets) - 1):
self.address += 1
Expand All @@ -43,6 +44,7 @@ def get_next_video(self):
self.address = 0
self.target = self.targets[self.address]

# Parse the user input
def input_parsing(self, input_queue):
for input in input_queue: # allows the user to pause the video
if input == "LEFT_P":
Expand All @@ -55,6 +57,23 @@ def input_parsing(self, input_queue):
if input == "DOWN_P":
self.new_video = True

# Draws frame to screen
def draw_frame(self, frame):
# Get frame of which pixels need to get updated
diff_frame = np.not_equal(frame, self.previous_frame)

for r in range(self.screen.x_width):
for c in range(self.screen.y_height):
# If pixel is different from last frame, update
if diff_frame[r, c]:
self.screen.draw_pixel(c, r, int(frame[r, c]))

# Update previous frame
self.previous_frame = frame.copy()

# Push the frame to the screen
self.screen.push()

def run(self):
# Create generator here
while True:
Expand All @@ -64,39 +83,38 @@ def run(self):
self.screen.push()
yield

with open(self.path + self.target, "r") as input_file:
y = 0
for index, input_line in enumerate(input_file):
self.next_frame = False
if not self.input_queue.empty():
while True:
action = self.input_parsing(
get_all_from_queue(self.input_queue)
)

# FIXME: Remove this for input refactor
self.input_queue.queue.clear()

if (not self.pause) or self.next_frame or self.new_video:
break
yield
if self.new_video:
break

input_data = input_line.strip("\n").split(",")
y = 0
for x_index, pixel in enumerate(input_data):
if pixel == "":
y += 1
continue
x = x_index % (self.screen.x_width + 1)

if not self.previous_frame[int(x_index)] == int(pixel):
self.screen.draw_pixel(x, y, int(pixel))
self.previous_frame[x_index] = pixel
self.screen.push()
yield
self.get_next_video()
# Load the video
loaded_video = np.load(self.path + self.target)
loaded_video = loaded_video["arr_0"]

# Iterate through the frames
for frame in loaded_video:
self.next_frame = False

# Parse through the user input
if not self.input_queue.empty():
while True:
action = self.input_parsing(
get_all_from_queue(self.input_queue)
)

self.input_queue.queue.clear()

# If the user wants to go to the next video, break out of the loop
if (not self.pause) or self.next_frame or self.new_video:
break
yield

# Skip to the next video
if self.new_video:
break

# Draw frame to screen
self.draw_frame(frame)
yield

# Go to next video
self.get_next_video()

def stop(self):
# Reset the state of the demo if needed, else leave blank
Expand Down
Loading
Loading