@ -65,6 +65,12 @@ TogglesPanel::TogglesPanel(SettingsWindow *parent) : ListWidget(parent) { 
			
		
	
		
		
			
				
					
					      " " ,        " " ,   
			
		
	
		
		
			
				
					
					      " ../assets/offroad/icon_road.png " ,        " ../assets/offroad/icon_road.png " ,   
			
		
	
		
		
			
				
					
					    } ,      } ,   
			
		
	
		
		
			
				
					
					    {   
			
		
	
		
		
			
				
					
					      " ExperimentalLongitudinalEnabled " ,   
			
		
	
		
		
			
				
					
					      tr ( " Experimental openpilot longitudinal control " ) ,   
			
		
	
		
		
			
				
					
					      tr ( " <b>WARNING: openpilot longitudinal control is experimental for this car and will disable AEB.</b> " ) ,   
			
		
	
		
		
			
				
					
					      " ../assets/offroad/icon_speed_limit.png " ,   
			
		
	
		
		
			
				
					
					    } ,   
			
		
	
		
		
			
				
					
					# ifdef ENABLE_MAPS # ifdef ENABLE_MAPS  
			
		
	
		
		
			
				
					
					    {      {   
			
		
	
		
		
			
				
					
					      " NavSettingTime24h " ,        " NavSettingTime24h " ,   
			
		
	
	
		
		
			
				
					
						
							
								 
						
						
							
								 
						
						
					 
					@ -92,23 +98,7 @@ TogglesPanel::TogglesPanel(SettingsWindow *parent) : ListWidget(parent) { 
			
		
	
		
		
			
				
					
					    toggles [ param . toStdString ( ) ]  =  toggle ;      toggles [ param . toStdString ( ) ]  =  toggle ;   
			
		
	
		
		
			
				
					
					  }    }   
			
		
	
		
		
			
				
					
					
 
			
		
	
		
		
			
				
					
					  QObject : : connect ( toggles [ " EndToEndLong " ] ,  & ParamControl : : toggleFlipped ,  [ = ] ( bool  state )  {    connect ( toggles [ " ExperimentalLongitudinalEnabled " ] ,  & ToggleControl : : toggleFlipped ,  [ = ] ( )  {   
			
				
				
			
		
	
		
		
			
				
					
					    auto  cp_bytes  =  params . get ( " CarParamsPersistent " ) ;   
			
		
	
		
		
			
				
					
					    if  ( ! cp_bytes . empty ( ) )  {   
			
		
	
		
		
			
				
					
					      AlignedBuffer  aligned_buf ;   
			
		
	
		
		
			
				
					
					      capnp : : FlatArrayMessageReader  cmsg ( aligned_buf . align ( cp_bytes . data ( ) ,  cp_bytes . size ( ) ) ) ;   
			
		
	
		
		
			
				
					
					      cereal : : CarParams : : Reader  CP  =  cmsg . getRoot < cereal : : CarParams > ( ) ;   
			
		
	
		
		
			
				
					
					      if  ( CP . getExperimentalLongitudinalAvailable ( ) )  {   
			
		
	
		
		
			
				
					
					        params . putBool ( " ExperimentalLongitudinalEnabled " ,  state ) ;   
			
		
	
		
		
			
				
					
					      }  else  {   
			
		
	
		
		
			
				
					
					        params . remove ( " ExperimentalLongitudinalEnabled " ) ;   
			
		
	
		
		
			
				
					
					      }   
			
		
	
		
		
			
				
					
					    }  else  {   
			
		
	
		
		
			
				
					
					      params . remove ( " ExperimentalLongitudinalEnabled " ) ;   
			
		
	
		
		
			
				
					
					    }   
			
		
	
		
		
			
				
					
					  } ) ;   
			
		
	
		
		
			
				
					
					
 
			
		
	
		
		
			
				
					
					  connect ( uiState ( ) ,  & UIState : : offroadTransition ,  [ = ] ( )  {   
			
		
	
		
		
	
		
		
			
				
					
					    updateToggles ( ) ;      updateToggles ( ) ;   
			
		
	
		
		
			
				
					
					  } ) ;    } ) ;   
			
		
	
		
		
			
				
					
					} }  
			
		
	
	
		
		
			
				
					
						
						
						
							
								 
						
					 
					@ -118,8 +108,8 @@ void TogglesPanel::showEvent(QShowEvent *event) { 
			
		
	
		
		
			
				
					
					} }  
			
		
	
		
		
			
				
					
					
 
			
		
	
		
		
			
				
					
					void  TogglesPanel : : updateToggles ( )  { void  TogglesPanel : : updateToggles ( )  {  
			
		
	
		
		
			
				
					
					  // update e2e toggle
    auto  e2e_toggle  =  toggles [ " EndToEndLong " ] ;   
			
				
				
			
		
	
		
		
			
				
					
					  auto  toggle  =  toggles [ " EndToEndLong  " ] ;    auto  op_long_ toggle=  toggles [ " ExperimentalLongitudinalEnabled  " ] ;   
			
				
				
			
		
	
		
		
	
		
		
	
		
		
			
				
					
					  const  QString  e2e_description  =  tr ( " Let the driving model control the gas and brakes. openpilot will drive as it thinks a human would. Super experimental. " ) ;    const  QString  e2e_description  =  tr ( " Let the driving model control the gas and brakes. openpilot will drive as it thinks a human would. Super experimental. " ) ;   
			
		
	
		
		
			
				
					
					
 
			
		
	
		
		
			
				
					
					  auto  cp_bytes  =  params . get ( " CarParamsPersistent " ) ;    auto  cp_bytes  =  params . get ( " CarParamsPersistent " ) ;   
			
		
	
	
		
		
			
				
					
						
						
						
							
								 
						
					 
					@ -128,29 +118,31 @@ void TogglesPanel::updateToggles() { 
			
		
	
		
		
			
				
					
					    capnp : : FlatArrayMessageReader  cmsg ( aligned_buf . align ( cp_bytes . data ( ) ,  cp_bytes . size ( ) ) ) ;      capnp : : FlatArrayMessageReader  cmsg ( aligned_buf . align ( cp_bytes . data ( ) ,  cp_bytes . size ( ) ) ) ;   
			
		
	
		
		
			
				
					
					    cereal : : CarParams : : Reader  CP  =  cmsg . getRoot < cereal : : CarParams > ( ) ;      cereal : : CarParams : : Reader  CP  =  cmsg . getRoot < cereal : : CarParams > ( ) ;   
			
		
	
		
		
			
				
					
					
 
			
		
	
		
		
			
				
					
					    const  bool  exp_long  =  CP . getExperimentalLongitudinalAvailable ( ) ;      if  ( ! CP . getExperimentalLongitudinalAvailable ( ) )  {   
			
				
				
			
		
	
		
		
			
				
					
					    const  bool  op_long  =  CP . getOpenpilotLongitudinalControl ( )  & &  ! CP . getExperimentalLongitudinalAvailable ( ) ;   
			
		
	
		
		
			
				
					
					
 
			
		
	
		
		
			
				
					
					    if  ( op_long )  {   
			
		
	
		
		
			
				
					
					      // normal description and toggle
   
			
		
	
		
		
	
		
		
			
				
					
					      params . remove ( " ExperimentalLongitudinalEnabled " ) ;        params . remove ( " ExperimentalLongitudinalEnabled " ) ;   
			
		
	
		
		
			
				
					
					      toggle - > setDescription ( e2e_description ) ;   
			
		
	
		
		
			
				
					
					    }  else  if  ( exp_long )  {   
			
		
	
		
		
			
				
					
					      toggle - > setDescription ( " <b>WARNING: openpilot longitudinal control is experimental for this car and will disable AEB.</b><br><br> "  +  e2e_description ) ;   
			
		
	
		
		
			
				
					
					      if  ( params . getBool ( " EndToEndLong " )  & &  ! params . getBool ( " ExperimentalLongitudinalEnabled " ) )  {   
			
		
	
		
		
			
				
					
					        params . remove ( " EndToEndLong " ) ;   
			
		
	
		
		
			
				
					
					    }      }   
			
		
	
		
		
			
				
					
					    op_long_toggle - > setVisible ( CP . getExperimentalLongitudinalAvailable ( ) ) ;   
			
		
	
		
		
			
				
					
					
 
			
		
	
		
		
			
				
					
					    const  bool  op_long  =  CP . getOpenpilotLongitudinalControl ( )  & &  ! CP . getExperimentalLongitudinalAvailable ( ) ;   
			
		
	
		
		
			
				
					
					    const  bool  exp_long_enabled  =  CP . getExperimentalLongitudinalAvailable ( )  & &  params . getBool ( " ExperimentalLongitudinalEnabled " ) ;   
			
		
	
		
		
			
				
					
					    if  ( op_long  | |  exp_long_enabled )  {   
			
		
	
		
		
			
				
					
					      // normal description and toggle
   
			
		
	
		
		
			
				
					
					      e2e_toggle - > setEnabled ( true ) ;   
			
		
	
		
		
			
				
					
					      e2e_toggle - > setDescription ( e2e_description ) ;   
			
		
	
		
		
			
				
					
					    }  else  {      }  else  {   
			
		
	
		
		
			
				
					
					      // no long for now
        // no long for now
   
			
		
	
		
		
			
				
					
					      e2e_toggle - > setEnabled ( false ) ;   
			
		
	
		
		
			
				
					
					      params . remove ( " EndToEndLong " ) ;        params . remove ( " EndToEndLong " ) ;   
			
		
	
		
		
			
				
					
					      params . remove ( " ExperimentalLongitudinalEnabled " ) ;  
 
			
				
				
			
		
	
		
		
			
				
					
					      toggle - > setDescription ( " <b>openpilot longitudinal control is not currently available for this car.</b><br><br> "  +  e2e_description ) ;        const  QString  no_long  =  " openpilot longitudinal control is not currently available for this car. " ;   
			
				
				
			
		
	
		
		
	
		
		
	
		
		
			
				
					
					      const  QString  exp_long  =  " Enable experimental longitudinal control to enable this. " ;   
			
		
	
		
		
			
				
					
					      e2e_toggle - > setDescription ( " <b> "  +  ( CP . getExperimentalLongitudinalAvailable ( )  ?  exp_long  :  no_long )  +  " </b><br><br> "  +  e2e_description ) ;   
			
		
	
		
		
			
				
					
					    }      }   
			
		
	
		
		
			
				
					
					
 
			
		
	
		
		
			
				
					
					    toggle - > refresh ( ) ;      e2e_toggle - > refresh ( ) ;   
			
				
				
			
		
	
		
		
			
				
					
					    toggle - > setEnabled ( op_long  | |  ( exp_long  & &  ! uiState ( ) - > scene . started ) ) ;   
			
		
	
		
		
	
		
		
			
				
					
					  }  else  {    }  else  {   
			
		
	
		
		
			
				
					
					    toggle - > setDescription ( e2e_description ) ;      e2e_toggle - > setDescription ( e2e_description ) ;   
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					    op_long_toggle - > setVisible ( false ) ;   
			
		
	
		
		
			
				
					
					  }    }   
			
		
	
		
		
			
				
					
					} }