Skip to content

Commit

Permalink
Code comments/formatting #docs
Browse files Browse the repository at this point in the history
  • Loading branch information
pyr0ball committed May 9, 2020
1 parent 3b46a42 commit 7086002
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 40 deletions.
10 changes: 10 additions & 0 deletions firmware/AVR-Source/Pyr0_Piezo_Sensor_v2.x.x/src/pP_cmd.cpp
Expand Up @@ -22,6 +22,7 @@ void updateVFol(int value) {
EEPROM.put(FOLLOWER_THRESHOLD_ADDRESS, followerThrs);
}
}

/*------------------------------------------------*/

void updateVComp(int value) {
Expand All @@ -40,6 +41,7 @@ void updateLoopDuration(int value) {
EEPROM.put(LOOP_DUR_ADDRESS, LOOP_DUR);
}
}

/*------------------------------------------------*/

void updateTrigDuration(int value) {
Expand All @@ -48,6 +50,7 @@ void updateTrigDuration(int value) {
EEPROM.put(TRG_DUR_ADDRESS, TRG_DUR);
}
}

/*------------------------------------------------*/

void updateHysteresis(int value) {
Expand All @@ -56,6 +59,7 @@ void updateHysteresis(int value) {
EEPROM.put(HYST_ADDRESS, Hyst);
}
}

/*------------------------------------------------*/

void updateLogic(int value) {
Expand All @@ -65,6 +69,7 @@ void updateLogic(int value) {
pulse();
}
}

/*------------------------------------------------*/

void updatePzDet(int value) {
Expand All @@ -73,6 +78,7 @@ void updatePzDet(int value) {
EEPROM.put(PZDET_ADDRESS, PZDET);
}
}

/*------------------------------------------------*/

void updateVccSwitch(int value) {
Expand All @@ -82,13 +88,17 @@ void updateVccSwitch(int value) {
}
}

/*------------------------------------------------*/

void updateConstant(long value) {
if (value >= 0) {
voltMeterConstant = value;
EEPROM.put(VM_CONST_ADDRESS, voltMeterConstant);
}
}

/*------------------------------------------------*/

void adjustConstant(int value) {
if (value > 0 && Vin > 0) {
voltMeterConstant = (long)(1.1 * value / Vin * 1023 * 1000);
Expand Down
Expand Up @@ -16,6 +16,7 @@ long voltMeterConstant = VM_CONST_DEFAULT;
uint8_t pP_i2c_address = 0x10;

/*------------------------------------------------*/

void eraseEEPROM() {

setDefaultConfig();
Expand All @@ -32,6 +33,8 @@ void eraseEEPROM() {
EEPROM.put(VM_CONST_ADDRESS, voltMeterConstant);
}

/*------------------------------------------------*/

// Restore config from EEPROM, otherwise erase config and write to EEPROM
void restoreConfig() {
int temp;
Expand Down Expand Up @@ -117,6 +120,8 @@ void restoreConfig() {
adjustComp();
}

/*------------------------------------------------*/

void setDefaultConfig() {
GAIN_FACTOR = GAIN_FACTOR_DEFAULT;
followerThrs = FOLLOWER_THRESHOLD_DEFAULT;
Expand Down
13 changes: 0 additions & 13 deletions firmware/AVR-Source/Pyr0_Piezo_Sensor_v2.x.x/src/pP_function.cpp
Expand Up @@ -192,19 +192,6 @@ void adjustVcc() {

/*------------------------------------------------*/

// void checkError () {
// if (ERR_STATE == 1) {
// digitalWriteFast(ERR_LED, BlinkState);
// BlinkState = !BlinkState;
// }
// else if (ERR_STATE == 0) {
// BlinkState = LOW;
// digitalWriteFast(ERR_LED, BlinkState);
// }
//}

/*------------------------------------------------*/

void pzConCheck() {
PZ_STATE = digitalRead(PZDET_PIN);
if (PZ_STATE == PZDET) {
Expand Down
27 changes: 0 additions & 27 deletions firmware/AVR-Source/Pyr0_Piezo_Sensor_v2.x.x/src/pP_function.h
Expand Up @@ -16,39 +16,12 @@ int analogReadFast(uint8_t ADCpin);
void doubleFlash();
void pulse();
long readVcc();

/*-------------------------------------------------
The above function assumes an "ideal" multiplier constant.
Each Atmega chip is slightly different, so it won't be completely accurate
without tuning. Most of the time this won't be necessary, so don't mess
with this if you don't know what you're doing!
The reading can be fine-tuned by using a multimeter, and this equation:
scale_constant = internal1.1Ref * 1023 * 1000
where
internal1.1Ref = 1.1 * Vcc1 (per voltmeter) / Vcc2 (per readVcc() function)
If the scale_constant calculated is different from the default 1125300,
update the voltMeterConstant variable in pP_config.h with the correct value
--------------------------------------------------*/
void readVin();
void adjustFollow();
void adjustComp();
void adjustVcc();
void calibrateAlert();
void adjustGain();
// void checkError () {
// if (ERR_STATE == 1) {
// digitalWriteFast(ERR_LED, BlinkState);
// BlinkState = !BlinkState;
// }
// else if (ERR_STATE == 0) {
// BlinkState = LOW;
// digitalWriteFast(ERR_LED, BlinkState);
// }
//}
void pzConCheck();

#endif // PP_FUNCTION_H

0 comments on commit 7086002

Please sign in to comment.