Commits

Anonymous committed 9d97592 Draft

add pin.py usage on every module

  • Participants
  • Parent commits 625d1df

Comments (0)

Files changed (4)

src/platform/stm32f4/gpio.py

 # Pin is specified as an integer, 0-15
 #
 # Return value is boolean True/False, can be treated as 1/0
-def digitalRead(port, pin):
+def _digitalRead(port, pin):
     """__NATIVE__
     GPIO_TypeDef *port;
     uint16_t pin_mask;
     """
     pass
 
+def digitalRead(pin):
+    """
+    digital read from static pin name
+    see pin.py module
+    """
+    _digitalRead(pin[0],pin[1])
+    
+
 def _get_pin_mask(pin_num):
     return 1<<pin_num
     
 # Pin is specified as an integer, 0-15
 # Value is either boolean True/False or Integer 0 or non-zero.
 #
-def digital_write(port, pin, value):
+def _digital_write(port, pin, value):
     """__NATIVE__
     GPIO_TypeDef *port;
     uint16_t pin_mask;
     """
     pass
     
+def digital_write(pin, value):
+    """
+    digital write on pin from static pin name
+    see pin.py module
+    """
+    _digital_write(pin[0], pin[1], value)
 
-def pin_mode(port, pin, direction):
+def _pin_mode(port, pin, direction):
     """__NATIVE__
     GPIO_TypeDef *port;
     uint16_t pin_mask;
     return retval;	
 	"""
     pass
+
+def pin_mode(pin, direction):
+    """
+    configure pin mode from static pin name
+    see pin.py module
+    """
+    _pin_mode(pin[0],pin[1],direction)

src/platform/stm32f4/lcd.py

                 LiquidCrystal(rs, None, enable, d0, d1, d2, d3, d4, d5, d6, d7)
                 LiquidCrystal(rs, rw, enable, d0, d1, d2, d3, d4, d5, d6, d7) 
                 
-                    # RW => E7
-                    # E => E8
-                    # D4 => E9
-                    # D5 => E10
-                    # D6 => E11
-                    # D7 => E12
+                    # RW => PE7
+                    # E => PE8
+                    # D4 => PE9
+                    # D5 => PE10
+                    # D6 => PE11
+                    # D7 => PE12
                 from lcd import LiquidCrystal
                 screen = LiquidCrystal(PE7, None, PE8, PE9, PE10, PE11, PE12)
                 screen.
     def dg_write(self, s_pin, value):
         """
         """
-        name_pin_part = s_pin[0]
-        int_pin_part = s_pin[1]
-        gpio.digital_write(name_pin_part, int_pin_part, value)
+        gpio.digital_write(s_pin, value)
 
     def pn_mode(self, s_pin, value):
         """
         """
-        name_pin_part = s_pin[0]
-        int_pin_part = s_pin[1]
-        gpio.pin_mode(name_pin_part, int_pin_part, value)
+        gpio.pin_mode(s_pin, value)
 
     def begin(self, cols, lines, dotsize=0):
         """

src/platform/stm32f4/main.py

 import sys
 import ipm
 import stm32f4discovery
+from pin import PE7
+
 x=stm32f4discovery
 i=0
 def wait_a_bit():
 def gpio_demo() :
     """import gpio
     print "gpio imported"
-    gpio.pin_mode("E", 7, gpio.OUTPUT)
+    gpio.pin_mode(PE7, gpio.OUTPUT)
     print "looping"
     while True:
-        gpio.digital_write("E", 7, gpio.HIGH)
-        gpio.digital_write("E", 7, gpio.LOW)"""
+        gpio.digital_write(PE7, gpio.HIGH)
+        gpio.digital_write(PE7, gpio.LOW)"""
     
     from gpio import pin_mode, digital_write, OUTPUT, INPUT, HIGH, LOW
     print "gpio imported"
     pin_mode("E", 7, OUTPUT)
     print "looping"
     while True:
-        digital_write("E", 7, HIGH)
-        digital_write("E", 7, LOW)
+        digital_write(PE7, HIGH)
+        digital_write(PE7, LOW)
 
 def launch_ipm():
     """

src/platform/stm32f4/wire.py

 # this module allow communication with I2C peripheral
 # and STM32F4 board.
-# this module just wrap the work of Torrentula inside python
+# this module just wrap the work of elias inside python
 # method. Like every time python is a glue :)
 # thx elias blog !
 # reference : http://eliaselectronics.com/