Skip to content

Commit

Permalink
python: Rename module to just inputmodule
Browse files Browse the repository at this point in the history
Signed-off-by: Daniel Schaefer <dhs@frame.work>
  • Loading branch information
JohnAZoidberg committed Nov 27, 2023
1 parent 7deffa0 commit 61e45b1
Show file tree
Hide file tree
Showing 14 changed files with 54 additions and 41 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/software.yml
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ jobs:
uses: Martin005/pyinstaller-action@main
with:
python_ver: '3.11'
spec: python/framework16_inputmodule/cli.py #'src/build.spec'
spec: python/inputmodule/cli.py #'src/build.spec'
requirements: 'requirements.txt'
upload_exe_with_name: 'ledmatrixgui'
options: --onefile, --windowed, --add-data 'res;res'
Expand Down
2 changes: 1 addition & 1 deletion python/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ This repository contains a python library and scripts to control the
Pre-requisites: Python with pip

```sh
python3 -m pip install framework16_inputmodule
python3 -m pip install inputmodule
```

## Control from the host
Expand Down
File renamed without changes.
29 changes: 17 additions & 12 deletions python/framework16_inputmodule/cli.py → python/inputmodule/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
from serial.tools import list_ports

# Local dependencies
from framework16_inputmodule import gui
from framework16_inputmodule.inputmodule import (
from inputmodule import gui
from inputmodule.inputmodule import (
INPUTMODULE_PIDS,
send_command,
get_version,
Expand All @@ -18,15 +18,15 @@
GameOfLifeStartParam,
GameControlVal,
)
from framework16_inputmodule.gui.games import (
from inputmodule.gui.games import (
snake,
snake_embedded,
pong_embedded,
game_of_life_embedded,
wpm_demo,
)
from framework16_inputmodule.gui.ledmatrix import random_eq, clock, blinking
from framework16_inputmodule.inputmodule.ledmatrix import (
from inputmodule.gui.ledmatrix import random_eq, clock, blinking
from inputmodule.inputmodule.ledmatrix import (
eq,
breathing,
camera,
Expand All @@ -44,7 +44,7 @@
image_bl,
image_greyscale,
)
from framework16_inputmodule.inputmodule.b1display import (
from inputmodule.inputmodule.b1display import (
b1image_bl,
invert_screen_cmd,
screen_saver_cmd,
Expand All @@ -56,7 +56,7 @@
display_on_cmd,
display_string,
)
from framework16_inputmodule.inputmodule.c1minimal import (
from inputmodule.inputmodule.c1minimal import (
set_color,
get_color,
RGB_COLORS,
Expand Down Expand Up @@ -121,12 +121,14 @@ def main_cli():
help="Display a PNG or GIF image in greyscale",
type=argparse.FileType("rb"),
)
parser.add_argument("--camera", help="Stream from the webcam", action="store_true")
parser.add_argument(
"--camera", help="Stream from the webcam", action="store_true")
parser.add_argument("--video", help="Play a video", type=str)
parser.add_argument(
"--percentage", help="Fill a percentage of the screen", type=int
)
parser.add_argument("--clock", help="Display the current time", action="store_true")
parser.add_argument(
"--clock", help="Display the current time", action="store_true")
parser.add_argument(
"--string", help="Display a string or number, like FPS", type=str
)
Expand All @@ -146,7 +148,8 @@ def main_cli():
"--breathing", help="Breathing of the current pattern", action="store_true"
)
parser.add_argument("--eq", help="Equalizer", nargs="+", type=int)
parser.add_argument("--random-eq", help="Random Equalizer", action="store_true")
parser.add_argument(
"--random-eq", help="Random Equalizer", action="store_true")
parser.add_argument("--wpm", help="WPM Demo", action="store_true")
parser.add_argument("--snake", help="Snake", action="store_true")
parser.add_argument(
Expand Down Expand Up @@ -207,7 +210,8 @@ def main_cli():
parser.add_argument(
"--set-power-mode", help="Set screen power mode", choices=["high", "low"]
)
parser.add_argument("--get-fps", help="Set screen FPS", action="store_true")
parser.add_argument("--get-fps", help="Set screen FPS",
action="store_true")
parser.add_argument(
"--get-power-mode", help="Set screen power mode", action="store_true"
)
Expand Down Expand Up @@ -236,7 +240,8 @@ def main_cli():
gui.popup(args.gui, "No device found")
sys.exit(1)
elif args.serial_dev is not None:
filtered_devs = [port for port in ports if port.name in args.serial_dev]
filtered_devs = [
port for port in ports if port.name in args.serial_dev]
if not filtered_devs:
print("Failed to find requested device")
sys.exit(1)
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,18 @@

import PySimpleGUI as sg

from framework16_inputmodule.inputmodule import (
from inputmodule.inputmodule import (
send_command,
get_version,
brightness,
get_brightness,
bootloader,
CommandVals,
)
from framework16_inputmodule.gui.games import snake
from framework16_inputmodule.gui.ledmatrix import countdown, random_eq, clock
from framework16_inputmodule.gui.gui_threading import stop_thread, is_dev_disconnected
from framework16_inputmodule.inputmodule.ledmatrix import (
from inputmodule.gui.games import snake
from inputmodule.gui.ledmatrix import countdown, random_eq, clock
from inputmodule.gui.gui_threading import stop_thread, is_dev_disconnected
from inputmodule.inputmodule.ledmatrix import (
percentage,
pattern,
animate,
Expand Down Expand Up @@ -98,7 +98,8 @@ def run_gui(devices):
[sg.HorizontalSeparator()],
[sg.Text("Countdown Timer")],
[
sg.Spin([i for i in range(1, 60)], initial_value=10, k="-COUNTDOWN-"),
sg.Spin([i for i in range(1, 60)],
initial_value=10, k="-COUNTDOWN-"),
sg.Text("Seconds"),
sg.Button("Start", k="-START-COUNTDOWN-"),
sg.Button("Stop", k="-STOP-COUNTDOWN-"),
Expand All @@ -115,13 +116,15 @@ def run_gui(devices):
sg.Column(
[
[sg.Text("Greyscale Image")],
[sg.Button("Send greyscale.gif", k="-SEND-GREY-IMAGE-")],
[sg.Button("Send greyscale.gif",
k="-SEND-GREY-IMAGE-")],
]
),
],
[sg.HorizontalSeparator()],
[sg.Text("Display Current Time")],
[sg.Button("Start", k="-START-TIME-"), sg.Button("Stop", k="-STOP-TIME-")],
[sg.Button("Start", k="-START-TIME-"),
sg.Button("Stop", k="-STOP-TIME-")],
[sg.HorizontalSeparator()],
[
sg.Column(
Expand Down Expand Up @@ -200,7 +203,8 @@ def run_gui(devices):
thread.start()

if event == "-START-TIME-":
thread = threading.Thread(target=clock, args=(dev,), daemon=True)
thread = threading.Thread(
target=clock, args=(dev,), daemon=True)
thread.start()

if event == "-PLAY-SNAKE-":
Expand Down Expand Up @@ -249,7 +253,8 @@ def run_gui(devices):
image_bl(dev, path)

if event == "-SEND-GREY-IMAGE-":
path = os.path.join(resource_path(), "res", "greyscale.gif")
path = os.path.join(
resource_path(), "res", "greyscale.gif")
image_greyscale(dev, path)

if event == "-SEND-TEXT-":
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@
import time
import threading

from framework16_inputmodule.inputmodule import (
from inputmodule.inputmodule import (
GameControlVal,
send_command,
CommandVals,
Game,
)
from framework16_inputmodule.inputmodule.ledmatrix import (
from inputmodule.inputmodule.ledmatrix import (
show_string,
WIDTH,
HEIGHT,
Expand Down Expand Up @@ -181,7 +181,8 @@ def snake(dev):
elif head == food:
body.insert(0, oldhead)
while food == head:
food = (random.randint(0, WIDTH - 1), random.randint(0, HEIGHT - 1))
food = (random.randint(0, WIDTH - 1),
random.randint(0, HEIGHT - 1))
elif body:
body.pop()
body.insert(0, oldhead)
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,18 @@
import time
import random

from framework16_inputmodule.gui.gui_threading import (
from inputmodule.gui.gui_threading import (
reset_thread,
is_thread_stopped,
is_dev_disconnected,
)
from framework16_inputmodule.inputmodule.ledmatrix import (
from inputmodule.inputmodule.ledmatrix import (
light_leds,
show_string,
eq,
breathing,
)
from framework16_inputmodule.inputmodule import brightness
from inputmodule.inputmodule import brightness


def countdown(dev, seconds):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import serial

# TODO: Make independent from GUI
from framework16_inputmodule.gui.gui_threading import disconnect_dev
from inputmodule.gui.gui_threading import disconnect_dev

FWK_MAGIC = [0x32, 0xAC]
FWK_VID = 0x32AC
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import sys

from framework16_inputmodule.inputmodule import send_command, CommandVals, FWK_MAGIC
from inputmodule.inputmodule import send_command, CommandVals, FWK_MAGIC

B1_WIDTH = 300
B1_HEIGHT = 400
GREYSCALE_DEPTH = 32

SCREEN_FPS = ["quarter", "half", "one", "two", "four", "eight", "sixteen", "thirtytwo"]
SCREEN_FPS = ["quarter", "half", "one", "two",
"four", "eight", "sixteen", "thirtytwo"]
HIGH_FPS_MASK = 0b00010000
LOW_FPS_MASK = 0b00000111

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from framework16_inputmodule.inputmodule import send_command, CommandVals
from inputmodule.inputmodule import send_command, CommandVals

RGB_COLORS = ["white", "black", "red", "green", "blue", "cyan", "yellow", "purple"]
RGB_COLORS = ["white", "black", "red", "green",
"blue", "cyan", "yellow", "purple"]


def get_color(dev):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

import serial

from framework16_inputmodule import font
from framework16_inputmodule.inputmodule import (
from inputmodule import font
from inputmodule.inputmodule import (
send_command,
CommandVals,
PatternVals,
Expand Down
8 changes: 4 additions & 4 deletions python/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ requires = ["hatchling", "hatch-vcs"]
build-backend = "hatchling.build"

[project]
name = "framework16_inputmodule"
name = "inputmodule"
# TODO: Dynamic version from git (requires tags)
#dynamic = ["version"]
version = "0.1.1"
Expand Down Expand Up @@ -38,16 +38,16 @@ Source = "https://github.com/FrameworkComputer/inputmodule-rs"

# TODO: Figure out how to add a runnable-script
[project.scripts]
ledmatrixctl = "framework16_inputmodule.cli:main_cli"
ledmatrixctl = "inputmodule.cli:main_cli"

[project.gui-scripts]
ledmatrixgui = "framework16_inputmodule.cli:main_gui"
ledmatrixgui = "inputmodule.cli:main_gui"

#[tool.hatch.version]
#source = "vcs"
#
#[tool.hatch.build.hooks.vcs]
#version-file = "framework16_inputmodule/_version.py"
#version-file = "inputmodule/_version.py"

[tool.hatch.build.targets.sdist]
exclude = [
Expand Down

0 comments on commit 61e45b1

Please sign in to comment.