#ifndef SOFTWARE_PWM_H #define SOFTWARE_PWM_H #include #define SOFTPWM_PIN_COUNT 8 #define PWM_FREQ 300 //hz /** Our microcontroller we have laying around only has 4 hardware pwm channels. * Because we want 8, we will create software PWM as an alternative. * * Notes to self to forcast nessessary optimizations (translates to color accuracy): * Our error margin is 1/255th (13us at pwm freq 300hz) of a cycle. * Cycles until next channel could be triggered: * 209 at 16Mhz * 130 at 10Mhz (have one available) * 104 at 8Mhz * 13 at 1Mhz (have one available) * * To decrease the amount of cycles every pwm timer interrupt, we'll generate the * * We might also want to make sure these values aren't updated every loop * from random noise coming from the potentiometer. Test without, decide then. */ void init_softpwm(); void initilize_duty_cycle(uint8_t pin); void softpwm_set(uint8_t pin, uint8_t duty); #endif