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.h@7:8248af58df5a, 2019-11-19 (annotated)
- Committer:
- Stumi
- Date:
- Tue Nov 19 12:55:44 2019 +0000
- Revision:
- 7:8248af58df5a
- Parent:
- 6:2cc2aac35868
- Child:
- 9:326b8f261ef0
Added blue user button function and LED to show power status
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Stumi | 6:2cc2aac35868 | 1 | /*-------------------------------------------------------------------------------- |
Stumi | 6:2cc2aac35868 | 2 | Filename: LED.h |
Stumi | 6:2cc2aac35868 | 3 | Description: Header file for the Buzzer and LEDs |
Stumi | 6:2cc2aac35868 | 4 | --------------------------------------------------------------------------------*/ |
Stumi | 6:2cc2aac35868 | 5 | |
Stumi | 5:bc5081f0c063 | 6 | #include "mbed.h" |
Stumi | 5:bc5081f0c063 | 7 | |
Stumi | 5:bc5081f0c063 | 8 | #ifndef LED_H |
Stumi | 5:bc5081f0c063 | 9 | #define LED_H |
Stumi | 5:bc5081f0c063 | 10 | |
Stumi | 5:bc5081f0c063 | 11 | #define DIAG_GRN PD_14 |
Stumi | 5:bc5081f0c063 | 12 | #define DIAG_BLU PD_15 |
Stumi | 5:bc5081f0c063 | 13 | #define DIAG_RED PF_12 |
Stumi | 5:bc5081f0c063 | 14 | |
Stumi | 6:2cc2aac35868 | 15 | class cRGB_LED |
Stumi | 5:bc5081f0c063 | 16 | { |
Stumi | 5:bc5081f0c063 | 17 | public: |
Stumi | 6:2cc2aac35868 | 18 | cRGB_LED(DigitalOut DIAG_RED, PwmOut DIAG_BLU, PwmOut DIAG_GRN); //Constructor, initialises the 3 outputs |
Stumi | 6:2cc2aac35868 | 19 | void red_led(); //Turns on Red LED |
Stumi | 6:2cc2aac35868 | 20 | void blue_led(); //Turns on Blue LED |
Stumi | 6:2cc2aac35868 | 21 | void green_led(); //Turns on Green LED |
Stumi | 6:2cc2aac35868 | 22 | void yellow_led(); //Turns on multiple LEDs to make yellow |
Stumi | 7:8248af58df5a | 23 | void orange_led(); //Turns on multiple LEDs to make orange |
Stumi | 6:2cc2aac35868 | 24 | void led_off(); //Turns all LEDs off |
Stumi | 7:8248af58df5a | 25 | void record_power(float vBatt); //Saves power value to private variable for use inside class |
Stumi | 7:8248af58df5a | 26 | void display_power(); //Sets LED colour based on battery level |
Stumi | 5:bc5081f0c063 | 27 | private: |
Stumi | 5:bc5081f0c063 | 28 | DigitalOut _DIAG_RED; |
Stumi | 6:2cc2aac35868 | 29 | PwmOut _DIAG_BLU; |
Stumi | 5:bc5081f0c063 | 30 | PwmOut _DIAG_GRN; |
Stumi | 7:8248af58df5a | 31 | float _battery_level; |
Stumi | 5:bc5081f0c063 | 32 | }; |
Stumi | 5:bc5081f0c063 | 33 | |
Stumi | 5:bc5081f0c063 | 34 | |
Stumi | 5:bc5081f0c063 | 35 | #endif |