Code Monkey home page Code Monkey logo

awtrix.js's Introduction

Awtrix

Awtrix in JavaScript

https://awtrixdocs.blueforcer.de/#/en-en/api

Install

~$ npm i awtrix --save

Command-line Usage

~$ npm i -g awtrix
~$ export AWTRIX_API=https://awtrix.lsong.me/api/v3
~$ awtrix

  awtrix 0.0.0

  Usage: awtrix <command>

  Commands:

  get_settings
  set <key> <value>
  brightness <value>
  notify <text>
  draw <array>

  Examples:

  awtrix get_settings
  awtrix set Brightness 50
  awtrix brightness 50
  awtrix notify "Hello World"

Example

const Awtrix = require('awtrix');

const awtrix = new Awtrix({
  api: 'https://awtrix.lsong.me/api/v3',
});

get settings:

(async () => {
  const settings = await awtrix.get_settings();
  console.log(settings);
})();

set brightness:

(async () => {
  await awtrix.brightness(50);
})();

notify:

(async () => {
  await awtrix.notify('hello');
})();

draw:

(async () => {

  const show = new Awtrix.Show();
  const wait = new Awtrix.Wait(1000);
  const clear = new Awtrix.Clear();
  const fill = new Awtrix.Fill(50, 50, 50);
  const text = new Awtrix.Text('Hello World');
  text.position = new Awtrix.Position(4, 1);
  text.color = new Awtrix.Color(255, 0, 0);

  const circle = new Awtrix.Circle(3);
  circle.position = new Awtrix.Position(4, 4);
  circle.color = new Awtrix.Color(255, 0, 255);

  const rect = new Awtrix.Rect(5, 5);
  rect.position = new Awtrix.Position(24, 2);
  rect.color = new Awtrix.Color(0, 0, 255);


  const line = new Awtrix.Line();
  line.start = new Awtrix.Position(0, 0);
  line.end = new Awtrix.Position(10, 10);
  line.color = new Awtrix.Color(255, 0, 0);

  const exit = new Awtrix.Exit();

  await awtrix.draw([
    fill,
    text,
    show,
    wait,
    circle,
    show,
    wait,
    rect,
    show,
    wait,
    clear,
    line,
    show,
    wait,
    exit,

  ]);
})();

License

MIT @ Lsong [email protected]

awtrix.js's People

Contributors

lsongdev avatar

Stargazers

 avatar

Watchers

 avatar  avatar

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.