Code comments/formatting #docs

This commit is contained in:
pyr0ball 2020-05-09 12:24:03 -07:00
parent 3b46a42023
commit 7086002db5
4 changed files with 15 additions and 40 deletions

View file

@ -22,6 +22,7 @@ void updateVFol(int value) {
EEPROM.put(FOLLOWER_THRESHOLD_ADDRESS, followerThrs); EEPROM.put(FOLLOWER_THRESHOLD_ADDRESS, followerThrs);
} }
} }
/*------------------------------------------------*/ /*------------------------------------------------*/
void updateVComp(int value) { void updateVComp(int value) {
@ -40,6 +41,7 @@ void updateLoopDuration(int value) {
EEPROM.put(LOOP_DUR_ADDRESS, LOOP_DUR); EEPROM.put(LOOP_DUR_ADDRESS, LOOP_DUR);
} }
} }
/*------------------------------------------------*/ /*------------------------------------------------*/
void updateTrigDuration(int value) { void updateTrigDuration(int value) {
@ -48,6 +50,7 @@ void updateTrigDuration(int value) {
EEPROM.put(TRG_DUR_ADDRESS, TRG_DUR); EEPROM.put(TRG_DUR_ADDRESS, TRG_DUR);
} }
} }
/*------------------------------------------------*/ /*------------------------------------------------*/
void updateHysteresis(int value) { void updateHysteresis(int value) {
@ -56,6 +59,7 @@ void updateHysteresis(int value) {
EEPROM.put(HYST_ADDRESS, Hyst); EEPROM.put(HYST_ADDRESS, Hyst);
} }
} }
/*------------------------------------------------*/ /*------------------------------------------------*/
void updateLogic(int value) { void updateLogic(int value) {
@ -65,6 +69,7 @@ void updateLogic(int value) {
pulse(); pulse();
} }
} }
/*------------------------------------------------*/ /*------------------------------------------------*/
void updatePzDet(int value) { void updatePzDet(int value) {
@ -73,6 +78,7 @@ void updatePzDet(int value) {
EEPROM.put(PZDET_ADDRESS, PZDET); EEPROM.put(PZDET_ADDRESS, PZDET);
} }
} }
/*------------------------------------------------*/ /*------------------------------------------------*/
void updateVccSwitch(int value) { void updateVccSwitch(int value) {
@ -82,6 +88,8 @@ void updateVccSwitch(int value) {
} }
} }
/*------------------------------------------------*/
void updateConstant(long value) { void updateConstant(long value) {
if (value >= 0) { if (value >= 0) {
voltMeterConstant = value; voltMeterConstant = value;
@ -89,6 +97,8 @@ void updateConstant(long value) {
} }
} }
/*------------------------------------------------*/
void adjustConstant(int value) { void adjustConstant(int value) {
if (value > 0 && Vin > 0) { if (value > 0 && Vin > 0) {
voltMeterConstant = (long)(1.1 * value / Vin * 1023 * 1000); voltMeterConstant = (long)(1.1 * value / Vin * 1023 * 1000);

View file

@ -16,6 +16,7 @@ long voltMeterConstant = VM_CONST_DEFAULT;
uint8_t pP_i2c_address = 0x10; uint8_t pP_i2c_address = 0x10;
/*------------------------------------------------*/ /*------------------------------------------------*/
void eraseEEPROM() { void eraseEEPROM() {
setDefaultConfig(); setDefaultConfig();
@ -32,6 +33,8 @@ void eraseEEPROM() {
EEPROM.put(VM_CONST_ADDRESS, voltMeterConstant); EEPROM.put(VM_CONST_ADDRESS, voltMeterConstant);
} }
/*------------------------------------------------*/
// Restore config from EEPROM, otherwise erase config and write to EEPROM // Restore config from EEPROM, otherwise erase config and write to EEPROM
void restoreConfig() { void restoreConfig() {
int temp; int temp;
@ -117,6 +120,8 @@ void restoreConfig() {
adjustComp(); adjustComp();
} }
/*------------------------------------------------*/
void setDefaultConfig() { void setDefaultConfig() {
GAIN_FACTOR = GAIN_FACTOR_DEFAULT; GAIN_FACTOR = GAIN_FACTOR_DEFAULT;
followerThrs = FOLLOWER_THRESHOLD_DEFAULT; followerThrs = FOLLOWER_THRESHOLD_DEFAULT;

View file

@ -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() { void pzConCheck() {
PZ_STATE = digitalRead(PZDET_PIN); PZ_STATE = digitalRead(PZDET_PIN);
if (PZ_STATE == PZDET) { if (PZ_STATE == PZDET) {

View file

@ -16,39 +16,12 @@ int analogReadFast(uint8_t ADCpin);
void doubleFlash(); void doubleFlash();
void pulse(); void pulse();
long readVcc(); 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 readVin();
void adjustFollow(); void adjustFollow();
void adjustComp(); void adjustComp();
void adjustVcc(); void adjustVcc();
void calibrateAlert(); void calibrateAlert();
void adjustGain(); 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(); void pzConCheck();
#endif // PP_FUNCTION_H #endif // PP_FUNCTION_H