Giter Club home page Giter Club logo

dashd's Introduction

DashD

Lightweight daemon for Raspberry Pi driven kiosks

Features

  • software control for screen buttons (power, source, menu, plus, minus)
  • lighting integration with Artemis-RGB (UDP and HTTP support)
  • website display using Chromium based browser
  • control via HTTP server

Display

On startup DashD will create a browser window with the specified position and size, which can be changed later over HTTP. If the window is closed, DashD will exit.

CLI Flag Default Unit
display_enabled true Bool
browser_path "/usr/bin/chromium-browser" String (Path)
default_url String (URL)
window_x 0 UInt (Pixel)
window_y 0 UInt (Pixel)
window_width 1920 UInt (Pixel)
window_height 1080 UInt (Pixel)

Lighting

DashD can drive a single addressable LED strip with WS281X LEDs (any GRB LEDs should work). On most Raspberry Pi GPIO 12, 18, 40, and 52 can be used for connecting the data line of the LED strip. However if you are using Model B+, 2B or 3B only GPIO 12 and 18 are supported due to a hardware limitation.

CLI Flag Default Unit
lighting_enabled true Bool
ledstrip_pin 18 UInt (GPIO)
ledstrip_length 100 UInt (Count)

Screen

DashD virtualizes the buttons of the screen, so they can be remote controlled via the HTTP server. The GPIOs should be connected to transistors in a way that a high output corresponds to pressing down the button.

CLI Flag Default Unit
screen_enabled true Bool
power_pin 17 UInt (GPIO)
source_pin 24 UInt (GPIO)
menu_pin 27 UInt (GPIO)
plus_pin 22 UInt (GPIO)
minus_pin 23 UInt (GPIO)

Server

On startup DashD will start a HTTP server on the specified port, which serves a basic web interface. It allows the user to change the website shown, move and resize the window, configure the lighting and press the virtual screen buttons, if those modules are enabled.

CLI Flag Default Unit
server_enabled true Bool
server_port 80 UInt (Port)

Socket

DashD will listen for UDP packets on the specified port, which can be used to control the lighting with Artemis-RGB or any compatible program that supports the Artemis Lighting Protocol. If lighting is disabled, this module will be disabled.

CLI Flag Default Unit
socket_enabled true Bool
socket_port 1872 UInt (Port)

Installation

Download the latest release from GitHub Releases for your platform. Then run the following commands in the directory where you downloaded DashD:

sudo apt-get update
sudo apt-get install chromium-browser
sudo mv DashD.* /usr/local/sbin/dashd
sudo chmod +x /usr/local/sbin/dashd

Usage

One possible way to use DashD is to run it on startup with systemd and xinit as basic display manager. To use this configuration install xinit like so:

sudo apt-get update
sudo apt-get install xserver-xorg xfonts-base xinit

Then put the following in /etc/X11/xinit/xinitrc:

#!/bin/bash

xhost +

/usr/local/sbin/dashd &> /var/log/dashd.log

Make a new systemd unit for xinit at /etc/systemd/system/xinit.service with this content:

[Unit]
Description=Xinit display manager using startx

[Service]
Type=simple
ExecStart=/usr/bin/startx -- -nocursor
Restart=always

[Install]
Alias=display-manager.service

Finally enable the service, switch to the graphical target and reboot. The logs will be put in /var/log/DashD.log.

sudo systemctl enable xinit.service
sudo systemctl set-default graphical.target
sudo reboot

Building

DashD utilizes Docker to cross-compile for the Raspberry Pi. The Dockerfile in this repository creates an image that can be used to build DashD. To build the docker image run docker build -t dashd_builder:arm32 -f Dockerfile.arm32 . in the root directory of this repository. Then run docker run --rm --volume $(pwd):/dashd/app dashd_builder:arm32 to build DashD for 32-bit. The binary is located at build/DashD.arm32. Replace arm32 with arm64 in the previous commands to build for 64-bit.

HTTP API

The endpoints ignore the HTTP method used, however POST is recommended for all, except / and /config, which should be used with GET.

Endpoint Description Parameters Parameter Description
/ Get the web interface
/display Set the website to be displayed url the URL of the website as a percent-encoded string
data URLs are also supported
/move Set the window position posX
posY
the x position in pixel
the y position in pixel
/resize Set the window size width
height
the width in pixel
the height in pixel
/config Get the LED count in JSON (Artemis API)
/update Set colors of LED strip (Artemis API) base64 a UDP packet (described below) as a base64 encoded string
name is not enforced; must be the first parameter
/reset Set all LEDs to black (Artemis API)
/power Toggle the power button
/source Toggle the source button
/menu Toggle the menu button
/plus Toggle the plus button
/minus Toggle the minus button

UDP Lighting Protocol

Each UDP packet contains a single frame of lighting data. The first byte is the sequence number which is used for basic packet ordering and must be incremented with each request. The second byte is the channel number which is ignored by DashD because it supports only a single channel. The remaining packet consists of byte triplets which represent the RGB value in that order. The number of byte triplets does not need to be equal to the number of LEDs. Any extra bytes are ignored and LEDs not contained in the packet retain their color. To calculate the length of a packet that sets all LEDs use: 2 + (leds * 3).

License

DashD - Lightweight daemon for Raspberry Pi driven kiosks
Copyright (C) 2022 Elias*

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see https://www.gnu.org/licenses/.

dashd's People

Contributors

eliasstar avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar  avatar

dashd's Issues

Set temporary display

Description
Expose another http endpoint for temporary displaying a URL for given amount of seconds and then it goes back to the previously displayed URL.

Possible Solutions
Expose endpoint /display_temporary with get params url and 'duration'. The duration param gets integer value specifying the duration of seconds. After these number of seconds are passed, it loads the previously loaded URL, the one before the /display_temporary request occurred.

Additional Context
This feature would be very useful in cases like:

  • Show a camera feed on doorbell ring.
  • Show CCTV perimeter cameras on security alarm trigger.

After some time passes, displays return to their previously displayed page.

Unable to init server: Could not connect: Connection refused

Description
When /usr/local/sbin/dashd is executed I get the following error:

sudo /usr/local/sbin/dashd -lighting_enabled=false -screen_enabled=false -default_url="http://192.168.80.100:7878/"
[Display] Starting.
[Server] Starting.
[Server] Listening on: 80
Unable to init server: Could not connect: Connection refused
fatal error: unexpected signal during runtime execution
[signal SIGSEGV: segmentation violation code=0x1 addr=0x8 pc=0x5fb950]

runtime stack:
runtime.throw({0x675bb7?, 0xffff70003d70?})
        /usr/local/go/src/runtime/panic.go:992 +0x50
runtime.sigpanic()
        /usr/local/go/src/runtime/signal_unix.go:802 +0x1e8

goroutine 34 [syscall]:
runtime.cgocall(0x5fb454, 0x4000030ee8)
        /usr/local/go/src/runtime/cgocall.go:157 +0x54 fp=0x4000030eb0 sp=0x4000030e70 pc=0x4086b4
github.com/webview/webview._Cfunc_webview_set_title(0x0, 0xffff70003d70)
        _cgo_gotypes.go:277 +0x38 fp=0x4000030ee0 sp=0x4000030eb0 pc=0x4da3b8
github.com/webview/webview.(*webview).SetTitle.func2(0xffff70003d70?, 0x5?)
        /go/pkg/mod/github.com/webview/[email protected]/webview.go:180 +0x54 fp=0x4000030f20 sp=0x4000030ee0 pc=0x4dab64
github.com/webview/webview.(*webview).SetTitle(0x0?, {0x6680f9?, 0x0?})
        /go/pkg/mod/github.com/webview/[email protected]/webview.go:180 +0x58 fp=0x4000030f60 sp=0x4000030f20 pc=0x4daab8
github.com/EliasStar/DashD/display.Init.func1()
        /dashd/app/display/display.go:20 +0xe4 fp=0x4000030fd0 sp=0x4000030f60 pc=0x4db884
runtime.goexit()
        /usr/local/go/src/runtime/asm_arm64.s:1263 +0x4 fp=0x4000030fd0 sp=0x4000030fd0 pc=0x467be4
created by github.com/EliasStar/DashD/display.Init
        /dashd/app/display/display.go:17 +0xc0

goroutine 1 [chan receive, locked to thread]:
main.main()
        /dashd/app/main.go:44 +0x300

goroutine 5 [syscall]:
os/signal.signal_recv()
        /usr/local/go/src/runtime/sigqueue.go:151 +0x34
os/signal.loop()
        /usr/local/go/src/os/signal/signal_unix.go:23 +0x20
created by os/signal.Notify.func1.1
        /usr/local/go/src/os/signal/signal.go:151 +0x30

goroutine 35 [IO wait]:
internal/poll.runtime_pollWait(0xffff862e8ee8, 0x72)
        /usr/local/go/src/runtime/netpoll.go:302 +0xa4
internal/poll.(*pollDesc).wait(0x4000188000?, 0x648c20?, 0x0)
        /usr/local/go/src/internal/poll/fd_poll_runtime.go:83 +0x2c
internal/poll.(*pollDesc).waitRead(...)
        /usr/local/go/src/internal/poll/fd_poll_runtime.go:88
internal/poll.(*FD).Accept(0x4000188000)
        /usr/local/go/src/internal/poll/fd_unix.go:614 +0x1d8
net.(*netFD).accept(0x4000188000)
        /usr/local/go/src/net/fd_unix.go:172 +0x28
net.(*TCPListener).accept(0x40000a6150)
        /usr/local/go/src/net/tcpsock_posix.go:139 +0x2c
net.(*TCPListener).Accept(0x40000a6150)
        /usr/local/go/src/net/tcpsock.go:288 +0x30
net/http.(*Server).Serve(0x86a540, {0x6dffd8, 0x40000a6150})
        /usr/local/go/src/net/http/server.go:3039 +0x300
net/http.(*Server).ListenAndServe(0x86a540)
        /usr/local/go/src/net/http/server.go:2968 +0x88
github.com/EliasStar/DashD/server.Listen(0x0?, 0x0?)
        /dashd/app/server/server.go:53 +0xe4
created by main.main
        /dashd/app/main.go:42 +0x2ec

From what I understand, this issue could be because of multithreaded CPU. Go runs the http on another goroutine.
This is a thread with more info: golang/go#26698

How To Reproduce
Just run on a multithreaded CPU.

About DashD

The DashD project seems exactly what I'm looking for to put on my armbian boards around my home and turn them into proper kiosks. I'm really excited about the HTTP control (make a request to a particular display to load a web page). However I have no idea how to use the DashD binary. There's no documentation available. I tried to wild guess it, but so far unsuccessfully. Can you please provide such information in the README, plus an example? Really, really thank you!

Do we need a full-blown Gnome?

Do we need a full-blown Gnome? I'm trying to setup DashD on Armbian without GUI. I see that we can use xX.Org Server for a window manager. I'm unable to install gtk-3 however on the Debian Bullseye Armbian (it says there's no such package). Can you please state minimum software requirements?

Blank screen on webkit2gtk-4.0 versions above 2.32

Description
When running it I get a blank screen and this error on the terminal:
Overriding existing handler for signal 10. Set JSC_SIGNAL_FOR_GC if you want WebKit to use a different signal

This error seems to be a because of a bug in webkit2gtk-4.0 versions above 2.32. The current version is 2.36.3.

I tried to understand how to workaround it and got here - a fix in Wails for exactly this issue:
wailsapp/wails@e015517

And here is the thread: wailsapp/wails#658

How To Reproduce
apt-get install webkit2gtk-4.0 (install latest version, e.g. currently that is 2.36.3-1)

Expected Behavior
Show the webpage

Actual Behavior
Blank screen

Make features disableable

Description
image

How To Reproduce

Run sudo /usr/local/sbin/dashd on non-raspberry arm board and no ws2811 hardware.

Any way we can disable Lighting if it's not used?

arm64 build

Description
Can we have an arm64 build?

Possible Solutions
GOARCH=arm64

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.