GithubHelp home page GithubHelp logo

internet-button-playground's Introduction

Internet Button Playground

The repository contains code used to create Internet Button projects.

Projects

This repository is structure to hold multiple project that can switched between buttons.

Five Thirty Eight Election Odds Displayer:

This project from 2016 illuminated the LEDs at random. Each time an LED turned on it had a variable percentage chance of being blue or red.

Gif of internet button illuminating LEDs in sequence in blue or red.

Watch this YouTube Video from @fauxalgore for a full explanation.

The source code used in this video is in button_fte.

GitHub Status Reporter

This project displays the commit statuses of the default branch of a set of repos.

Picture of internet button

The LEDs light up after button 2 is pressed.

A looping gif showing the button light up after button 2 is pressed. It turns off after button 1 is pressed.

It only takes one or two seconds but a lot happens in that time. There are six main steps.

1. The button sends an event to the Particle Cloud

The firmware at button/src/IbOmni.ino publishes many events to the Particle Cloud. This event, the pressing of button 2, has a Particle webhook connected to it.

Diagram 0

The Particle Cloud is pre-configured to hit a Google Cloud Function

The Particle Cloud can GET or POST to arbitrary URLs in response to events. The URL in this case is a Google Cloud function. The JavaScript code for the Google Cloud Function is stored in gcp-serverless/ci-status-reporter.

Diagram 1

Hitting the GitHub GraphQL API to search for the commit statuses

The JavaScript running on Google Cloud (stored in gcp-serverless/ci-status-reporter) then uses the graphql-got library to ask GitHub for the respostory statuses.

Diagram 2

GraphQL responds with deeply nested JSON

The response from GitHub looks something like this (but with 11 nodes instead of 1):

{
  "search": {
    "edges": [
      {
        "node": {
          "nameWithOwner": "stevector/nerdologues-d8",
          "defaultBranchRef": {
            "target": {
              "status": {
                "state": "SUCCESS"
              }
            }
          }
        }
      }
    ]
  }
}

Diagram 3

The response is flattened and sent back to the Particle Cloud

The Google Cloud Function uses got to send a POST to https://api.particle.io/v1/devices/' + deviceId + '/circleCi'. In that URL deviceId is a unique identifier for the button to be illuminated and circleCi is the name of the function to call on the button. The body of the POST contains the a pattern like g,r,g,g,g,g,g,g,g,g,g, to be parsed by the button.

Diagram 4

The Particle Cloud calls a function on the button

The function circleCi parses the string of comma-separated rs and gs.

Diagram 5

internet-button-playground's People

Contributors

stevector avatar fauxalgore avatar

Stargazers

 avatar Taylor D. Edmiston avatar

Watchers

 avatar James Cloos avatar  avatar

internet-button-playground's Issues

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.