refactor timer and pwm to reduce runtime compares

remove switch case by adding member variables