液晶仪表部分的模拟上电其实和HUD部分的模拟上电逻辑是一样的,这里先看下效果。
看下舒适模式下的初始化
/** * @brief MD_Comfort::init_MD_Comfort * @param initType * 舒适画面初始化 */ void MD_Comfort::init_MD_Comfort(int initType) { switch (initType) { case 0: { m_turnLeftAndRightLight->hide(); m_rotateSpeed->hide(); m_carSpeed->hide(); m_title->hide(); m_Map->hide(); m_startLogo->hide(); m_tpms->hide(); break; } case 1: { m_turnLeftAndRightLight->show(); m_turnLeftAndRightLight->powerUp(); m_rotateSpeed->show(); m_rotateSpeed->powerUp(); m_carSpeed->show(); m_carSpeed->powerUp(); m_title->show(); m_Map->hide(); m_startLogo->show(); m_startLogo->powerUp(); m_tpms->show(); m_tpms->powerUp(); break; } case 2: break; case 3: break; default: break; } }
这部分代码开始没有多少,是因为在液晶仪表这里,我把到多东西都写进里子控件里面,每个控件有一个上电函数“powerup”
每一个powerup的实现原理就是开始都是隐藏的,根据需要显示出来
/** * @brief MD_Core_TurnLight::powerUp * 转向灯上电模拟 */ void MD_Core_TurnLight::powerUp() { ui->label_turnLight_L->show(); ui->label_turnLight_R->show(); QTimer::singleShot(2000,this,[=](){ ui->label_turnLight_L->hide(); ui->label_turnLight_R->hide(); }); }
/** * @brief MDC_RotateSpeed::init_MDC_RotateSpeed * 速度表模拟上电 */ void MDC_RotateSpeed::powerUp() { timer_Init_RootSpeed->start(2000/200); timer_Init_Temperature->start(2000/114); } /** * @brief MDC_RotateSpeed::slot_init_RootSpeed * 初始化转速表 */ void MDC_RotateSpeed::slot_init_RootSpeed() { if(flag_init_rotateSpeed) { m_RotateSpeed = m_RotateSpeed + 40; if(m_RotateSpeed == 8000) { flag_init_rotateSpeed = ! flag_init_rotateSpeed; } } else { m_RotateSpeed = m_RotateSpeed - 40; if(m_RotateSpeed == 0) { flag_init_rotateSpeed = ! flag_init_rotateSpeed; timer_Init_RootSpeed->stop(); } } update(); } /** * @brief MDC_RotateSpeed::slot_init_Temperature * 初始化温度表 */ void MDC_RotateSpeed::slot_init_Temperature() { if(flag_Temperature) { m_Temperature ++; if(m_Temperature == 114) { flag_Temperature = !flag_Temperature; } } else { m_Temperature --; if(m_Temperature == 0) { flag_Temperature = !flag_Temperature; timer_Init_Temperature->stop(); } } update(); }
/** * @brief MDC_CarSpeed::powerUp *转速表模拟上电 */ void MDC_CarSpeed::powerUp() { timer_Init_CarSpeed->start(2000/240); timer_Init_Oil->start(1900/100); } /** * @brief MDC_CarSpeed::slot_init_CarSpeed */ void MDC_CarSpeed::slot_init_CarSpeed() { if(flag_init_CarSpeed) { m_CarSpeed++;; if(m_CarSpeed == 240) { flag_init_CarSpeed = ! flag_init_CarSpeed; } } else { m_CarSpeed--; if(m_CarSpeed == 0) { flag_init_CarSpeed = ! flag_init_CarSpeed; timer_Init_CarSpeed->stop(); } } update(); } /** * @brief MDC_CarSpeed::slot_init_Oil */ void MDC_CarSpeed::slot_init_Oil() { if(flag_Oil) { m_Oil ++; if(m_Oil == 100) { flag_Oil = !flag_Oil; } } else { m_Oil --; if(m_Oil == 0) { flag_Oil = !flag_Oil; timer_Init_Oil->stop(); } } update(); }
/** * @brief MD_Core_StartLogo::powerUp *启动logo模拟上电 */ void MD_Core_StartLogo::powerUp() { ui->label_mainback->show(); ui->label_mainback->setGeometry(268,268,5,5); ui->label_mainback->setStyleSheet("border-image:url(:/MeterDisplay/core/Resources/MeterDisplay/core/LOGO.png)"); if(timer_InitLogo) { timer_InitLogo->start(15); } else { timer_InitLogo = new QTimer; connect(timer_InitLogo,&QTimer::timeout,this,&MD_Core_StartLogo::slot_init_Logo); timer_InitLogo->start(15); } }
/** * @brief MD_Core_TPMS::powerUp * 胎压检测模拟上电 */ void MD_Core_TPMS::powerUp() { ui->label_mainBack->hide(); ui->label_Prease_L_D->hide(); ui->label_Prease_L_U->hide(); ui->label_Prease_R_D->hide(); ui->label_Prease_R_U->hide(); ui->label_Temperature_L_D->hide(); ui->label_Temperature_L_U->hide(); ui->label_Temperature_R_D->hide(); ui->label_Temperature_R_U->hide(); QTimer::singleShot(4500,this,[=](){ ui->label_mainBack->show(); ui->label_Prease_L_D->show(); ui->label_Prease_L_U->show(); ui->label_Prease_R_D->show(); ui->label_Prease_R_U->show(); ui->label_Temperature_L_D->show(); ui->label_Temperature_L_U->show(); ui->label_Temperature_R_D->show(); ui->label_Temperature_R_U->show(); }); }