@ -220,6 +220,7 @@ DevicePanel::DevicePanel(SettingsWindow *parent) : ListWidget(parent) { 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					          params . remove ( " LiveParametersV2 " ) ;   
					 
					 
					 
					          params . remove ( " LiveParametersV2 " ) ;   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					          params . remove ( " LiveDelay " ) ;   
					 
					 
					 
					          params . remove ( " LiveDelay " ) ;   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					          params . putBool ( " OnroadCycleRequested " ,  true ) ;   
					 
					 
					 
					          params . putBool ( " OnroadCycleRequested " ,  true ) ;   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					 
					 
					 
					 
					          updateCalibDescription ( ) ;   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					        }   
					 
					 
					 
					        }   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					      }   
					 
					 
					 
					      }   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					    }  else  {   
					 
					 
					 
					    }  else  {   
				
			 
			
		
	
	
		
		
			
				
					
						
							
								 
							 
						
						
							
								 
							 
						
						
					 
					 
					@ -297,10 +298,10 @@ DevicePanel::DevicePanel(SettingsWindow *parent) : ListWidget(parent) { 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					}  
					 
					 
					 
					}  
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					
 
					 
					 
					 
					
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					void  DevicePanel : : updateCalibDescription ( )  {  
					 
					 
					 
					void  DevicePanel : : updateCalibDescription ( )  {  
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					//  QString desc = tr("openpilot continuously calibrates the device's orientation and steering response. Resetting is rarely required.");
  
					 
					 
					 
					//  QString desc = tr("openpilot continuously calibrates the device's orientation and learns your vehicle's  steering response. Resetting is rarely required.");
  
				
			 
			
				
				
			
		
	
		
		
			
				
					
					 
					 
					 
					  QString  desc  =  tr ( " openpilot continuously calibrates device orientation and learns how your car responds to steering commands. Resetting is rarely required. " ) ;   
					 
					 
					 
					  QString  desc  =  tr ( " " ) ;   
				
			 
			
				
				
			
		
	
		
		
	
		
		
	
		
		
			
				
					
					 
					 
					 
					
 
					 
					 
					 
					
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					  desc  + =  tr ( " \n \n openpilot requires the device to be mounted within 4° left or right and within 5° up or 9° down. " ) ;   
					 
					 
					 
					  desc  + =  tr ( " \n openpilot requires the device to be mounted within 4° left or right and within 5° up or 9° down. " ) ;   
				
			 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					 
					 
					 
					  std : : string  calib_bytes  =  params . get ( " CalibrationParams " ) ;   
					 
					 
					 
					  std : : string  calib_bytes  =  params . get ( " CalibrationParams " ) ;   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					  if  ( ! calib_bytes . empty ( ) )  {   
					 
					 
					 
					  if  ( ! calib_bytes . empty ( ) )  {   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					    try  {   
					 
					 
					 
					    try  {   
				
			 
			
		
	
	
		
		
			
				
					
						
						
						
							
								 
							 
						
					 
					 
					@ -319,55 +320,49 @@ void DevicePanel::updateCalibDescription() { 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					    }   
					 
					 
					 
					    }   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					  }   
					 
					 
					 
					  }   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					
 
					 
					 
					 
					
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					//  desc += tr("\n\nopenpilot also learns how your car responds to steering inputs while it is engaged.");
  
					 
					 
					 
					  int  lag_perc  =  0 ;   
				
			 
			
				
				
			
		
	
		
		
			
				
					
					 
					 
					 
					
 
					 
					 
					 
					  std : : string  lag_bytes  =  params . get ( " LiveDelay " ) ;   
				
			 
			
				
				
			
		
	
		
		
			
				
					
					 
					 
					 
					  std : : string  lagd_bytes  =  params . get ( " LiveDelay " ) ;   
					 
					 
					 
					  if  ( ! lag_bytes . empty ( ) )  {   
				
			 
			
				
				
			
		
	
		
		
			
				
					
					 
					 
					 
					  int  lagd_perc  =  0 ;   
					 
					 
					 
					 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					  if  ( ! lagd_bytes . empty ( ) )  {   
					 
					 
					 
					 
				
			 
			
		
	
		
		
	
		
		
	
		
		
	
		
		
			
				
					
					 
					 
					 
					    try  {   
					 
					 
					 
					    try  {   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					      AlignedBuffer  aligned_buf ;   
					 
					 
					 
					      AlignedBuffer  aligned_buf ;   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					      capnp : : FlatArrayMessageReader  cmsg ( aligned_buf . align ( lagd_bytes . data ( ) ,  lagd_bytes . size ( ) ) ) ;   
					 
					 
					 
					      capnp : : FlatArrayMessageReader  cmsg ( aligned_buf . align ( lag_bytes . data ( ) ,  lag_bytes . size ( ) ) ) ;   
				
			 
			
				
				
			
		
	
		
		
			
				
					
					 
					 
					 
					      auto  lagd  =  cmsg . getRoot < cereal : : Event > ( ) . getLiveDelay ( ) ;   
					 
					 
					 
					      auto  lag  =  cmsg . getRoot < cereal : : Event > ( ) . getLiveDelay ( ) ;   
				
			 
			
				
				
			
		
	
		
		
			
				
					
					 
					 
					 
					      lagd_perc  =  lagd . getCalPerc ( ) ;   
					 
					 
					 
					      lag_perc  =  lag . getCalPerc ( ) ;   
				
			 
			
				
				
			
		
	
		
		
			
				
					
					 
					 
					 
					//      desc += tr("\n\nopenpilot continually learns how your vehicle responds to commands. Steering delay learning is %1% complete.")
  
					 
					 
					 
					 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					//                  .arg(lagd.getCalPerc());
  
					 
					 
					 
					 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					////      if (lagd.calibPerc() > 0) {
  
					 
					 
					 
					 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					////        desc += tr(" The current delay is %1 ms.").arg(lagd.getLagMs());
  
					 
					 
					 
					 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					////      }
  
					 
					 
					 
					 
				
			 
			
		
	
		
		
	
		
		
	
		
		
	
		
		
			
				
					
					 
					 
					 
					    }  catch  ( kj : : Exception )  {   
					 
					 
					 
					    }  catch  ( kj : : Exception )  {   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					      qInfo ( )  < <  " invalid LiveDelay " ;   
					 
					 
					 
					      qInfo ( )  < <  " invalid LiveDelay " ;   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					    }   
					 
					 
					 
					    }   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					  }   
					 
					 
					 
					  }   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					
 
					 
					 
					 
					
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					//  desc += tr("\n\nopenpilot continually adapts to your vehicle's  responds to commands.");
  
					 
					 
					 
					  if  ( lag_perc  <  100 )  {   
				
			 
			
				
				
			
		
	
		
		
			
				
					
					 
					 
					 
					
 
					 
					 
					 
					    desc  + =  tr ( " \n \n - Learning the vehicle's steering lag: %1% complete. " ) . arg ( lag_perc ) ;   
				
			 
			
				
				
			
		
	
		
		
			
				
					
					 
					 
					 
					  if  ( lagd_perc  <  100 )  {   
					 
					 
					 
					 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					    desc  + =  tr ( " \n Steering lag learning is %1% complete. " ) . arg ( lagd_perc ) ;   
					 
					 
					 
					 
				
			 
			
		
	
		
		
	
		
		
	
		
		
			
				
					
					 
					 
					 
					  }  else  {   
					 
					 
					 
					  }  else  {   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					    desc  + =  tr ( " \n Steering lag learning is  complete." ) ;   
					 
					 
					 
					    desc  + =  tr ( " \n \n - Vehicle's steering lag learning complete. " ) ;   
				
			 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					 
					 
					 
					  }   
					 
					 
					 
					  }   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					
 
					 
					 
					 
					
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					  std : : string  torqued_bytes  =  params . get ( " LiveTorqueParameters " ) ;   
					 
					 
					 
					  std : : string  torque_bytes  =  params . get ( " LiveTorqueParameters " ) ;   
				
			 
			
				
				
			
		
	
		
		
			
				
					
					 
					 
					 
					  int  torqued_perc  =  0 ;   
					 
					 
					 
					  if  ( ! torque_bytes . empty ( ) )  {   
				
			 
			
				
				
			
		
	
		
		
			
				
					
					 
					 
					 
					  if  ( ! torqued_bytes . empty ( ) )  {   
					 
					 
					 
					 
				
			 
			
		
	
		
		
	
		
		
	
		
		
			
				
					
					 
					 
					 
					    try  {   
					 
					 
					 
					    try  {   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					      AlignedBuffer  aligned_buf ;   
					 
					 
					 
					      AlignedBuffer  aligned_buf ;   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					      capnp : : FlatArrayMessageReader  cmsg ( aligned_buf . align ( torqued_bytes . data ( ) ,  torqued_bytes . size ( ) ) ) ;   
					 
					 
					 
					      capnp : : FlatArrayMessageReader  cmsg ( aligned_buf . align ( torque_bytes . data ( ) ,  torque_bytes . size ( ) ) ) ;   
				
			 
			
				
				
			
		
	
		
		
			
				
					
					 
					 
					 
					      auto  torqued  =  cmsg . getRoot < cereal : : Event > ( ) . getLiveTorqueParameters ( ) ;   
					 
					 
					 
					      auto  torque  =  cmsg . getRoot < cereal : : Event > ( ) . getLiveTorqueParameters ( ) ;   
				
			 
			
				
				
			
		
	
		
		
			
				
					
					 
					 
					 
					      torqued_perc  =  torqued . getCalPerc ( ) ;   
					 
					 
					 
					
 
				
			 
			
				
				
			
		
	
		
		
	
		
		
	
		
		
	
		
		
			
				
					
					 
					 
					 
					 
					 
					 
					 
					      // don't add for non-torque cars
   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					 
					 
					 
					 
					      if  ( torque . getUseParams ( ) )  {   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					 
					 
					 
					 
					        int  torque_perc  =  100 ; //torque.getCalPerc();
   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					 
					 
					 
					 
					        if  ( torque_perc  <  100 )  {   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					 
					 
					 
					 
					          desc  + =  tr ( " \n - Learning the vehicle's steering response: %1% complete. " ) . arg ( torque_perc ) ;   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					 
					 
					 
					 
					        }  else  {   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					 
					 
					 
					 
					          desc  + =  tr ( " \n - Vehicle's steering response learning complete. " ) ;   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					 
					 
					 
					 
					        }   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					 
					 
					 
					 
					      }   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					 
					 
					 
					 
					
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					    }  catch  ( kj : : Exception )  {   
					 
					 
					 
					    }  catch  ( kj : : Exception )  {   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					      qInfo ( )  < <  " invalid LiveTorqueParameters " ;   
					 
					 
					 
					      qInfo ( )  < <  " invalid LiveTorqueParameters " ;   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					    }   
					 
					 
					 
					    }   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					  }   
					 
					 
					 
					  }   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					
 
					 
					 
					 
					
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					  if  ( torqued_perc  <  100 )  {   
					 
					 
					 
					  desc  + =  tr ( " \n \n openpilot is continuously calibrating, resetting is rarely required.  "   
				
			 
			
				
				
			
		
	
		
		
			
				
					
					 
					 
					 
					    desc  + =  tr ( " \n Steering torque learning is %1% complete. " ) . arg ( torqued_perc ) ;   
					 
					 
					 
					             " Resetting calibration will restart openpilot if the car is powered on. " ) ;   
				
			 
			
				
				
			
		
	
		
		
			
				
					
					 
					 
					 
					  }  else  {   
					 
					 
					 
					 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					    desc  + =  tr ( " \n Steering torque learning is complete. " ) ;   
					 
					 
					 
					 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					  }   
					 
					 
					 
					 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					
 
					 
					 
					 
					 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					//  desc += tr("\n\nopenpilot is continuously calibrating, resetting is rarely required.");
  
					 
					 
					 
					 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					  desc  + =  tr ( " \n Resetting calibration will restart openpilot if the car is powered on. " ) ;   
					 
					 
					 
					 
				
			 
			
		
	
		
		
	
		
		
	
		
		
			
				
					
					 
					 
					 
					  qobject_cast < ButtonControl  * > ( sender ( ) ) - > setDescription ( desc ) ;   
					 
					 
					 
					  qobject_cast < ButtonControl  * > ( sender ( ) ) - > setDescription ( desc ) ;   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					}  
					 
					 
					 
					}