@@ -339,7 +339,6 @@ def Melody(self, pin, melody, durations):
339339 else :
340340 return - 1
341341
342-
343342 def capacitivePin (self , pin ):
344343 '''
345344 Input:
@@ -351,7 +350,7 @@ def capacitivePin(self, pin):
351350 the pin is toggled to output mode to discharge the port,
352351 and if connected to a voltage source,
353352 will short circuit the pin, potentially damaging
354- the Arduino/Shrimp and any hardware attached to the pin.
353+ the Arduino/Shrimp and any hardware attached to the pin.
355354 '''
356355 cmd_str = build_cmd_str ("cap" , (pin ,))
357356 self .sr .write (cmd_str )
@@ -397,16 +396,16 @@ class Shrimp(Arduino):
397396 def __init__ (self ):
398397 Arduino .__init__ (self )
399398
400-
401- class Wires (object ):
399+
400+ class Wires (object ):
402401 """
403402 Class for Arduino wire (i2c) support
404403 """
405404 def __init__ (self , board ):
406405 self .board = board
407406 self .sr = board .sr
408407
409-
408+
410409class Servos (object ):
411410 """
412411 Class for Arduino servo support
@@ -417,14 +416,13 @@ def __init__(self, board):
417416 self .sr = board .sr
418417 self .servo_pos = {}
419418
420-
421- def attach (self ,pin ,min = 544 , max = 2400 ):
419+ def attach (self , pin , min = 544 , max = 2400 ):
422420 cmd_str = build_cmd_str ("sva" , (pin , min , max ))
423-
421+
424422 while True :
425423 self .sr .write (cmd_str )
426424 self .sr .flush ()
427-
425+
428426 rd = self .sr .readline ().replace ("\r \n " ,"" )
429427 if rd :
430428 break
@@ -434,8 +432,7 @@ def attach(self,pin,min = 544, max = 2400):
434432 self .servo_pos [pin ] = position
435433 return 1
436434
437-
438- def detach (self ,pin ):
435+ def detach (self , pin ):
439436 cmd_str = build_cmd_str ("svd" , (position ,))
440437 try :
441438 self .sr .write (cmd_str )
@@ -444,8 +441,7 @@ def detach(self,pin):
444441 pass
445442 del self .servo_pos [pin ]
446443
447-
448- def write (self ,pin ,angle ):
444+ def write (self , pin , angle ):
449445 position = self .servo_pos [pin ]
450446 cmd_str = build_cmd_str ("svw" (position , angle ))
451447
@@ -455,13 +451,13 @@ def write(self,pin,angle):
455451 def writeMicroseconds (self , pin , uS ):
456452 position = self .servo_pos [pin ]
457453 cmd_str = build_cmd_str ("svw" , (position , uS ))
458-
454+
459455 self .sr .write (cmd_str )
460456 self .sr .flush ()
461457
462- def read (self ,pin ):
458+ def read (self , pin ):
463459 if pin not in self .servo_pos .keys ():
464- self .attach (pin )
460+ self .attach (pin )
465461 position = self .servo_pos [pin ]
466462 cmd_str = build_cmd_str ("svr" , (position ,))
467463 try :
@@ -481,15 +477,14 @@ class SoftwareSerial(object):
481477 """
482478 Class for Arduino software serial functionality
483479 """
484- def __init__ (self ,board ):
485- self .board = board
480+ def __init__ (self , board ):
481+ self .board = board
486482 self .sr = board .sr
487483 self .connected = False
488484
489-
490- def begin (self ,p1 ,p2 ,baud ):
485+ def begin (self , p1 , p2 , baud ):
491486 """
492- Create software serial instance on
487+ Create software serial instance on
493488 specified tx,rx pins, at specified baud
494489 """
495490 cmd_str = build_cmd_str ("ss" , (p1 , p2 , baud ))
@@ -498,18 +493,17 @@ def begin(self,p1,p2,baud):
498493 self .sr .flush ()
499494 except :
500495 pass
501- response = self .sr .readline ().replace ("\r \n " ,"" )
496+ response = self .sr .readline ().replace ("\r \n " ,"" )
502497 if response == "ss OK" :
503498 self .connected = True
504499 return True
505500 else :
506501 self .connected = False
507502 return False
508503
509-
510- def write (self ,data ):
504+ def write (self , data ):
511505 """
512- sends data to existing software serial instance
506+ sends data to existing software serial instance
513507 using Arduino's 'write' function
514508 """
515509 if self .connected :
@@ -519,13 +513,12 @@ def write(self,data):
519513 self .sr .flush ()
520514 except :
521515 pass
522- response = self .sr .readline ().replace ("\r \n " ,"" )
516+ response = self .sr .readline ().replace ("\r \n " ,"" )
523517 if response == "ss OK" :
524518 return True
525519 else :
526520 return False
527521
528-
529522 def read (self ):
530523 """
531524 returns first character read from
@@ -535,8 +528,8 @@ def read(self):
535528 cmd_str = build_cmd_str ("sr" )
536529 self .sr .write (cmd_str )
537530 self .sr .flush ()
538- response = self .sr .readline ().replace ("\r \n " ,"" )
531+ response = self .sr .readline ().replace ("\r \n " ,"" )
539532 if response :
540533 return response
541534 else :
542- return False
535+ return False
0 commit comments