obj
Timer.swift:73This declaration is gated by at least one @_spi attribute.
let obj: UnsafeMutableRawPointer
This declaration is gated by at least one @_spi attribute.
let obj: UnsafeMutableRawPointer
import SwiftIO
The SwiftIO library allows you to access and control the hardware in an easy way.
final class Timer
The Timer class can measure the time passed. If the time limit is reached, it can execute a specified task.
@frozen struct UnsafeMutableRawPointer
A raw pointer for accessing and manipulating untyped data.
init(mode: Mode = .period, period: Int = 1000)
Initializes a timer.
func getRemaining() -> UInt32
Computes the (approximate) time remaining before a running timer next expires. If the timer is not running, it returns zero.
func getStatus() -> UInt32
Gets the timer’s status which indicates how many times the timer has expired since it was last read. It will reset the status to zero.
func setInterrupt(start: Bool = true, _ callback: @escaping () -> Void)
Executes a designated task at a scheduled time interval.
func start(mode: Mode? = nil, period: Int? = nil)
Starts the timer and reset its status to zero.
func stop()
Stops the timer.
enum Mode
There are two timer modes: oneShot
means the timer works only once; period
means the timer works periodically.