GithubHelp home page GithubHelp logo

adammoses-github / pixlet Goto Github PK

View Code? Open in Web Editor NEW

This project forked from tidbyt/pixlet

0.0 0.0 0.0 23.72 MB

Build apps for pixel-based displays ✨<AMFORK>

Home Page: https://tidbyt.com

License: Apache License 2.0

Shell 1.16% JavaScript 9.01% Go 88.18% CSS 0.30% Makefile 0.21% HTML 0.56% Starlark 0.59%

pixlet's Introduction

Pixlet

Docs Build & test Discourse Discord Server GoDoc

Pixlet is an app runtime and UX toolkit for highly-constrained displays. We use Pixlet to develop applets for Tidbyt, which has a 64x32 RGB LED matrix display:

Example of a Tidbyt

Apps developed with Pixlet can be served in a browser, rendered as WebP or GIF animations, or pushed to a physical Tidbyt device.

Documentation

Hey! We have a new docs site! Check it out at tidbyt.dev. We'll be updating this repo in the coming weeks.

Getting started

Install on macOS

brew install tidbyt/tidbyt/pixlet

Install on Linux

Download the pixlet binary from the latest release.

Alternatively you can build from source.

Hello, World!

Pixlet applets are written in a simple, Python-like language called Starlark. Here's the venerable Hello World program:

load("render.star", "render")
def main():
    return render.Root(
        child = render.Text("Hello, World!")
    )

Render and serve it with:

curl https://raw.githubusercontent.com/tidbyt/pixlet/main/examples/hello_world.star | \
  pixlet serve /dev/stdin

You can view the result by navigating to http://localhost:8080:

How it works

Pixlet scripts are written in a simple, Python-like language called Starlark. The scripts can retrieve data over HTTP, transform it and use a collection of Widgets to describe how the data should be presented visually.

The Pixlet CLI runs these scripts and renders the result as a WebP or GIF animation. You can view the animation in your browser, save it, or even push it to a Tidbyt device with pixlet push.

Example: A Clock App

This applet accepts a timezone parameter and produces a two frame animation displaying the current time with a blinking ':' separator between the hour and minute components.

load("render.star", "render")
load("time.star", "time")

def main(config):
    timezone = config.get("timezone") or "America/New_York"
    now = time.now().in_location(timezone)

    return render.Root(
        delay = 500,
        child = render.Box(
            child = render.Animation(
                children = [
                    render.Text(
                        content = now.format("3:04 PM"),
                        font = "6x13",
                    ),
                    render.Text(
                        content = now.format("3 04 PM"),
                        font = "6x13",
                    ),
                ],
            ),
        ),
    )

Here's the resulting image:

Example: A Bitcoin Tracker

Applets can get information from external data sources. For example, here is a Bitcoin price tracker:

Read the in-depth tutorial to learn how to make an applet like this.

Push to a Tidbyt

If you have a Tidbyt, pixlet can push apps directly to it. For example, to show the Bitcoin tracker on your Tidbyt:

# render the bitcoin example
pixlet render examples/bitcoin.star

# login to your Tidbyt account
pixlet login

# list available Tidbyt devices
pixlet devices

# push to your favorite Tidbyt
pixlet push <YOUR DEVICE ID> examples/bitcoin.webp

To get the ID for a device, run pixlet devices. Alternatively, you can open the settings for the device in the Tidbyt app on your phone, and tap Get API key.

If all goes well, you should see the Bitcoin tracker appear on your Tidbyt:

Push as an Installation

Pushing an applet to your Tidbyt without an installation ID simply displays your applet one time. If you would like your applet to continously display as part of the rotation, add an installation ID to the push command:

pixlet render examples/bitcoin.star
pixlet push --installation-id <INSTALLATION ID> <YOUR DEVICE ID> examples/bitcoin.webp

For example, if we set the installationID to "Bitcoin", it would appear in the mobile app as follows:

Note: pixlet render executes your Starlark code and generates a WebP image. pixlet push deploys the generated WebP image to your device. You'll need to repeat this process if you want to keep the app updated. You can also create Community Apps that run on Tidbyt’s servers and update automatically.

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.