Commit 2bd2d0fee9f05ed3fa5732849bcc73fdd7faa934
1 parent
fc102800db
Exists in
master
change keypressed behaviour
Showing 1 changed file with 11 additions and 15 deletions Side-by-side Diff
pm100d_waist.py
| ... | ... | @@ -104,20 +104,7 @@ |
| 104 | 104 | try: |
| 105 | 105 | keypressed = raw_input("Press Enter to continue...\n") |
| 106 | 106 | |
| 107 | - if keypressed=='': | |
| 108 | - # Power values | |
| 109 | - sensors_values = instrument.value() | |
| 110 | - sensors_values = sensors_values.replace('E', 'e') | |
| 111 | - string = "%f\t%s" % (dx , sensors_values) | |
| 112 | - data_file.write(string) # Write in a file | |
| 113 | - print(string) | |
| 114 | - | |
| 115 | - xmes.append(dx) | |
| 116 | - Pmes.append(float(sensors_values)) | |
| 117 | - | |
| 118 | - dx = dx + 0.05 | |
| 119 | - | |
| 120 | - elif keypressed.isdigit(): | |
| 107 | + if keypressed.isdigit(): | |
| 121 | 108 | print('Closing %s' %filename) |
| 122 | 109 | data_file.close() |
| 123 | 110 | t0 = time.time() |
| 124 | 111 | |
| ... | ... | @@ -131,8 +118,17 @@ |
| 131 | 118 | line1, = ax1.plot(xmes, Pmes, 'o') |
| 132 | 119 | |
| 133 | 120 | else: |
| 134 | - raise KeyboardInterrupt | |
| 121 | + # Power values | |
| 122 | + sensors_values = instrument.value() | |
| 123 | + sensors_values = sensors_values.replace('E', 'e') | |
| 124 | + string = "%f\t%s" % (dx , sensors_values) | |
| 125 | + data_file.write(string) # Write in a file | |
| 126 | + print(string) | |
| 135 | 127 | |
| 128 | + xmes.append(dx) | |
| 129 | + Pmes.append(float(sensors_values)) | |
| 130 | + | |
| 131 | + dx = dx + 0.05 | |
| 136 | 132 | |
| 137 | 133 | line1.set_data(xmes, Pmes) |
| 138 | 134 | ax1.relim() |