From 4f3558b79198da40932a678d410cca57b1e0d801 Mon Sep 17 00:00:00 2001 From: pyr0ball Date: Tue, 12 Nov 2019 17:51:25 -0800 Subject: [PATCH 1/3] removed file that shouldn't be tracked --- .../.vscode/c_cpp_properties.json | 23 ------------------- 1 file changed, 23 deletions(-) delete mode 100644 firmware/AVR-Source/Pyr0_Piezo_Sensor_v2.x.x/.vscode/c_cpp_properties.json diff --git a/firmware/AVR-Source/Pyr0_Piezo_Sensor_v2.x.x/.vscode/c_cpp_properties.json b/firmware/AVR-Source/Pyr0_Piezo_Sensor_v2.x.x/.vscode/c_cpp_properties.json deleted file mode 100644 index cea90cc..0000000 --- a/firmware/AVR-Source/Pyr0_Piezo_Sensor_v2.x.x/.vscode/c_cpp_properties.json +++ /dev/null @@ -1,23 +0,0 @@ -{ - "configurations": [ - { - "name": "Win32", - "includePath": [ - "${HOME}\\AppData\\Local\\Arduino15\\packages\\MiniCore\\hardware\\avr\\2.0.3\\**", - "${workspaceFolder}\\**", - "D:\\Arduino\\**" - ], - "defines": [ - "_DEBUG", - "UNICODE", - "_UNICODE" - ], - "compilerPath": "C:\\Program Files\\LLVM\\bin\\clang.exe", - "cStandard": "c11", - "cppStandard": "c++17", - "intelliSenseMode": "clang-x64", - "forcedInclude": [] - } - ], - "version": 4 -} \ No newline at end of file From bc2de746b469d2f04452b55baafd523cc7e335da Mon Sep 17 00:00:00 2001 From: pyr0ball Date: Tue, 12 Nov 2019 18:19:54 -0800 Subject: [PATCH 2/3] slight edit to platformio.ini, added dependencies --- .../Pyr0_Piezo_Sensor_v2.x.x/platformio.ini | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/firmware/AVR-Source/Pyr0_Piezo_Sensor_v2.x.x/platformio.ini b/firmware/AVR-Source/Pyr0_Piezo_Sensor_v2.x.x/platformio.ini index e6e49ba..715165e 100644 --- a/firmware/AVR-Source/Pyr0_Piezo_Sensor_v2.x.x/platformio.ini +++ b/firmware/AVR-Source/Pyr0_Piezo_Sensor_v2.x.x/platformio.ini @@ -8,19 +8,24 @@ ; Please visit documentation for the other options and examples ; https://docs.platformio.org/page/projectconf.html +[platformio] +default_envs = ATmega328PB + [env:ATmega88P] platform = atmelavr board = ATmega88P framework = arduino +lib_deps = Arduino upload_protocol = stk500v1 ; each flag in a new line upload_flags = -P$UPLOAD_PORT -b$UPLOAD_SPEED + -fmax_errors=5 ; edit these lines -upload_port = COM4 -upload_speed = 19200 +; upload_port = COM4 +upload_speed = 38400 board_build.f_cpu = 8000000L board_fuses.lfuse = "0xE2" @@ -31,14 +36,16 @@ board_fuses.efuse = "0xF9" platform = atmelavr board = ATmega328PB framework = arduino +lib_deps = Arduino upload_protocol = stk500v1 ; each flag in a new line upload_flags = -P$UPLOAD_PORT -b$UPLOAD_SPEED + -fmax_errors=5 ; edit these lines -upload_port = COM4 -upload_speed = 19200 +;upload_port = COM4 +upload_speed = 38400 board_build.f_cpu = 8000000L \ No newline at end of file From 5b8c409c109954ea520e5c1e6de9c1f0834889c2 Mon Sep 17 00:00:00 2001 From: pyr0ball Date: Tue, 12 Nov 2019 18:25:14 -0800 Subject: [PATCH 3/3] Adds support for inverting trigger logic. #featureadd - Addresses #61 --- .../Pyr0_Piezo_Sensor_v2.x.x/src/pP_config.cpp | 10 ++++++++++ .../Pyr0_Piezo_Sensor_v2.x.x/src/pP_config.h | 12 +++++++++--- .../Pyr0_Piezo_Sensor_v2.x.x/src/pP_function.h | 4 ++-- .../Pyr0_Piezo_Sensor_v2.x.x/src/pP_volatile.h | 2 +- 4 files changed, 22 insertions(+), 6 deletions(-) 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 98edefe..d5a67d4 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 @@ -7,6 +7,7 @@ int compThrs = COMP_THRESHOLD_DEFAULT; int LOOP_DUR = LOOP_DUR_DEFAULT; // duration of time between ADC checks and other loop functions int TRG_DUR = TRG_DUR_DEFAULT; // duration of the Z-axis pulse sent, in ms int Hyst = HYST_DEFAULT; // Hysteresis value for ADC measurements +bool LOGIC = LOGIC_DEFAULT; // Trigger output logic (active low or active high) int Debug = 0; long voltMeterConstant = VM_CONST_DEFAULT; uint8_t pP_i2c_address = 0xa0; @@ -21,6 +22,7 @@ void eraseEEPROM() { EEPROM.put(LOOP_DUR_ADDRESS, LOOP_DUR); EEPROM.put(TRG_DUR_ADDRESS, TRG_DUR); EEPROM.put(HYST_ADDRESS, Hyst); + EEPROM.put(LOGIC_ADDRESS, LOGIC); EEPROM.put(VM_CONST_ADDRESS, voltMeterConstant); } @@ -72,6 +74,13 @@ void restoreConfig() { Hyst = temp; } + EEPROM.get(LOGIC_ADDRESS, temp); + if (temp < 0 || temp > 1) { + reset = true; + } else { + LOGIC = temp; + } + long longTemp; EEPROM.get(VM_CONST_ADDRESS, longTemp); if (longTemp < 1000000L || longTemp > 1200000L) { @@ -92,5 +101,6 @@ void setDefaultConfig() { LOOP_DUR = LOOP_DUR_DEFAULT; TRG_DUR = TRG_DUR_DEFAULT; Hyst = HYST_DEFAULT; + LOGIC = LOGIC_DEFAULT; voltMeterConstant = VM_CONST_DEFAULT; } diff --git a/firmware/AVR-Source/Pyr0_Piezo_Sensor_v2.x.x/src/pP_config.h b/firmware/AVR-Source/Pyr0_Piezo_Sensor_v2.x.x/src/pP_config.h index 9eb7dcc..92dc4f7 100644 --- a/firmware/AVR-Source/Pyr0_Piezo_Sensor_v2.x.x/src/pP_config.h +++ b/firmware/AVR-Source/Pyr0_Piezo_Sensor_v2.x.x/src/pP_config.h @@ -43,8 +43,14 @@ extern int Hyst; // Hysteresis value for ADC measurements #endif +#define LOGIC_DEFAULT 0 +#define LOGIC_ADDRESS 24 +#if !(defined(LOGIC)) + extern bool LOGIC; // Trigger logic scheme, Active LOW is default +#endif + #if !(defined(Debug)) - extern int Debug; + extern int Debug; #endif #define VM_CONST_ADDRESS 28 @@ -58,10 +64,10 @@ #if !(defined(pP_i2c_address)) extern uint8_t pP_i2c_address; // I2C Bus Address #endif -#endif +#endif // I2C_INPUT void eraseEEPROM(); void setDefaultConfig(); void restoreConfig(); -#endif +#endif // PP_CONFIG_H 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 4395428..450a8df 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 @@ -23,10 +23,10 @@ int inline analogReadFast(byte ADCpin) /*------------------------------------------------*/ void pulse() { - digitalWriteFast(TRG_OUT, LOW); + digitalWriteFast(TRG_OUT, LOGIC); sensorHReading = 1; delay(TRG_DUR); - digitalWriteFast(TRG_OUT, HIGH); + digitalWriteFast(TRG_OUT, !LOGIC); Serial.println("Trig'd!"); } diff --git a/firmware/AVR-Source/Pyr0_Piezo_Sensor_v2.x.x/src/pP_volatile.h b/firmware/AVR-Source/Pyr0_Piezo_Sensor_v2.x.x/src/pP_volatile.h index 38852e1..7a0b8ce 100644 --- a/firmware/AVR-Source/Pyr0_Piezo_Sensor_v2.x.x/src/pP_volatile.h +++ b/firmware/AVR-Source/Pyr0_Piezo_Sensor_v2.x.x/src/pP_volatile.h @@ -23,7 +23,7 @@ int VFol = 0; // Error blink parameters -int BlinkState = LOW; +int BlinkState = 0; int BlinkCount = (InitCount * 2) + 1; // Multiply Blink count by 2 to handle toggle state, add one extra to make sure light is on after // Serial Input Parsing Variables