PRO2_Team 1_collected code with ticker and headers_not working yet

Dependencies:   SHTx mbed

Fork of PRO2_samlet_kode by Olga Høyer

data_out.cpp

Committer:
OlgaHoeyer
Date:
2017-06-20
Revision:
11:3ff48fb0aa0b
Parent:
7:75d5c1db2027

File content as of revision 11:3ff48fb0aa0b:

/*
--------------------------------------------------------------------------------
-- Project:         PRO2 "Awareness and Optimisation of energy consumption"
-- Team:            Team 1

-- File Name:       data_out.cpp
-- Author:          Poul Erik Tjørnfelt
-- Date:            07/05-2017
-- Copyright:       Open to all
-- Version:         0.6 - Creation of file.
--                  0.7 - Added a 5th choice for colour. Red_Blink.
--                  1.0 - Finished file.
--
-- Description:     A program (for a school project) that needs to collect
--                  data from sensors, and show an output to 3 seven-segmented
--                  displays and to a RGB-LED.
--
--------------------------------------------------------------------------------
*/

#include "mbed.h"
#include "rgb_led.h"
#include "7_segment_control.h"
#include "data_out.h"

void rgb_outp(int status)
{
    RGB_LED lamp(PC_8,PC_6,PB_9);   // Creates an object out of the class RGB_LED.
    // Connect pins on the Nucleo, to the pins the
    // class.
    // Following is a object of the class segment_7. It is the actual analogy
    // to our 7 segmented displays. There needs to go 11 pins into the
    // parenteses. 
    // segment_7 seg_num(11 pins);

    enum colour     // Enumeration is used only for making the program more
    {               // easily readable.
        green,      // Is alike an int, starts at green = 1,
        orange,     // orange = 2 etc.
        red,
        red_blink,
        blue
    };

    colour RGB_out = static_cast<colour>(status);
    // Taking the value from the sensors and change them the enum type.
    // Enum is somewhat akin to an int already, but RGB_out != status..

    switch(RGB_out)
    {
        case green:
            lamp.set(0.0f, 1.0f, 0.0f);
            lamp.flash(1.0f, 1.0f);         // On constantly.
            break;
        case orange:
            lamp.set(1.0f, 0.6f, 0.0f);
            lamp.flash(1.0f, 1.0f);         // On constantly.
            break;
        case red:
            lamp.set(1.0f, 0.0f, 0.0f);
            lamp.flash(1.0f, 1.0f);         // On constantly.
            break;
        case red_blink:
            lamp.set(1.0f, 0.0f, 0.0f);
            lamp.flash(2.0f, 0.5f);         // On for 50% of every 2 seconds.
            break;
        case blue:
            lamp.set(0.0f, 0.0f, 1.0f);
            lamp.flash(2.0f, 0.5f);         // On for 50% of every 2 seconds.
            break;
        default:   // Error has occured, blue. Could just have defaulted instead
            lamp.set(0.0f, 0.0f, 1.0f);     // of case blue, however as it is an
            lamp.flash(2.0f, 0.5f);         // error and blue is error..
    }

    return;
}