diff --git a/control/app/picadae_api.py b/control/app/picadae_api.py index 1ee2c89..e6620dd 100644 --- a/control/app/picadae_api.py +++ b/control/app/picadae_api.py @@ -275,6 +275,12 @@ class Picadae: time.sleep( dur_ms / 1000.0 ) return self.note_off(midi_pitch) + def make_seq( self, midi_pitch, base_atk_us, dur_ms, delta_us, note_cnt ): + for i in range(note_cnt): + self.make_note( midi_pitch, base_atk_us + i*delta_us, dur_ms ) + time.sleep( dur_ms / 1000.0 ) + return Result() + def set_log_level( self, log_level ): self.log_level = log_level return Result() @@ -286,13 +292,17 @@ class Picadae: return vel def _usec_to_coarse_and_fine( self, usec ): + + coarse_usec = self.prescaler_usec*255 # usec's in one coarse tick - coarse = int( usec / (self.prescaler_usec*255)) - fine = int((usec - coarse*self.prescaler_usec*255) / self.prescaler_usec) + coarse = int( usec / coarse_usec ) + fine = int((usec - coarse*coarse_usec) / self.prescaler_usec) assert( coarse <= 255 ) assert( fine <= 255) + print("C:%i F:%i : %i " % (coarse,fine, coarse*coarse_usec + fine*self.prescaler_usec )) + return coarse,fine def _send( self, opcode, i2c_addr, reg_addr, byteL ): diff --git a/control/app/picadae_shell.py b/control/app/picadae_shell.py index ae7c655..1ea4ebc 100644 --- a/control/app/picadae_shell.py +++ b/control/app/picadae_shell.py @@ -21,7 +21,8 @@ class PicadaeShell: 'f':{ "func":"get_pwm_freq", "minN":1, "maxN":1, "help":"freq "}, 'i':{ "func":"get_pwm_div", "minN":1, "maxN":1, "help":"div "}, 'W':{ "func":"write_table", "minN":1, "maxN":1, "help":"write_table "}, - 'N':{ "func":"make_note", "minN":3, "maxN":3, "help":"note atkUs durMs"}, + 'N':{ "func":"make_note", "minN":3, "maxN":3, "help":"note "}, + 'S':{ "func":"make_seq", "minN":5, "maxN":5, "help":"seq "}, 'L':{ "func":"set_log_level","minN":1, "maxN":1, "help":"log (0-1)."} }