Commits

Tino de Bruijn  committed 6fbd81f

BIC; removed type argument and replaced with a layout argument. The layout should now be explicitly passed. For ease of use an Arduino and ArduinoMega class have been added that automatically setup the boards as their name implies.

  • Participants
  • Parent commits 2c60fbb
  • Tags v0.9.1

Comments (0)

Files changed (2)

File pyfirmata/__init__.py

 from pyfirmata import *
+from boards import BOARDS
 
-__version__ = '0.9'
+__version__ = '0.9.1'
+
+# shortcut classes
+
+class Arduino(Board):
+    """
+    A board that wil set itself up as a normal Arduino.
+    """
+    def __init__(*args, **kwargs):
+        args.append(BOARDS['arduino'])
+        super(Arduino, self).__init__(*args, **kwargs)
+        
+    def __str__(self):
+        return 'Arduino %s on %s' % (self.name, self.sp.port)
+    
+class ArduinoMega(Board):
+    """
+    A board that wil set itself up as an Arduino Mega.
+    """
+    def __init__(*args, **kwargs):
+        args.append(BOARDS['arduino_mega'])
+        super(Arduino, self).__init__(*args, **kwargs)
+    
+    def __str__(self):
+        return 'Arduino Mega %s on %s' % (self.name, self.sp.port)

File pyfirmata/pyfirmata.py

     _stored_data = []
     _parsing_sysex = False
     
-    def __init__(self, port, type="arduino", baudrate=57600, name=None):
+    def __init__(self, port, layout, baudrate=57600, name=None):
         self.sp = serial.Serial(port, baudrate)
         # Allow 2 secs for Arduino's auto-reset to happen
+        # TODO Is this still necessary?
         self.pass_time(2)
-        self.type = type
         self.name = name
         if not self.name:
             self.name = port
-        self.setup_layout(BOARDS[type])
+        self.setup_layout(layout)
         # TODO Test if we get a firmware name and version, otherwise there 
         # probably isn't any Firmata installed
         
     def __str__(self):
-        return "Board (%s) on %s" % (self.type, self.sp.port)
+        return "Board %s on %s" % (self.name, self.sp.port)
         
     def __del__(self):
         '''