Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2777da423e
|
No files matched your search
Generated
+61
@@ -0,0 +1,61 @@
|
|||||||
|
{
|
||||||
|
"nodes": {
|
||||||
|
"flake-schemas": {
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1780327564,
|
||||||
|
"narHash": "sha256-HiRPtA0spK+Dkgbhz/1zW9glXxNVB+L4Rj2VYmdawb8=",
|
||||||
|
"rev": "6cc9bd98891b1fc6bb2b8cb3277df8bc72799ca6",
|
||||||
|
"revCount": 149,
|
||||||
|
"type": "tarball",
|
||||||
|
"url": "https://api.flakehub.com/f/pinned/DeterminateSystems/flake-schemas/0.5.0/019e83cf-9af3-78b1-ac5b-70e68ad1efe1/source.tar.gz"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"type": "tarball",
|
||||||
|
"url": "https://flakehub.com/f/DeterminateSystems/flake-schemas/%2A.tar.gz"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"nixpkgs": {
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1794872590,
|
||||||
|
"narHash": "sha256-E+XLAfnC7+bdr4qlEgRv6cdGmiqTU5oeFNKCha7epqQ=",
|
||||||
|
"rev": "f68407657ad294471eb4b2e65d193df26edf729f",
|
||||||
|
"revCount": 1018921,
|
||||||
|
"type": "tarball",
|
||||||
|
"url": "https://api.flakehub.com/f/pinned/NixOS/nixpkgs/0.2605.1018921%2Brev-f68407657ad294471eb4b2e65d193df26edf729f/01a1ea95-6db4-7d02-8a1d-753f3849fe0e/source.tar.gz"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"type": "tarball",
|
||||||
|
"url": "https://flakehub.com/f/NixOS/nixpkgs/%2A.tar.gz"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"root": {
|
||||||
|
"inputs": {
|
||||||
|
"flake-schemas": "flake-schemas",
|
||||||
|
"nixpkgs": "nixpkgs",
|
||||||
|
"rust-overlay": "rust-overlay"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"rust-overlay": {
|
||||||
|
"inputs": {
|
||||||
|
"nixpkgs": [
|
||||||
|
"nixpkgs"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1795082704,
|
||||||
|
"narHash": "sha256-YK+6Nl8oR2Fhh3YO3DhBNCN7TmIGWw3tLhk25kfiWw4=",
|
||||||
|
"owner": "oxalica",
|
||||||
|
"repo": "rust-overlay",
|
||||||
|
"rev": "85d4adbbd952fcaf89fed3cb4ba540a4770d6e64",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "oxalica",
|
||||||
|
"repo": "rust-overlay",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"root": "root",
|
||||||
|
"version": 7
|
||||||
|
}
|
||||||
@@ -0,0 +1,71 @@
|
|||||||
|
{
|
||||||
|
description = "bleak";
|
||||||
|
|
||||||
|
# Flake inputs
|
||||||
|
inputs = {
|
||||||
|
flake-schemas.url = "https://flakehub.com/f/DeterminateSystems/flake-schemas/*.tar.gz";
|
||||||
|
nixpkgs.url = "https://flakehub.com/f/NixOS/nixpkgs/*.tar.gz";
|
||||||
|
rust-overlay = {
|
||||||
|
url = "github:oxalica/rust-overlay";
|
||||||
|
inputs.nixpkgs.follows = "nixpkgs";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
# Flake outputs that other flakes can use
|
||||||
|
outputs = {
|
||||||
|
self,
|
||||||
|
flake-schemas,
|
||||||
|
nixpkgs,
|
||||||
|
rust-overlay,
|
||||||
|
}: let
|
||||||
|
# Nixpkgs overlays
|
||||||
|
overlays = [
|
||||||
|
rust-overlay.overlays.default
|
||||||
|
(final: prev: {
|
||||||
|
rustToolchain = final.rust-bin.stable.latest.default.override {extensions = ["rust-src"];};
|
||||||
|
})
|
||||||
|
];
|
||||||
|
|
||||||
|
# Helpers for producing system-specific outputs
|
||||||
|
supportedSystems = ["x86_64-linux" "aarch64-darwin" "x86_64-darwin" "aarch64-linux"];
|
||||||
|
forEachSupportedSystem = f:
|
||||||
|
nixpkgs.lib.genAttrs supportedSystems (system:
|
||||||
|
f {
|
||||||
|
pkgs = import nixpkgs {inherit overlays system;};
|
||||||
|
});
|
||||||
|
in {
|
||||||
|
# Schemas tell Nix about the structure of your flake's outputs
|
||||||
|
schemas = flake-schemas.schemas;
|
||||||
|
|
||||||
|
# Development environments
|
||||||
|
devShells = forEachSupportedSystem ({pkgs}: {
|
||||||
|
default = pkgs.mkShell {
|
||||||
|
# Pinned packages available in the environment
|
||||||
|
packages = with pkgs; [
|
||||||
|
rustToolchain
|
||||||
|
rust-analyzer
|
||||||
|
curl
|
||||||
|
git
|
||||||
|
jq
|
||||||
|
wget
|
||||||
|
nixpkgs-fmt
|
||||||
|
openssl
|
||||||
|
openssl.dev
|
||||||
|
patchelf
|
||||||
|
cargo-watch
|
||||||
|
cargo-chef
|
||||||
|
pkg-config-unwrapped
|
||||||
|
];
|
||||||
|
|
||||||
|
# Environment variables
|
||||||
|
env = {
|
||||||
|
RUST_BACKTRACE = "1";
|
||||||
|
RUST_SRC_PATH = "${pkgs.rustToolchain}/lib/rustlib/src/rust/library";
|
||||||
|
PKG_CONFIG_PATH = "${pkgs.openssl.dev}/lib/pkgconfig";
|
||||||
|
# ZELLIJ_CONFIG_FILE = "config.kdl";
|
||||||
|
# PATH = "$PATH:$HOME/.local/share/nvim/mason/bin/deno";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
});
|
||||||
|
};
|
||||||
|
}
|
||||||
+62
-22
@@ -1,17 +1,36 @@
|
|||||||
// enum used when a certain TV app is being used
|
// enum used when a certain TV app is being used
|
||||||
#[warn(dead_code)]
|
#[warn(dead_code)]
|
||||||
pub enum ActiveApp {
|
pub enum ActiveApp {
|
||||||
Roku,
|
Roku(ActiveAppData),
|
||||||
Netflix,
|
Netflix(ActiveAppData),
|
||||||
Hulu,
|
Hulu(ActiveAppData),
|
||||||
AmazonPrime,
|
AmazonPrime(ActiveAppData),
|
||||||
Plex,
|
Plex(ActiveAppData),
|
||||||
Pandora,
|
Pandora(ActiveAppData),
|
||||||
Spotify,
|
Spotify(ActiveAppData),
|
||||||
Crunchyroll,
|
Crunchyroll(ActiveAppData),
|
||||||
Funimation,
|
Nothing,
|
||||||
VRV,
|
}
|
||||||
Nothing
|
|
||||||
|
pub struct ActiveAppData {
|
||||||
|
pub app_name: String,
|
||||||
|
pub rgb: [u8; 3],
|
||||||
|
}
|
||||||
|
|
||||||
|
impl ActiveApp {
|
||||||
|
pub fn data(&self) -> Option<&ActiveAppData> {
|
||||||
|
match self {
|
||||||
|
ActiveApp::Roku(data)
|
||||||
|
| ActiveApp::Netflix(data)
|
||||||
|
| ActiveApp::Hulu(data)
|
||||||
|
| ActiveApp::AmazonPrime(data)
|
||||||
|
| ActiveApp::Plex(data)
|
||||||
|
| ActiveApp::Pandora(data)
|
||||||
|
| ActiveApp::Spotify(data)
|
||||||
|
| ActiveApp::Crunchyroll(data) => Some(data),
|
||||||
|
ActiveApp::Nothing => None,
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// enum used to select what kind of TV you are using
|
// enum used to select what kind of TV you are using
|
||||||
@@ -33,17 +52,38 @@ pub fn match_to_app(text: String) -> ActiveApp {
|
|||||||
let mut result = text.split_whitespace();
|
let mut result = text.split_whitespace();
|
||||||
|
|
||||||
match result.next() {
|
match result.next() {
|
||||||
Some("Roku") => ActiveApp::Roku,
|
Some("Roku") => ActiveApp::Roku(ActiveAppData {
|
||||||
Some("Netflix") => ActiveApp::Netflix,
|
app_name: String::from("Roku"),
|
||||||
Some("Hulu") => ActiveApp::Hulu,
|
rgb: [255, 0, 255],
|
||||||
Some("Prime") => ActiveApp::AmazonPrime,
|
}),
|
||||||
Some("Plex") => ActiveApp::Plex,
|
Some("Netflix") => ActiveApp::Netflix(ActiveAppData {
|
||||||
Some("Pandora") => ActiveApp::Pandora,
|
app_name: String::from("Netflix"),
|
||||||
Some("Spotify") => ActiveApp::Spotify,
|
rgb: [255, 77, 77],
|
||||||
Some("Plex") => ActiveApp::Plex,
|
}),
|
||||||
Some("Crunchyroll") => ActiveApp::Crunchyroll,
|
Some("Hulu") => ActiveApp::Hulu(ActiveAppData {
|
||||||
Some("Funimation") => ActiveApp::Funimation,
|
app_name: String::from("Hulu"),
|
||||||
Some("VRV") => ActiveApp::VRV,
|
rgb: [51, 255, 85],
|
||||||
|
}),
|
||||||
|
Some("Prime") => ActiveApp::AmazonPrime(ActiveAppData {
|
||||||
|
app_name: String::from("Prime"),
|
||||||
|
rgb: [99, 193, 255],
|
||||||
|
}),
|
||||||
|
Some("Plex") => ActiveApp::Plex(ActiveAppData {
|
||||||
|
app_name: String::from("Plex"),
|
||||||
|
rgb: [255, 187, 51],
|
||||||
|
}),
|
||||||
|
Some("Pandora") => ActiveApp::Pandora(ActiveAppData {
|
||||||
|
app_name: String::from("Pandora"),
|
||||||
|
rgb: [99, 193, 255],
|
||||||
|
}),
|
||||||
|
Some("Spotify") => ActiveApp::Spotify(ActiveAppData {
|
||||||
|
app_name: String::from("Spotify"),
|
||||||
|
rgb: [51, 255, 85],
|
||||||
|
}),
|
||||||
|
Some("Crunchyroll") => ActiveApp::Crunchyroll(ActiveAppData {
|
||||||
|
app_name: String::from("Crunchyroll"),
|
||||||
|
rgb: [255, 187, 51],
|
||||||
|
}),
|
||||||
_ => ActiveApp::Nothing,
|
_ => ActiveApp::Nothing,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+16
-152
@@ -3,15 +3,15 @@ use std::{thread, time};
|
|||||||
|
|
||||||
// actual third party library being imported
|
// actual third party library being imported
|
||||||
use rppal::spi::{Bus, Mode, SlaveSelect, Spi};
|
use rppal::spi::{Bus, Mode, SlaveSelect, Spi};
|
||||||
use smart_leds::{RGB8, SmartLedsWrite, brightness};
|
use smart_leds::{brightness, SmartLedsWrite, RGB8};
|
||||||
use ws2812_spi::Ws2812;
|
use ws2812_spi::Ws2812;
|
||||||
|
|
||||||
// local files that need to be imported
|
// local files that need to be imported
|
||||||
mod app;
|
mod app;
|
||||||
mod config;
|
mod config;
|
||||||
mod generate;
|
mod generate;
|
||||||
mod request;
|
|
||||||
mod queue;
|
mod queue;
|
||||||
|
mod request;
|
||||||
|
|
||||||
const NUM_LEDS: usize = 150;
|
const NUM_LEDS: usize = 150;
|
||||||
|
|
||||||
@@ -44,10 +44,11 @@ fn main() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
queue.enqueue(data[i]);
|
queue.enqueue(data[i]);
|
||||||
ws.write(brightness(queue.queue.iter().cloned(), 32)).unwrap();
|
ws.write(brightness(queue.queue.iter().cloned(), 32))
|
||||||
|
.unwrap();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
|
||||||
app::TVPower::On => {
|
app::TVPower::On => {
|
||||||
if false == configuration.is_change_app() {
|
if false == configuration.is_change_app() {
|
||||||
is_headless = false;
|
is_headless = false;
|
||||||
@@ -56,161 +57,24 @@ fn main() {
|
|||||||
configuration.change_active_app(&app_text);
|
configuration.change_active_app(&app_text);
|
||||||
let activeapp = app::match_to_app(app_text);
|
let activeapp = app::match_to_app(app_text);
|
||||||
|
|
||||||
match activeapp {
|
if let Some(data) = activeapp.data() {
|
||||||
app::ActiveApp::Roku => {
|
let [red, green, blue] = data.rgb;
|
||||||
let color = RGB8::new(255, 0, 255);
|
let color = RGB8::new(red, green, blue);
|
||||||
let mut data = [RGB8::default(); NUM_LEDS];
|
|
||||||
|
|
||||||
for i in 0..NUM_LEDS {
|
for _ in 0..NUM_LEDS {
|
||||||
data[i] = color;
|
if queue.length() == NUM_LEDS {
|
||||||
|
|
||||||
if (queue.length() == NUM_LEDS) {
|
|
||||||
queue.dequeue();
|
queue.dequeue();
|
||||||
}
|
}
|
||||||
|
|
||||||
queue.enqueue(data[i]);
|
queue.enqueue(color);
|
||||||
ws.write(brightness(queue.queue.iter().cloned(), 32)).unwrap();
|
ws.write(brightness(queue.queue.iter().cloned(), 32))
|
||||||
|
.unwrap();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
println!("We don't know what app is running right now...");
|
||||||
}
|
}
|
||||||
},
|
|
||||||
app::ActiveApp::Hulu => {
|
|
||||||
let color = RGB8::new(51, 255, 85);
|
|
||||||
let mut data = [RGB8::default(); NUM_LEDS];
|
|
||||||
|
|
||||||
for i in 0..NUM_LEDS {
|
|
||||||
data[i] = color;
|
|
||||||
|
|
||||||
if (queue.length() == NUM_LEDS) {
|
|
||||||
queue.dequeue();
|
|
||||||
}
|
|
||||||
|
|
||||||
queue.enqueue(data[i]);
|
|
||||||
ws.write(brightness(queue.queue.iter().cloned(), 32)).unwrap();
|
|
||||||
}
|
|
||||||
},
|
|
||||||
app::ActiveApp::Netflix => {
|
|
||||||
let color = RGB8::new(255, 77, 77);
|
|
||||||
let mut data = [RGB8::default(); NUM_LEDS];
|
|
||||||
|
|
||||||
for i in 0..NUM_LEDS {
|
|
||||||
data[i] = color;
|
|
||||||
|
|
||||||
if (queue.length() == NUM_LEDS) {
|
|
||||||
queue.dequeue();
|
|
||||||
}
|
|
||||||
|
|
||||||
queue.enqueue(data[i]);
|
|
||||||
ws.write(brightness(queue.queue.iter().cloned(), 32)).unwrap();
|
|
||||||
}
|
|
||||||
},
|
|
||||||
app::ActiveApp::AmazonPrime => {
|
|
||||||
let color = RGB8::new(99, 193, 255);
|
|
||||||
let mut data = [RGB8::default(); NUM_LEDS];
|
|
||||||
|
|
||||||
for i in 0..NUM_LEDS {
|
|
||||||
data[i] = color;
|
|
||||||
|
|
||||||
if (queue.length() == NUM_LEDS) {
|
|
||||||
queue.dequeue();
|
|
||||||
}
|
|
||||||
|
|
||||||
queue.enqueue(data[i]);
|
|
||||||
ws.write(brightness(queue.queue.iter().cloned(), 32)).unwrap();
|
|
||||||
}
|
|
||||||
},
|
|
||||||
app::ActiveApp::Pandora => {
|
|
||||||
let color = RGB8::new(99, 123, 255);
|
|
||||||
let mut data = [RGB8::default(); NUM_LEDS];
|
|
||||||
|
|
||||||
for i in 0..NUM_LEDS {
|
|
||||||
data[i] = color;
|
|
||||||
|
|
||||||
if (queue.length() == NUM_LEDS) {
|
|
||||||
queue.dequeue();
|
|
||||||
}
|
|
||||||
|
|
||||||
queue.enqueue(data[i]);
|
|
||||||
ws.write(brightness(queue.queue.iter().cloned(), 32)).unwrap();
|
|
||||||
}
|
|
||||||
},
|
|
||||||
app::ActiveApp::Spotify => {
|
|
||||||
let color = RGB8::new(51, 255, 85);
|
|
||||||
let mut data = [RGB8::default(); NUM_LEDS];
|
|
||||||
|
|
||||||
for i in 0..NUM_LEDS {
|
|
||||||
data[i] = color;
|
|
||||||
|
|
||||||
if (queue.length() == NUM_LEDS) {
|
|
||||||
queue.dequeue();
|
|
||||||
}
|
|
||||||
|
|
||||||
queue.enqueue(data[i]);
|
|
||||||
ws.write(brightness(queue.queue.iter().cloned(), 32)).unwrap();
|
|
||||||
}
|
|
||||||
},
|
|
||||||
app::ActiveApp::Plex => {
|
|
||||||
let color = RGB8::new(255, 187, 51);
|
|
||||||
let mut data = [RGB8::default(); NUM_LEDS];
|
|
||||||
|
|
||||||
for i in 0..NUM_LEDS {
|
|
||||||
data[i] = color;
|
|
||||||
|
|
||||||
if (queue.length() == NUM_LEDS) {
|
|
||||||
queue.dequeue();
|
|
||||||
}
|
|
||||||
|
|
||||||
queue.enqueue(data[i]);
|
|
||||||
ws.write(brightness(queue.queue.iter().cloned(), 32)).unwrap();
|
|
||||||
}
|
|
||||||
},
|
|
||||||
app::ActiveApp::Crunchyroll => {
|
|
||||||
let color = RGB8::new(255, 187, 51);
|
|
||||||
let mut data = [RGB8::default(); NUM_LEDS];
|
|
||||||
|
|
||||||
for i in 0..NUM_LEDS {
|
|
||||||
data[i] = color;
|
|
||||||
|
|
||||||
if (queue.length() == NUM_LEDS) {
|
|
||||||
queue.dequeue();
|
|
||||||
}
|
|
||||||
|
|
||||||
queue.enqueue(data[i]);
|
|
||||||
ws.write(brightness(queue.queue.iter().cloned(), 32)).unwrap();
|
|
||||||
}
|
|
||||||
},
|
|
||||||
app::ActiveApp::Funimation => {
|
|
||||||
let color = RGB8::new(255, 0, 255);
|
|
||||||
let mut data = [RGB8::default(); NUM_LEDS];
|
|
||||||
|
|
||||||
for i in 0..NUM_LEDS {
|
|
||||||
data[i] = color;
|
|
||||||
|
|
||||||
if (queue.length() == NUM_LEDS) {
|
|
||||||
queue.dequeue();
|
|
||||||
}
|
|
||||||
|
|
||||||
queue.enqueue(data[i]);
|
|
||||||
ws.write(brightness(queue.queue.iter().cloned(), 32)).unwrap();
|
|
||||||
}
|
|
||||||
},
|
|
||||||
app::ActiveApp::VRV => {
|
|
||||||
let color = RGB8::new(255, 187, 51);
|
|
||||||
let mut data = [RGB8::default(); NUM_LEDS];
|
|
||||||
|
|
||||||
for i in 0..NUM_LEDS {
|
|
||||||
data[i] = color;
|
|
||||||
|
|
||||||
if (queue.length() == NUM_LEDS) {
|
|
||||||
queue.dequeue();
|
|
||||||
}
|
|
||||||
|
|
||||||
queue.enqueue(data[i]);
|
|
||||||
ws.write(brightness(queue.queue.iter().cloned(), 32)).unwrap();
|
|
||||||
}
|
|
||||||
},
|
|
||||||
_ => println!("We don't know what app is running right now..."),
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
|
||||||
}
|
}
|
||||||
|
|
||||||
let sec = time::Duration::from_secs(1);
|
let sec = time::Duration::from_secs(1);
|
||||||
|
|||||||
Reference in new issue
Block a user