Code Monkey home page Code Monkey logo

timemachine_xmastree's Introduction

Time Machine - Xmas Tree

GitHub release (latest by date) GitHub All Releases GitHub Github Arduino Library CI

XmasTree is an Arduino library used to emulate Back to the Future's Time Machine XmasTree in a 1.3inch I2C OLED monochrome display.

This library is used to emulate the lightings of the Back to the Future Delorean Time Machine XmasTree, to place it on a scale model car.

If you like XmasTree, give it a star, or fork it and contribute!

donate

Installation

  1. Navigate to the Releases page.
  2. Download the latest release.
  3. In the Arduino IDE, navigate to Sketch > Include Library > Add .ZIP Library

How it works

XmasTree uses a a 1.3inch I2C OLED monochrome display.has 13 LED lights. XmasTree displays a 10 x 20 5-pixel square matrix. Each matrix column displays random values, depending on the level it is at. There are eigth "speed levels". Each level has different random values ranges for each xmas column. Levels goes from level 1 to level 8. When the xmas is off, it is on level 0. When the xmas is turned on, it is set to level 1.

image info

Note: It is the responsibility of the user to generate the code that changes levels at desired time.

Usage

#include <XmasTree.h> // Add include to XmasTree.h

using namespace bttf::timemachine; // Add using namespace

// XmasTree declaration
XmasTree tree; // create an object called: tree. (No parameters are required)

/**
 * Variable created for the purposes of this example
 * it is used to execute some task in 5 seconds loop.
 */
unsigned long _previousExecutionMillis = 0;

void setup() {

    tree.init();  // [REQUIRED] ALWAYS call init() method on setup()

}

void loop() {

    // Check Xmas state
    // If it is OFF (state == false) then turn it on.
    if (!tree.state()) {
        tree.on();  // XmasTree ON
    }

    // Enter every 5 seconds
    if (millis() >= _previousExecutionMillis + 5000) {
        _previousExecutionMillis += 5000;

        // if tree level is 8, then turn it off
        if (tree.level() == 8) {
            tree.off();    // Tree is turned OFF
        }

        // set Xmas Tree to next level
        tree.next();
    }

    // Call tree.loop() ALWAYS in the end of sketch loop().
    tree.loop();
}

Components and functions

XmasTree Class

Example

XmasTree tree; // create an object called: tree. (No parameters are required).

Public methods

Method Description
XmasTree tree(); Constructor.
.init(); Initialize XmasTree, it should run always in setup() section.
.on(); Turns on XmasTree (It is set to Level 1).
.off(); Turns off XmasTree.
.setLevel(byte level); Set XmasTree level (1-8).
.next(); Set XmasTree to next level.
.level(); Returns the current XmasTree level (1-8).
.state(); Returns the current bool state of XmasTree. returns False when it is turned OFF and returns True when it is turned On.
.loop(); function used to manage concurrent actions. It should be ALWAYS added in the end of sketch loop() method.

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

donate

License

This library is licensed under GPLv3.

timemachine_xmastree's People

Contributors

zerfoinder avatar

Stargazers

 avatar

Watchers

 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.