Tobias Müller 9 kuukautta sitten
vanhempi
commit
1dbc065e09
1 muutettua tiedostoa jossa 24 lisäystä ja 3 poistoa
  1. 24 3
      Libs/LCD_Shield/__init__.py

+ 24 - 3
Libs/LCD_Shield/__init__.py

@@ -17,13 +17,30 @@ class LCD:
 
     ##############################           Attributes           ##############################
 
-    __lcd_setting = {}
+    __lcd_setting = {"CONTROL_BYTE": 0x80,          # Set Continue Bit
+                     "LCD_PARA_FUNC1": 0x3A,        # Function Set 1 (8 Bit, RE = 1, IS = 0)
+                     "LCD_PARA_EXT_FUNC": 0x09,     # Extended Function
+                     "LCD_PARA_ENTRY_MODE": 0x06,   # Bottom View
+                     "LCD_PARA_BIAS_SET": 0x1E,     # Bias Setting
+                     "LCD_PARA_FUNC2": 0x39,        # Function Set 2 (8 Bit, RE = 0, IS = 1)
+                     "LCD_PARA_INT_OSC": 0x1B,      # Internal OSC (BS0 = 1, Bias = 1/6)
+                     "LCD_PARA_FOL_CON": 0x6E,      # Follower Control (Devider on, Set Value)
+                     "LCD_PARA_POW_CON": 0x56,      # Power Control (Booster on, Set Contrast)
+                     "LCD_PARA_CONTRAST": 0x7A,     # Set Contrast
+                     "LCD_PARA_FUNC3": 0x38,        # Function Set 3 (8 Bit, RE = 0, IS = 0)
+                     "LCD_PARA_DIS_CON": 0x0C,      # Display on/off Control (Cursor off, Blink off)
+                     "LCD_PARA_CLR_DIS": 0x01}      # Clear Display
 
     ##############################           Constructor          ##############################
 
-    def __init__(self):
+    def __init__(self,
+                 I2C_SDA_Pin: int = 2,
+                 I2C_SCL_Pin: int = 3,
+                 LCD_Brightness: int = 100):
 
-        self.__lcd_brightness = self.__check_lcd_brightness(100)
+        self.__i2c_sda_pin, self.__i2c_scl_pin = self.__check_i2c_ports(I2C_SDA_Pin,
+                                                                        I2C_SCL_Pin)
+        self.__lcd_brightness = self.__check_lcd_brightness(LCD_Brightness)
 
     ##############################           Properties           ##############################
 
@@ -50,6 +67,10 @@ class LCD:
     def __set_lcd_brightness(self):
         pass
 
+    @staticmethod
+    def __check_i2c_ports(SDA_Pin, SCL_Pin):
+        return SDA_Pin, SCL_Pin
+
     ##############################         Methods public         ##############################
 
     def change_I2C_port(self, SDA_Pin, SCL_Pin):