Skip to content
/ Mobius Public

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

Notifications You must be signed in to change notification settings

RubaXa/Mobius

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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: git@github.com: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

About

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

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published