Commits

Christophe Combelles committed a4956ad

continue dev

Comments (0)

Files changed (6)

 [buildout]
-develop = . ../pycnic/
+develop = .
+          ../pycnic/
 parts = tests eggs
 versions = versions
 
 
 [eggs]
 recipe = zc.recipe.egg
-eggs = ipython
-       pylibusb
+eggs = reliefcnc
        pycnic
 
 interpreter = python

reliefcnc/__init__.py

+#

reliefcnc/main.py

 import sys
-import ctypes
-import time
-import subprocess
 from optparse import OptionParser
-from pycnic.music import MusicPlayer
-from pycnic.shoot import ReliefShooter
+from reliefcnc.music import MusicPlayer
+from reliefcnc.shoot import ReliefShooter
 
-if __name__ =='__main__':
+def main():
     parser = OptionParser()
     parser.add_option('-d', '--debug', nargs=0, help='set debug mode')
-    parser.add_option('', '--music', nargs=0, help='play music')
-    parser.add_option('', '--test', nargs=0, help='test')
+    parser.add_option('-m', '--music', nargs=0, help='play music')
+    parser.add_option('-t', '--test', nargs=0, help='test')
     (options, args) = parser.parse_args()
     if options.debug is not None:
         debug = True
-    else debug = False
+    else:
+        debug = False
 
     if options.music is not None:
-        MusicPlayer().play()
+        MusicPlayer().test()
+        sys.exit()
     
     if options.test is not None:
-        ReliefShooter().test()
+        ReliefShooter(debug=debug).test()
+        sys.exit()
 
-
+    print u'doing nothing is boring'

reliefcnc/music.py

 import sys
-import ctypes
-import time
-import subprocess
-from optparse import OptionParser
-from pycnic import
+from pycnic.pycnic import TinyCN
 
 class MusicPlayer(object):
     """music player with a stepper motor
     current_position = 0
     way = 1 # forward = 1, backward = -1
 
-    def __init__(self):
+    def __init__(self, debug=False):
         self.tiny = TinyCN(debug=debug)
         self.tiny.motor.res_x = 30
         self.tiny.tool.speed = 700
-        self.tiny.set_speed(tiny.tool.speed, tiny.motor.res_x)
+        #self.tiny.set_speed(self.tiny.tool.speed, self.tiny.motor.res_x)
+
     def reset(self):
         # return to zero
         self.tiny.move_var_x(0, 0, 400, 'up')
             speed = notfreqs[note]
         else:
             speed = note
-        tiny.set_speed(speed, tiny.motor.res_x)
+        self.tiny.set_speed(speed, self.tiny.motor.res_x)
         # set final position
         steps_to_move = self.way * speed * duration
         final_position = self.current_position + steps_to_move
             raise('range too large')
     
         self.current_position = final_position
-        tiny.move_const_x(final_position)
+        self.tiny.move_const_x(final_position)
 
-
-
-
-
-
-    # Also sprach Python
-    player = MusicPlayer()
-    player.play('C', 1)
-    player.play('G', 1)
-    player.play('C2', 1.7)
-    player.play('E2', 0.3)
-    player.play('D2#', 1)
-    player.play('C', 0.3)
-    player.play('C', 0.3, -1)
-    player.play('C', 0.3, -1)
-    player.play('C', 0.3, -1)
-    player.play('C', 0.3, -1)
-    player.play('C', 0.3, -1)
-    player.play('C', 0.3, -1)
-    player.play('C', 1, -1)
-
-    player.play('C', 1)
-    player.play('G', 1)
-    player.play('C2', 1.7)
-    player.play('D2#', 0.3)
-    player.play('E2', 1)
-    player.play('C', 0.3)
-    player.play('C', 0.3, -1)
-    player.play('C', 0.3, -1)
-    player.play('C', 0.3, -1)
-    player.play('C', 0.3, -1)
-    player.play('C', 0.3, -1)
-    player.play('C', 0.3, -1)
-    player.play('C', 1, -1)
-
-    player.play('C', 1)
-    player.play('G', 1)
-    player.play('C2', 1.7)
-    player.play('G2', 0.3)
-    player.play('A2', 2)
-
-
-    player.play('A2', 0.33, -1)
-    player.play('B3', 0.33)
-    player.play('C3', 1)
-    player.play('D3', 1)
-
-    player.play('E3', 0.5)
-    player.play('F3', 0.5)
-    player.play('G3', 1)
-
-    player.play('E3', 0.5)
-    player.play('C3', 0.5)
-    player.play('G2', 0.5)
-    player.play('E2', 0.5)
-
-    player.play('E3', 0.5)
-    player.play('F3', 0.5)
-    player.play('G3', 1)
-
-    player.play('A4', 1)
-    player.play('B4', 1)
-    player.play('C4', 2)
-
-    sys.exit()
+    def test(self):
+        # Also sprach Python
+        player = MusicPlayer()
+        player.play('C', 1)
+        player.play('G', 1)
+        player.play('C2', 1.7)
+        player.play('E2', 0.3)
+        player.play('D2#', 1)
+        player.play('C', 0.3)
+        player.play('C', 0.3, -1)
+        player.play('C', 0.3, -1)
+        player.play('C', 0.3, -1)
+        player.play('C', 0.3, -1)
+        player.play('C', 0.3, -1)
+        player.play('C', 0.3, -1)
+        player.play('C', 1, -1)
+    
+        player.play('C', 1)
+        player.play('G', 1)
+        player.play('C2', 1.7)
+        player.play('D2#', 0.3)
+        player.play('E2', 1)
+        player.play('C', 0.3)
+        player.play('C', 0.3, -1)
+        player.play('C', 0.3, -1)
+        player.play('C', 0.3, -1)
+        player.play('C', 0.3, -1)
+        player.play('C', 0.3, -1)
+        player.play('C', 0.3, -1)
+        player.play('C', 1, -1)
+    
+        player.play('C', 1)
+        player.play('G', 1)
+        player.play('C2', 1.7)
+        player.play('G2', 0.3)
+        player.play('A2', 2)
+    
+    
+        player.play('A2', 0.33, -1)
+        player.play('B3', 0.33)
+        player.play('C3', 1)
+        player.play('D3', 1)
+    
+        player.play('E3', 0.5)
+        player.play('F3', 0.5)
+        player.play('G3', 1)
+    
+        player.play('E3', 0.5)
+        player.play('C3', 0.5)
+        player.play('G2', 0.5)
+        player.play('E2', 0.5)
+    
+        player.play('E3', 0.5)
+        player.play('F3', 0.5)
+        player.play('G3', 1)
+    
+        player.play('A4', 1)
+        player.play('B4', 1)
+        player.play('C4', 2)
+    
+        sys.exit()

reliefcnc/shoot.py

 # coding: utf-8
-from optparse import OptionParser
-from pycnic import
-import ctypes
 import subprocess
-import sys
 import time
-import time
-
+from pycnic.pycnic import TinyCN
 
 class ReliefShooter(object):
 
         self.tiny.motor.res_y = 200
         self.tiny.motor.res_z = 200
 
-        # misc tests and inits
-        self.tiny.set_prompt(0)
-        self.tiny.read_name()
-        self.tiny.set_fifo_depth(255) # 255 pulses
-        self.tiny.set_pulse_width(64) # 5µs (?)
-        res = self.tiny.get_speed_calc()
-        self.tiny.tool.numerateur = ByteToInt(res[4:8])
-        self.tiny.tool.denominateur = ByteToInt(res[0:4])
-        print('resolution = %s' % ByteToHex(res))
-        print('numerateur = %s' % self.tiny.tool.numerateur)
-        print('denominateur = %s' % self.tiny.tool.denominateur)
 
     def test(self):
         # calibrate zero
       author_email='ccomb@gorfou.fr',
       url='',
       license='proprietary',
-      packages=find_packages(exclude=['ez_setup', 'examples', 'tests']),
+      packages=find_packages(),
+      #packages=find_packages(exclude=['ez_setup', 'examples', 'tests']),
       include_package_data=True,
       zip_safe=False,
       install_requires=[
           # -*- Extra requirements: -*-
-          'pylibusb',
+          'setuptools',
+          'pycnic',
       ],
       entry_points="""
-      # -*- Entry points: -*-
+      [console_scripts]
+      shoot = reliefcnc.main:main
       """,
       )