Giter Site home page Giter Site logo

l1ght-str1p's Introduction

L1ght-Str1p


Codeship Status for moonthug/l1ght-str1p

The light strip in my lounge.

Features

  • Runs on a Raspberry Pi Zero
  • CI/CD integration
  • Plugin interface
  • IOT (Homekit) compatibility

Weather Example

import axios, { AxiosResponse } from 'axios';
import { Canvas } from '../Canvas';
import { Scene } from './Scene';

interface WeatherData {
  error?: boolean;
  type?: string;
}

interface OpenWeatherMapResponse {
  weather: [
    {
      main: string;
      description: string;
    }
  ];
}

export const scene: Scene<WeatherData> = {
  data: {
    type: ''
  },
  setup (canvas: Canvas) {
    axios('http://api.openweathermap.org/data/2.5/weather?q=<LOCATION>&appid=<APP_ID>')
      .then((response: AxiosResponse<OpenWeatherMapResponse>) => {
        scene.data = {
          error: false,
          type: response.data.weather[0].main
        };
      })
      .catch((e) => {
        console.log(e);
        scene.data = {
          error: true
        };
      });
  },
  draw (canvas, frame) {
    const { error, type } = scene.data;

    canvas.clear();

    if (type === 'Rain') {
      canvas.gradient(0, canvas.getLength(), [0, 50, 255], [0, 128, 255]);
    } else if (type === 'Clouds') {
      canvas.fill([50, 50, 50]);
    } else {
      canvas.fill([0, 0, 0]);
    }

    if (error) {
      canvas.fill([255, 0, 0]);
    }
  }
};

Debug Mode

Add the following environment variable(s) to enable debug mode. It is already included in the start:dev npm script

DEBUG=1

# Optional
FORCE_COLOR=3 # Enable colour regardless of the terminal (see https://github.com/chalk/chalk#chalksupportscolor)

Debug Mode

l1ght-str1p's People

Watchers

 avatar James Cloos 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.