From 7086002db535978ebb8bbd9deb0b0a25816f8a55 Mon Sep 17 00:00:00 2001 From: pyr0ball Date: Sat, 9 May 2020 12:24:03 -0700 Subject: [PATCH] Code comments/formatting #docs --- .../Pyr0_Piezo_Sensor_v2.x.x/src/pP_cmd.cpp | 10 +++++++ .../src/pP_config.cpp | 5 ++++ .../src/pP_function.cpp | 13 --------- .../src/pP_function.h | 27 ------------------- 4 files changed, 15 insertions(+), 40 deletions(-) diff --git a/firmware/AVR-Source/Pyr0_Piezo_Sensor_v2.x.x/src/pP_cmd.cpp b/firmware/AVR-Source/Pyr0_Piezo_Sensor_v2.x.x/src/pP_cmd.cpp index 856e6db..3284c1b 100644 --- a/firmware/AVR-Source/Pyr0_Piezo_Sensor_v2.x.x/src/pP_cmd.cpp +++ b/firmware/AVR-Source/Pyr0_Piezo_Sensor_v2.x.x/src/pP_cmd.cpp @@ -22,6 +22,7 @@ void updateVFol(int value) { EEPROM.put(FOLLOWER_THRESHOLD_ADDRESS, followerThrs); } } + /*------------------------------------------------*/ void updateVComp(int value) { @@ -40,6 +41,7 @@ void updateLoopDuration(int value) { EEPROM.put(LOOP_DUR_ADDRESS, LOOP_DUR); } } + /*------------------------------------------------*/ void updateTrigDuration(int value) { @@ -48,6 +50,7 @@ void updateTrigDuration(int value) { EEPROM.put(TRG_DUR_ADDRESS, TRG_DUR); } } + /*------------------------------------------------*/ void updateHysteresis(int value) { @@ -56,6 +59,7 @@ void updateHysteresis(int value) { EEPROM.put(HYST_ADDRESS, Hyst); } } + /*------------------------------------------------*/ void updateLogic(int value) { @@ -65,6 +69,7 @@ void updateLogic(int value) { pulse(); } } + /*------------------------------------------------*/ void updatePzDet(int value) { @@ -73,6 +78,7 @@ void updatePzDet(int value) { EEPROM.put(PZDET_ADDRESS, PZDET); } } + /*------------------------------------------------*/ void updateVccSwitch(int value) { @@ -82,6 +88,8 @@ void updateVccSwitch(int value) { } } +/*------------------------------------------------*/ + void updateConstant(long value) { if (value >= 0) { voltMeterConstant = value; @@ -89,6 +97,8 @@ void updateConstant(long value) { } } +/*------------------------------------------------*/ + void adjustConstant(int value) { if (value > 0 && Vin > 0) { voltMeterConstant = (long)(1.1 * value / Vin * 1023 * 1000); diff --git a/firmware/AVR-Source/Pyr0_Piezo_Sensor_v2.x.x/src/pP_config.cpp b/firmware/AVR-Source/Pyr0_Piezo_Sensor_v2.x.x/src/pP_config.cpp index 87e7be6..b681de5 100644 --- a/firmware/AVR-Source/Pyr0_Piezo_Sensor_v2.x.x/src/pP_config.cpp +++ b/firmware/AVR-Source/Pyr0_Piezo_Sensor_v2.x.x/src/pP_config.cpp @@ -16,6 +16,7 @@ long voltMeterConstant = VM_CONST_DEFAULT; uint8_t pP_i2c_address = 0x10; /*------------------------------------------------*/ + void eraseEEPROM() { setDefaultConfig(); @@ -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; @@ -117,6 +120,8 @@ void restoreConfig() { adjustComp(); } +/*------------------------------------------------*/ + void setDefaultConfig() { GAIN_FACTOR = GAIN_FACTOR_DEFAULT; followerThrs = FOLLOWER_THRESHOLD_DEFAULT; diff --git a/firmware/AVR-Source/Pyr0_Piezo_Sensor_v2.x.x/src/pP_function.cpp b/firmware/AVR-Source/Pyr0_Piezo_Sensor_v2.x.x/src/pP_function.cpp index 2f84907..288efe1 100644 --- a/firmware/AVR-Source/Pyr0_Piezo_Sensor_v2.x.x/src/pP_function.cpp +++ b/firmware/AVR-Source/Pyr0_Piezo_Sensor_v2.x.x/src/pP_function.cpp @@ -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) { diff --git a/firmware/AVR-Source/Pyr0_Piezo_Sensor_v2.x.x/src/pP_function.h b/firmware/AVR-Source/Pyr0_Piezo_Sensor_v2.x.x/src/pP_function.h index e442aae..9abc4f8 100644 --- a/firmware/AVR-Source/Pyr0_Piezo_Sensor_v2.x.x/src/pP_function.h +++ b/firmware/AVR-Source/Pyr0_Piezo_Sensor_v2.x.x/src/pP_function.h @@ -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 \ No newline at end of file