Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed Servo ros_lib_kinetic
RGB_LED/LED.cpp
- Committer:
- Stumi
- Date:
- 2019-11-12
- Revision:
- 6:2cc2aac35868
- Parent:
- 5:bc5081f0c063
- Child:
- 7:8248af58df5a
File content as of revision 6:2cc2aac35868:
/*--------------------------------------------------------------------------------
Filename: LED.cpp
Description: Holds source code for configuring the RGB LED and also buzzer becuase
where else do I put it :P
--------------------------------------------------------------------------------*/
#include "LED.h"
/*--------------------------------------------------------------------------------
Function name: cRGB_LED
Input Parameters: N/A
Output Parameters: N/A
Description: Class constructor (Initialisation upon creating class)
----------------------------------------------------------------------------------*/
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)
{
// Set initial condition of PWM
_DIAG_BLU.period(0.001); //1KHz
_DIAG_BLU = 0;
// Set initial condition of PWM
_DIAG_GRN.period(0.001); //1KHz
_DIAG_GRN = 0;
// Initial condition of output enables
_DIAG_RED = 0;
}
/*--------------------------------------------------------------------------------
Function name: cRGB_LED
Input Parameters: N/A
Output Parameters: N/A
Description: Turns on red led
----------------------------------------------------------------------------------*/
void cRGB_LED::red_led()
{
_DIAG_RED = 1; //Enable red
_DIAG_BLU = 0.0; //Disable Blue
_DIAG_GRN = 0.0; //Disable Green
}
/*--------------------------------------------------------------------------------
Function name: blue_led()
Input Parameters: N/A
Output Parameters: N/A
Description: Turns on blue led
----------------------------------------------------------------------------------*/
void cRGB_LED::blue_led()
{
_DIAG_RED = 0; //Disable Red
_DIAG_BLU = 1.0; //Enable Blue
_DIAG_GRN = 0.0; //Enable Green
}
/*--------------------------------------------------------------------------------
Function name: green_led()
Input Parameters: N/A
Output Parameters: N/A
Description: Turns on green led
----------------------------------------------------------------------------------*/
void cRGB_LED::green_led()
{
_DIAG_RED = 0; //Disable Red
_DIAG_BLU = 0.0; //Disable Blue
_DIAG_GRN = 1.0; //Enable Green
}
/*--------------------------------------------------------------------------------
Function name: yellow_led()
Input Parameters: N/A
Output Parameters: N/A
Description: Turns on yellow led
----------------------------------------------------------------------------------*/
void cRGB_LED::yellow_led()
{
_DIAG_RED = 1; //Enable Red
_DIAG_BLU = 0.0; //Disable Blue
_DIAG_GRN = 0.35; //Enable Green at 35% duty
}
/*--------------------------------------------------------------------------------
Function name: led_off()
Input Parameters: N/A
Output Parameters: N/A
Description: Turns the led off
----------------------------------------------------------------------------------*/
void cRGB_LED::led_off()
{
_DIAG_RED = 0; //Disable Red
_DIAG_BLU = 0; //Disable Blue
_DIAG_GRN = 0; //Disable Green
}