RoverButton, RoverBuzzer classes added.

Signed-off-by: Mustafa Ozcelikors <mozcelikors@gmail.com>
diff --git a/rover/include/roverapi/rover_button.hpp b/rover/include/roverapi/rover_button.hpp
new file mode 100644
index 0000000..cc67476
--- /dev/null
+++ b/rover/include/roverapi/rover_button.hpp
@@ -0,0 +1,91 @@
+/*
+ * Copyright (c) 2017 FH Dortmund and others
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Description:
+ *    RoverButton API - Interfaces for Rover button application development - Header file
+ *
+ * Contributors:
+ *    M.Ozcelikors <mozcelikors@gmail.com>, created C++API 05.12.2017
+ *
+ */
+
+#ifndef ROVERAPI_ROVER_BUTTON_HPP_
+#define ROVERAPI_ROVER_BUTTON_HPP_
+
+
+#include <roverapi/rover_gpio.hpp>
+
+namespace rover
+{
+
+	/**
+	 * @brief Button type
+	 */
+	enum RoverButtonType_t { USER_BUTTON = 0,
+							 SHUTDOWN_BUTTON = 1,
+							 CUSTOM_BUTTON = 2};
+
+	/**
+	 * @brief RoverButton class contains member functions to access Shutdown button, User button, and customly installed buttons on the rover.
+	 */
+	class RoverButton : public RoverGpio
+	{
+		private:
+			/**
+			 * @brief Shutdown button pin in wiringPi format
+			 */
+			static const int SHUTDOWN_BUTTON_PIN = 29;	//BCM-21, wiringpi 29
+
+			/**
+			 * @brief User button pin in wiringPi format
+			 */
+			static const int USER_BUTTON_PIN = 27;		//BCM-16, wiringpi 27
+
+			/**
+			 * @brief Button pin
+			 */
+			int buttonPin;
+
+			/**
+			 * @brief Button type
+			 */
+			RoverButtonType_t buttonType;
+
+			/**
+			 * @brief Flag to hold if RoverButton is set up
+			 */
+			int ROVERBUTTON_INIT_;
+
+		public:
+			/**
+			 * @brief (assigning) Constructor for RoverButton
+			 */
+			RoverButton (const RoverButtonType_t button_type);
+
+			/**
+			 * @brief RoverButton initializer
+			 * @return void
+			 */
+			void initialize (void);
+
+			/**
+			 * @brief Reads the digital value of the a button
+			 * @return val RoverGpio::LO (low) or RoverGpio::HI (high). Embedded shutdown and user buttons are pulled-up. Therefore, when the button is pressed a LOW (0) is returned.
+			 */
+			int readButton (void);
+
+			/**
+			 * @brief Overrides the default button pin used in wiringPi format
+			 * @param button_pin
+			 * @return void
+			 */
+			void setButtonPin (const int button_pin);
+	};
+}
+
+
+#endif /* ROVERAPI_ROVER_BUTTON_HPP_ */
diff --git a/rover/include/roverapi/rover_buzzer.hpp b/rover/include/roverapi/rover_buzzer.hpp
new file mode 100644
index 0000000..b347654
--- /dev/null
+++ b/rover/include/roverapi/rover_buzzer.hpp
@@ -0,0 +1,113 @@
+/*
+ * Copyright (c) 2017 FH Dortmund and others
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Description:
+ *    RoverBuzzer API - Interfaces for Rover buzzer application development
+ *    Header file
+ *
+ * Contributors:
+ *    M.Ozcelikors <mozcelikors@gmail.com>, created C++API 05.12.2017
+ *
+ */
+
+#ifndef ROVERAPI_ROVER_BUZZER_HPP_
+#define ROVERAPI_ROVER_BUZZER_HPP_
+
+#include <roverapi/rover_gpio.hpp>
+
+namespace rover
+{
+	/**
+	 * @brief RoverBuzzer class provides the member functions related to embedded buzzer on the rover.
+	 */
+	class RoverBuzzer : public RoverGpio
+	{
+		private:
+			/* Pins */
+			/**
+			 * @brief Embedded buzzer pin on rover in wiringPi format
+			 */
+			static const int DEFAULT_BUZZER_PIN = 28; //BCM-20, wiringpi 28
+
+			/**
+			 * @brief Buzzer pin in wiringPi format
+			 */
+			int BUZZER_PIN;
+
+			/* Variable members */
+			/**
+			 * @brief Default buzzer frequency used by setBuzzerOn function.
+			 */
+			int BUZZER_FREQUENCY;
+
+			/**
+			 * @brief Flag to hold if RoverBuzzer is initialized
+			 */
+			int ROVERBUZZER_INIT_;
+
+		public:
+
+			/**
+			 * @brief RoverBuzzer classs constructor
+			 */
+			RoverBuzzer();
+
+			/**
+			 * @brief Initializes the RoverBuzzer that is instantiated.
+			 * @return void
+			 */
+			void initialize (void);
+
+			/**
+			 * @brief Sets the default buzzer frequency in Hz. Values between 0-1000 Hz are conventionally used for the buzzer frequency.
+			 * @param buzzer_freq Buzzer frequency to be set in Hz
+			 * @return void
+			 */
+			void setBuzzerFrequency (const int buzzer_freq);
+
+			/**
+			 * @brief Retrieves the default buzzer frequency in Hz.
+			 * @return buzzer_freq Default buzzer frequency in Hz.
+			 */
+			int getBuzzerFrequency (void);
+
+			/**
+			 * @brief Plays the buzzer with the default frequency.
+			 * @return void
+			 */
+			void setBuzzerOn (void);
+
+			/**
+			 * @brief Turns off the buzzer.
+			 * @return void
+			 */
+			void setBuzzerOff (void);
+
+			/**
+			 * @brief Overrides the default buzzer pin in wiringPi format
+			 * @param pin in wiringPi format
+			 * @return void
+			 */
+			void setBuzzerPin (const int pin);
+
+			/**
+			 * @brief Plays the buzzer with custom buzzer frequency.
+			 * @param buzzer_freq Buzzer frequency to be set in Hz
+			 * @return void
+			 */
+			void setBuzzerTone (const int buzzer_freq);
+
+			/**
+			 * @brief Plays the shutdown tone.
+			 * @return void
+			 */
+			void shutdownTone (void);
+	};
+}
+
+
+#endif /* ROVERAPI_ROVER_BUZZER_HPP_ */
diff --git a/rover/src/roverapi/rover_button.cpp b/rover/src/roverapi/rover_button.cpp
new file mode 100644
index 0000000..90fcc8d
--- /dev/null
+++ b/rover/src/roverapi/rover_button.cpp
@@ -0,0 +1,77 @@
+/*
+ * Copyright (c) 2017 FH Dortmund and others
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Description:
+ *    RoverButton API - Interfaces for Rover button application development
+ *
+ * Contributors:
+ *    M.Ozcelikors <mozcelikors@gmail.com>, created C++API 05.12.2017
+ *
+ */
+
+#include <roverapi/rover_button.hpp>
+#include <stdio.h>
+#include <unistd.h>
+#include <stdint.h>
+
+rover::RoverButton::RoverButton (const RoverButtonType_t button_type)
+{
+	this->ROVERBUTTON_INIT_ = 0;
+
+	if (button_type == USER_BUTTON)
+	{
+		this->buttonType = USER_BUTTON;
+		this->buttonPin = USER_BUTTON_PIN;
+	}
+	else if (button_type == SHUTDOWN_BUTTON)
+	{
+		this->buttonType = SHUTDOWN_BUTTON;
+		this->buttonPin = SHUTDOWN_BUTTON_PIN;
+	}
+	else if (button_type == CUSTOM_BUTTON)
+	{
+		this->buttonType = CUSTOM_BUTTON;
+	}
+}
+
+void rover::RoverButton::initialize (void)
+{
+	if (this->buttonType == SHUTDOWN_BUTTON)
+	{
+		/* Setup shutdown button */
+		this->wPiPinMode (this->SHUTDOWN_BUTTON_PIN, this->INPUT_);
+	}
+	else if (this->buttonType == USER_BUTTON)
+	{
+		/* Setup user button */
+		this->wPiPinMode (this->USER_BUTTON_PIN, this->INPUT_);
+	}
+	else if (this->buttonType == CUSTOM_BUTTON)
+	{
+		/* Setup custom button */
+		this->wPiPinMode (this->buttonPin, this->INPUT_);
+	}
+
+	this->ROVERBUTTON_INIT_ = 1;
+}
+
+int rover::RoverButton::readButton (void)
+{
+	if (this->ROVERBUTTON_INIT_ != 1)
+	{
+		fprintf(stderr,"You havent initialized RoverButton. Use RoverButton()::initialize() !\n");
+	}
+	else
+	{
+		return this->wPiDigitalRead (this->buttonPin);
+	}
+}
+
+void rover::RoverButton::setButtonPin (const int button_pin)
+{
+	this->buttonPin = button_pin;
+}
diff --git a/rover/src/roverapi/rover_buzzer.cpp b/rover/src/roverapi/rover_buzzer.cpp
new file mode 100644
index 0000000..9425be1
--- /dev/null
+++ b/rover/src/roverapi/rover_buzzer.cpp
@@ -0,0 +1,107 @@
+/*
+ * Copyright (c) 2017 FH Dortmund and others
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Description:
+ *    RoverBuzzer API - Interfaces for Rover buzzer application development
+ *
+ * Contributors:
+ *    M.Ozcelikors <mozcelikors@gmail.com>, created C++API 05.12.2017
+ *
+ */
+
+
+#include <roverapi/rover_buzzer.hpp>
+#include <wiringPi.h>
+#include <softTone.h>
+#include <stdio.h>
+#include <unistd.h>
+#include <stdint.h>
+
+rover::RoverBuzzer::RoverBuzzer()
+:BUZZER_FREQUENCY(200), /* Initialize default buzzer frequency */
+ ROVERBUZZER_INIT_(0),
+ BUZZER_PIN (DEFAULT_BUZZER_PIN)
+{
+
+}
+
+void rover::RoverBuzzer::initialize (void)
+{
+	//wiringPiSetup();
+	/* Setup buzzer */
+	this->wPiPinMode (this->BUZZER_PIN, this->SOFT_TONE_OUTPUT_);
+	this->wPiSoftToneCreate (this->BUZZER_PIN);
+
+	this->ROVERBUZZER_INIT_ = 1;
+}
+
+void rover::RoverBuzzer::setBuzzerFrequency (const int buzzer_freq)
+{
+	this->BUZZER_FREQUENCY = buzzer_freq;
+}
+
+int rover::RoverBuzzer::getBuzzerFrequency (void)
+{
+	return this->BUZZER_FREQUENCY;
+}
+
+void rover::RoverBuzzer::setBuzzerOn (void)
+{
+	if (this->ROVERBUZZER_INIT_ != 1)
+	{
+		fprintf(stderr,"You havent initialized RoverGpio. Use RoverGpio()::initialize() !\n");
+	}
+	else
+	{
+		this->wPiSoftToneWrite (this->BUZZER_PIN, this->BUZZER_FREQUENCY);
+	}
+}
+
+void rover::RoverBuzzer::setBuzzerOff (void)
+{
+	if (this->ROVERBUZZER_INIT_ != 1)
+	{
+		fprintf(stderr,"You havent initialized RoverGpio. Use RoverGpio()::initialize() !\n");
+	}
+	else
+	{
+		this->wPiSoftToneWrite (this->BUZZER_PIN, 0);
+	}
+}
+
+void rover::RoverBuzzer::shutdownTone (void)
+{
+	if (this->ROVERBUZZER_INIT_ != 1)
+	{
+		fprintf(stderr,"You havent initialized RoverGpio. Use RoverGpio()::initialize() !\n");
+	}
+	else
+	{
+		this->wPiSoftToneWrite (this->BUZZER_PIN, 300);
+		this->wPiDelay (2000);
+		this->wPiSoftToneWrite (BUZZER_PIN, 0);
+	}
+}
+
+void rover::RoverBuzzer::setBuzzerTone (const int buzzer_freq)
+{
+	if (this->ROVERBUZZER_INIT_ != 1)
+	{
+		fprintf(stderr,"You havent initialized RoverGpio. Use RoverGpio()::initialize() !\n");
+	}
+	else
+	{
+		this->wPiSoftToneWrite (this->BUZZER_PIN, buzzer_freq);
+	}
+}
+
+void rover::RoverBuzzer::setBuzzerPin (const int pin)
+{
+	this->BUZZER_PIN = pin;
+}
+
+