Skip to content

Commit

Permalink
Formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
loredan committed Mar 27, 2020
1 parent 60a26ad commit f2c3843
Show file tree
Hide file tree
Showing 16 changed files with 353 additions and 443 deletions.
3 changes: 3 additions & 0 deletions firmware/AVR-Source/Pyr0_Piezo_Sensor_v2.x.x/.clang-format
@@ -0,0 +1,3 @@
BasedOnStyle: LLVM
ColumnLimit: 200
AllowShortFunctionsOnASingleLine: false
@@ -1,7 +1,7 @@
{
// See http://go.microsoft.com/fwlink/?LinkId=827846
// for the documentation about the extensions.json format
"recommendations": [
"platformio.platformio-ide"
]
}
// See http://go.microsoft.com/fwlink/?LinkId=827846
// for the documentation about the extensions.json format
"recommendations": [
"platformio.platformio-ide"
]
}
28 changes: 12 additions & 16 deletions firmware/AVR-Source/Pyr0_Piezo_Sensor_v2.x.x/src/LightChrono.cpp
@@ -1,22 +1,22 @@
/*
* Lightweight chronometer class.
* Simple chronometer/stopwatch class that counts the time passed since started.
*
*
* (c) 2015 Sofian Audry :: info(@)sofianaudry(.)com
* (c) 2015 Thomas O Fredericks :: tof(@)t-o-f(.)info
*
* The MIT License (MIT)
*
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
Expand All @@ -32,24 +32,23 @@
#endif
#include "LightChrono.h"

LightChrono::LightChrono()
{
LightChrono::LightChrono() {
restart();
}

void LightChrono::start() { restart(); }
void LightChrono::start() {
restart();
}

void LightChrono::restart()
{
void LightChrono::restart() {
_startTime = millis();
}

LightChrono::chrono_t LightChrono::elapsed() const {
return (millis() - _startTime);
return (millis() - _startTime);
}

bool LightChrono::hasPassed(LightChrono::chrono_t timeout) const
{
bool LightChrono::hasPassed(LightChrono::chrono_t timeout) const {
return (elapsed() >= timeout);
}

Expand All @@ -58,10 +57,7 @@ bool LightChrono::hasPassed(LightChrono::chrono_t timeout, bool restartIfPassed)
if (restartIfPassed)
restart();
return true;
}
else {
} else {
return false;
}
}


13 changes: 5 additions & 8 deletions firmware/AVR-Source/Pyr0_Piezo_Sensor_v2.x.x/src/LightChrono.h
@@ -1,22 +1,22 @@
/*
* Lightweight chronometer class.
* Simple chronometer/stopwatch class that counts the time passed since started.
*
*
* (c) 2015 Sofian Audry :: info(@)sofianaudry(.)com
* (c) 2015 Thomas O Fredericks :: tof(@)t-o-f(.)info
*
* The MIT License (MIT)
*
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
Expand All @@ -39,8 +39,7 @@
* // do something
* // ...
*/
class LightChrono
{
class LightChrono {
public:
#if defined(ARDUINO_ARC32_TOOLS)
typedef uint64_t chrono_t;
Expand Down Expand Up @@ -68,5 +67,3 @@ class LightChrono
};

#endif


Expand Up @@ -85,39 +85,39 @@ update the voltMeterConstant variable in pP_config.h with the correct value
------------------------------------------------------------*/

// Headers, variables, and functions
#include <Arduino.h>
#include <EEPROM.h>
#include "LightChrono.h"
#include "pP_pins.h"
#include <Arduino.h>
#include <EEPROM.h>
// #include "pP_config.h"
#include "pP_volatile.h"
#include "pP_function.h"
#include "pP_serial.h"
#include "pP_volatile.h"

// i2c input toggle. Uncomment to enable
#define I2C_INPUT

void setup() {
//Setup PWM on voltage follower (PD3)
// Setup PWM on voltage follower (PD3)
TCCR2A = (1 << COM2B1) | (0 << COM2B0) | (0 << WGM21) | (1 << WGM20);
TCCR2B = (0 << WGM22) | (0 << CS22) | (0 << CS21) | (1 << CS20);
DDRD |= (1 << DDD3);

//Setup PWM on comparator (PB1)
// Setup PWM on comparator (PB1)
TCCR1A = (1 << COM1A1) | (0 << COM1A0) | (1 << WGM11) | (1 << WGM10);
TCCR1B = (0 << WGM13) | (0 << WGM12) | (0 << CS12) | (0 << CS11) | (1 << CS10);
DDRB |= (1 << DDB1);

pinMode(TRG_OUT, OUTPUT); // declare the Trigger as as OUTPUT
pinMode(TRG_OUT, OUTPUT); // declare the Trigger as as OUTPUT
pinMode(ERR_LED, OUTPUT);
pinMode(PZDET_PIN, INPUT_PULLUP);
pinMode(Z_TRG, INPUT_PULLUP); // declare z-sense input with pullup
pinMode(Z_TRG, INPUT_PULLUP); // declare z-sense input with pullup
pinMode(V_FOLLOW_PIN, INPUT);
pinMode(VCOMP_SENSE_PIN, INPUT);
pinMode(GADJ_R0, INPUT); // declare input to set high impedance
pinMode(GADJ_R1, INPUT); // declare input to set high impedance
pinMode(GADJ_R2, INPUT); // declare input to set high impedance
pinMode(GADJ_R3, INPUT); // declare input to set high impedance
pinMode(GADJ_R0, INPUT); // declare input to set high impedance
pinMode(GADJ_R1, INPUT); // declare input to set high impedance
pinMode(GADJ_R2, INPUT); // declare input to set high impedance
pinMode(GADJ_R3, INPUT); // declare input to set high impedance

attachInterrupt(digitalPinToInterrupt(Z_TRG), pulse, FALLING);

Expand All @@ -140,7 +140,7 @@ void loop() {
if (BlinkCount > 0) {
BlinkState = !BlinkState;
digitalWriteFast(ERR_LED, BlinkState);
//digitalWriteFast(TRG_OUT, BlinkState);
// digitalWriteFast(TRG_OUT, BlinkState);
--BlinkCount;
}

Expand All @@ -162,11 +162,11 @@ void loop() {

VLast = VOld - Vin;
if (VLast > Hyst || VLast < -Hyst) {
// Voltage Follower adjustment
// Voltage Follower adjustment
adjustFollow();
// Voltage Comparator adjustment
// Voltage Comparator adjustment
adjustComp();
// Alert the user that auto-calibration is ongoing
// Alert the user that auto-calibration is ongoing
ERR_STATE = 1;
} else {
ERR_STATE = 0;
Expand All @@ -179,11 +179,11 @@ void loop() {
if (BlinkCount > 0) {
BlinkState = !BlinkState;
digitalWriteFast(ERR_LED, BlinkState);
// digitalWriteFast(TRG_OUT, BlinkState);
// digitalWriteFast(TRG_OUT, BlinkState);
--BlinkCount;
// } else {
// } else {
// Check for error state
// checkError();
// checkError();
} else {
digitalWriteFast(ERR_LED, 0);
}
Expand All @@ -193,7 +193,7 @@ void loop() {
serialPrintState();
}
// Sets trigger output state to false after completing loop
//digitalWriteFast(TRG_OUT, HIGH);
// digitalWriteFast(TRG_OUT, HIGH);
sensorHReading = 0;
}
}

0 comments on commit f2c3843

Please sign in to comment.