Ret_M v1.0

master
Joaquin Villalba 2018-10-18 03:38:17 -03:00 committed by GitHub
parent 35e8d6c65b
commit a341696029
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 94 additions and 0 deletions

2
KEYWORDS.txt Normal file
View File

@ -0,0 +1,2 @@
Ret_M KEYWORD1
ret KEYWORD2

9
README.md Normal file
View File

@ -0,0 +1,9 @@
Ret_M Arduino Library
===========================================
Small simple library to simplify applying delays utilizing the millis() function.
Ideal for time sensitive projects, debouncing, or for those who want to avoid utilizing delay(), delayMicroseconds(), or other of the kind that halts the program.
### Usage
- Include Ret_M.h: #include "Ret_M.h"
- Initialize a delay: Ret_M name(interval)
- name.ret() returns true if the interval has passed.

27
Ret_M.cpp Normal file
View File

@ -0,0 +1,27 @@
/*
Ret_M.cpp - Version 1.0
Library for a delay method without
the delay() function and no actual delays.
Created by Carlos Joaquin Villalba, October 18, 2018.
Released under GNU GPLv3.
*/
#include "Arduino.h"
#include "Ret_M.h"
Ret_M::Ret_M(long intervalo)
{
_intervalo = intervalo;
}
bool Ret_M::ret()
{
if ((millis() - _millis_ant) >= _intervalo)
{
_millis_ant = millis();
return true;
}
else{
return false;
}
}

24
Ret_M.h Normal file
View File

@ -0,0 +1,24 @@
/*
Ret_M.h - Version 1.0
Library for a delay method without
the delay() function and no actual delays.
Created by Carlos Joaquin Villalba, October 18, 2018.
Released under GNU GPLv3.
*/
#ifndef Ret_M_h
#define Ret_M_h
#include "Arduino.h"
class Ret_M
{
public:
Ret_M(long intervalo);
bool ret();
private:
unsigned long _millis_ant;
long _intervalo;
};
#endif

View File

@ -0,0 +1,23 @@
// Example demonstrating the capabilities of using Ret_M instead of regular delays
// By Carlos Joaquin Villalba, 18 October 2018
// Makes the built-in led blink in intervals of 500 miliseconds
#include "Ret_M.h" //We include the library
//We declare the delay (miliseconds):
Ret_M d1(500); // 500 miliseconds
bool state; // Variable used to change the state of the LED
void setup() {
pinMode(LED_BUILTIN, OUTPUT); // Built-in LED pin as output
}
void loop() {
// If the interval has passed,
// invert the value of "state"
// and use its value to light the LED
if (d1.ret() == true){
state = !state;
digitalWrite(13,state);
}
}

9
library.properties Normal file
View File

@ -0,0 +1,9 @@
name=Ret_M delay millis library
version=1.0
author=Carlos Joaquin Villalba
maintainer=https://github.com/Dragonop
sentence=Arduino library for easy implementation of delays without pauses
paragraph= Delays utilizing the millis function, for use in time sensitive programs or to avoid pauses in the program
category=Timing
url=https://github.com/Dragonop/Ret_M
architectures=*