PROJ515-MASTER-No-PWM

Dependencies:   mbed mbed-rtos ShiftReg2 TextLCD

Control/Control.cpp

Committer:
thomasmorris
Date:
2019-05-07
Revision:
4:020f93d35f6e
Child:
5:dbb984e01ded

File content as of revision 4:020f93d35f6e:

#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
}