a

Files at this revision

API Documentation at this revision

Comitter:
fundokukiri
Date:
Wed Oct 09 12:55:47 2019 +0000
Commit message:
a

Changed in this revision

F746GUI.cpp Show annotated file Show diff for this revision Revisions of this file
F746GUI.hpp Show annotated file Show diff for this revision Revisions of this file
F746_BUTTON.cpp Show annotated file Show diff for this revision Revisions of this file
F746_BUTTON.hpp Show annotated file Show diff for this revision Revisions of this file
F746_SLIDER.cpp Show annotated file Show diff for this revision Revisions of this file
F746_SLIDER.hpp Show annotated file Show diff for this revision Revisions of this file
diff -r 000000000000 -r a7fb0dba4c8a F746GUI.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/F746GUI.cpp	Wed Oct 09 12:55:47 2019 +0000
@@ -0,0 +1,13 @@
+//-----------------------------------------------------------
+//
+//  F746_GUI
+//
+//-----------------------------------------------------------
+
+#include "F746GUI.hpp"
+
+    LCD_DISCO_F746NG GUI::lcd_;
+    TS_DISCO_F746NG GUI::ts_;
+
+
+
diff -r 000000000000 -r a7fb0dba4c8a F746GUI.hpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/F746GUI.hpp	Wed Oct 09 12:55:47 2019 +0000
@@ -0,0 +1,48 @@
+/*-----------------------------------------------------------
+ * F746_GUI Library v1.0
+ * Copyright (c) 2018 Wynand Steenberg
+ * s216875730@mandela.ac.za
+ *
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *-----------------------------------------------------------
+ */
+
+#ifndef F746_GUI_HPP
+#define F746_GUI_HPP
+
+#include "mbed.h"
+#include <string>
+#include "TS_DISCO_F746NG.h"
+#include "LCD_DISCO_F746NG.h"
+
+
+    class GUI
+    {
+    public:                    
+        static LCD_DISCO_F746NG* GetLcdPtr() { return &lcd_; }
+        static TS_DISCO_F746NG* GetTsPtr() { return &ts_; }
+
+
+    protected:
+        static LCD_DISCO_F746NG lcd_;  // for LCD display
+        static TS_DISCO_F746NG ts_;    // for touch panel
+    };
+
+#endif  // F746_GUI_HPP
diff -r 000000000000 -r a7fb0dba4c8a F746_BUTTON.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/F746_BUTTON.cpp	Wed Oct 09 12:55:47 2019 +0000
@@ -0,0 +1,116 @@
+//-----------------------------------------------------------
+//
+//  F746_BUTTON class
+//
+//-----------------------------------------------------------
+
+#include "F746_BUTTON.hpp"
+
+// Draw button
+void Button::Render()
+    {
+        active_ = true;
+        
+        switch(STYLE_)
+            {
+                case 1:                                     // Style 1 - Normal button 
+                    lcd_.SetTextColor(BUTTON_COLOUR_);      // Set Textcolour to original
+                    lcd_.FillRect(ButtonX_, ButtonY_, ButtonW_, ButtonH_);  // Draw button rectangle
+                    break;
+        
+                case 2:                                     // Style 2 - 3D button
+                    lcd_.SetTextColor(LCD_COLOR_DARKGRAY);  // Set Textcolour to shadow colour
+                    lcd_.FillRect(ButtonX_+1, ButtonY_+2, (ButtonW_+3), ButtonH_+3);// Draw shadow
+                    
+                    lcd_.SetTextColor(BUTTON_COLOUR_);      // Set Textcolour to original
+                    lcd_.FillRect(ButtonX_, ButtonY_, ButtonW_, ButtonH_);  // Draw button
+                    break; 
+            }  
+             if (LABEL_.length() != 0)                        // If the label is larger than 0
+                    {
+                        lcd_.SetFont(FONTS_);
+                        lcd_.SetBackColor(BUTTON_COLOUR_);    // Set background colour
+                        lcd_.SetTextColor(LCD_COLOR_WHITE);   // Set textcolour
+
+                        uint16_t x0 = ButtonX_ + (ButtonW_ - FONT_WIDTH_*(LABEL_.length()))/2;      // Calcukate x value for Button name
+                        uint16_t y0 = ButtonY_ + (ButtonH_ - FONT_HEIGHT_)/2 + 1;                   // Calcukate y value for Button name
+                        lcd_.DisplayStringAt(x0, y0, (uint8_t *)LABEL_.c_str(),   
+                                 LEFT_MODE);                    // Write button name
+                        lcd_.SetBackColor(LCD_COLOR_WHITE);     // Set back colour
+                    }        
+    }
+    
+
+void Button::Change()   // Change colour of button when pressed
+    {
+        switch(STYLE_)
+            {
+                case 1:                                     // Style 1 - Normal button 
+                    lcd_.SetTextColor(CHANGE_COLOUR_);      // Set Textcolour to the change colour
+                    lcd_.FillRect(ButtonX_, ButtonY_, ButtonW_, ButtonH_);          // Draw button rectangle
+                    break;
+        
+                case 2:                                     // Style 2 - 3D button
+                    lcd_.SetTextColor(LCD_COLOR_WHITE);     // Set Textcolour to background colour
+                    lcd_.FillRect(ButtonX_, ButtonY_, (ButtonW_+3), ButtonH_+3);    // Clears background
+    
+                    lcd_.SetTextColor(LCD_COLOR_GRAY);      // Set Textcolour to shadow colour
+                    lcd_.FillRect(ButtonX_+1, ButtonY_+2, (ButtonW_+3), ButtonH_+3);// Draws shadow
+        
+                    lcd_.SetTextColor(CHANGE_COLOUR_);      // Indent button
+                    lcd_.FillRect((ButtonX_+6), (ButtonY_+6), (ButtonW_-3), (ButtonH_-2));  // Draw indented button
+                    break; 
+                }         
+        
+             if (LABEL_.length() != 0)            
+                    {
+                        lcd_.SetFont(FONTS_);
+                        lcd_.SetBackColor(CHANGE_COLOUR_);
+                        lcd_.SetTextColor(LCD_COLOR_BLACK);
+                        uint16_t x0 = ButtonX_ + (ButtonW_ - FONT_WIDTH_*(LABEL_.length()))/2;  // Calcukate x value for Button name
+                        uint16_t y0 = ButtonY_ + (ButtonH_ - FONT_HEIGHT_)/2 + 1;               // Calcukate y value for Button name
+                        lcd_.DisplayStringAt(x0, y0, (uint8_t *)LABEL_.c_str(),
+                                 LEFT_MODE);                // Write button name 
+                        lcd_.SetBackColor(LCD_COLOR_WHITE); // Set back colour
+                    }          
+    }
+    
+        
+
+void Button::Hide()     // Hide button
+    {
+        lcd_.SetTextColor(LCD_COLOR_WHITE);                     // Set textcolour to background colour
+        lcd_.FillRect(ButtonX_, ButtonY_, ButtonW_, ButtonH_);  // Draw rectangle in background colour     
+        active_ = false;                                        // Set active boolean to false
+    }
+      
+
+bool Button::Press()      // Check if touch detected
+    {
+        ts_.GetState(&state_);
+        if (!state_.touchDetected) return false;
+        if (!active_) return false;
+        if (!ButtonBoundaryCheck()) return false;
+        Change();           // Run the Change routine to change the colour of the button
+        wait(0.2);          // Wait to allow the colour change to be visible
+        Render();           // Draw the original button
+        return true;
+    } 
+
+bool Button::ButtonBoundaryCheck()       // Check if touch is within button boundaries
+    {
+        int nTouch = multiTouch ? state_.touchDetected : 1;
+        for (int n=0; n<nTouch; n++)
+        {
+            uint16_t x = state_.touchX[n];                  // Assign touch x pos to x
+            uint16_t y = state_.touchY[n];                  // Assign touch y pos to y
+
+            if ( (ButtonX_ <= x) && (x <= ButtonX_+ButtonW_) &&               // Check x value inside boundary
+                 (ButtonY_ <= y) && (y <= ButtonY_+ButtonH_) ) return true;   // Check y value inside boundary
+        }
+        return false;
+    }
+    
+TS_StateTypeDef Button::state_;
+bool Button::multiTouch = false;
+
diff -r 000000000000 -r a7fb0dba4c8a F746_BUTTON.hpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/F746_BUTTON.hpp	Wed Oct 09 12:55:47 2019 +0000
@@ -0,0 +1,240 @@
+/*-----------------------------------------------------------
+ * F746_BUTTON Library v1.0
+ * Copyright (c) 2018 Wynand Steenberg
+ * s216875730@mandela.ac.za
+ *
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *-----------------------------------------------------------
+ */
+
+#ifndef F746_BUTTON_HPP
+#define F746_BUTTON_HPP
+
+#include "mbed.h"
+#include <string>
+#include "TS_DISCO_F746NG.h"
+#include "LCD_DISCO_F746NG.h"
+#include "F746GUI.hpp"
+
+/** A Class library for using Buttons on the DISCO-F746NG Development board.  The class
+ * uses the existing BSP class created by Team ST.
+ *
+ * Example:
+ * @code
+ * #include "mbed.h"
+ * #include "F746_BUTTON.hpp"
+ * 
+ * TS_DISCO_F746NG ts_;
+ * LCD_DISCO_F746NG lcd_;
+ * 
+ * int main()
+ * {
+ *     lcd_.Clear(LCD_COLOR_WHITE);                                        // Set LCD Background colour
+ *        
+ *     Button btn1(lcd_, ts_, 20, 50, 80, 40,           
+ *                  LCD_COLOR_BLUE, LCD_COLOR_YELLOW, 1, "BUTTON1", Font12);  // Define btn1 button            
+ *     btn1.Render();                                                         // Draw btn1 button
+ *     
+ *     Button test(lcd_, ts_, 120, 50, 80, 40,
+ *                  LCD_COLOR_DARKBLUE, LCD_COLOR_GREEN, 1, "TEST", Font12);  // Define test button                   
+ *     test.Render();                                                         // Draw test button
+ *     
+ *     Button show(lcd_, ts_, 220, 50, 80, 40,            
+ *                  LCD_COLOR_BROWN, LCD_COLOR_GRAY, 1,  "SHOW", Font12);     // Define hide button            
+ *     show.Hide();  
+ *     
+ *     Button hide(lcd_, ts_, 220, 50, 80, 40,            
+ *                  LCD_COLOR_BROWN, LCD_COLOR_GRAY, 1,  "HIDE", Font12);     // Define hide button             
+ *     hide.Render();                                                         // Draw hide button
+ *     
+ *     Button button3D(lcd_, ts_, 320, 50, 120, 40,             
+ *                  LCD_COLOR_BLUE, LCD_COLOR_YELLOW, 2, "3D BUTTON", Font12);    // Define button3D button            
+ *     button3D.Render();                                                         // Draw 3Dbutton button
+ * 
+ *     lcd_.SetTextColor(LCD_COLOR_BLACK);                                                         // Set Text colour to Black
+ *     lcd_.SetFont(&Font12);                                                                      // Font size 12
+ *     lcd_.DisplayStringAt(5, 5, (uint8_t *)"Button / Slider driver for DISCO_F746", LEFT_MODE);  // Display main header text
+ *     lcd_.DisplayStringAt(5, 20, (uint8_t *)"Button example", LEFT_MODE);  // Display secondary header text
+ *     lcd_.DisplayStringAt(5, 135, (uint8_t *)"Slider example", LEFT_MODE);  // Display secondary header text
+ * 
+ *     while (true)                                                    // Main program loop
+ *     {
+ *     
+ *         if (btn1.Press())                                         // Check if btn1 button was touched and run instructions if true
+ *         {    
+ *             lcd_.SetFont(&Font12);
+ *             lcd_.SetTextColor(LCD_COLOR_BLACK);
+ *             lcd_.DisplayStringAt(5, 110, (uint8_t *)"Button1 pressed", LEFT_MODE);
+ *             wait(0.5); 
+ *             lcd_.DisplayStringAt(5, 110, (uint8_t *)"                                        ", LEFT_MODE);
+ *         }                                                         // End btn1 button instructions
+ *         
+ *         if (test.Press())                                         // Check if test button was touched and run instructions if true
+ *         {
+ *             lcd_.SetFont(&Font12);
+ *             lcd_.SetTextColor(LCD_COLOR_BLACK);
+ *             lcd_.DisplayStringAt(5, 110, (uint8_t *)"TEST pressed", LEFT_MODE);
+ *             wait(0.5);
+ *             lcd_.DisplayStringAt(5, 110, (uint8_t *)"                                        ", LEFT_MODE);
+ *             
+ *         }                                                         // End test button instructions
+ *         
+ *         if (hide.Press())                                         // Check if hide button was touched and run instructions if true
+ *         {    
+ *             lcd_.SetFont(&Font12);
+ *             lcd_.SetTextColor(LCD_COLOR_BLACK);
+ *             lcd_.DisplayStringAt(5, 110, (uint8_t *)"Hide pressed - Hide other buttons", LEFT_MODE);
+ *             btn1.Hide();                                            // Hide btn1 button
+ *             test.Hide();                                            // Hide test button
+ *             hide.Hide();  
+ *             show.Render();
+ *             wait(0.5);
+ *             lcd_.DisplayStringAt(5, 110, (uint8_t *)"                                        ", LEFT_MODE);
+ *         }                                                           // End hide button instructions
+ *         
+ *          if (show.Press())                                        // Check if hide button was touched and run instructions if true
+ *         {  
+ *             lcd_.SetFont(&Font12);
+ *             lcd_.SetTextColor(LCD_COLOR_BLACK);
+ *             lcd_.DisplayStringAt(5, 110, (uint8_t *)"UNHIDE pressed - Restore other buttons", LEFT_MODE);
+ *             wait(0.5);
+ *             lcd_.DisplayStringAt(5, 110, (uint8_t *)"                                        ", LEFT_MODE);
+ *             show.Hide();                                            // Hide show button before drawing new button in same place
+ *             hide.Render();                                            // Draw hide button after hiding button in same position
+ *             btn1.Render();                                            // Draw btn1 button
+ *             test.Render();                                            // Draw test button
+ *            
+ *         }         
+ *         
+ *         if (button3D.Press())                                     // Check if 3Dbutton button was touched and run instructions if true
+ *         {    
+ *             lcd_.SetFont(&Font12);
+ *             lcd_.SetTextColor(LCD_COLOR_BLACK);
+ *             lcd_.DisplayStringAt(5, 110, (uint8_t *)"3D Button pressed", LEFT_MODE);
+ *             wait(0.5);
+ *             lcd_.DisplayStringAt(5, 110, (uint8_t *)"                                           ", LEFT_MODE);
+ *         }                                                           // End 3D button instructions
+ *  
+ *         wait(0.02f);   
+ *     }                                                               // End Main program loop
+ * }                                                                   // End Main program 
+ * @endcode
+ */
+
+    class Button
+    {
+    public:
+    
+        //! Constructor
+        Button(LCD_DISCO_F746NG &lcd, TS_DISCO_F746NG &ts,
+               uint16_t x, uint16_t y, uint16_t width, uint16_t height,
+               uint32_t buttonColour, uint32_t changeColour,
+               int style, const string label = "", sFONT &fonts = Font12,
+               uint32_t textColour = LCD_COLOR_WHITE)
+               : lcd_(lcd), ts_(ts), ButtonX_(x), ButtonY_(y), ButtonW_(width), ButtonH_(height),
+                 BUTTON_COLOUR_(buttonColour), CHANGE_COLOUR_(changeColour),
+                 STYLE_(style), LABEL_(label), FONTS_(&fonts), FONT_WIDTH_(fonts.Width),
+                 FONT_HEIGHT_(fonts.Height), active_(true)
+                 { Render(); }
+
+        /**
+          * @brief  Draw Button.
+          *         
+          */
+        void Render();
+        
+        /**
+          * @brief  Draw 3D Button.
+          *         
+          */
+        void Render3D();
+        
+        /**
+          * @brief  Change colour of Button.
+          *         
+          */
+        void Change();
+
+        /**
+          * @brief  Change colour of 3D Button.
+          *         
+          */
+        void Change3D();
+        
+        /**
+          * @brief  Hide Button.
+          *         
+          */
+        void Hide();
+
+        /**
+          * @brief  Check touch detected on Button.
+          *         
+          */
+        bool Press();
+        
+        /**
+          * @brief  Check if touch is on Button.
+          *         
+          */      
+        bool ButtonBoundaryCheck();
+        
+        /**
+          * @brief  Check previous state of Button.
+          *         
+          */
+        static TS_StateTypeDef GottenState()
+        {   return state_; }
+
+        /**
+          * @brief  Set or reset multi-touch.
+          *         
+          */
+        static void SetMultiTouch(bool tf) { multiTouch = tf; }
+
+
+    private:
+
+        LCD_DISCO_F746NG &lcd_;         // LCD
+        TS_DISCO_F746NG &ts_;           // Touch
+        
+        const uint16_t ButtonX_, ButtonY_, ButtonW_, ButtonH_;
+        const uint32_t BUTTON_COLOUR_;  // Original colour
+        const uint32_t CHANGE_COLOUR_;  // Colour to change to color
+        const int STYLE_;               // Button style
+        const string LABEL_;            // Button label
+        sFONT *const FONTS_;            // Button Style
+        const uint16_t FONT_WIDTH_;     
+        const uint16_t FONT_HEIGHT_;
+        bool active_;                   // Button active boolean
+        
+        static TS_StateTypeDef state_;
+        static bool multiTouch;
+
+        /**
+          * @brief  Disallow copy constructor and assignment operator.
+          *         
+          */ 
+        Button(const Button&);
+        Button& operator=(const Button&);
+        
+
+    };
+#endif  // F746_BUTTON_HPP
diff -r 000000000000 -r a7fb0dba4c8a F746_SLIDER.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/F746_SLIDER.cpp	Wed Oct 09 12:55:47 2019 +0000
@@ -0,0 +1,137 @@
+//-----------------------------------------------------------
+//
+//  F746_SLIDER class
+//
+//-----------------------------------------------------------
+
+#include "F746_SLIDER.hpp"
+
+extern uint16_t SliderDisplayValue_;
+
+// Draw Slider
+void Slider::Render()
+    {
+        active_ = true;
+        char min_[3];               //string Slider minimum;
+        char max_[3];               //string Slider maximum;
+        
+        switch(STYLE_)
+            {
+                case 1:                                     // Style 1 - Normal Slider         
+                    lcd_.SetTextColor(SLIDER_COLOUR_);                  // Slider rectangle
+                    lcd_.FillRect(SliderX_, SliderY_, SliderW_, 40);
+                    lcd_.SetTextColor(LCD_COLOR_GRAY);                  // Slider Control rectangle
+                    uint16_t xC = (SliderW_/(Max_-Min_)* valueControl_);          // Calculate initial value of Slider control
+                    lcd_.FillRect(SliderX_+xC-20, SliderY_, 40, 40);
+                    break;
+        
+                case 2:                                     // Style 2 - 3D Slider
+                    lcd_.SetTextColor(LCD_COLOR_DARKGRAY);  // Set Textcolour to shadow colour
+                    lcd_.FillRect(SliderX_+2, SliderY_+2, SliderW_+3, 40+3);    // Draws shadow                
+                    lcd_.SetTextColor(SLIDER_COLOUR_);                          // Slider rectangle
+                    lcd_.FillRect(SliderX_, SliderY_, SliderW_, 40);
+                    lcd_.SetTextColor(LCD_COLOR_GRAY);                          // Slider Control rectangle
+                    xC = (SliderW_/(Max_-Min_)* valueControl_);                           // Calculate initial value of Slider control
+                    lcd_.FillRect(SliderX_+xC-20, SliderY_, 40, 40);
+                    break; 
+            }          
+     
+        if (LABEL_.length() != 0)
+            {
+                lcd_.SetFont(FONTS_);
+                lcd_.SetBackColor(LCD_COLOR_WHITE);
+                lcd_.SetTextColor(LCD_COLOR_BLACK);
+                        
+                sprintf(min_, "%2d", (int) Min_);           // Convert minimum value to string
+                lcd_.DisplayStringAt(SliderX_, SliderY_+50, (uint8_t *)min_, LEFT_MODE);  // Display Slider minimum value
+
+                sprintf(max_, "%2d", (int) Max_);           // Convert maximum value to string
+                lcd_.DisplayStringAt((SliderX_+SliderW_-40), (SliderY_+50), (uint8_t *)max_, LEFT_MODE);  // Display Slider minimum value                        
+
+                uint16_t x0 = SliderX_ + (SliderW_ - FONT_WIDTH_*(LABEL_.length()))/2;      // Calcukate middle x value for Slider name
+                uint16_t y0 = SliderY_ + (SliderH_ - FONT_HEIGHT_)/2 + 1;                   // Calcukate y value for Slider name
+                lcd_.DisplayStringAt(x0, y0-50, (uint8_t *)LABEL_.c_str(),    
+                                 LEFT_MODE);                                        // Write Slider name
+            }        
+    }
+    
+        
+// Service Slider
+void Slider::Service()
+    {  
+        uint16_t xC_;           // X value of Control rectangle
+        uint16_t valueControl_; // Value of Slider control to display
+        
+        switch(STYLE_)
+            {
+                case 1:                                     // Style 1 - Normal button 
+                lcd_.SetTextColor(SLIDER_COLOUR_);          // Draw Slider rectangle
+                lcd_.FillRect(SliderX_, SliderY_, SliderW_, 40);
+                break;
+        
+                case 2:                                                     // Style 2 - 3D button
+                    lcd_.SetTextColor(LCD_COLOR_DARKGRAY);                  // Set Textcolour to shadow colour
+                    lcd_.FillRect(SliderX_+2, SliderY_+2, SliderW_+3, 40+3);// Draws shadow                
+                    lcd_.SetTextColor(SLIDER_COLOUR_);                      // Slider rectangle
+                    lcd_.FillRect(SliderX_, SliderY_, SliderW_, 40);
+                    lcd_.SetTextColor(LCD_COLOR_GRAY);                      // Slider Control rectangle
+                    break; 
+            }
+
+        uint16_t newX = state_.touchX[0];                       // Find new x value of touch
+             
+        if ((newX >= SliderX_) and (newX <= SliderX_+ 40))      // if touch at beginning of Slider
+            {
+                    {   xC_ = SliderX_;   }                     // Sets x value of Slider control to left x value defined for slider rectangle
+            }
+                            
+        else if ((newX >= SliderX_+SliderW_-40) and (newX <= SliderX_+ SliderW_))   // if touch at the end of Slider
+            {
+                xC_ = SliderX_+SliderW_-40;                     // Sets x value of Slider control to right x value defined for slider rectangle - width of slider control
+            }
+                            
+        else xC_ = newX - 20;                       // if touch inside Slider    
+                       
+        lcd_.SetTextColor(LCD_COLOR_YELLOW);        // Colour to change the control of the Slider when touched    
+        lcd_.FillRect(xC_, SliderY_, 40, 40);
+                        
+        valueControl_ = (newX - SliderX_) * (Max_ - Min_) / SliderW_ + Min_;      // Value to display of the control of the Slider
+        if (valueControl_== (Min_+1))valueControl_= Min_;               // Set value value to display to minimum
+        if (valueControl_== (Max_-1))valueControl_= Max_;               // Set value value to display to maximum                                              
+                        
+                        
+        lcd_.SetTextColor(LCD_COLOR_BLACK);    
+        SliderDisplayValue_ = valueControl_;
+        lcd_.SetTextColor(LCD_COLOR_YELLOW);       
+    } 
+
+
+        
+bool Slider::Moved()          // Check touch detected
+    {
+        ts_.GetState(&state_);  // Get state of touch
+        if (!state_.touchDetected) return false;
+        if (!active_) return false;
+        if (!SliderBoundaryCheck()) return false;
+        Service();              // Run Service routine
+        return SliderBoundaryCheck();
+    }
+ 
+
+bool Slider::SliderBoundaryCheck()       // Check if touch is within Slider boundaries
+    {
+        int nTouch = multiTouch ? state_.touchDetected : 1;
+        for (int n=0; n<nTouch; n++)
+        {
+            uint16_t x = state_.touchX[n];                  // Find x value of touch
+            uint16_t y = state_.touchY[n];                  // Find y value of touch
+
+            if ( (SliderX_ <= x) && (x <= SliderX_+SliderW_) &&               
+                 (SliderY_ <= y) && (y <= SliderY_+SliderH_) ) return true;   // Check if touch is within Slider defined values
+        }
+        return false;
+    }
+ 
+TS_StateTypeDef Slider::state_;
+bool Slider::multiTouch = false;    // Disable multitouch for Slider
+
diff -r 000000000000 -r a7fb0dba4c8a F746_SLIDER.hpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/F746_SLIDER.hpp	Wed Oct 09 12:55:47 2019 +0000
@@ -0,0 +1,197 @@
+/*-----------------------------------------------------------
+ * F746_SLIDER Library v1.0
+ * Copyright (c) 2018 Wynand Steenberg
+ * s216875730@mandela.ac.za
+ *
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *-----------------------------------------------------------
+ */
+
+#ifndef F746_SLIDER_HPP
+#define F746_SLIDER_HPP
+
+#include "mbed.h"
+#include <string>
+#include "TS_DISCO_F746NG.h"
+#include "LCD_DISCO_F746NG.h"
+#include "F746GUI.hpp"
+
+/** A Class library for using Sliders on the DISCO-F746NG Development board.  The class
+ * uses the existing BSP class created by Team ST.
+ *
+ * Example:
+ * @code
+ * #include "mbed.h"
+ * #include "F746_SLIDER.hpp"
+ * 
+ * TS_DISCO_F746NG ts_;
+ * LCD_DISCO_F746NG lcd_;
+ * 
+ * 
+ * char char_SliderDisplayValue[4];    // String Value to display for the Slider Control value 
+ * uint16_t SliderDisplayValue_;       // Variable used to access Slider Control Value in F746SLIDER.cpp
+ * 
+ * int main()
+ * {
+ *     lcd_.Clear(LCD_COLOR_WHITE);                                        // Set LCD Background colour
+ *    
+ *     Slider sld1(lcd_, ts_, 20, 205, 150, 20, 5, 1, 20,     
+ *                  LCD_COLOR_BLUE, LCD_COLOR_YELLOW, 1, "Slider1", Font12);   // Define sld1 slider            
+ *     sld1.Render();                                                          // Draw sld1 Slider  
+ *    
+ *     Slider Slider2(lcd_, ts_, 240, 205, 220, 20, 50, 1, 100,        
+ *                  LCD_COLOR_BLUE, LCD_COLOR_YELLOW, 2, "Slider2", Font12);   // Define Slider2 slider            
+ *     Slider2.Render();                                                       // Draw Slider2 Slider      
+ *        
+ *     lcd_.SetTextColor(LCD_COLOR_BLACK);                                                         // Set Text colour to Black
+ *     lcd_.SetFont(&Font12);                                                                      // Font size 12
+ *     lcd_.DisplayStringAt(5, 5, (uint8_t *)"Slider driver for DISCO_F746", LEFT_MODE);  // Display main header text
+ *     lcd_.DisplayStringAt(5, 135, (uint8_t *)"Slider example", LEFT_MODE);  // Display secondary header text
+ * 
+ *     while (true)                                                    // Main program loop
+ *     {
+ *         if (sld1.Moved())                                           // Check if sld1 Slider was touched and run instructions if true
+ *         {    
+ *             lcd_.SetTextColor(LCD_COLOR_BLACK);                     
+ *             lcd_.FillRect(130, 140, 80, 40);                         // Draw border to display Slider Control Value
+ *             lcd_.SetTextColor(LCD_COLOR_WHITE);
+ *             lcd_.FillRect(140, 145, 60, 30);                         // Draw border to display Slider Control Value                                     
+ *             
+ *             sprintf(char_SliderDisplayValue, "%3d", (int) SliderDisplayValue_);                     // Convert integer to text
+ *             lcd_.SetFont(&Font12);                                                                  // Set Font size
+ *             lcd_.SetTextColor(LCD_COLOR_BLACK);                                                     // Set Font colour
+ *             lcd_.DisplayStringAt(150, 155, (uint8_t *)char_SliderDisplayValue, LEFT_MODE);          // Write Slider Control Value to the LCD
+ *             
+ *             if (SliderDisplayValue_ < 10)                                                           // Slider Control Value decision
+ *                 {
+ *                     lcd_.DisplayStringAt(60, 190, (uint8_t *)"                     ", LEFT_MODE);   // Overwrite previous text
+ *                     lcd_.DisplayStringAt(60, 190, (uint8_t *)"SLIDER1 < 50%", LEFT_MODE);           // Write text to LCD
+ *                 }
+ *             else if (SliderDisplayValue_ == 10)                                                     // Slider Control Value decision
+ *                 {  
+ *                     lcd_.DisplayStringAt(60, 190, (uint8_t *)"                     ", LEFT_MODE);   // Overwrite previous text
+ *                     lcd_.DisplayStringAt(60, 190, (uint8_t *)"SLIDER1 = 50%", LEFT_MODE);           // Write text to LCD
+ *                 }
+ *             else                                                                                    // Slider Control Value decision
+ *                 {  
+ *                     lcd_.DisplayStringAt(60, 190, (uint8_t *)"                     ", LEFT_MODE);   // Overwrite previous text
+ *                     lcd_.DisplayStringAt(60, 190, (uint8_t *)"SLIDER1 > 50%", LEFT_MODE);           // Write text to LCD
+ *                 }          
+ *         }                                                                                           // End sld1 instructions
+ * 
+ *         if (Slider2.Moved())                                      // Check if Slider2 Slider was touched and run instructions if true
+ *         {    
+ *             lcd_.SetTextColor(LCD_COLOR_BLACK);                     
+ *             lcd_.FillRect(390, 140, 80, 40);                         // Draw border to display Slider Control Value
+ *             lcd_.SetTextColor(LCD_COLOR_WHITE);
+ *             lcd_.FillRect(400, 145, 60, 30);                         // Draw border to display Slider Control Value                                     
+ *             
+ *             sprintf(char_SliderDisplayValue, "%3d", (int) SliderDisplayValue_);                     // Convert integer to text
+ *             lcd_.SetFont(&Font12);                                                                  // Set Font size
+ *             lcd_.SetTextColor(LCD_COLOR_BLACK);                                                     // Set Font colour
+ *             lcd_.DisplayStringAt(415, 155, (uint8_t *)char_SliderDisplayValue, LEFT_MODE);          // Write Slider Control Value to the LCD
+ *         }    
+ *     
+ *         wait(0.02f);   
+ *     }                                                               // End Main program loop
+ * }                                                                   // End Main program 
+ * @endcode
+ */
+
+    class Slider
+    {
+    public:
+        //! Constructor
+        Slider(LCD_DISCO_F746NG &lcd, TS_DISCO_F746NG &ts,
+               uint16_t x, uint16_t y, uint16_t width, uint16_t height,
+               uint16_t value_C, uint16_t min, uint16_t max,
+               uint32_t sliderColour, uint32_t changeColour,
+               int style, const string label = "", sFONT &fonts = Font12,
+               uint32_t textColour = LCD_COLOR_WHITE)
+               : lcd_(lcd), ts_(ts), SliderX_(x), SliderY_(y), SliderW_(width), SliderH_(height),
+                 valueControl_(value_C), Min_ (min), Max_ (max), 
+                 SLIDER_COLOUR_(sliderColour), CHANGE_COLOUR_(changeColour),
+                 STYLE_(style), LABEL_(label), FONTS_(&fonts), FONT_WIDTH_(fonts.Width),
+                 FONT_HEIGHT_(fonts.Height), active_(true)
+                 { Render(); }
+
+        /**
+          * @brief  Draw Slider.
+          *         
+          */
+        void Render();
+        
+        /**
+          * @brief  Service Slider.
+          *         
+          */
+        void Service();
+               
+        /**
+          * @brief  Check touch detected on Slider.
+          *         
+          */
+        bool Moved();
+   
+        /**
+          * @brief  Check if touch is on Slider.
+          *         
+          */
+        bool SliderBoundaryCheck();
+        
+        /**
+          * @brief  Check previous state of Slider.
+          *         
+          */
+        static TS_StateTypeDef GottenState()
+        {   return state_; }
+
+        /**
+          * @brief  Set or reset multi-touch.
+          *         
+          */
+        static void SetMultiTouch(bool tf) { multiTouch = tf; }
+
+                
+    private:
+        LCD_DISCO_F746NG &lcd_;
+        TS_DISCO_F746NG &ts_;
+
+        const uint16_t SliderX_, SliderY_, SliderW_, SliderH_, valueControl_, Min_, Max_;
+        const uint32_t SLIDER_COLOUR_;  // original color
+        const uint32_t CHANGE_COLOUR_;  // colour to change to color
+        const int STYLE_;               // Slider style        
+        const string LABEL_;            // Slider label
+        sFONT *const FONTS_;
+        const uint16_t FONT_WIDTH_;
+        const uint16_t FONT_HEIGHT_;
+        bool active_;                   // Slider active boolean
+        
+        static TS_StateTypeDef state_;
+        static bool multiTouch;
+
+        /**
+          * @brief  Disallow copy constructor and assignment operator.
+          *         
+          */
+        Slider(const Slider&);
+        Slider& operator=(const Slider&);
+    };
+#endif  // F746_SLIDER_HPP