Browse Source

HSA_LCD_Shield.h: extend De/Constructor, Config-Function, Write-Function

Tobias Müller 6 years ago
parent
commit
faf9cd9a04
1 changed files with 256 additions and 57 deletions
  1. 256 57
      HSA_LCD_Shield.h

+ 256 - 57
HSA_LCD_Shield.h

@@ -1,28 +1,27 @@
-//////////////////////////////////////////////////////////////////////
-//                                                                  //
-// Programmname: HSA_LCD_Shield - Header                            //
-// Datum: 23.04.2018                                                //
-// Beschreibung: Header-Datei für das LCD-Shield, welches im Modul  //
-//               "Elektronikdesign" erstellt wurde. Hier werden     //
-//               alle Funktionen der Klasse "HSA_LCD_Shield" auf-   //
-//               geführt und beschrieben.                           //
-//                                                                  //
-// Autor: Tobias Müller, M. Eng.                                    //
-//                                                                  //
-//////////////////////////////////////////////////////////////////////
-
-//////////////////////////////////////////////////////////////////////
-//////////                  create Header                   //////////
-//////////////////////////////////////////////////////////////////////
-
-#ifndef HSA_LCD_Shield
-#define HSA_LCD_Shield
-
-//////////////////////////////////////////////////////////////////////
-//////////                  Define Symbol                   //////////
-//////////////////////////////////////////////////////////////////////
-
-// I²C Addresse
+////////////////////////////////////////////////////////////////////////////////
+//                                                                            //
+// Programname: HSA_LCD_Shield - Header                                       //
+// Date: 23.04.2018                                                           //
+// Description: Header-File of the LCD-Shield, which was designed and built   //
+//              in the Modul "Elektronikdesign". In this file you can find    //
+//              the description of all functions of the class HSA_LCD_Shield. //
+//                                                                            //
+// Author: Tobias Müller, M. Eng.                                             //
+//                                                                            //
+////////////////////////////////////////////////////////////////////////////////
+
+////////////////////////////////////////////////////////////////////////////////
+////////////////////             Create Header              ////////////////////
+////////////////////////////////////////////////////////////////////////////////
+
+#ifndef HSA_LCD_SHIELD
+#define HSA_LCD_SHIELD
+
+////////////////////////////////////////////////////////////////////////////////
+////////////////////             Define Symbol              ////////////////////
+////////////////////////////////////////////////////////////////////////////////
+
+// I²C Addresse (Default)
 #ifndef I2C_ADDRESS
 #define I2C_ADDRESS 0x3C
 #endif
@@ -62,57 +61,257 @@
 #define LCD_BACKLIGHT 0x08
 #endif
 
-//////////////////////////////////////////////////////////////////////
-//////////              Include Header-File                 //////////
-//////////////////////////////////////////////////////////////////////
+// Config: LEDs = On, Buttons = On (Default)
+#ifndef CONFIG_L1B1
+#define CONFIG_L1B1 "L1B1"
+#endif
+
+// Config: LEDs = On, Buttons = Off
+#ifndef CONFIG_L1B0
+#define CONFIG_L1B0 "L1B0"
+#endif
+
+// Config: LEDs = Off, Buttons = On
+#ifndef CONFIG_L0B1
+#define CONFIG_L0B1 "L0B1"
+#endif
+
+// Config: LEDs = Off, Buttons = Off
+#ifndef CONFIG_L0B0
+#define CONFIG_L0B0 "L0B0"
+#endif
+
+// Control Byte: Continue Bit
+#ifndef CONTROL_BYTE_CB
+#define CONTROL_BYTE_CB 0x80
+#endif
+
+// Control Byte: Data/Command Selection Bit
+#ifndef CONTROL_BYTE_DCB
+#define CONTROL_BYTE_DCB 0x40
+#endif
+
+// LCD-Parameter: Function Set 1
+#ifndef LCD_PARA_FUNC1
+#define LCD_PARA_FUNC1 0x3A        // 8 Bit, RE = 1, IS = 0
+#endif
+
+// LCD-Parameter: Function Set 2
+#ifndef LCD_PARA_FUNC2
+#define LCD_PARA_FUNC2 0x39        // 8 Bit, RE = 0, IS = 1
+#endif
+
+// LCD-Parameter: Function Set 3
+#ifndef LCD_PARA_FUNC3
+#define LCD_PARA_FUNC3 0x38        // 8 Bit, RE = 0, IS = 0
+#endif
+
+// LCD-Parameter: Extended Function
+#ifndef LCD_PARA_EXT_FUNC
+#define LCD_PARA_EXT_FUNC 0x09    // 4-Line Display
+#endif
+
+// LCD-Parameter: Entry Mode
+#ifndef LCD_PARA_ENTRY_MODE
+#define LCD_PARA_ENTRY_MODE 0x06  // Bottom View
+#endif
+
+// LCD-Parameter: Bias Setting
+#ifndef LCD_PARA_BIAS_SET
+#define LCD_PARA_BIAS_SET 0x1E    // BS1 = 1
+#endif
+
+// LCD-Parameter: Internal OSC
+#ifndef LCD_PARA_INT_OSC
+#define LCD_PARA_INT_OSC 0x1B     // BS0 = 1, Bias = 1/6
+#endif
+
+// LCD-Parameter: Follower Control
+#ifndef LCD_PARA_FOL_CON
+#define LCD_PARA_FOL_CON 0x6E     // Devider on, Set Value
+#endif
+
+// LCD-Parameter: Power Control
+#ifndef LCD_PARA_POW_CON
+#define LCD_PARA_POW_CON 0x56     // Booster on, Set Contrast
+#endif
+
+// LCD-Parameter: Contrast Set
+#ifndef LCD_PARA_CONTRAST
+#define LCD_PARA_CONTRAST 0x7A
+#endif
+
+// LCD-Parameter: Display on/off Control
+#ifndef LCD_PARA_DIS_CON
+#define LCD_PARA_DIS_CON 0x0F     // Display on, Cursor on, Blink on
+#endif
+
+// LCD-Parameter: Clear Display 
+#ifndef LCD_PARA_CLR_DIS
+#define LCD_PARA_CLR_DIS 0x01
+#endif
+
+// LCD-Parameter: Display Row 1 
+#ifndef LCD_PARA_DIS_ROW1
+#define LCD_PARA_DIS_ROW1 0x80
+#endif
+
+// LCD-Parameter: Display Row 2
+#ifndef LCD_PARA_DIS_ROW2
+#define LCD_PARA_DIS_ROW2 0xA0
+#endif
+
+// LCD-Parameter: Display Row 3 
+#ifndef LCD_PARA_DIS_ROW3
+#define LCD_PARA_DIS_ROW3 0xC0
+#endif
+
+// LCD-Parameter: Display Row 4 
+#ifndef LCD_PARA_DIS_ROW4
+#define LCD_PARA_DIS_ROW4 0xE0
+#endif
+
+// Free Space 
+#ifndef FREE_SPACE
+#define FREE_SPACE ' '
+#endif
+
+
+////////////////////////////////////////////////////////////////////////////////
+////////////////////         Include Header-File            ////////////////////
+////////////////////////////////////////////////////////////////////////////////
 
 #include <Arduino.h>
 #include <Wire.h>
+#include <stdio.h>
 
-//////////////////////////////////////////////////////////////////////
-//////////                Global Variable                   //////////
-//////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////
+////////////////////             Define Class               ////////////////////
+////////////////////////////////////////////////////////////////////////////////
 
+/**
+ * @brief LCD-Shield Class to control all functionalities of the Shield
+ */
+class HSA_LCD_Shield {
 
+////////////////////////////////////////////////////////////////////////////////
+////////////////////     protected Functions/Variables      ////////////////////
+////////////////////////////////////////////////////////////////////////////////
 
-//////////////////////////////////////////////////////////////////////
-//////////                  Define Class                    //////////
-//////////////////////////////////////////////////////////////////////
+protected:
 
-/// @brief HSA_LCD_Shield class 
-/// @details Is used, to control all functions of the HSA_LCD_Shield 
-class HSA_LCD_Shield {
+////////////////////          protected Variables           ////////////////////
 
-//////////////////////////////////////////////////////////////////////
-//////////                  Privat Area                     //////////
-//////////////////////////////////////////////////////////////////////
+char __i2cAddress;  //! @brief Store the I²C-Address of the LC-Display
+char __config[5];   //! @brief Store the Buttons/LEDs-Configuration
+
+////////////////////////////////////////////////////////////////////////////////
+////////////////////       Privat Functions/Variables       ////////////////////
+////////////////////////////////////////////////////////////////////////////////
 
 private:
 
-Byte _i2cAddress;
-Byte _buttonRight;
-Byte _buttonDown;
-Byte _buttonUp;
-Byte _buttonLeft;
-Byte _buttonRight;
-Byte _ledRed;
-Byte _ledGreen;
-Byte _lcdBacklight;
+////////////////////               Send Message             ////////////////////
+
+/**
+ * @brief Used, to send an array of bytes to the LC-Display
+ * 
+ * @param bytes Array of bytes
+ * @param sizeBytes Size of the array of Bytes
+ */
+void _sendMessage(byte* bytes, byte sizeBytes);
+
+////////////////////          protected Variables           ////////////////////
 
-//////////////////////////////////////////////////////////////////////
-//////////                Public Functions                  //////////
-//////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////
+////////////////////     Public Functions/Variables         ////////////////////
+////////////////////////////////////////////////////////////////////////////////
 
 public:
 
-//////////                Public Functions                  //////////
+////////////////////               Constructor              ////////////////////
+
+/**
+ * @brief Construct a new HSA_LCD_Shield object with default I²C-Address/Config
+ */
+HSA_LCD_Shield();
+
+/**
+ * @brief Construct a new HSA_LCD_Shield object with different I²C-Address
+ * 
+ * @param address Address of the LC-Display  
+ */
+HSA_LCD_Shield(char address);
+
+/**
+ * @brief Construct a new HSA_LCD_Shield object with different Config
+ * 
+ * @param config Configuration of Buttons and LEDs 
+ */
+HSA_LCD_Shield(const char config[5]);
+
+/**
+ * @brief Construct a new HSA_LCD_Shield object with different I²C-Address/Config
+ * 
+ * @param address Address of the LC-Display  
+ * @param config Configuration of Buttons and LEDs 
+ */
+HSA_LCD_Shield(char address,const char config[5]);
+
+////////////////////             Deconstructor              ////////////////////
+
+/**
+ * @brief Destroy the HSA_LCD_Shield object
+ */
+~HSA_LCD_Shield(void);
+
+////////////////////          Start Configuration           ////////////////////
+
+/**
+ * @brief Start Configuration of LC-Display and Buttons/LEDS
+ * 
+ * @return true Configuration is accepted
+ * @return false Configuration is not accepted, check construction
+ */
+bool begin(void);
+
+////////////////////             LCD-Backlight              ////////////////////
+
+/**
+ * @brief Turning on/off the LCD-Backlight
+ * 
+ * @param value Boolean value for turning on/off the LCD-Backlight
+ */
+void lcdBacklight(bool value);
+
+////////////////////             Clear Display              ////////////////////
+
+/**
+ * @brief Clear the LC-Display
+ */
+void clearDisplay(void);
+
+////////////////////             Return Config              ////////////////////
+
+/**
+ * @brief Return the Configuration of Buttons/LEDs
+ * 
+ * @return char* Return the Address of the Configuration Buttons/LEDs
+ */
+char* returnConfig(void);
 
-HSA_LCD_Shield
+////////////////////            Return I²C-Address          ////////////////////
 
+/**
+ * @brief Return the I²C-Address of the LC-Display
+ * 
+ * @return char Return the I²C-Address of the LC-Display
+ */
+char returnAddress(void);
 
-//////////////////////////////////////////////////////////////////////
-//////////                  close Header                    //////////
-//////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////
+////////////////////             close Header               ////////////////////
+////////////////////////////////////////////////////////////////////////////////
 
 };
 #endif