Enhanced with onPeriodicNotification() and Bresenham's algorithm.
Fixed a critical bug regarding frequency out of range.