PRO2_Team 1_collected code with ticker and headers_not working yet

Dependencies:   SHTx mbed

Fork of PRO2_samlet_kode by Olga Høyer

Committer:
OlgaHoeyer
Date:
Tue Jun 20 12:18:09 2017 +0000
Revision:
11:3ff48fb0aa0b
Parent:
7:75d5c1db2027
with pointers

Who changed what in which revision?

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