PRO2_Team 1_collected code with ticker_not working yet

Dependencies:   SHTx mbed

Fork of PRO2_samlet_kode by Software hold - Team 1 - PRO2 2017

Committer:
OlgaHoeyer
Date:
Thu May 11 11:40:27 2017 +0000
Revision:
0:21e9cc38dd31
EDE PRO2 Team 1: "Awareness and Energioptimering. Udluftnings infoinator". Summary of the code.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
OlgaHoeyer 0:21e9cc38dd31 1 /*
OlgaHoeyer 0:21e9cc38dd31 2 ================================================================================
OlgaHoeyer 0:21e9cc38dd31 3 == == ==
OlgaHoeyer 0:21e9cc38dd31 4 == Source File: == main.cpp ==
OlgaHoeyer 0:21e9cc38dd31 5 == File Name: == rgb_led.cpp ==
OlgaHoeyer 0:21e9cc38dd31 6 == Author: == Poul Erik Tjørnfelt ==
OlgaHoeyer 0:21e9cc38dd31 7 == Date: == 07/05-2017 ==
OlgaHoeyer 0:21e9cc38dd31 8 == Copyright: == Open to all ==
OlgaHoeyer 0:21e9cc38dd31 9 == Version: == 0.6 - Creation of file. ==
OlgaHoeyer 0:21e9cc38dd31 10 == == ==
OlgaHoeyer 0:21e9cc38dd31 11 == Description: == The .cpp file for a class, that creates instances of ==
OlgaHoeyer 0:21e9cc38dd31 12 == == the actual RGB lamp that is used. ==
OlgaHoeyer 0:21e9cc38dd31 13 == == ==
OlgaHoeyer 0:21e9cc38dd31 14 ================================================================================
OlgaHoeyer 0:21e9cc38dd31 15 */
OlgaHoeyer 0:21e9cc38dd31 16
OlgaHoeyer 0:21e9cc38dd31 17 #include "mbed.h"
OlgaHoeyer 0:21e9cc38dd31 18 #include "rgb_led.h"
OlgaHoeyer 0:21e9cc38dd31 19
OlgaHoeyer 0:21e9cc38dd31 20 RGB_LED::RGB_LED(PinName pin_R, PinName pin_G, PinName pin_B)
OlgaHoeyer 0:21e9cc38dd31 21 :pin_r(pin_R), pin_g(pin_G), pin_b(pin_B) // Constructor
OlgaHoeyer 0:21e9cc38dd31 22 {
OlgaHoeyer 0:21e9cc38dd31 23
OlgaHoeyer 0:21e9cc38dd31 24 }
OlgaHoeyer 0:21e9cc38dd31 25
OlgaHoeyer 0:21e9cc38dd31 26 void RGB_LED::set(float red,float green, float blue)
OlgaHoeyer 0:21e9cc38dd31 27 {
OlgaHoeyer 0:21e9cc38dd31 28 pin_r = red; // The amount of the single colours that we want in the
OlgaHoeyer 0:21e9cc38dd31 29 pin_g = green; // actual colour (ex. purple = 0.7f, 0.0, 0.7f), gotten from
OlgaHoeyer 0:21e9cc38dd31 30 pin_b = blue; // www.w3schools.com/colors/colors_picker.asp.
OlgaHoeyer 0:21e9cc38dd31 31 /*
OlgaHoeyer 0:21e9cc38dd31 32 We only use red, orange (2 parts red, 1 part green), green and blue.
OlgaHoeyer 0:21e9cc38dd31 33 */
OlgaHoeyer 0:21e9cc38dd31 34 }
OlgaHoeyer 0:21e9cc38dd31 35
OlgaHoeyer 0:21e9cc38dd31 36 void RGB_LED::flash(float period, float on_timer)
OlgaHoeyer 0:21e9cc38dd31 37 {
OlgaHoeyer 0:21e9cc38dd31 38 pin_r.period(period); // Sets the period in seconds of the LED.
OlgaHoeyer 0:21e9cc38dd31 39 pin_r.write(on_timer); // The %age of the period that the LED is turned on.
OlgaHoeyer 0:21e9cc38dd31 40 pin_g.period(period);
OlgaHoeyer 0:21e9cc38dd31 41 pin_g.write(on_timer);
OlgaHoeyer 0:21e9cc38dd31 42 pin_b.period(period);
OlgaHoeyer 0:21e9cc38dd31 43 pin_b.write(on_timer);
OlgaHoeyer 0:21e9cc38dd31 44 }