SOFT564Z Group 3 / Mbed 2 deprecated SOFT564Z_Group_3_final

Dependencies:   mbed Servo ros_lib_kinetic

Committer:
Stumi
Date:
Tue Nov 12 12:56:02 2019 +0000
Revision:
6:2cc2aac35868
Parent:
5:bc5081f0c063
Child:
7:8248af58df5a
Added buzzer functionality; Added buzzer and LED into obstacle avoidance routine; Made class declaration for led and buzzer in motor.cpp NOT MAIN

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Stumi 6:2cc2aac35868 1 /*--------------------------------------------------------------------------------
Stumi 6:2cc2aac35868 2 Filename: LED.cpp
Stumi 6:2cc2aac35868 3 Description: Holds source code for configuring the RGB LED and also buzzer becuase
Stumi 6:2cc2aac35868 4 where else do I put it :P
Stumi 6:2cc2aac35868 5 --------------------------------------------------------------------------------*/
Stumi 6:2cc2aac35868 6
Stumi 5:bc5081f0c063 7 #include "LED.h"
Stumi 5:bc5081f0c063 8
Stumi 6:2cc2aac35868 9 /*--------------------------------------------------------------------------------
Stumi 6:2cc2aac35868 10 Function name: cRGB_LED
Stumi 6:2cc2aac35868 11 Input Parameters: N/A
Stumi 6:2cc2aac35868 12 Output Parameters: N/A
Stumi 6:2cc2aac35868 13 Description: Class constructor (Initialisation upon creating class)
Stumi 6:2cc2aac35868 14 ----------------------------------------------------------------------------------*/
Stumi 6:2cc2aac35868 15 cRGB_LED::cRGB_LED(DigitalOut DIAG_RED, PwmOut DIAG_BLU, PwmOut DIAG_GRN): _DIAG_RED(DIAG_RED), _DIAG_BLU(DIAG_BLU), _DIAG_GRN(DIAG_GRN)
Stumi 5:bc5081f0c063 16 {
Stumi 5:bc5081f0c063 17 // Set initial condition of PWM
Stumi 5:bc5081f0c063 18 _DIAG_BLU.period(0.001); //1KHz
Stumi 5:bc5081f0c063 19 _DIAG_BLU = 0;
Stumi 5:bc5081f0c063 20
Stumi 5:bc5081f0c063 21 // Set initial condition of PWM
Stumi 5:bc5081f0c063 22 _DIAG_GRN.period(0.001); //1KHz
Stumi 5:bc5081f0c063 23 _DIAG_GRN = 0;
Stumi 5:bc5081f0c063 24
Stumi 5:bc5081f0c063 25 // Initial condition of output enables
Stumi 5:bc5081f0c063 26 _DIAG_RED = 0;
Stumi 5:bc5081f0c063 27 }
Stumi 5:bc5081f0c063 28
Stumi 6:2cc2aac35868 29 /*--------------------------------------------------------------------------------
Stumi 6:2cc2aac35868 30 Function name: cRGB_LED
Stumi 6:2cc2aac35868 31 Input Parameters: N/A
Stumi 6:2cc2aac35868 32 Output Parameters: N/A
Stumi 6:2cc2aac35868 33 Description: Turns on red led
Stumi 6:2cc2aac35868 34 ----------------------------------------------------------------------------------*/
Stumi 6:2cc2aac35868 35 void cRGB_LED::red_led()
Stumi 5:bc5081f0c063 36 {
Stumi 6:2cc2aac35868 37 _DIAG_RED = 1; //Enable red
Stumi 6:2cc2aac35868 38 _DIAG_BLU = 0.0; //Disable Blue
Stumi 6:2cc2aac35868 39 _DIAG_GRN = 0.0; //Disable Green
Stumi 5:bc5081f0c063 40 }
Stumi 5:bc5081f0c063 41
Stumi 6:2cc2aac35868 42 /*--------------------------------------------------------------------------------
Stumi 6:2cc2aac35868 43 Function name: blue_led()
Stumi 6:2cc2aac35868 44 Input Parameters: N/A
Stumi 6:2cc2aac35868 45 Output Parameters: N/A
Stumi 6:2cc2aac35868 46 Description: Turns on blue led
Stumi 6:2cc2aac35868 47 ----------------------------------------------------------------------------------*/
Stumi 6:2cc2aac35868 48 void cRGB_LED::blue_led()
Stumi 5:bc5081f0c063 49 {
Stumi 6:2cc2aac35868 50 _DIAG_RED = 0; //Disable Red
Stumi 6:2cc2aac35868 51 _DIAG_BLU = 1.0; //Enable Blue
Stumi 6:2cc2aac35868 52 _DIAG_GRN = 0.0; //Enable Green
Stumi 5:bc5081f0c063 53 }
Stumi 5:bc5081f0c063 54
Stumi 6:2cc2aac35868 55 /*--------------------------------------------------------------------------------
Stumi 6:2cc2aac35868 56 Function name: green_led()
Stumi 6:2cc2aac35868 57 Input Parameters: N/A
Stumi 6:2cc2aac35868 58 Output Parameters: N/A
Stumi 6:2cc2aac35868 59 Description: Turns on green led
Stumi 6:2cc2aac35868 60 ----------------------------------------------------------------------------------*/
Stumi 6:2cc2aac35868 61 void cRGB_LED::green_led()
Stumi 5:bc5081f0c063 62 {
Stumi 6:2cc2aac35868 63 _DIAG_RED = 0; //Disable Red
Stumi 6:2cc2aac35868 64 _DIAG_BLU = 0.0; //Disable Blue
Stumi 6:2cc2aac35868 65 _DIAG_GRN = 1.0; //Enable Green
Stumi 5:bc5081f0c063 66 }
Stumi 5:bc5081f0c063 67
Stumi 6:2cc2aac35868 68 /*--------------------------------------------------------------------------------
Stumi 6:2cc2aac35868 69 Function name: yellow_led()
Stumi 6:2cc2aac35868 70 Input Parameters: N/A
Stumi 6:2cc2aac35868 71 Output Parameters: N/A
Stumi 6:2cc2aac35868 72 Description: Turns on yellow led
Stumi 6:2cc2aac35868 73 ----------------------------------------------------------------------------------*/
Stumi 6:2cc2aac35868 74 void cRGB_LED::yellow_led()
Stumi 5:bc5081f0c063 75 {
Stumi 6:2cc2aac35868 76 _DIAG_RED = 1; //Enable Red
Stumi 6:2cc2aac35868 77 _DIAG_BLU = 0.0; //Disable Blue
Stumi 6:2cc2aac35868 78 _DIAG_GRN = 0.35; //Enable Green at 35% duty
Stumi 5:bc5081f0c063 79 }
Stumi 5:bc5081f0c063 80
Stumi 6:2cc2aac35868 81 /*--------------------------------------------------------------------------------
Stumi 6:2cc2aac35868 82 Function name: led_off()
Stumi 6:2cc2aac35868 83 Input Parameters: N/A
Stumi 6:2cc2aac35868 84 Output Parameters: N/A
Stumi 6:2cc2aac35868 85 Description: Turns the led off
Stumi 6:2cc2aac35868 86 ----------------------------------------------------------------------------------*/
Stumi 6:2cc2aac35868 87 void cRGB_LED::led_off()
Stumi 5:bc5081f0c063 88 {
Stumi 6:2cc2aac35868 89 _DIAG_RED = 0; //Disable Red
Stumi 6:2cc2aac35868 90 _DIAG_BLU = 0; //Disable Blue
Stumi 6:2cc2aac35868 91 _DIAG_GRN = 0; //Disable Green
Stumi 5:bc5081f0c063 92 }