Skeleton code. LCD, Serial, Feedback, MOSFETS
Dependencies: mbed mbed-rtos ShiftReg2 TextLCD
Diff: Control/Control.cpp
- Revision:
- 4:020f93d35f6e
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Control/Control.cpp Tue May 07 21:55:57 2019 +0000 @@ -0,0 +1,33 @@ +#include "Control.hpp" +int PWM_on_time = 0; +int PWM_off_time = 100; +ShiftReg SR(PA_10, PA_12, PA_15, PA_11); //data, store, clock, output enable +int Output = 0; +int Data = 0; +void Control_Main()//This is where the control of the board will be run from, just to not have all of the code inside of the main +{ + Control_Shift_Regs(0xF0F0,20);//Pass in the muscle and fan selection along with the PWM +} +void Control_Shift_Regs(uint16_t Selection, int PWM)//Controling the output of the shift registers +{ + if(PWM < 0 || PWM > 100) + { + PWM = 0; + //Also run an error + } + PWM_on_time = PWM; + PWM_off_time = PWM_off_time - PWM; + while(1) + { + SR.Write(0x0000);//All off + SR.Write(Selection);//Turn the selection on + Thread::wait(PWM_on_time);//20ms on + SR.Write(0x0000); + Thread::wait(PWM_off_time);//80ms off + } +} +void Control_Post()//The POST function runs here +{ + POST();//Run the power on self test routine +} +