### Demonstrating GyverTimers Library Functions (C++) Source: https://github.com/gyverlibs/gyvertimers/blob/main/README_EN.md This C++ example demonstrates various functions of the GyverTimers library, including setting timer periods and frequencies, enabling and disabling timer interrupts (ISRs) for specific channels, pausing and resuming timers, stopping and restarting timers, and resetting timers to their default Arduino configurations. It also shows the structure for defining timer interrupt service routines. ```CPP // Demonstration of all functions of the library #include VOID setup () { // reconfigure the timer and set him a period or frequency // All functions return the real period / frequency that may differ from the introduced Timer2.Setperiod (1000);// set a specific period of 1000 μs (~ 1000 Hz), will return the real period to the ISS Timer0.setfrequency (250);// Set the frequency of the timer interruptions in Hz, will return the real frequency in Herza Timer1.setfrequencyFloat (50.20);// Set the frequency more accurately, in fractional numbers, it is relevant for low frequencies and timer 1 // From that moment on, the timer is already reconfigured and drives with a fractured frequency / period // Connect the interruption of the timer, from this moment the interruption will begin to be called Timer0.enableisr ();// connect the standard interruption, channel A, without a phase retire Timer2.enableisr (Channel_b);// Connect the interruption of timer 2, channel b Timer1.enableisr (Channel_a);// Connect the interruption of the channel a Timer1.enableisr (Channel_b);// connect the second interruption of timer 1 // interruption will already begin to be called // if suddenly the interruption needs to be turned off without stopping the timer Timer1.disableisr (Channel_b); // From this moment, interruption b will no longer be called // if you need to suspend the timer completely, hardware Timer2.pause (); // From that moment on the timer stands still, the contents of the counter remains untouched // Now the timer can be returned to duty Timer2.Resum (); // Timer continued to count from the same place // if you need to completely stop the timer and drop the contents of the counter Timer1.Stop (); // Timer stands, the counter is dropped // Return the timer to duty Timer1.Restart (); // The timer is restarted, began to count from the beginning // if you need to return the standard arduino - timer settings Timer0.Setdefault (); // Now the timer works in Stanland mode } // Vectors of interruptions ISR (Timer1_a) { } ISR (Timer1_b) { } ISR (Timer2_b) { } ISR (Timer0_A) { } VOID loop () { } ``` -------------------------------- ### Demonstrating GyverTimers Functions (C++) Source: https://github.com/gyverlibs/gyvertimers/blob/main/README.md This C++ snippet illustrates how to use various functions from the GyverTimers library. It covers setting timer periods and frequencies, enabling and disabling interrupts for specific timer channels, pausing, resuming, stopping, and restarting timers, and resetting timers to their default Arduino configuration. It also shows the structure for defining timer interrupt service routines (ISRs). ```cpp // Демонстрация всех функций библиотеки #include void setup() { // Перенастроить таймер и задать ему период или частоту // Все функции возвращают реальный период / частоту, которые могут отличаться от введенных Timer2.setPeriod(1000); // Задать конкретный период 1000 мкс (~ 1000 гц), вернет реальный период в мкс Timer0.setFrequency(250); // Задать частоту прерываний таймера в Гц, вернет реальную частоту в герцах Timer1.setFrequencyFloat(50.20); // Задать частоту более точно, в дробных числах, актуально для низких частот и таймера 1 // С этого момента таймер уже перенастроен и гоняет с выьранной частотой / периодом // Подключить прерывание таймера, с этого момента прерывания начнут вызываться Timer0.enableISR(); // Подключить стандартное прерывание, канал А, без сдига фаз Timer2.enableISR(CHANNEL_B); // Подключить прерывание таймера 2, канал B Timer1.enableISR(CHANNEL_A); // Подключить прерывание канала А Timer1.enableISR(CHANNEL_B); // Подключить второе прерывание таймера 1 // Прерывание уже начнет вызываться // Если вдруг прерывание нужно отключить, не останавливая таймер Timer1.disableISR(CHANNEL_B); // С этого момента прерывание B больше не будет вызываться // Если нужно приостановить таймер ПОЛНОСТЬЮ, аппаратно Timer2.pause(); // С этого момента таймер стоит на месте, содержимое счетчика остается нетронутым // Теперь таймер можно вернуть в строй Timer2.resume(); // Таймер продолжил считать с того же места // Если нужно полностью остановить таймер и сбросить содержимое счетчика Timer1.stop(); // Таймер стоит, счетчик сброшен // Возвращаем таймер в строй Timer1.restart(); // Таймер перезапущен, начал считать с начала // Если нужно вернуть стандартные Arduino - настройки таймера Timer0.setDefault(); // Теперь таймер работает в станлартном режиме } // векторы прерываний ISR(TIMER1_A) { } ISR(TIMER1_B) { } ISR(TIMER2_B) { } ISR(TIMER0_A) { } void loop() { } ``` -------------------------------- ### Handling Timer1 Channel A Interrupt C++ Source: https://github.com/gyverlibs/gyvertimers/blob/main/README_EN.md Demonstrates how to define an Interrupt Service Routine (ISR) for Timer1's Channel A using the GyverTimers library. Code placed inside this block will execute automatically when the Timer1 Channel A interrupt is triggered. ```CPP ISR (Timer1_a) { // Your code } ``` -------------------------------- ### Handling Timer2 Channel B Interrupt C++ Source: https://github.com/gyverlibs/gyvertimers/blob/main/README_EN.md Demonstrates how to define an Interrupt Service Routine (ISR) for Timer2's Channel B using the GyverTimers library. Code placed inside this block will execute automatically when the Timer2 Channel B interrupt is triggered. ```CPP ISR (Timer2_b) { // Your code } ``` -------------------------------- ### Handling Timer0 Channel A Interrupt C++ Source: https://github.com/gyverlibs/gyvertimers/blob/main/README_EN.md Demonstrates how to define an Interrupt Service Routine (ISR) for Timer0's Channel A using the GyverTimers library. Code placed inside this block will execute automatically when the Timer0 Channel A interrupt is triggered. ```CPP ISR (Timer0_A) { // Your code } ``` -------------------------------- ### Handling Timer1 Channel B Interrupt C++ Source: https://github.com/gyverlibs/gyvertimers/blob/main/README_EN.md Demonstrates how to define an Interrupt Service Routine (ISR) for Timer1's Channel B using the GyverTimers library. Code placed inside this block will execute automatically when the Timer1 Channel B interrupt is triggered. ```CPP ISR (Timer1_b) { // Your code } ``` -------------------------------- ### GyverTimers Library Methods C++ Source: https://github.com/gyverlibs/gyvertimers/blob/main/README_EN.md Lists the available methods in the GyverTimers library for configuring and controlling hardware timers on Arduino microcontrollers. Includes functions for setting period/frequency, enabling/disabling interrupts, pausing/resuming, stopping, restarting, setting defaults, and controlling output pins. ```CPP uint32_t setperiod (period);// Installation of the period in microseconds and starting the timer.Returns the real period (accuracy is limited by the timer resolution). uint32_t setfrequency (frequency);// Frequency installation in Hertz and the timer launch.Returns the real frequency (accuracy is limited by the timer resolution). Float SetFrequencyFloat// Frequency installation in Hertsa and the timer launch, decimal fractions are allowed.Returns the riverfrequency (accuracy is limited by timer resolution). VOID Enableisr (source);// Turn on the interruptions, the channel of interruptions Channel_a or Channel_b (+ Channel_C by Mega2560) Void Disableisr (source);// Turn off the interruptions, channel Channel_a or Channel_b.The timer account does not stop (the channel A will be turned off without specifying the parameters). VOID PAUSE ();// suspend the timer account without dropping the counter VOID Resume ();// Continue the score after a pause VOID Stop ();// stop the score and drop the counter VOID RESTART ();// restart the timer (drop the counter) VOID Setdefault ();// Install the default timer parameters ("arduino-wilting") VOID outputenable (channel, mode);// Channel: Turn on the output of the Channel_a or Channel_b timer (+ channel_c in Mega2560).Mode: Toggle_pin, Clear_pin, Set_pin (switch/turn off/turn on the PIN on interruption) VOID outputdisable (channel);// Disconnect the output of the Channel_a or Channel_b timer (+ channel_c from Mega2560, see Thamere Taklitsa) VOID outputState (channel, condition);// Change the condition of the channel: High / Low VOID PHASSHIFT (source, phase);// shift the phase of the channel by 0-360 degrees (only channel b moves 8 bits of timers) Bool Ready (Uint8_T Channel);// returns True if an interruption on the specified channel occurs Bool Ready ();// returns True if there is an interruption on the channel A ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.