Skip to content

Commit

Permalink
Updated Device Firmware to 3.0.3
Browse files Browse the repository at this point in the history
  • Loading branch information
maxritter committed May 7, 2023
1 parent ba78c70 commit 8d114cd
Show file tree
Hide file tree
Showing 134 changed files with 6,123 additions and 3,783 deletions.
5 changes: 1 addition & 4 deletions firmware/3.0/.gitignore
100644 → 100755
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
7 changes: 0 additions & 7 deletions firmware/3.0/.vscode/extensions.json

This file was deleted.

7 changes: 0 additions & 7 deletions firmware/3.0/.vscode/settings.json

This file was deleted.

2 changes: 1 addition & 1 deletion firmware/3.0/lib/ADC/AnalogBufferDMA.cpp
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ void AnalogBufferDMA::init(ADC *adc, int8_t adc_num)
_dmachannel_adc.enable();

adc->startContinuous(adc_num);
adc->enableDMA(adc_num);
adc->adc[adc_num]->enableDMA();
#ifdef DEBUG_DUMP_DATA
dumpDMA_TCD(&_dmachannel_adc);
#endif
Expand Down
176 changes: 88 additions & 88 deletions firmware/3.0/lib/Bounce/Bounce.cpp
100644 → 100755
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; }

41 changes: 1 addition & 40 deletions firmware/3.0/lib/EEPROM/EEPROM.cpp
100644 → 100755
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
42 changes: 41 additions & 1 deletion firmware/3.0/lib/EEPROM/EEPROM.h
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
#include <type_traits>
#endif

#include <WString.h> // need to include this so String is defined

/***
EERef class.
Expand Down Expand Up @@ -149,7 +150,7 @@ struct EEPROMClass{

template< typename T > const T &put( int idx, const T &t ){
#if defined(__has_include) && __has_include(<type_traits>)
static_assert(std::is_trivially_copyable<T>::value, "You can not use this type with EEPROM.get"); // the code below only makes sense if you can "memcpy" T
static_assert(std::is_trivially_copyable<T>::value, "You can not use this type with EEPROM.put"); // the code below only makes sense if you can "memcpy" T
#endif
const uint8_t *ptr = (const uint8_t*) &t;
#ifdef __arm__
Expand All @@ -163,5 +164,44 @@ struct EEPROMClass{
};


// 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 <>
inline 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 <>
inline 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;
}


static EEPROMClass EEPROM __attribute__ ((unused));
#endif
Loading

0 comments on commit 8d114cd

Please sign in to comment.