Coder Social home page Coder Social logo

curioustauseef / mobius Goto Github PK

View Code? Open in Web Editor NEW

This project forked from rubaxa/mobius

0.0 0.0 0.0 548 KB

Möbius — Experimental OOP/C++ framework for Arduino. Event-driven architecture, Maximum abstraction, Visual effects and etc.

Home Page: http://rubaxa.github.io/Mobius/

C++ 88.92% Makefile 1.56% HTML 9.52%

mobius's Introduction

Möbius

Features

  • Event-driven architecture
  • Maximum abstraction
  • Demonstrativeness and ease of assembly
  • Visual effects
  • No delays!

 

 

 

 

 


A very simple example ([SEE ALL] (https://github.com/RubaXa/Mobius/wiki/))

See http://youtu.be/Y4l9nhQlWT0

#include <Mobius.h>

using namespace Mobius;

LED *led = new LED(10);
LED::Array *indicator = LED::Array::range(2, 9);

Power *power = new Power(500); // duration, ms
Button *btn = new Button(11);

void setup() {
	led->setEffect(new Effects::Blink(500));

	power->attach(indicator);
	btn->attach(power);

	power->bind(Power::PROGRESS, &handleEvent);
}

void handleEvent(int id) {
	switch (id) {
		case Power::VALUE:
			if (power->value == 1) {
				led->on();
			} else if (led->value) {
				led->off();
			}
			break;
	}
}

void loop() {
	Mobius::strip();
}

Using motor

#include <Mobius.h>

using namespace Mobius;

Button *btn = new Button(2);
Motor *motor = new Motor(3, 4);
Power *acceleration = new Power(1000);

void setup() {
	motor->setDirection(Motor::CW);
	acceleration->attach(motor);
	btn->attach(acceleration);
}

void loop() {
	Mobius::strip();
}

Сomponents


LED

  • on() — turn on (1)
  • off() — turn off (0)
  • setValue(float value) — set brightness 0..1
  • getValue() — get brightness 0..1
  • setEffect(Effects::Effect *effect)
byte pin = 13;
LED *led = new Led(pin);

// Add fade effect
led->setEffect(new Effects::Fade(500, 300)); // 500ms — fadeIn, 300ms - fadeOut

// Or blinking effect
led->setEffect(new Effects::Blink(150)); // 150ms — interval between blinks

// Turn on
led->on();

LED::Array

byte startPin = 2;
byte endPin = 12;
LED::Array *bar = LED::Array::range(startPin, endPin);

// Turn on
bar->on();

// Enable only half
bar->setValue(0.5);

Button

  • pressed:bool — state true or false
  • attach(Pin *pin)
  • bind(int eventId, void *callback(int)) — add event listener: Button::DOWN or Button::UP
byte pin = 10;
Button *btn = new Button(pin);

// Turn on LED by pressing the button
btn->attach(new LED(13));

// Add event listener
btn->bind(Button::DOWN, &handleEvent);

Power

Power *power = new Power(3000); // 3000ms — 0 to 1
Button *btn = new Button(13);

power->attach(LED::Array::range(1, 10));
btn->attach(power);

Motor

Support L298N.

Motor *motor = new Motor(2, 3);

motor->setSpeed(1); // max
motor->setSpeed(0); // stop

motor->setDirection(Motor::CW); // OR `Motor::CCW`

Sensor::Ultrasonic

Support HC-SR04.

Sensor::Ultrasonic *sonar = new Sensor::Ultrasonic(2, 3);

// Subscribe to the change in distance
sonar->bind(Sensor::Ultrasonic::DISTANCE, &handleEvent);

// Current distance
sonar->value; // cm

Installation

  1. Download the Arduino Software
  2. Run IDE
  3. Clone this repository: [email protected]:RubaXa/Mobius.git
  4. cd Mobius
  5. make all (Create a Mobius.zip)
  6. IDE: [Sketch] > [Include Library] -> [Add .ZIP Library]
  7. Enjoy!
#include <Mobius.h>

using namespace Mobius;

// Variables

void setup() {
	// Logic
}

void loop() {
	Mobius::strip();
}

MIT LICENSE

mobius's People

Contributors

rubaxa 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.