PROJ515-MASTER-No-PWM

Dependencies:   mbed mbed-rtos ShiftReg2 TextLCD

Committer:
thomasmorris
Date:
Wed May 08 09:39:42 2019 +0000
Revision:
5:dbb984e01ded
Parent:
4:020f93d35f6e
Working code not PWM;

Who changed what in which revision?

UserRevisionLine numberNew contents of line
thomasmorris 4:020f93d35f6e 1 #include "Control.hpp"
thomasmorris 4:020f93d35f6e 2 int PWM_on_time = 0;
thomasmorris 4:020f93d35f6e 3 int PWM_off_time = 100;
thomasmorris 4:020f93d35f6e 4 ShiftReg SR(PA_10, PA_12, PA_15, PA_11); //data, store, clock, output enable
thomasmorris 4:020f93d35f6e 5 int Output = 0;
thomasmorris 4:020f93d35f6e 6 int Data = 0;
thomasmorris 4:020f93d35f6e 7 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
thomasmorris 4:020f93d35f6e 8 {
thomasmorris 5:dbb984e01ded 9 Control_Shift_Regs(0xF0F0,2);//Pass in the muscle and fan selection along with the PWM
thomasmorris 4:020f93d35f6e 10 }
thomasmorris 4:020f93d35f6e 11 void Control_Shift_Regs(uint16_t Selection, int PWM)//Controling the output of the shift registers
thomasmorris 4:020f93d35f6e 12 {
thomasmorris 4:020f93d35f6e 13 if(PWM < 0 || PWM > 100)
thomasmorris 4:020f93d35f6e 14 {
thomasmorris 4:020f93d35f6e 15 PWM = 0;
thomasmorris 4:020f93d35f6e 16 //Also run an error
thomasmorris 4:020f93d35f6e 17 }
thomasmorris 4:020f93d35f6e 18 PWM_on_time = PWM;
thomasmorris 4:020f93d35f6e 19 PWM_off_time = PWM_off_time - PWM;
thomasmorris 4:020f93d35f6e 20 while(1)
thomasmorris 4:020f93d35f6e 21 {
thomasmorris 4:020f93d35f6e 22 SR.Write(Selection);//Turn the selection on
thomasmorris 5:dbb984e01ded 23 //Thread::wait(100);//20ms on
thomasmorris 4:020f93d35f6e 24 SR.Write(0x0000);
thomasmorris 5:dbb984e01ded 25 //Thread::wait(100);//80ms off
thomasmorris 4:020f93d35f6e 26 }
thomasmorris 4:020f93d35f6e 27 }
thomasmorris 4:020f93d35f6e 28 void Control_Post()//The POST function runs here
thomasmorris 4:020f93d35f6e 29 {
thomasmorris 4:020f93d35f6e 30 POST();//Run the power on self test routine
thomasmorris 4:020f93d35f6e 31 }
thomasmorris 4:020f93d35f6e 32