initial commit
This commit is contained in:
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
||||
__pycache__
|
||||
15
artnet.py
Normal file
15
artnet.py
Normal file
@@ -0,0 +1,15 @@
|
||||
def buildPacket(universe, dimmer, dmxdata):
|
||||
# Stolen from fire-ohmlogo.py by OHM2013
|
||||
size = len(dmxdata) * 3
|
||||
# 01234567 8 9 a b c d e f 10 11
|
||||
# op-code protver seq phy universe len
|
||||
data = bytearray("Art-Net\x00\x00\x50\x00\x0e\x00\x00",'ascii')
|
||||
data.append(int(universe % 256))
|
||||
data.append(int(universe / 256))
|
||||
data.append(int(size / 256))
|
||||
data.append(int(size % 256))
|
||||
for (r, g, b) in dmxdata:
|
||||
data.append(int(dimmer*r/255))
|
||||
data.append(int(dimmer*g/255))
|
||||
data.append(int(dimmer*b/255))
|
||||
return data
|
||||
56
effects.py
Normal file
56
effects.py
Normal file
@@ -0,0 +1,56 @@
|
||||
from colormath.color_objects import HSVColor, sRGBColor
|
||||
from colormath.color_conversions import convert_color
|
||||
import time
|
||||
import math
|
||||
|
||||
def rainbow_whole(framecount, index, target):
|
||||
current_degree = framecount % 360
|
||||
hsv = HSVColor(current_degree, 1, 1)
|
||||
rgb = [ x for x in convert_color(hsv, sRGBColor).get_upscaled_value_tuple() ]
|
||||
target[0] = rgb[0]
|
||||
target[1] = rgb[1]
|
||||
target[2] = rgb[2]
|
||||
|
||||
def rainbow_whole_offset_stat(framecount, index, target):
|
||||
offset = index*90
|
||||
current_degree = (framecount + offset) % 360
|
||||
hsv = HSVColor(current_degree, 1, 1)
|
||||
rgb = [ x for x in convert_color(hsv, sRGBColor).get_upscaled_value_tuple() ]
|
||||
target[0] = rgb[0]
|
||||
target[1] = rgb[1]
|
||||
target[2] = rgb[2]
|
||||
|
||||
def rainbow_whole_offset_dyn(framecount, index, target):
|
||||
offset_hue_pixel = math.sin(framecount / 10000)*90*(index+1)
|
||||
saturation_pixel = math.fabs(math.cos(framecount / 5000))*70
|
||||
current_hue_degree = (framecount / 1000 + offset_hue_pixel) % 360
|
||||
current_sat = (30+saturation_pixel) / 100
|
||||
hsv = HSVColor(current_hue_degree, current_sat, 1)
|
||||
rgb = [ x for x in convert_color(hsv, sRGBColor).get_upscaled_value_tuple() ]
|
||||
target[0] = rgb[0]
|
||||
target[1] = rgb[1]
|
||||
target[2] = rgb[2]
|
||||
|
||||
def two_colors(framecount, index, target, hue1, hue2):
|
||||
saturation_pixel = 1
|
||||
hue_min = min(hue1, hue2)
|
||||
hue_max = max(hue1, hue2)
|
||||
current_hue_degree = hue_min + (hue_max - hue_min) / 2 + math.sin(framecount / 400 + index*100)*(hue_max - hue_min)/2
|
||||
current_sat = 1
|
||||
hsv = HSVColor(current_hue_degree, current_sat, 1)
|
||||
rgb = [ x for x in convert_color(hsv, sRGBColor).get_upscaled_value_tuple() ]
|
||||
target[0] = rgb[0]
|
||||
target[1] = rgb[1]
|
||||
target[2] = rgb[2]
|
||||
|
||||
def two_colors_red_blue(framecount, index, target):
|
||||
two_colors(framecount, index, target, 210, 359)
|
||||
|
||||
def two_colors_red_red(framecount, index, target):
|
||||
two_colors(framecount, index, target, 0, 30)
|
||||
|
||||
def two_colors_cyan_blue(framecount, index, target):
|
||||
two_colors(framecount, index, target, 180, 240)
|
||||
|
||||
def two_colors_cyan_orange(framecount, index, target):
|
||||
two_colors(framecount, index, target, 25, 180)
|
||||
91
main.py
Normal file
91
main.py
Normal file
@@ -0,0 +1,91 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
# WS server example that synchronizes state across clients
|
||||
|
||||
import asyncio
|
||||
import json
|
||||
import logging
|
||||
import websockets
|
||||
import processor
|
||||
import random
|
||||
import time
|
||||
import state
|
||||
|
||||
logging.basicConfig()
|
||||
|
||||
USERS = set()
|
||||
|
||||
def state_event(state):
|
||||
return json.dumps({
|
||||
"type": "state",
|
||||
"payload": {**state}
|
||||
})
|
||||
|
||||
def options_event():
|
||||
return json.dumps({
|
||||
"type": "options",
|
||||
"payload": {
|
||||
**processor.get_options()
|
||||
}
|
||||
})
|
||||
|
||||
def users_event():
|
||||
return json.dumps({"type": "users", "count": len(USERS)})
|
||||
|
||||
|
||||
async def notify_state(old_state, new_state):
|
||||
if USERS: # asyncio.wait doesn't accept an empty list
|
||||
message = state_event(new_state)
|
||||
await asyncio.wait([user.send(message) for user in USERS])
|
||||
|
||||
async def notify_users():
|
||||
if USERS: # asyncio.wait doesn't accept an empty list
|
||||
message = users_event()
|
||||
await asyncio.wait([user.send(message) for user in USERS])
|
||||
|
||||
|
||||
async def register(websocket):
|
||||
USERS.add(websocket)
|
||||
await notify_users()
|
||||
|
||||
|
||||
async def unregister(websocket):
|
||||
USERS.remove(websocket)
|
||||
await notify_users()
|
||||
|
||||
|
||||
async def counter(websocket, path):
|
||||
# register(websocket) sends user_event() to websocket
|
||||
await register(websocket)
|
||||
try:
|
||||
await websocket.send(state_event(await state.get_data()))
|
||||
await websocket.send(options_event())
|
||||
async for message in websocket:
|
||||
data = json.loads(message)
|
||||
if data["type"] == "mutation":
|
||||
await state.mutate(data["payload"])
|
||||
else:
|
||||
logging.error("unsupported event: {}", data)
|
||||
finally:
|
||||
await unregister(websocket)
|
||||
|
||||
async def serve():
|
||||
state.register_callback(notify_state)
|
||||
await state.inc_initialized()
|
||||
start_server = websockets.serve(counter, "localhost", 6789)
|
||||
await start_server
|
||||
|
||||
async def tick():
|
||||
while True:
|
||||
logging.warning("tick")
|
||||
await asyncio.sleep(1)
|
||||
|
||||
async def main():
|
||||
random.seed(time.time())
|
||||
await asyncio.gather(
|
||||
tick(),
|
||||
serve(),
|
||||
processor.main(["192.168.178.123", "192.168.178.124"]),
|
||||
)
|
||||
|
||||
asyncio.run(main())
|
||||
23
moodconsole/.gitignore
vendored
Normal file
23
moodconsole/.gitignore
vendored
Normal file
@@ -0,0 +1,23 @@
|
||||
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
|
||||
|
||||
# dependencies
|
||||
/node_modules
|
||||
/.pnp
|
||||
.pnp.js
|
||||
|
||||
# testing
|
||||
/coverage
|
||||
|
||||
# production
|
||||
/build
|
||||
|
||||
# misc
|
||||
.DS_Store
|
||||
.env.local
|
||||
.env.development.local
|
||||
.env.test.local
|
||||
.env.production.local
|
||||
|
||||
npm-debug.log*
|
||||
yarn-debug.log*
|
||||
yarn-error.log*
|
||||
46
moodconsole/README.md
Normal file
46
moodconsole/README.md
Normal file
@@ -0,0 +1,46 @@
|
||||
# Getting Started with Create React App
|
||||
|
||||
This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app).
|
||||
|
||||
## Available Scripts
|
||||
|
||||
In the project directory, you can run:
|
||||
|
||||
### `yarn start`
|
||||
|
||||
Runs the app in the development mode.\
|
||||
Open [http://localhost:3000](http://localhost:3000) to view it in the browser.
|
||||
|
||||
The page will reload if you make edits.\
|
||||
You will also see any lint errors in the console.
|
||||
|
||||
### `yarn test`
|
||||
|
||||
Launches the test runner in the interactive watch mode.\
|
||||
See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information.
|
||||
|
||||
### `yarn build`
|
||||
|
||||
Builds the app for production to the `build` folder.\
|
||||
It correctly bundles React in production mode and optimizes the build for the best performance.
|
||||
|
||||
The build is minified and the filenames include the hashes.\
|
||||
Your app is ready to be deployed!
|
||||
|
||||
See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information.
|
||||
|
||||
### `yarn eject`
|
||||
|
||||
**Note: this is a one-way operation. Once you `eject`, you can’t go back!**
|
||||
|
||||
If you aren’t satisfied with the build tool and configuration choices, you can `eject` at any time. This command will remove the single build dependency from your project.
|
||||
|
||||
Instead, it will copy all the configuration files and the transitive dependencies (webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point you’re on your own.
|
||||
|
||||
You don’t have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldn’t feel obligated to use this feature. However we understand that this tool wouldn’t be useful if you couldn’t customize it when you are ready for it.
|
||||
|
||||
## Learn More
|
||||
|
||||
You can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started).
|
||||
|
||||
To learn React, check out the [React documentation](https://reactjs.org/).
|
||||
11
moodconsole/craco.config.js
Normal file
11
moodconsole/craco.config.js
Normal file
@@ -0,0 +1,11 @@
|
||||
// craco.config.js
|
||||
module.exports = {
|
||||
style: {
|
||||
postcss: {
|
||||
plugins: [
|
||||
require('tailwindcss'),
|
||||
require('autoprefixer'),
|
||||
],
|
||||
},
|
||||
},
|
||||
}
|
||||
50
moodconsole/package.json
Normal file
50
moodconsole/package.json
Normal file
@@ -0,0 +1,50 @@
|
||||
{
|
||||
"name": "moodconsole",
|
||||
"version": "0.1.0",
|
||||
"private": true,
|
||||
"dependencies": {
|
||||
"@craco/craco": "^6.1.1",
|
||||
"@testing-library/jest-dom": "^5.11.4",
|
||||
"@testing-library/react": "^11.1.0",
|
||||
"@testing-library/user-event": "^12.1.10",
|
||||
"@types/jest": "^26.0.15",
|
||||
"@types/node": "^12.0.0",
|
||||
"@types/react": "^17.0.0",
|
||||
"@types/react-dom": "^17.0.0",
|
||||
"react": "^17.0.2",
|
||||
"react-dom": "^17.0.2",
|
||||
"react-scripts": "4.0.3",
|
||||
"typescript": "^4.1.2",
|
||||
"web-vitals": "^1.0.1"
|
||||
},
|
||||
"scripts": {
|
||||
"start": "craco start",
|
||||
"build": "craco build",
|
||||
"test": "craco test",
|
||||
"eject": "react-scripts eject"
|
||||
},
|
||||
"eslintConfig": {
|
||||
"extends": [
|
||||
"react-app",
|
||||
"react-app/jest"
|
||||
]
|
||||
},
|
||||
"browserslist": {
|
||||
"production": [
|
||||
">0.2%",
|
||||
"not dead",
|
||||
"not op_mini all"
|
||||
],
|
||||
"development": [
|
||||
"last 1 chrome version",
|
||||
"last 1 firefox version",
|
||||
"last 1 safari version"
|
||||
]
|
||||
},
|
||||
"devDependencies": {
|
||||
"@tailwindcss/postcss7-compat": "^2.0.4",
|
||||
"autoprefixer": "^9",
|
||||
"postcss": "^7",
|
||||
"tailwindcss": "npm:@tailwindcss/postcss7-compat"
|
||||
}
|
||||
}
|
||||
BIN
moodconsole/public/favicon.ico
Normal file
BIN
moodconsole/public/favicon.ico
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 3.8 KiB |
43
moodconsole/public/index.html
Normal file
43
moodconsole/public/index.html
Normal file
@@ -0,0 +1,43 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<link rel="icon" href="%PUBLIC_URL%/favicon.ico" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||
<meta name="theme-color" content="#000000" />
|
||||
<meta
|
||||
name="description"
|
||||
content="Web site created using create-react-app"
|
||||
/>
|
||||
<link rel="apple-touch-icon" href="%PUBLIC_URL%/logo192.png" />
|
||||
<!--
|
||||
manifest.json provides metadata used when your web app is installed on a
|
||||
user's mobile device or desktop. See https://developers.google.com/web/fundamentals/web-app-manifest/
|
||||
-->
|
||||
<link rel="manifest" href="%PUBLIC_URL%/manifest.json" />
|
||||
<!--
|
||||
Notice the use of %PUBLIC_URL% in the tags above.
|
||||
It will be replaced with the URL of the `public` folder during the build.
|
||||
Only files inside the `public` folder can be referenced from the HTML.
|
||||
|
||||
Unlike "/favicon.ico" or "favicon.ico", "%PUBLIC_URL%/favicon.ico" will
|
||||
work correctly both with client-side routing and a non-root public URL.
|
||||
Learn how to configure a non-root public URL by running `npm run build`.
|
||||
-->
|
||||
<title>React App</title>
|
||||
</head>
|
||||
<body>
|
||||
<noscript>You need to enable JavaScript to run this app.</noscript>
|
||||
<div id="root"></div>
|
||||
<!--
|
||||
This HTML file is a template.
|
||||
If you open it directly in the browser, you will see an empty page.
|
||||
|
||||
You can add webfonts, meta tags, or analytics to this file.
|
||||
The build step will place the bundled scripts into the <body> tag.
|
||||
|
||||
To begin the development, run `npm start` or `yarn start`.
|
||||
To create a production bundle, use `npm run build` or `yarn build`.
|
||||
-->
|
||||
</body>
|
||||
</html>
|
||||
BIN
moodconsole/public/logo192.png
Normal file
BIN
moodconsole/public/logo192.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 5.2 KiB |
BIN
moodconsole/public/logo512.png
Normal file
BIN
moodconsole/public/logo512.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 9.4 KiB |
25
moodconsole/public/manifest.json
Normal file
25
moodconsole/public/manifest.json
Normal file
@@ -0,0 +1,25 @@
|
||||
{
|
||||
"short_name": "React App",
|
||||
"name": "Create React App Sample",
|
||||
"icons": [
|
||||
{
|
||||
"src": "favicon.ico",
|
||||
"sizes": "64x64 32x32 24x24 16x16",
|
||||
"type": "image/x-icon"
|
||||
},
|
||||
{
|
||||
"src": "logo192.png",
|
||||
"type": "image/png",
|
||||
"sizes": "192x192"
|
||||
},
|
||||
{
|
||||
"src": "logo512.png",
|
||||
"type": "image/png",
|
||||
"sizes": "512x512"
|
||||
}
|
||||
],
|
||||
"start_url": ".",
|
||||
"display": "standalone",
|
||||
"theme_color": "#000000",
|
||||
"background_color": "#ffffff"
|
||||
}
|
||||
3
moodconsole/public/robots.txt
Normal file
3
moodconsole/public/robots.txt
Normal file
@@ -0,0 +1,3 @@
|
||||
# https://www.robotstxt.org/robotstxt.html
|
||||
User-agent: *
|
||||
Disallow:
|
||||
38
moodconsole/src/App.css
Normal file
38
moodconsole/src/App.css
Normal file
@@ -0,0 +1,38 @@
|
||||
.App {
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.App-logo {
|
||||
height: 40vmin;
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
@media (prefers-reduced-motion: no-preference) {
|
||||
.App-logo {
|
||||
animation: App-logo-spin infinite 20s linear;
|
||||
}
|
||||
}
|
||||
|
||||
.App-header {
|
||||
background-color: #282c34;
|
||||
min-height: 100vh;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
font-size: calc(10px + 2vmin);
|
||||
color: white;
|
||||
}
|
||||
|
||||
.App-link {
|
||||
color: #61dafb;
|
||||
}
|
||||
|
||||
@keyframes App-logo-spin {
|
||||
from {
|
||||
transform: rotate(0deg);
|
||||
}
|
||||
to {
|
||||
transform: rotate(360deg);
|
||||
}
|
||||
}
|
||||
9
moodconsole/src/App.test.tsx
Normal file
9
moodconsole/src/App.test.tsx
Normal file
@@ -0,0 +1,9 @@
|
||||
import React from 'react';
|
||||
import { render, screen } from '@testing-library/react';
|
||||
import App from './App';
|
||||
|
||||
test('renders learn react link', () => {
|
||||
render(<App />);
|
||||
const linkElement = screen.getByText(/learn react/i);
|
||||
expect(linkElement).toBeInTheDocument();
|
||||
});
|
||||
137
moodconsole/src/App.tsx
Normal file
137
moodconsole/src/App.tsx
Normal file
@@ -0,0 +1,137 @@
|
||||
import React, { FC, useEffect, useState } from "react";
|
||||
import "./App.css";
|
||||
|
||||
type BorderColor = "green" | "red" | "gray";
|
||||
const Button: FC<{
|
||||
onClick: () => void;
|
||||
color: BorderColor;
|
||||
children: React.ReactNode;
|
||||
}> = ({ onClick, color, children }) => {
|
||||
return (
|
||||
<button
|
||||
className={`m-2 p-2 border-2 border-${color}-500 text-${color}-500 text-3xl text-center leading-none align-middle`}
|
||||
onClick={(event) => {
|
||||
onClick();
|
||||
}}
|
||||
>
|
||||
{children}
|
||||
</button>
|
||||
);
|
||||
};
|
||||
|
||||
const Display: FC<{
|
||||
color: BorderColor;
|
||||
}> = ({ color, children }) => {
|
||||
return (
|
||||
<div
|
||||
className={`m-2 p-2 border-2 border-${color}-500 text-${color}-500 text-3xl text-center leading-none align-middle`}
|
||||
>
|
||||
{children}
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
interface State {
|
||||
initialized: number;
|
||||
current_effect: string;
|
||||
}
|
||||
|
||||
interface Options {
|
||||
effects: {
|
||||
available: string[];
|
||||
};
|
||||
}
|
||||
|
||||
function App() {
|
||||
const [state, setState] = useState<State | undefined>(undefined);
|
||||
const [options, setOptions] = useState<Options | undefined>(undefined);
|
||||
const [users, setUsers] = useState(0);
|
||||
const [socket, setSocket] = useState<WebSocket | undefined>(undefined);
|
||||
|
||||
const [timerId, setTimerId] = useState<NodeJS.Timeout>();
|
||||
|
||||
const keepAlive = () => {
|
||||
if (socket?.readyState === WebSocket.OPEN) {
|
||||
socket.send("");
|
||||
}
|
||||
setTimerId(setTimeout(keepAlive, 2000));
|
||||
};
|
||||
|
||||
const cancelKeepAlive = () => {
|
||||
timerId && clearTimeout(timerId);
|
||||
};
|
||||
|
||||
const onSocketClose = () => {
|
||||
setSocket(undefined);
|
||||
setOptions(undefined);
|
||||
setState(undefined);
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
if (socket === undefined) {
|
||||
const websocket = new WebSocket("ws://127.0.0.1:6789/");
|
||||
websocket.onmessage = (event) => {
|
||||
const data = JSON.parse(event.data);
|
||||
switch (data.type) {
|
||||
case "state":
|
||||
setState(data.payload as State);
|
||||
break;
|
||||
case "options":
|
||||
setOptions(data.payload as Options);
|
||||
break;
|
||||
case "users":
|
||||
setUsers(data.count);
|
||||
break;
|
||||
default:
|
||||
console.error("Unsupported event", data);
|
||||
}
|
||||
};
|
||||
websocket.onerror = (ev) => {
|
||||
console.error(ev);
|
||||
if (websocket.readyState === WebSocket.OPEN) {
|
||||
websocket.close();
|
||||
}
|
||||
cancelKeepAlive();
|
||||
};
|
||||
websocket.onclose = (ev) => {
|
||||
onSocketClose();
|
||||
};
|
||||
setSocket(websocket);
|
||||
keepAlive();
|
||||
}
|
||||
}, [socket]);
|
||||
|
||||
const onEffectButtonClick = (name: string) => {
|
||||
socket?.send(
|
||||
JSON.stringify({ type: "mutation", payload: { current_effect: name } })
|
||||
);
|
||||
};
|
||||
|
||||
return (
|
||||
<div>
|
||||
{options && state ? (
|
||||
<div className="font-mono flex justify-center flex-col">
|
||||
<Display color="gray">Current Effect {state.current_effect}</Display>
|
||||
{options.effects.available.map((effect) => {
|
||||
return (
|
||||
<Button
|
||||
key={effect}
|
||||
color="green"
|
||||
onClick={() => {
|
||||
onEffectButtonClick(effect);
|
||||
}}
|
||||
>
|
||||
{effect}
|
||||
</Button>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
) : (
|
||||
<div className="font-mono text-center text-8xl">OFFLINE</div>
|
||||
)}
|
||||
{users} online
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
export default App;
|
||||
3
moodconsole/src/index.css
Normal file
3
moodconsole/src/index.css
Normal file
@@ -0,0 +1,3 @@
|
||||
@tailwind base;
|
||||
@tailwind components;
|
||||
@tailwind utilities;
|
||||
17
moodconsole/src/index.tsx
Normal file
17
moodconsole/src/index.tsx
Normal file
@@ -0,0 +1,17 @@
|
||||
import React from 'react';
|
||||
import ReactDOM from 'react-dom';
|
||||
import './index.css';
|
||||
import App from './App';
|
||||
import reportWebVitals from './reportWebVitals';
|
||||
|
||||
ReactDOM.render(
|
||||
<React.StrictMode>
|
||||
<App />
|
||||
</React.StrictMode>,
|
||||
document.getElementById('root')
|
||||
);
|
||||
|
||||
// If you want to start measuring performance in your app, pass a function
|
||||
// to log results (for example: reportWebVitals(console.log))
|
||||
// or send to an analytics endpoint. Learn more: https://bit.ly/CRA-vitals
|
||||
reportWebVitals();
|
||||
1
moodconsole/src/logo.svg
Normal file
1
moodconsole/src/logo.svg
Normal file
@@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 841.9 595.3"><g fill="#61DAFB"><path d="M666.3 296.5c0-32.5-40.7-63.3-103.1-82.4 14.4-63.6 8-114.2-20.2-130.4-6.5-3.8-14.1-5.6-22.4-5.6v22.3c4.6 0 8.3.9 11.4 2.6 13.6 7.8 19.5 37.5 14.9 75.7-1.1 9.4-2.9 19.3-5.1 29.4-19.6-4.8-41-8.5-63.5-10.9-13.5-18.5-27.5-35.3-41.6-50 32.6-30.3 63.2-46.9 84-46.9V78c-27.5 0-63.5 19.6-99.9 53.6-36.4-33.8-72.4-53.2-99.9-53.2v22.3c20.7 0 51.4 16.5 84 46.6-14 14.7-28 31.4-41.3 49.9-22.6 2.4-44 6.1-63.6 11-2.3-10-4-19.7-5.2-29-4.7-38.2 1.1-67.9 14.6-75.8 3-1.8 6.9-2.6 11.5-2.6V78.5c-8.4 0-16 1.8-22.6 5.6-28.1 16.2-34.4 66.7-19.9 130.1-62.2 19.2-102.7 49.9-102.7 82.3 0 32.5 40.7 63.3 103.1 82.4-14.4 63.6-8 114.2 20.2 130.4 6.5 3.8 14.1 5.6 22.5 5.6 27.5 0 63.5-19.6 99.9-53.6 36.4 33.8 72.4 53.2 99.9 53.2 8.4 0 16-1.8 22.6-5.6 28.1-16.2 34.4-66.7 19.9-130.1 62-19.1 102.5-49.9 102.5-82.3zm-130.2-66.7c-3.7 12.9-8.3 26.2-13.5 39.5-4.1-8-8.4-16-13.1-24-4.6-8-9.5-15.8-14.4-23.4 14.2 2.1 27.9 4.7 41 7.9zm-45.8 106.5c-7.8 13.5-15.8 26.3-24.1 38.2-14.9 1.3-30 2-45.2 2-15.1 0-30.2-.7-45-1.9-8.3-11.9-16.4-24.6-24.2-38-7.6-13.1-14.5-26.4-20.8-39.8 6.2-13.4 13.2-26.8 20.7-39.9 7.8-13.5 15.8-26.3 24.1-38.2 14.9-1.3 30-2 45.2-2 15.1 0 30.2.7 45 1.9 8.3 11.9 16.4 24.6 24.2 38 7.6 13.1 14.5 26.4 20.8 39.8-6.3 13.4-13.2 26.8-20.7 39.9zm32.3-13c5.4 13.4 10 26.8 13.8 39.8-13.1 3.2-26.9 5.9-41.2 8 4.9-7.7 9.8-15.6 14.4-23.7 4.6-8 8.9-16.1 13-24.1zM421.2 430c-9.3-9.6-18.6-20.3-27.8-32 9 .4 18.2.7 27.5.7 9.4 0 18.7-.2 27.8-.7-9 11.7-18.3 22.4-27.5 32zm-74.4-58.9c-14.2-2.1-27.9-4.7-41-7.9 3.7-12.9 8.3-26.2 13.5-39.5 4.1 8 8.4 16 13.1 24 4.7 8 9.5 15.8 14.4 23.4zM420.7 163c9.3 9.6 18.6 20.3 27.8 32-9-.4-18.2-.7-27.5-.7-9.4 0-18.7.2-27.8.7 9-11.7 18.3-22.4 27.5-32zm-74 58.9c-4.9 7.7-9.8 15.6-14.4 23.7-4.6 8-8.9 16-13 24-5.4-13.4-10-26.8-13.8-39.8 13.1-3.1 26.9-5.8 41.2-7.9zm-90.5 125.2c-35.4-15.1-58.3-34.9-58.3-50.6 0-15.7 22.9-35.6 58.3-50.6 8.6-3.7 18-7 27.7-10.1 5.7 19.6 13.2 40 22.5 60.9-9.2 20.8-16.6 41.1-22.2 60.6-9.9-3.1-19.3-6.5-28-10.2zM310 490c-13.6-7.8-19.5-37.5-14.9-75.7 1.1-9.4 2.9-19.3 5.1-29.4 19.6 4.8 41 8.5 63.5 10.9 13.5 18.5 27.5 35.3 41.6 50-32.6 30.3-63.2 46.9-84 46.9-4.5-.1-8.3-1-11.3-2.7zm237.2-76.2c4.7 38.2-1.1 67.9-14.6 75.8-3 1.8-6.9 2.6-11.5 2.6-20.7 0-51.4-16.5-84-46.6 14-14.7 28-31.4 41.3-49.9 22.6-2.4 44-6.1 63.6-11 2.3 10.1 4.1 19.8 5.2 29.1zm38.5-66.7c-8.6 3.7-18 7-27.7 10.1-5.7-19.6-13.2-40-22.5-60.9 9.2-20.8 16.6-41.1 22.2-60.6 9.9 3.1 19.3 6.5 28.1 10.2 35.4 15.1 58.3 34.9 58.3 50.6-.1 15.7-23 35.6-58.4 50.6zM320.8 78.4z"/><circle cx="420.9" cy="296.5" r="45.7"/><path d="M520.5 78.1z"/></g></svg>
|
||||
|
After Width: | Height: | Size: 2.6 KiB |
1
moodconsole/src/react-app-env.d.ts
vendored
Normal file
1
moodconsole/src/react-app-env.d.ts
vendored
Normal file
@@ -0,0 +1 @@
|
||||
/// <reference types="react-scripts" />
|
||||
15
moodconsole/src/reportWebVitals.ts
Normal file
15
moodconsole/src/reportWebVitals.ts
Normal file
@@ -0,0 +1,15 @@
|
||||
import { ReportHandler } from 'web-vitals';
|
||||
|
||||
const reportWebVitals = (onPerfEntry?: ReportHandler) => {
|
||||
if (onPerfEntry && onPerfEntry instanceof Function) {
|
||||
import('web-vitals').then(({ getCLS, getFID, getFCP, getLCP, getTTFB }) => {
|
||||
getCLS(onPerfEntry);
|
||||
getFID(onPerfEntry);
|
||||
getFCP(onPerfEntry);
|
||||
getLCP(onPerfEntry);
|
||||
getTTFB(onPerfEntry);
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
export default reportWebVitals;
|
||||
5
moodconsole/src/setupTests.ts
Normal file
5
moodconsole/src/setupTests.ts
Normal file
@@ -0,0 +1,5 @@
|
||||
// jest-dom adds custom jest matchers for asserting on DOM nodes.
|
||||
// allows you to do things like:
|
||||
// expect(element).toHaveTextContent(/react/i)
|
||||
// learn more: https://github.com/testing-library/jest-dom
|
||||
import '@testing-library/jest-dom';
|
||||
11
moodconsole/tailwind.config.js
Normal file
11
moodconsole/tailwind.config.js
Normal file
@@ -0,0 +1,11 @@
|
||||
module.exports = {
|
||||
purge: [],
|
||||
darkMode: false, // or 'media' or 'class'
|
||||
theme: {
|
||||
extend: {},
|
||||
},
|
||||
variants: {
|
||||
extend: {},
|
||||
},
|
||||
plugins: [],
|
||||
}
|
||||
26
moodconsole/tsconfig.json
Normal file
26
moodconsole/tsconfig.json
Normal file
@@ -0,0 +1,26 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"target": "es5",
|
||||
"lib": [
|
||||
"dom",
|
||||
"dom.iterable",
|
||||
"esnext"
|
||||
],
|
||||
"allowJs": true,
|
||||
"skipLibCheck": true,
|
||||
"esModuleInterop": true,
|
||||
"allowSyntheticDefaultImports": true,
|
||||
"strict": true,
|
||||
"forceConsistentCasingInFileNames": true,
|
||||
"noFallthroughCasesInSwitch": true,
|
||||
"module": "esnext",
|
||||
"moduleResolution": "node",
|
||||
"resolveJsonModule": true,
|
||||
"isolatedModules": true,
|
||||
"noEmit": true,
|
||||
"jsx": "react-jsx"
|
||||
},
|
||||
"include": [
|
||||
"src"
|
||||
]
|
||||
}
|
||||
11633
moodconsole/yarn.lock
Normal file
11633
moodconsole/yarn.lock
Normal file
File diff suppressed because it is too large
Load Diff
139
poetry.lock
generated
Normal file
139
poetry.lock
generated
Normal file
@@ -0,0 +1,139 @@
|
||||
[[package]]
|
||||
name = "colormath"
|
||||
version = "3.0.0"
|
||||
description = "Color math and conversion library."
|
||||
category = "main"
|
||||
optional = false
|
||||
python-versions = "*"
|
||||
|
||||
[package.dependencies]
|
||||
networkx = ">=2.0"
|
||||
numpy = "*"
|
||||
|
||||
[[package]]
|
||||
name = "decorator"
|
||||
version = "4.4.2"
|
||||
description = "Decorators for Humans"
|
||||
category = "main"
|
||||
optional = false
|
||||
python-versions = ">=2.6, !=3.0.*, !=3.1.*"
|
||||
|
||||
[[package]]
|
||||
name = "deepmerge"
|
||||
version = "0.2.1"
|
||||
description = "a toolset to deeply merge python dictionaries."
|
||||
category = "main"
|
||||
optional = false
|
||||
python-versions = "*"
|
||||
|
||||
[[package]]
|
||||
name = "networkx"
|
||||
version = "2.5"
|
||||
description = "Python package for creating and manipulating graphs and networks"
|
||||
category = "main"
|
||||
optional = false
|
||||
python-versions = ">=3.6"
|
||||
|
||||
[package.dependencies]
|
||||
decorator = ">=4.3.0"
|
||||
|
||||
[package.extras]
|
||||
all = ["numpy", "scipy", "pandas", "matplotlib", "pygraphviz", "pydot", "pyyaml", "lxml", "pytest"]
|
||||
gdal = ["gdal"]
|
||||
lxml = ["lxml"]
|
||||
matplotlib = ["matplotlib"]
|
||||
numpy = ["numpy"]
|
||||
pandas = ["pandas"]
|
||||
pydot = ["pydot"]
|
||||
pygraphviz = ["pygraphviz"]
|
||||
pytest = ["pytest"]
|
||||
pyyaml = ["pyyaml"]
|
||||
scipy = ["scipy"]
|
||||
|
||||
[[package]]
|
||||
name = "numpy"
|
||||
version = "1.20.1"
|
||||
description = "NumPy is the fundamental package for array computing with Python."
|
||||
category = "main"
|
||||
optional = false
|
||||
python-versions = ">=3.7"
|
||||
|
||||
[[package]]
|
||||
name = "websockets"
|
||||
version = "8.1"
|
||||
description = "An implementation of the WebSocket Protocol (RFC 6455 & 7692)"
|
||||
category = "main"
|
||||
optional = false
|
||||
python-versions = ">=3.6.1"
|
||||
|
||||
[metadata]
|
||||
lock-version = "1.1"
|
||||
python-versions = "^3.9"
|
||||
content-hash = "707b5b9ea11c0176f2bd44ac948d79e5177c653ed34a82452b7f861f2a3f36c8"
|
||||
|
||||
[metadata.files]
|
||||
colormath = [
|
||||
{file = "colormath-3.0.0.tar.gz", hash = "sha256:3d4605af344527da0e4f9f504fad7ddbebda35322c566a6c72e28edb1ff31217"},
|
||||
]
|
||||
decorator = [
|
||||
{file = "decorator-4.4.2-py2.py3-none-any.whl", hash = "sha256:41fa54c2a0cc4ba648be4fd43cff00aedf5b9465c9bf18d64325bc225f08f760"},
|
||||
{file = "decorator-4.4.2.tar.gz", hash = "sha256:e3a62f0520172440ca0dcc823749319382e377f37f140a0b99ef45fecb84bfe7"},
|
||||
]
|
||||
deepmerge = [
|
||||
{file = "deepmerge-0.2.1-py2.py3-none-any.whl", hash = "sha256:8270901f85fbe249686236cb18bf4bccc69775da2c2e1fa35de3714d5d9d01b3"},
|
||||
{file = "deepmerge-0.2.1.tar.gz", hash = "sha256:5fbd777507dd86c767048bddb2c50adf7da30f7688fe3f3f4e6ede6226dd4b20"},
|
||||
]
|
||||
networkx = [
|
||||
{file = "networkx-2.5-py3-none-any.whl", hash = "sha256:8c5812e9f798d37c50570d15c4a69d5710a18d77bafc903ee9c5fba7454c616c"},
|
||||
{file = "networkx-2.5.tar.gz", hash = "sha256:7978955423fbc9639c10498878be59caf99b44dc304c2286162fd24b458c1602"},
|
||||
]
|
||||
numpy = [
|
||||
{file = "numpy-1.20.1-cp37-cp37m-macosx_10_9_x86_64.whl", hash = "sha256:ae61f02b84a0211abb56462a3b6cd1e7ec39d466d3160eb4e1da8bf6717cdbeb"},
|
||||
{file = "numpy-1.20.1-cp37-cp37m-manylinux1_i686.whl", hash = "sha256:65410c7f4398a0047eea5cca9b74009ea61178efd78d1be9847fac1d6716ec1e"},
|
||||
{file = "numpy-1.20.1-cp37-cp37m-manylinux1_x86_64.whl", hash = "sha256:2d7e27442599104ee08f4faed56bb87c55f8b10a5494ac2ead5c98a4b289e61f"},
|
||||
{file = "numpy-1.20.1-cp37-cp37m-manylinux2010_i686.whl", hash = "sha256:4ed8e96dc146e12c1c5cdd6fb9fd0757f2ba66048bf94c5126b7efebd12d0090"},
|
||||
{file = "numpy-1.20.1-cp37-cp37m-manylinux2010_x86_64.whl", hash = "sha256:ecb5b74c702358cdc21268ff4c37f7466357871f53a30e6f84c686952bef16a9"},
|
||||
{file = "numpy-1.20.1-cp37-cp37m-manylinux2014_aarch64.whl", hash = "sha256:b9410c0b6fed4a22554f072a86c361e417f0258838957b78bd063bde2c7f841f"},
|
||||
{file = "numpy-1.20.1-cp37-cp37m-win32.whl", hash = "sha256:3d3087e24e354c18fb35c454026af3ed8997cfd4997765266897c68d724e4845"},
|
||||
{file = "numpy-1.20.1-cp37-cp37m-win_amd64.whl", hash = "sha256:89f937b13b8dd17b0099c7c2e22066883c86ca1575a975f754babc8fbf8d69a9"},
|
||||
{file = "numpy-1.20.1-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:a1d7995d1023335e67fb070b2fae6f5968f5be3802b15ad6d79d81ecaa014fe0"},
|
||||
{file = "numpy-1.20.1-cp38-cp38-manylinux1_i686.whl", hash = "sha256:60759ab15c94dd0e1ed88241fd4fa3312db4e91d2c8f5a2d4cf3863fad83d65b"},
|
||||
{file = "numpy-1.20.1-cp38-cp38-manylinux1_x86_64.whl", hash = "sha256:125a0e10ddd99a874fd357bfa1b636cd58deb78ba4a30b5ddb09f645c3512e04"},
|
||||
{file = "numpy-1.20.1-cp38-cp38-manylinux2010_i686.whl", hash = "sha256:c26287dfc888cf1e65181f39ea75e11f42ffc4f4529e5bd19add57ad458996e2"},
|
||||
{file = "numpy-1.20.1-cp38-cp38-manylinux2010_x86_64.whl", hash = "sha256:7199109fa46277be503393be9250b983f325880766f847885607d9b13848f257"},
|
||||
{file = "numpy-1.20.1-cp38-cp38-manylinux2014_aarch64.whl", hash = "sha256:72251e43ac426ff98ea802a931922c79b8d7596480300eb9f1b1e45e0543571e"},
|
||||
{file = "numpy-1.20.1-cp38-cp38-win32.whl", hash = "sha256:c91ec9569facd4757ade0888371eced2ecf49e7982ce5634cc2cf4e7331a4b14"},
|
||||
{file = "numpy-1.20.1-cp38-cp38-win_amd64.whl", hash = "sha256:13adf545732bb23a796914fe5f891a12bd74cf3d2986eed7b7eba2941eea1590"},
|
||||
{file = "numpy-1.20.1-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:104f5e90b143dbf298361a99ac1af4cf59131218a045ebf4ee5990b83cff5fab"},
|
||||
{file = "numpy-1.20.1-cp39-cp39-manylinux2010_i686.whl", hash = "sha256:89e5336f2bec0c726ac7e7cdae181b325a9c0ee24e604704ed830d241c5e47ff"},
|
||||
{file = "numpy-1.20.1-cp39-cp39-manylinux2010_x86_64.whl", hash = "sha256:032be656d89bbf786d743fee11d01ef318b0781281241997558fa7950028dd29"},
|
||||
{file = "numpy-1.20.1-cp39-cp39-manylinux2014_aarch64.whl", hash = "sha256:66b467adfcf628f66ea4ac6430ded0614f5cc06ba530d09571ea404789064adc"},
|
||||
{file = "numpy-1.20.1-cp39-cp39-win32.whl", hash = "sha256:12e4ba5c6420917571f1a5becc9338abbde71dd811ce40b37ba62dec7b39af6d"},
|
||||
{file = "numpy-1.20.1-cp39-cp39-win_amd64.whl", hash = "sha256:9c94cab5054bad82a70b2e77741271790304651d584e2cdfe2041488e753863b"},
|
||||
{file = "numpy-1.20.1-pp37-pypy37_pp73-manylinux2010_x86_64.whl", hash = "sha256:9eb551d122fadca7774b97db8a112b77231dcccda8e91a5bc99e79890797175e"},
|
||||
{file = "numpy-1.20.1.zip", hash = "sha256:3bc63486a870294683980d76ec1e3efc786295ae00128f9ea38e2c6e74d5a60a"},
|
||||
]
|
||||
websockets = [
|
||||
{file = "websockets-8.1-cp36-cp36m-macosx_10_6_intel.whl", hash = "sha256:3762791ab8b38948f0c4d281c8b2ddfa99b7e510e46bd8dfa942a5fff621068c"},
|
||||
{file = "websockets-8.1-cp36-cp36m-manylinux1_i686.whl", hash = "sha256:3db87421956f1b0779a7564915875ba774295cc86e81bc671631379371af1170"},
|
||||
{file = "websockets-8.1-cp36-cp36m-manylinux1_x86_64.whl", hash = "sha256:4f9f7d28ce1d8f1295717c2c25b732c2bc0645db3215cf757551c392177d7cb8"},
|
||||
{file = "websockets-8.1-cp36-cp36m-manylinux2010_i686.whl", hash = "sha256:295359a2cc78736737dd88c343cd0747546b2174b5e1adc223824bcaf3e164cb"},
|
||||
{file = "websockets-8.1-cp36-cp36m-manylinux2010_x86_64.whl", hash = "sha256:1d3f1bf059d04a4e0eb4985a887d49195e15ebabc42364f4eb564b1d065793f5"},
|
||||
{file = "websockets-8.1-cp36-cp36m-win32.whl", hash = "sha256:2db62a9142e88535038a6bcfea70ef9447696ea77891aebb730a333a51ed559a"},
|
||||
{file = "websockets-8.1-cp36-cp36m-win_amd64.whl", hash = "sha256:0e4fb4de42701340bd2353bb2eee45314651caa6ccee80dbd5f5d5978888fed5"},
|
||||
{file = "websockets-8.1-cp37-cp37m-macosx_10_6_intel.whl", hash = "sha256:9b248ba3dd8a03b1a10b19efe7d4f7fa41d158fdaa95e2cf65af5a7b95a4f989"},
|
||||
{file = "websockets-8.1-cp37-cp37m-manylinux1_i686.whl", hash = "sha256:ce85b06a10fc65e6143518b96d3dca27b081a740bae261c2fb20375801a9d56d"},
|
||||
{file = "websockets-8.1-cp37-cp37m-manylinux1_x86_64.whl", hash = "sha256:965889d9f0e2a75edd81a07592d0ced54daa5b0785f57dc429c378edbcffe779"},
|
||||
{file = "websockets-8.1-cp37-cp37m-manylinux2010_i686.whl", hash = "sha256:751a556205d8245ff94aeef23546a1113b1dd4f6e4d102ded66c39b99c2ce6c8"},
|
||||
{file = "websockets-8.1-cp37-cp37m-manylinux2010_x86_64.whl", hash = "sha256:3ef56fcc7b1ff90de46ccd5a687bbd13a3180132268c4254fc0fa44ecf4fc422"},
|
||||
{file = "websockets-8.1-cp37-cp37m-win32.whl", hash = "sha256:7ff46d441db78241f4c6c27b3868c9ae71473fe03341340d2dfdbe8d79310acc"},
|
||||
{file = "websockets-8.1-cp37-cp37m-win_amd64.whl", hash = "sha256:20891f0dddade307ffddf593c733a3fdb6b83e6f9eef85908113e628fa5a8308"},
|
||||
{file = "websockets-8.1-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:c1ec8db4fac31850286b7cd3b9c0e1b944204668b8eb721674916d4e28744092"},
|
||||
{file = "websockets-8.1-cp38-cp38-manylinux1_i686.whl", hash = "sha256:5c01fd846263a75bc8a2b9542606927cfad57e7282965d96b93c387622487485"},
|
||||
{file = "websockets-8.1-cp38-cp38-manylinux1_x86_64.whl", hash = "sha256:9bef37ee224e104a413f0780e29adb3e514a5b698aabe0d969a6ba426b8435d1"},
|
||||
{file = "websockets-8.1-cp38-cp38-manylinux2010_i686.whl", hash = "sha256:d705f8aeecdf3262379644e4b55107a3b55860eb812b673b28d0fbc347a60c55"},
|
||||
{file = "websockets-8.1-cp38-cp38-manylinux2010_x86_64.whl", hash = "sha256:c8a116feafdb1f84607cb3b14aa1418424ae71fee131642fc568d21423b51824"},
|
||||
{file = "websockets-8.1-cp38-cp38-win32.whl", hash = "sha256:e898a0863421650f0bebac8ba40840fc02258ef4714cb7e1fd76b6a6354bda36"},
|
||||
{file = "websockets-8.1-cp38-cp38-win_amd64.whl", hash = "sha256:f8a7bff6e8664afc4e6c28b983845c5bc14965030e3fb98789734d416af77c4b"},
|
||||
{file = "websockets-8.1.tar.gz", hash = "sha256:5c65d2da8c6bce0fca2528f69f44b2f977e06954c8512a952222cea50dad430f"},
|
||||
]
|
||||
67
processor.py
Normal file
67
processor.py
Normal file
@@ -0,0 +1,67 @@
|
||||
import asyncio
|
||||
import socket
|
||||
import copy
|
||||
import logging
|
||||
from artnet import buildPacket
|
||||
from effects import *
|
||||
import state
|
||||
|
||||
AVAILABLE_EFFECTS = [rainbow_whole, rainbow_whole_offset_stat, rainbow_whole_offset_dyn, two_colors_red_blue, two_colors_red_red, two_colors_cyan_blue, two_colors_cyan_orange ]
|
||||
|
||||
current_effect = rainbow_whole
|
||||
framecount = 0
|
||||
|
||||
def function_str(func):
|
||||
return str(func).split(" ")[1]
|
||||
|
||||
def get_options():
|
||||
return {
|
||||
"effects": {
|
||||
"available": [ function_str(e) for e in AVAILABLE_EFFECTS ]
|
||||
}
|
||||
}
|
||||
|
||||
def set_immidiate(framecount, channels, update):
|
||||
for inx, (current, target) in enumerate(zip(channels["current"], channels["target"])):
|
||||
update(framecount, inx, target)
|
||||
for i in range (0,3):
|
||||
current[i] = target[i]
|
||||
|
||||
# TODO make this an acceptor and then mutate
|
||||
async def handle_state_change(old, new):
|
||||
global current_effect
|
||||
global framecount
|
||||
if new["current_effect"] != function_str(current_effect):
|
||||
new_effect = [ x for x in AVAILABLE_EFFECTS if function_str(x) == new["current_effect"] ][0]
|
||||
current_effect = new_effect if new_effect != None else current_effect
|
||||
framecount = 0
|
||||
|
||||
async def main(target_ips):
|
||||
global current_effect
|
||||
global framecount
|
||||
channels = { "target": [], "current": [] }
|
||||
for x in range(0,4):
|
||||
channels["target"].append( [0,0,0] )
|
||||
channels["current"].append( [0,0,0] )
|
||||
|
||||
sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
|
||||
debug = False
|
||||
|
||||
current_state = await state.get_data()
|
||||
state.register_callback(handle_state_change)
|
||||
await state.mutate({ "current_effect": function_str(current_effect) })
|
||||
await state.inc_initialized()
|
||||
|
||||
while True:
|
||||
old_channels = copy.deepcopy(channels["current"])
|
||||
set_immidiate(framecount, channels, current_effect)
|
||||
if old_channels != channels["current"]:
|
||||
if debug:
|
||||
print("frame:{} channels:{}".format(framecount, channels))
|
||||
channels_transmit = channels["current"]
|
||||
for ip in target_ips:
|
||||
sock.sendto(buildPacket(1, 255, channels_transmit), (ip, 6454))
|
||||
await asyncio.sleep(0.02)
|
||||
framecount+=1
|
||||
sock.close()
|
||||
|
||||
17
pyproject.toml
Normal file
17
pyproject.toml
Normal file
@@ -0,0 +1,17 @@
|
||||
[tool.poetry]
|
||||
name = "moodconsole"
|
||||
version = "0.1.0"
|
||||
description = ""
|
||||
authors = ["Maximilian Güntner <code@mguentner.de>"]
|
||||
|
||||
[tool.poetry.dependencies]
|
||||
python = "^3.9"
|
||||
websockets = "^8.1"
|
||||
deepmerge = "^0.2.1"
|
||||
colormath = "^3.0.0"
|
||||
|
||||
[tool.poetry.dev-dependencies]
|
||||
|
||||
[build-system]
|
||||
requires = ["poetry-core>=1.0.0"]
|
||||
build-backend = "poetry.core.masonry.api"
|
||||
33
state.py
Normal file
33
state.py
Normal file
@@ -0,0 +1,33 @@
|
||||
import asyncio
|
||||
import copy
|
||||
from deepmerge import always_merger
|
||||
|
||||
STATE = {"initialized": 0}
|
||||
state_lock = asyncio.Lock()
|
||||
|
||||
NOTIFY_CALLBACKS = []
|
||||
|
||||
def register_callback(callback):
|
||||
global NOTIFY_CALLBACKS
|
||||
NOTIFY_CALLBACKS = NOTIFY_CALLBACKS + [callback]
|
||||
|
||||
def unregister_callback(callback):
|
||||
NOTIFY_CALLBACK = [ x for x in NOTIFY_CALLBACKS if x != callback ]
|
||||
|
||||
async def mutate(delta):
|
||||
global STATE
|
||||
async with state_lock:
|
||||
old_state = copy.deepcopy(STATE)
|
||||
STATE = always_merger.merge(STATE, delta)
|
||||
for callback in NOTIFY_CALLBACKS:
|
||||
await callback(old_state, STATE)
|
||||
|
||||
async def get_data():
|
||||
global STATE
|
||||
async with state_lock:
|
||||
return STATE
|
||||
|
||||
async def inc_initialized():
|
||||
global STATE
|
||||
async with state_lock:
|
||||
STATE["initialized"] += 1
|
||||
Reference in New Issue
Block a user