-
-
Notifications
You must be signed in to change notification settings - Fork 3
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
2 changed files
with
54 additions
and
1 deletion.
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,53 @@ | ||
import PixelBox from "../PixelBox.js" | ||
import Pixel from "../Pixel.js" | ||
import Scheduler from "../Scheduler.js" | ||
import Color from "../Color.js" | ||
import ControlGroup from "../ControlGroup.js" | ||
import Animator from "../Animator.js" | ||
import mqtt from "mqtt" | ||
import DrawCounter from "../draw/DrawCounter.js" | ||
import Marquee from "./Text/Marquee.js" | ||
import DrawBox from "../draw/DrawBox.js" | ||
import {colorBlack, colorRed} from "../Colors.js" | ||
|
||
|
||
export default class Template extends Animator { | ||
|
||
async run(box: PixelBox, scheduler: Scheduler, controls: ControlGroup) { | ||
|
||
const mqttHost = controls.input('MQTT host', 'mqtt://mqtt.why2025.org') | ||
const mqttTopic = controls.input('MQTT topic', 'why2025/ticketshop/quotas/Event Visitors/paid_orders') | ||
const digitCount=controls.value('Digits', 4) | ||
|
||
const xPad=8 | ||
const marquee=new Marquee() | ||
const counterX=box.xMax-(digitCount.value*7)-5 | ||
|
||
let marqueeBox=new PixelBox(box) | ||
box.add(marqueeBox) | ||
|
||
marquee.run(marqueeBox, scheduler, controls.group("Marquee")) | ||
|
||
|
||
box.add(new DrawBox(counterX-3, 0, box.xMax-counterX+xPad, box.height(), colorBlack )) | ||
|
||
|
||
let counter = new DrawCounter() | ||
counter.run(scheduler, controls,counterX , 0, 4, 0.001) | ||
box.add(counter) | ||
|
||
const mqttClient = mqtt.connect(mqttHost.text) | ||
|
||
mqttClient.on('connect', () => { | ||
console.log(`MQTT: ${mqttHost.text} connected`) | ||
|
||
mqttClient.subscribe(mqttTopic.text) | ||
}) | ||
|
||
mqttClient.on('message', async (topic, messageBuf) => { | ||
let message = messageBuf.toString() | ||
console.log("MQTT:", message) | ||
counter.update(message) | ||
}) | ||
} | ||
} |
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