Compare commits

...

2 Commits

Author SHA1 Message Date
r4 bfa80a629e component switch support to save power when waiting 2022-04-14 20:48:27 +02:00
r4 c2f41e41c7 add license 2022-04-11 19:42:06 +02:00
2 changed files with 25 additions and 0 deletions

7
LICENSE Normal file
View File

@ -0,0 +1,7 @@
Copyright 2022 Darwin Schuppan <darwin@nobrain.org>
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 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

View File

@ -1,3 +1,6 @@
// Copyright 2022 Darwin Schuppan <darwin@nobrain.org>
// SPDX license identifier: MIT
/*
*** SD Card Wiring ***
SD | Nano
@ -37,6 +40,9 @@
//#define DEBUG_RECORDING
//#define SERIAL_OUTPUT
//#define PIN_COMPONENT_SWITCH 2 /* Use a digital signal to switch on/off the microphone and SD card for less power draw. */
//#define COMPONENT_SWITCH_ON HIGH
#define SAMPLE_MODE_U8
//#define SAMPLE_MODE_S16
@ -267,12 +273,24 @@ void setup() {
#ifdef SERIAL_OUTPUT
Serial.begin(9600); /* Set baud rate. */
setup_serial_in_out(); /* Add printf support. */
#endif
// Component Switch Setup
#ifdef PIN_COMPONENT_SWITCH
pinMode(PIN_COMPONENT_SWITCH, OUTPUT);
#endif
// Delay Triggering
#if defined(RECORDING_DELAY_IN_MINUTES) && RECORDING_DELAY_IN_MINUTES != 0
#ifdef PIN_COMPONENT_SWITCH
digitalWrite(PIN_COMPONENT_SWITCH, !COMPONENT_SWITCH_ON);
#endif
printf(F("Waiting %u minute%s before starting to record...\n"), RECORDING_DELAY_IN_MINUTES, RECORDING_DELAY_IN_MINUTES == 1 ? "" : "s");
Serial.flush();
low_power_sleep_minutes(RECORDING_DELAY_IN_MINUTES); /* Draws ~12.5mA instead of ~30mA when using delay(). */
#endif
// Activate Components
#ifdef PIN_COMPONENT_SWITCH
digitalWrite(PIN_COMPONENT_SWITCH, COMPONENT_SWITCH_ON);
delay(500); /* Wait for components to initialize. */
#endif
// Start Watchdog (wdt_enable() doesn't fully reset)
start_watchdog_with_full_reset();