Commits

tuck...@gmail.com  committed 625d1df Draft

add pin declaration in new module

  • Participants
  • Parent commits 6e9ebd7

Comments (0)

Files changed (3)

File src/platform/stm32f4/SConscript

 SOURCES += glob.glob("FWlib/src/*.c")
 # SOURCES += glob.glob("FWlib/src/*.s")
 
-PY_SOURCES = ["main.py", "stm32f4discovery.py", "gpio.py", "lcd.py", "wire.py"]
+PY_SOURCES = ["main.py", "stm32f4discovery.py", "gpio.py", "pin.py", "lcd.py", "wire.py"]
 PM_LIB_ROOT = ["pmvm_%s" % vars.args["PLATFORM"]]
 
 env = Environment(variables = vars,

File src/platform/stm32f4/lcd.py

 #             
 #             If you're looking for detail :
 #             http://code.google.com/p/arduino/source/browse/trunk/libraries/LiquidCrystal/LiquidCrystal.cpp
+#
+#
+#                    # import module
+#                    from lcd import LiquidCrystal
+#                    from pin import *
+#                    # specify lcd pin out
+#                    screen = LiquidCrystal(PE7, None, PE8, PE9, PE10, PE11, PE12)
+#                    # specify lcd size : 2 rows x 16 cols
+#                    screen.begin(16,2)
+#                    # print TEOMAN on the first line
+#                    screen.prnt("TEOMAN")
+#                    screen.setCursor(0,1)
+#                    # print Hello World on the second line
+#                    screen.prnt("Hello World!")
+#              
+#             
 #  
 #             WARNING, THIS IS STILL EXPERIMENTAL
 #  
 
 # TODO: rewrite example for STM32F4
 # TODO: write int method in builtin (this is not possible !!!!)
-# TODO: rewrite easy function to make a digital_write with simple parameter
 
 class LiquidCrystal(object):
     """
 
     def __init__(self, rs, rw, enable, d0, d1, d2, d3, d4=0, d5=0, d6=0, d7=0):
         """
-        each pin should be string like ('E',7)
-
-        rw argument is kept in the same position.
+        each pin should be string like ('E',7), you can use pin.py module instead
+        and use PE7 declaration
 
         possible usage :
 
                 LiquidCrystal(rs, None, enable, d0, d1, d2, d3, d4, d5, d6, d7)
                 LiquidCrystal(rs, rw, enable, d0, d1, d2, d3, d4, d5, d6, d7) 
                 
-                d0, d1, d2, d3 ... should be utple composed
-                by letter and an integer like ("E",7) etc ...
-
                     # RW => E7
                     # E => E8
                     # D4 => E9
                     # D5 => E10
                     # D6 => E11
                     # D7 => E12
-
-                    from lcd import LiquidCrystal
-                    screen = LiquidCrystal(("E",7), None, ("E",8), ("E",9), ("E",10), ("E",11), ("E",12))
-                    screen.begin(16,2)
-                    screen.prnt("TEOMAN")
-        """
+                from lcd import LiquidCrystal
+                screen = LiquidCrystal(PE7, None, PE8, PE9, PE10, PE11, PE12)
+                screen.
+       """
         # value authorized for rw are string 'E7' or None !
         if rw is None :
             rw = 255

File src/platform/stm32f4/pin.py

+#-----------------------------------------------------------------------------
+# Name:        pin.py
+# Purpose:     pin from STM32F4 declaration for general purpose
+#
+#              to simplify pin usage, just import pin module
+#              sample :
+#              from pin import *
+#              from lcd import LiquidCrystal
+#              screen = LiquidCrystal(PE7, None, PE8, PE9, PE10, PE11, PE12)
+#              ...
+#              
+# Author:      Stéphane Bard
+#
+# Created:     2012/10/25
+# RCS-ID:      $Id: lcd.py $
+# Licence:     BSD
+#-----------------------------------------------------------------------------
+
+
+PC0 = ('C',0)
+PC1 = ('C',1)
+PC2 = ('C',2)
+PC3 = ('C',3)
+PA0 = ('A',0)
+PA1 = ('A',1)
+PA2 = ('A',2)
+PA3 = ('A',3)
+PA4 = ('A',4)
+PA5 = ('A',5)
+PA6 = ('A',6)
+PA8 = ('A',8)
+PC4 = ('C',4)
+PC5 = ('C',5)
+PB0 = ('B',0)
+PB1 = ('B',1)
+PB2 = ('B',2)
+PE7 = ('E',7)
+PE8 = ('E',8)
+PE9 = ('E',9)
+PE10 = ('E',10)
+PE11 = ('E',11)
+PE12 = ('E',12)
+PE13 = ('E',13)
+PE14 = ('E',14)
+PE15 = ('E',15)
+PB10 = ('B',10)
+PB11 = ('B',11)
+PB12 = ('B',12)
+PB13 = ('B',13)
+PB14 = ('B',14)
+PB15 = ('B',15)
+PD8 = ('D',8)
+PD9 = ('D',9)
+PD10 = ('D',10)
+PD11 = ('D',11)
+PD12 = ('D',12)
+PD13 = ('D',13)
+PD14 = ('D',14)
+PD15 = ('D',15)
+PH0 = ('H',0)
+PH1 = ('H',1)
+PC14 = ('C',14)
+PC15 = ('C',15)
+PE6 = ('E',6)
+PC13 = ('C',13)
+PE4 = ('E',4)
+PE5 = ('E',5)
+PE2 = ('E',2)
+PE3 = ('E',3)
+PE0 = ('E',0)
+PE1 = ('E',1)
+PB8 = ('B',8)
+PB9 = ('B',9)
+PB6 = ('B',6)
+PB7 = ('B',7)
+PB4 = ('B',4)
+PB5 = ('B',5)
+PD7 = ('D',7)
+PB3 = ('B',3)
+PD5 = ('D',5)
+PD6 = ('D',6)
+PD3 = ('D',3)
+PD4 = ('D',4)
+PD1 = ('D',1)
+PD2 = ('D',2)
+PC12 = ('C',12)
+PD0 = ('D',0)
+PC10 = ('C',10)
+PC11 = ('C',11)
+PA14 = ('A',14)
+PA15 = ('A',15)
+PA10 = ('A',10)
+PA13 = ('A',13)
+PA8 = ('A',8)
+PA9 = ('A',9)
+PC8 = ('C',8)
+PC9 = ('C',9)
+PC6 = ('C',6)
+PC7 = ('C',7)