* Exclusively get semaphore and repeatedly takes a one-shot image. * The cycle for the timer shot is generated by the hardware timer provided by * the ESP32 module. This function initializes the timer for periodic execution * of the timer interrupt function for taking pictures. * @param period Period to shoot in seconds. * @param filenamePrefix File name for saving the captured imag
| 582 | * @param filenamePrefix File name for saving the captured image. |
| 583 | */ |
| 584 | void ESP32Cam::_timerShot(const unsigned long period, const char* filenamePrefix) { |
| 585 | if (!period) |
| 586 | return; |
| 587 | |
| 588 | if (!filenamePrefix) |
| 589 | filenamePrefix = "/" ESP32CAM_GLOBAL_IDENTIFIER; |
| 590 | if (!strlen(filenamePrefix)) |
| 591 | filenamePrefix = "/" ESP32CAM_GLOBAL_IDENTIFIER; |
| 592 | |
| 593 | // Save the global variables for the ISR and cancel the timer residue. |
| 594 | _captureName = filenamePrefix; |
| 595 | _purgeTimer(); |
| 596 | |
| 597 | // Register a task to secure and shoot a hardware timer. |
| 598 | _hwTimer = timerBegin(ESP32CAM_OCCUPIED_TIMER, getApbFrequency() / 1000000UL, true); |
| 599 | timerAttachInterrupt(_hwTimer, &ESP32Cam::_timerShotISR, true); |
| 600 | timerAlarmWrite(_hwTimer, period * 1000000UL, true); |
| 601 | |
| 602 | // Start an alarm |
| 603 | ESP32Cam_internal::esp32cam = this; |
| 604 | xSemaphoreGive(ESP32Cam_internal::xMutex); |
| 605 | timerAlarmEnable(_hwTimer); |
| 606 | } |
| 607 | |
| 608 | /** |
| 609 | * A hardware timer interrupt routine is called when the shooting cycle of the |
nothing calls this directly
no outgoing calls
no test coverage detected