From 7bf117d4c7cd10c45106a4831c3c5ac68befd1f8 Mon Sep 17 00:00:00 2001 From: Timur-Khabibulin <101925716+Timur-Khabibulin@users.noreply.github.com> Date: Fri, 25 Mar 2022 11:52:07 +0500 Subject: [PATCH] Add ISR.ino MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Реализованы прерывания по таймеру --- IntervalometerForCamera/ISR.ino | 54 +++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 IntervalometerForCamera/ISR.ino diff --git a/IntervalometerForCamera/ISR.ino b/IntervalometerForCamera/ISR.ino new file mode 100644 index 0000000..202bf87 --- /dev/null +++ b/IntervalometerForCamera/ISR.ino @@ -0,0 +1,54 @@ +/* Intervalometer / Timer for interval shooting. + Copyright © 2022 Timur Khabibulin. + All rights reserved. + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +ISR(TIMER1_COMPA_vect) { + hwTimer1.count++; // Период 1 с + + static uint32_t intervalTime; + static bool sleepState = false; + + if (camSettings.longExpNR) intervalTime = camSettings.interval + camSettings.shutter_speed / 1000; + else intervalTime = camSettings.interval; + + if (camSettings.hibernationSt) hibernation(intervalTime, sleepState); + + if (hwTimer1.count >= intervalTime) { + if (camSettings.frame_rate > 0) { + if (camSettings.AFControl) digitalWrite(FOCUS_PIN, HIGH); + digitalWrite(SHUTTER_PIN, HIGH); + } + hw_Timer_1_Stop(); + hw_Timer_2_Start(); + } + +} + +ISR(TIMER2_COMPA_vect) { + hwTimer2.count += 2; // Период 2 мс + + if (hwTimer2.count >= camSettings.shutter_speed) { + if (camSettings.frame_rate > 0) { + if (camSettings.AFControl) digitalWrite(FOCUS_PIN, LOW); + digitalWrite(SHUTTER_PIN, LOW); + camSettings.frame_rate--; + } + hw_Timer_2_Stop(); + hw_Timer_1_Start(); + } + +}