#NEWLINE# def _run( self , amt , fps , sleep , max_steps , untilComplete , max_cycles , seconds ) : #NEWLINE# #INDENT# self . preRun ( ) #NEWLINE# if fps : #NEWLINE# #INDENT# sleep = int ( ( 1000 / fps ) ) #NEWLINE# #UNINDENT# if ( seconds is not None ) : #NEWLINE# #INDENT# max_steps = int ( ( ( seconds * 1000 ) / sleep ) ) #NEWLINE# #UNINDENT# initSleep = sleep #NEWLINE# self . _step = 0 #NEWLINE# cur_step = 0 #NEWLINE# cycle_count = 0 #NEWLINE# self . animComplete = False #NEWLINE# while ( ( not self . _stopEvent . isSet ( ) ) and ( ( ( max_steps == 0 ) and ( not untilComplete ) ) or ( ( max_steps > 0 ) and ( cur_step < max_steps ) ) or ( ( max_steps == 0 ) and untilComplete and ( not self . animComplete ) ) ) ) : #NEWLINE# #INDENT# self . _timeRef = self . _msTime ( ) #NEWLINE# start = self . _msTime ( ) #NEWLINE# if hasattr ( self , '_input_dev' ) : #NEWLINE# #INDENT# self . _keys = self . _input_dev . getKeys ( ) #NEWLINE# #UNINDENT# self . preStep ( amt ) #NEWLINE# self . step ( amt ) #NEWLINE# self . postStep ( amt ) #NEWLINE# mid = self . _msTime ( ) #NEWLINE# if self . _internalDelay : #NEWLINE# #INDENT# sleep = self . _internalDelay #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if max_steps : #NEWLINE# #INDENT# sleep = initSleep #NEWLINE# #UNINDENT# #UNINDENT# self . _led . _frameGenTime = int ( ( mid - start ) ) #NEWLINE# self . _led . _frameTotalTime = sleep #NEWLINE# self . _led . update ( ) #NEWLINE# now = self . _msTime ( ) #NEWLINE# if ( self . animComplete and ( max_cycles > 0 ) ) : #NEWLINE# #INDENT# if ( cycle_count < ( max_cycles - 1 ) ) : #NEWLINE# #INDENT# cycle_count += 1 #NEWLINE# self . animComplete = False #NEWLINE# #UNINDENT# #UNINDENT# stepTime = int ( ( mid - start ) ) #NEWLINE# if self . _led . _threadedUpdate : #NEWLINE# #INDENT# updateTime = int ( self . _led . lastThreadedUpdate ( ) ) #NEWLINE# totalTime = updateTime #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# updateTime = int ( ( now - mid ) ) #NEWLINE# totalTime = ( stepTime + updateTime ) #NEWLINE# #UNINDENT# if self . _led . _threadedUpdate : #NEWLINE# #INDENT# log . debug ( 'Frame: %sms / Update Max: %sms' , stepTime , updateTime ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# log . debug ( '%sms/%sfps / Frame: %sms / Update: %sms' , totalTime , int ( ( 1000 / max ( totalTime , 1 ) ) ) , stepTime , updateTime ) #NEWLINE# #UNINDENT# if sleep : #NEWLINE# #INDENT# diff = ( self . _msTime ( ) - self . _timeRef ) #NEWLINE# t = max ( 0 , ( ( sleep - diff ) / 1000.0 ) ) #NEWLINE# if ( t == 0 ) : #NEWLINE# #INDENT# log . warning ( 'Frame-time of %dms set, but took %dms!' , sleep , diff ) #NEWLINE# #UNINDENT# if self . _threaded : #NEWLINE# #INDENT# self . _stopEvent . wait ( t ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# time . sleep ( t ) #NEWLINE# #UNINDENT# #UNINDENT# cur_step += 1 #NEWLINE# #UNINDENT# self . _exit ( None , None , None ) #NEWLINE# if self . _callback : #NEWLINE# #INDENT# self . _callback ( self )