-
Notifications
You must be signed in to change notification settings - Fork 174
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
134 changed files
with
6,123 additions
and
3,783 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,2 @@ | ||
.pio | ||
.vscode/.browse.c_cpp.db* | ||
.vscode/c_cpp_properties.json | ||
.vscode/launch.json | ||
.vscode/ipch | ||
.vscode |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,88 +1,88 @@ | ||
|
||
// Please read Bounce.h for information about the liscence and authors | ||
|
||
#include <Arduino.h> | ||
#include "Bounce.h" | ||
|
||
|
||
Bounce::Bounce(uint8_t pin,unsigned long interval_millis) | ||
{ | ||
interval(interval_millis); | ||
previous_millis = millis(); | ||
state = digitalRead(pin); | ||
this->pin = pin; | ||
} | ||
|
||
|
||
void Bounce::write(int new_state) | ||
{ | ||
this->state = new_state; | ||
digitalWrite(pin,state); | ||
} | ||
|
||
|
||
void Bounce::interval(unsigned long interval_millis) | ||
{ | ||
this->interval_millis = interval_millis; | ||
this->rebounce_millis = 0; | ||
} | ||
|
||
void Bounce::rebounce(unsigned long interval) | ||
{ | ||
this->rebounce_millis = interval; | ||
} | ||
|
||
|
||
|
||
int Bounce::update() | ||
{ | ||
if ( debounce() ) { | ||
rebounce(0); | ||
return stateChanged = 1; | ||
} | ||
|
||
// We need to rebounce, so simulate a state change | ||
|
||
if ( rebounce_millis && (millis() - previous_millis >= rebounce_millis) ) { | ||
previous_millis = millis(); | ||
rebounce(0); | ||
return stateChanged = 1; | ||
} | ||
|
||
return stateChanged = 0; | ||
} | ||
|
||
|
||
unsigned long Bounce::duration() | ||
{ | ||
return millis() - previous_millis; | ||
} | ||
|
||
|
||
int Bounce::read() | ||
{ | ||
return (int)state; | ||
} | ||
|
||
|
||
// Protected: debounces the pin | ||
int Bounce::debounce() { | ||
|
||
uint8_t newState = digitalRead(pin); | ||
if (state != newState ) { | ||
if (millis() - previous_millis >= interval_millis) { | ||
previous_millis = millis(); | ||
state = newState; | ||
return 1; | ||
} | ||
} | ||
|
||
return 0; | ||
|
||
} | ||
|
||
// The risingEdge method is true for one scan after the de-bounced input goes from off-to-on. | ||
bool Bounce::risingEdge() { return stateChanged && state; } | ||
// The fallingEdge method it true for one scan after the de-bounced input goes from on-to-off. | ||
bool Bounce::fallingEdge() { return stateChanged && !state; } | ||
|
||
|
||
// Please read Bounce.h for information about the liscence and authors | ||
|
||
#include <Arduino.h> | ||
#include "Bounce.h" | ||
|
||
|
||
Bounce::Bounce(uint8_t pin,unsigned long interval_millis) | ||
{ | ||
interval(interval_millis); | ||
previous_millis = millis(); | ||
state = digitalRead(pin); | ||
this->pin = pin; | ||
} | ||
|
||
|
||
void Bounce::write(int new_state) | ||
{ | ||
this->state = new_state; | ||
digitalWrite(pin,state); | ||
} | ||
|
||
|
||
void Bounce::interval(unsigned long interval_millis) | ||
{ | ||
this->interval_millis = interval_millis; | ||
this->rebounce_millis = 0; | ||
} | ||
|
||
void Bounce::rebounce(unsigned long interval) | ||
{ | ||
this->rebounce_millis = interval; | ||
} | ||
|
||
|
||
|
||
int Bounce::update() | ||
{ | ||
if ( debounce() ) { | ||
rebounce(0); | ||
return stateChanged = 1; | ||
} | ||
|
||
// We need to rebounce, so simulate a state change | ||
|
||
if ( rebounce_millis && (millis() - previous_millis >= rebounce_millis) ) { | ||
previous_millis = millis(); | ||
rebounce(0); | ||
return stateChanged = 1; | ||
} | ||
|
||
return stateChanged = 0; | ||
} | ||
|
||
|
||
unsigned long Bounce::duration() | ||
{ | ||
return millis() - previous_millis; | ||
} | ||
|
||
|
||
int Bounce::read() | ||
{ | ||
return (int)state; | ||
} | ||
|
||
|
||
// Protected: debounces the pin | ||
int Bounce::debounce() { | ||
|
||
uint8_t newState = digitalRead(pin); | ||
if (state != newState ) { | ||
if (millis() - previous_millis >= interval_millis) { | ||
previous_millis = millis(); | ||
state = newState; | ||
return 1; | ||
} | ||
} | ||
|
||
return 0; | ||
|
||
} | ||
|
||
// The risingEdge method is true for one scan after the de-bounced input goes from off-to-on. | ||
bool Bounce::risingEdge() { return stateChanged && state; } | ||
// The fallingEdge method it true for one scan after the de-bounced input goes from on-to-off. | ||
bool Bounce::fallingEdge() { return stateChanged && !state; } | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,40 +1 @@ | ||
#include <Arduino.h> | ||
#include <EEPROM.h> | ||
|
||
// put - Specialization for Arduino Strings ------------------------------- | ||
// to put an Arduino String to the EEPROM we copy its internal buffer | ||
// including the trailing \0 to the eprom | ||
|
||
template <> | ||
const String &EEPROMClass::put(int idx, const String &s) | ||
{ | ||
const uint8_t *ptr = (uint8_t *)s.c_str(); | ||
|
||
#ifdef __arm__ | ||
eeprom_write_block(ptr, (void *)idx, s.length() + 1); // length() doesn't account for the trailing \0 | ||
#else | ||
EEPtr e = idx; | ||
for (int count = s.length() + 1; count; --count, ++e) | ||
(*e).update(*ptr++); | ||
#endif | ||
return s; | ||
} | ||
|
||
// get - Specialization for Arduino Strings ------------------------------- | ||
// to "get" an Arduino String from the EEPROM we append chars from the EEPROM | ||
// into it until we find the delimiting /0. | ||
// String.append is not very efficient, code could probably be opitimized if required... | ||
|
||
template <> | ||
String &EEPROMClass::get(int idx, String &s){ | ||
s = ""; // just in case... | ||
EEPtr e = idx; | ||
|
||
char c = *e; // read in bytes until we find the terminating \0 | ||
while (c != '\0') { | ||
s.append(c); | ||
c = *(++e); | ||
} | ||
return s; | ||
} | ||
|
||
// this file no longer used |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.