SEG_DISPLAY.c 44.8 KB
Newer Older
hu's avatar
hu committed
1 2 3 4 5 6 7 8 9 10
#include "SEG_DISPLAY.h"
#include "Seg_Ref.h"
#include "Common_Interface.h"
#include "Data_Fuel_User.h"
#include "Data_AirPressure.h"
#include "Data_CoolantTemperature.h"
#include "Data_EngineSpeed.h"
#include "Data_VehicleSpeed.h"
#include "GaugesInterface.h"

hu's avatar
hu committed
11 12 13 14 15 16 17
#define PRI_SEG_NUM_MAX 17U
#define SEC_SEG_NUM_MAX 17U
#define COOLANT_SEG_NUM_MAX 12U
#define FUEL_SEG_NUM_MAX 12U
#define TACHO_SEG_NUM_MAX 27U
#define VEH_SEG_NUM_MAX 30U

hu's avatar
hu committed
18 19
static  uint8_t GaugesTimer;

hu's avatar
hu committed
20 21 22 23 24 25 26 27 28 29 30
static void Seg_General_Digit_Display(uint32_t Digit, uint8_t Len, uint8_t Blank, uint8_t *DigitBuf, uint8_t *Reg);
static void Seg_Digit_1_Disp(uint8_t Digit);
static void Seg_Digit_2_Disp(uint8_t Digit);
static void Seg_Digit_3_Disp(uint8_t Digit);
static void SEG_PRI_Display(uint8_t Value, uint8_t Valid, uint8_t seg_status);
static void SEG_SEC_Display(uint8_t Value, uint8_t Valid, uint8_t seg_status);
static void SEG_Coolant_Display(uint8_t Value, uint8_t Valid, uint8_t seg_status);
static void SEG_Fuel_Display(uint8_t Value, uint8_t Valid, uint8_t seg_status);
static void SEG_Tacho_Display(uint8_t Value, uint8_t Valid, uint8_t seg_status);
static void SEG_VehicleSpeed_Display(uint8_t Value, uint8_t Valid, uint8_t seg_status);
static void SEG_VehicleSpeed_Num(uint16_t Value, uint8_t Valid);
hu's avatar
hu committed
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91

/*****************************************************************************
某某灯(红)//_1_差速器锁
******************************************************************************/
void SEG_LED_INTER_DIFF_LOCK_T(uint8_t seg_status)
{
    SEG_BUFF_Set(BU98_CHIP1, SEG_REDEFINE_36, seg_status);
}

/*****************************************************************************
某某灯(红)//_2_智能四驱故障
******************************************************************************/
void SEG_LED_FOUR_MUL_FOUR_T(uint8_t seg_status)
{
    SEG_BUFF_Set(BU98_CHIP1, SEG_REDEFINE_35, seg_status);
}
/*****************************************************************************
某某灯(红)//_3_再生指示灯
******************************************************************************/
void SEG_LED_EXH_BRAKE_T(uint8_t seg_status)
{
    SEG_BUFF_Set(BU98_CHIP1, SEG_REDEFINE_33, seg_status);
}
/*****************************************************************************
//_4_预热指示灯
******************************************************************************/
void SEG_LED_QOS_GLOW_T(uint8_t seg_status)
{
    SEG_BUFF_Set(BU98_CHIP1, SEG_REDEFINE_32, seg_status);
}
/*****************************************************************************
//_5_远光灯开启提示
******************************************************************************/
void SEG_LED_HI_BEAM_T(uint8_t seg_status)
{
    SEG_BUFF_Set(BU98_CHIP1, SEG_REDEFINE_31, seg_status);
}
/*****************************************************************************
//_6_后雾灯开启提示
******************************************************************************/
void SEG_LED_Rr_FOG_LAMP_T(uint8_t seg_status)
{
    SEG_BUFF_Set(BU98_CHIP0, SEG_REDEFINE_161, seg_status);
}
/*****************************************************************************
//_7_发动机故障灯
******************************************************************************/
void SEG_LED_MIL_T(uint8_t seg_status)
{
    SEG_BUFF_Set(BU98_CHIP0, SEG_REDEFINE_160, seg_status);
}
/*****************************************************************************
//_8_维修保养指示灯
******************************************************************************/
void SEG_LED_SVS_T(uint8_t seg_status)
{
    SEG_BUFF_Set(BU98_CHIP0, SEG_REDEFINE_159, seg_status);
}
/*****************************************************************************
//_9_上坡起步辅助系统
******************************************************************************/
hu's avatar
hu committed
92
void SEG_LED_H_S_A_T(uint8_t seg_status)
hu's avatar
hu committed
93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268
{
    SEG_BUFF_Set(BU98_CHIP0, SEG_REDEFINE_158, seg_status);
}
/*****************************************************************************
//_10_减速器指示灯
******************************************************************************/
void SEG_LED_RETARDER_T(uint8_t seg_status)
{
    SEG_BUFF_Set(BU98_CHIP0, SEG_REDEFINE_157, seg_status);
}
/*****************************************************************************
//_11_自动调灯
******************************************************************************/
void SEG_LED_AUTO_LEVELING_T(uint8_t seg_status)
{
    SEG_BUFF_Set(BU98_CHIP0, SEG_REDEFINE_156, seg_status);
}
/*****************************************************************************
//_12_行侧报警灯
******************************************************************************/
void SEG_LED_ROWS_L(uint8_t seg_status)
{
    SEG_BUFF_Set(BU98_CHIP1, SEG_REDEFINE_126, seg_status);
}
/*****************************************************************************
//_13_后视镜bsm警报信号灯
******************************************************************************/
void SEG_LED_BSM_OFF_L(uint8_t seg_status)
{
    SEG_BUFF_Set(BU98_CHIP1, SEG_REDEFINE_127, seg_status);
}
/*****************************************************************************
//_14_紧急刹车辅助系统
******************************************************************************/
void SEG_LED_AEBS_OFF_L(uint8_t seg_status)
{
    SEG_BUFF_Set(BU98_CHIP1, SEG_REDEFINE_128, seg_status);
}
/*****************************************************************************
//_15_LDW系统状态提示故障报警
******************************************************************************/
void SEG_LED_LDWS_L(uint8_t seg_status)
{
    SEG_BUFF_Set(BU98_CHIP1, SEG_REDEFINE_129, seg_status);
}
/*****************************************************************************
//_16_安全气囊
******************************************************************************/
void SEG_LED_SRS_L(uint8_t seg_status)
{
    SEG_BUFF_Set(BU98_CHIP1, SEG_REDEFINE_122, seg_status);
}
/*****************************************************************************
//_17_机油压力异常报警
******************************************************************************/
void SEG_LED_ENG_OIL_L(uint8_t seg_status)
{
    SEG_BUFF_Set(BU98_CHIP1, SEG_REDEFINE_123, seg_status);
}
/*****************************************************************************
//_18_蓄电池充电状态提示
******************************************************************************/
void SEG_LED_CHARG_L(uint8_t seg_status)
{
    SEG_BUFF_Set(BU98_CHIP1, SEG_REDEFINE_124, seg_status);
}
/*****************************************************************************
//_19_安全带
******************************************************************************/
void SEG_LED_SEAT_BELT_L(uint8_t seg_status)
{
    SEG_BUFF_Set(BU98_CHIP1, SEG_REDEFINE_125, seg_status);
}
/*****************************************************************************
//_20_智能四驱故障
******************************************************************************/
void SEG_LED_RR_DIFF_LOCK_L(uint8_t seg_status)
{
    SEG_BUFF_Set(BU98_CHIP1, SEG_REDEFINE_118, seg_status);
}
/*****************************************************************************
//TPMS系统故障报警
******************************************************************************/
void SEG_LED_TPMS_L(uint8_t seg_status)
{
    SEG_BUFF_Set(BU98_CHIP1, SEG_REDEFINE_119, seg_status);
}
/*****************************************************************************
//_22_ASR/EVSC/ESC系统关闭提示
******************************************************************************/
void SEG_LED_ASR_or_EVSC_OFF_L(uint8_t seg_status)
{
    SEG_BUFF_Set(BU98_CHIP1, SEG_REDEFINE_120, seg_status);
}
/*****************************************************************************
//_23_EVSC/ESP/ESC/TCS系统介入提示//故障报警
******************************************************************************/
void SEG_LED_EVSC_L(uint8_t seg_status)
{
    SEG_BUFF_Set(BU98_CHIP1, SEG_REDEFINE_121, seg_status);
}
/*****************************************************************************
//_24_怠速启停系统状态提示-停机
******************************************************************************/
void SEG_LED_eco_stop_OFF_L(uint8_t seg_status)
{
    SEG_BUFF_Set(BU98_CHIP1, SEG_REDEFINE_76, seg_status);
}
/*****************************************************************************
//_25_自动变速箱系统故障报警
******************************************************************************/
void SEG_LED_AMT_L(uint8_t seg_status)
{
    SEG_BUFF_Set(BU98_CHIP1, SEG_REDEFINE_77, seg_status);
}
/*****************************************************************************
//_26_制动刹车片磨损指示灯
******************************************************************************/
void SEG_LED_WEAR_IND_L(uint8_t seg_status)
{
    SEG_BUFF_Set(BU98_CHIP1, SEG_REDEFINE_78, seg_status);
}
/*****************************************************************************
//_27_挂车制动阀指示灯
******************************************************************************/
void SEG_LED_TRAILER_BRAKE_R(uint8_t seg_status)
{
    SEG_BUFF_Set(BU98_CHIP0, SEG_REDEFINE_107, seg_status);
}
/*****************************************************************************
//_28_制动液不足报警-制动系统故障报警 (下黄)
******************************************************************************/
void SEG_LED_BRAKE_AIR_or_EBS_YELLOW_R(uint8_t seg_status)
{
    SEG_BUFF_Set(BU98_CHIP0, SEG_REDEFINE_108, seg_status);
}
/*****************************************************************************
//_29_气动避震指示灯
******************************************************************************/
void SEG_LED_ACC_AIR_R(uint8_t seg_status)
{
    SEG_BUFF_Set(BU98_CHIP0, SEG_REDEFINE_109, seg_status);
}
/*****************************************************************************
//_30_ABS系统故障报警
******************************************************************************/
void SEG_LED_ABS_R(uint8_t seg_status)
{
    SEG_BUFF_Set(BU98_CHIP0, SEG_REDEFINE_110, seg_status);
}
/*****************************************************************************
//_31_驻车制动器/EPB系统处于制动状态提示/AUTO HOLD驻车提示
******************************************************************************/
void SEG_LED_PARK_BRAKE_R(uint8_t seg_status)
{
    SEG_BUFF_Set(BU98_CHIP0, SEG_REDEFINE_31, seg_status);
}
/*****************************************************************************
//_32_制动液不足报警/制动系统故障报警 (上红)
******************************************************************************/
void SEG_LED_BRAKE_AIR_or_EBS_RED_R(uint8_t seg_status)
{
    SEG_BUFF_Set(BU98_CHIP0, SEG_REDEFINE_32, seg_status);
}
/*****************************************************************************
//_34_制动器锁
******************************************************************************/
void SEG_LED_BRAKE_LOCK_R(uint8_t seg_status)
{
    SEG_BUFF_Set(BU98_CHIP0, SEG_REDEFINE_33, seg_status);
}
/*****************************************************************************
//_35_空气悬架指示灯----FULL
******************************************************************************/
void SEG_LED_AIR_SUS_R(uint8_t seg_status)
{
hu's avatar
hu committed
269
    SEG_BUFF_Set(BU98_CHIP0, SEG_REDEFINE_34, seg_status);
hu's avatar
hu committed
270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359
}
/*****************************************************************************
//_36_拖车ABS系统故障报警
******************************************************************************/
void SEG_LED_TRAILER_ABS_U(uint8_t seg_status)
{
    SEG_BUFF_Set(BU98_CHIP0, SEG_REDEFINE_138, seg_status);
}
/*****************************************************************************
//_37_工作灯
******************************************************************************/
void SEG_LED_WORKING_LAMP_U(uint8_t seg_status)
{
    SEG_BUFF_Set(BU98_CHIP1, SEG_REDEFINE_55, seg_status);
}
/*****************************************************************************
//_38_拖车ABS信息
******************************************************************************/
void SEG_LED_TRAILER_ABS_INFO_U(uint8_t seg_status)
{
    SEG_BUFF_Set(BU98_CHIP0, SEG_REDEFINE_137, seg_status);
}
/*****************************************************************************
//_39_右转向灯
******************************************************************************/
void SEG_LED_TURN_RIGHT(uint8_t seg_status)
{
    SEG_BUFF_Set(BU98_CHIP0, SEG_REDEFINE_155, seg_status);
}
/*****************************************************************************
//_40_左转向灯
******************************************************************************/
void SEG_LED_TURN_LEFT(uint8_t seg_status)
{
    SEG_BUFF_Set(BU98_CHIP1, SEG_REDEFINE_37, seg_status);
}
/*:ZH*/

/*****************************************************************************
常显示
******************************************************************************/
//左侧弧线
void SEG_A25_Disp(uint8_t seg_status)
{
    SEG_BUFF_Set(BU98_CHIP1, SEG_REDEFINE_56, seg_status);
}
//右侧弧线
void SEG_C25_Disp(uint8_t seg_status)
{
    SEG_BUFF_Set(BU98_CHIP0, SEG_REDEFINE_136, seg_status);
}

/******************************************************************************
段码对应表
******************************************************************************/
#define NUM_1A(x) SEG_BUFF_Set(BU98_CHIP0, SEG_REDEFINE_45, x);
#define NUM_1B(x) SEG_BUFF_Set(BU98_CHIP0, SEG_REDEFINE_44, x);
#define NUM_1C(x) SEG_BUFF_Set(BU98_CHIP0, SEG_REDEFINE_41, x);
#define NUM_1D(x) SEG_BUFF_Set(BU98_CHIP0, SEG_REDEFINE_39, x);
#define NUM_1E(x) SEG_BUFF_Set(BU98_CHIP0, SEG_REDEFINE_38, x);
#define NUM_1F(x) SEG_BUFF_Set(BU98_CHIP0, SEG_REDEFINE_35, x);
#define NUM_1G(x) SEG_BUFF_Set(BU98_CHIP0, SEG_REDEFINE_40, x);
#define NUM_1H(x) SEG_BUFF_Set(BU98_CHIP0, SEG_REDEFINE_36, x);
#define NUM_1J(x) SEG_BUFF_Set(BU98_CHIP0, SEG_REDEFINE_37, x);
#define NUM_1K(x) SEG_BUFF_Set(BU98_CHIP0, SEG_REDEFINE_42, x);
#define NUM_1L(x) SEG_BUFF_Set(BU98_CHIP0, SEG_REDEFINE_43, x);

#define NUM_2A(x) SEG_BUFF_Set(BU98_CHIP0, SEG_REDEFINE_56, x);
#define NUM_2B(x) SEG_BUFF_Set(BU98_CHIP0, SEG_REDEFINE_55, x);
#define NUM_2C(x) SEG_BUFF_Set(BU98_CHIP0, SEG_REDEFINE_52, x);
#define NUM_2D(x) SEG_BUFF_Set(BU98_CHIP0, SEG_REDEFINE_50, x);
#define NUM_2E(x) SEG_BUFF_Set(BU98_CHIP0, SEG_REDEFINE_49, x);
#define NUM_2F(x) SEG_BUFF_Set(BU98_CHIP0, SEG_REDEFINE_46, x);
#define NUM_2G(x) SEG_BUFF_Set(BU98_CHIP0, SEG_REDEFINE_51, x);
#define NUM_2H(x) SEG_BUFF_Set(BU98_CHIP0, SEG_REDEFINE_47, x);
#define NUM_2J(x) SEG_BUFF_Set(BU98_CHIP0, SEG_REDEFINE_48, x);
#define NUM_2K(x) SEG_BUFF_Set(BU98_CHIP0, SEG_REDEFINE_53, x);
#define NUM_2L(x) SEG_BUFF_Set(BU98_CHIP0, SEG_REDEFINE_54, x);

#define NUM_3A(x) SEG_BUFF_Set(BU98_CHIP0, SEG_REDEFINE_67, x);
#define NUM_3B(x) SEG_BUFF_Set(BU98_CHIP0, SEG_REDEFINE_66, x);
#define NUM_3C(x) SEG_BUFF_Set(BU98_CHIP0, SEG_REDEFINE_63, x);
#define NUM_3D(x) SEG_BUFF_Set(BU98_CHIP0, SEG_REDEFINE_61, x);
#define NUM_3E(x) SEG_BUFF_Set(BU98_CHIP0, SEG_REDEFINE_60, x);
#define NUM_3F(x) SEG_BUFF_Set(BU98_CHIP0, SEG_REDEFINE_57, x);
#define NUM_3G(x) SEG_BUFF_Set(BU98_CHIP0, SEG_REDEFINE_62, x);
#define NUM_3H(x) SEG_BUFF_Set(BU98_CHIP0, SEG_REDEFINE_58, x);
#define NUM_3J(x) SEG_BUFF_Set(BU98_CHIP0, SEG_REDEFINE_59, x);
#define NUM_3K(x) SEG_BUFF_Set(BU98_CHIP0, SEG_REDEFINE_64, x);
#define NUM_3L(x) SEG_BUFF_Set(BU98_CHIP0, SEG_REDEFINE_65, x);
hu's avatar
hu committed
360 361 362 363 364 365 366 367 368 369 370
//      L K J //H G F E D C B A
// 0     1 1 1 //1 0 1 1 1 1 1 1  // 0x07Bf
// 1     1 1 0 //0 0 0 0 0 1 1 0  // 0x0606
// 2     0 1 1 //0 1 0 1 1 0 1 1  // 0x035b
// 3     1 1 0 //0 1 0 0 1 1 1 1  // 0x064f
// 4     1 1 1 //0 1 1 0 0 1 1 0  // 0x0766
// 5     0 1 1 //0 1 1 0 1 1 0 1  // 0x036d
// 6     0 1 1 //1 1 1 1 1 1 0 1  // 0x03fd
// 7     1 1 0 //0 0 0 0 0 1 1 1  // 0x0607
// 8     0 1 1 //0 1 1 1 1 1 1 1  // 0x037f
// 9     1 1 1 //0 1 1 0 1 1 1 1  // 0x076f
hu's avatar
hu committed
371 372 373 374 375
//      0 0 0   0 0 0 0 0 0 0 0  // 0x0000
//'-'   0 0 0   0 1 0 0 0 0 0 0  // 0x0040
static const uint16_t Seg_Digit_Nomal[] =
{
    /**0**  | **1**   |**2**    | **3**  |  **4**   | **5**  | **6**    | **7**   | **8**   |  **9** | **10 black** | **11 --** | **all light --**/
hu's avatar
hu committed
376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391
    0x07Bf,
    0x0606,
    0x035b,
    0x064f,
    0x0766,
    0x036d,
    0x03fd,
    0x0607,
    0x037f,
    0x076f,
    0x0000,
    0x0040,
    0xffff,
};

static void Seg_Digit_1_Disp(uint8_t Digit)
hu's avatar
hu committed
392 393 394 395 396 397 398 399 400 401 402 403 404
{
    uint8_t MUN_A;
    uint8_t MUN_B;
    uint8_t MUN_C;
    uint8_t MUN_D;
    uint8_t MUN_E;
    uint8_t MUN_F;
    uint8_t MUN_G;
    uint8_t MUN_H;
    uint8_t MUN_J;
    uint8_t MUN_K;
    uint8_t MUN_L;

hu's avatar
hu committed
405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427
    MUN_A = (((1 << 0) & Seg_Digit_Nomal[Digit]) >> 0) ? 7 : 0;
    MUN_B = (((1 << 1) & Seg_Digit_Nomal[Digit]) >> 1) ? 7 : 0;
    MUN_C = (((1 << 2) & Seg_Digit_Nomal[Digit]) >> 2) ? 7 : 0;
    MUN_D = (((1 << 3) & Seg_Digit_Nomal[Digit]) >> 3) ? 7 : 0;
    MUN_E = (((1 << 4) & Seg_Digit_Nomal[Digit]) >> 4) ? 7 : 0;
    MUN_F = (((1 << 5) & Seg_Digit_Nomal[Digit]) >> 5) ? 7 : 0;
    MUN_G = (((1 << 6) & Seg_Digit_Nomal[Digit]) >> 6) ? 7 : 0;
    MUN_H = (((1 << 7) & Seg_Digit_Nomal[Digit]) >> 7) ? 7 : 0;
    MUN_J = (((1 << 8) & Seg_Digit_Nomal[Digit]) >> 8) ? 7 : 0;
    MUN_K = (((1 << 9) & Seg_Digit_Nomal[Digit]) >> 9) ? 7 : 0;
    MUN_L = (((1 << 10) & Seg_Digit_Nomal[Digit]) >> 10) ? 7 : 0;

    NUM_1A(MUN_A);
    NUM_1B(MUN_B);
    NUM_1C(MUN_C);
    NUM_1D(MUN_D);
    NUM_1E(MUN_E);
    NUM_1F(MUN_F);
    NUM_1G(MUN_G);
    NUM_1H(MUN_H);
    NUM_1J(MUN_J);
    NUM_1K(MUN_K);
    NUM_1L(MUN_L);
hu's avatar
hu committed
428
}
hu's avatar
hu committed
429
static void Seg_Digit_2_Disp(uint8_t Digit)
hu's avatar
hu committed
430 431 432 433 434 435 436 437 438 439 440 441 442
{
    uint8_t MUN_A;
    uint8_t MUN_B;
    uint8_t MUN_C;
    uint8_t MUN_D;
    uint8_t MUN_E;
    uint8_t MUN_F;
    uint8_t MUN_G;
    uint8_t MUN_H;
    uint8_t MUN_J;
    uint8_t MUN_K;
    uint8_t MUN_L;

hu's avatar
hu committed
443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465
    MUN_A = (((1 << 0) & Seg_Digit_Nomal[Digit]) >> 0) ? 7 : 0;
    MUN_B = (((1 << 1) & Seg_Digit_Nomal[Digit]) >> 1) ? 7 : 0;
    MUN_C = (((1 << 2) & Seg_Digit_Nomal[Digit]) >> 2) ? 7 : 0;
    MUN_D = (((1 << 3) & Seg_Digit_Nomal[Digit]) >> 3) ? 7 : 0;
    MUN_E = (((1 << 4) & Seg_Digit_Nomal[Digit]) >> 4) ? 7 : 0;
    MUN_F = (((1 << 5) & Seg_Digit_Nomal[Digit]) >> 5) ? 7 : 0;
    MUN_G = (((1 << 6) & Seg_Digit_Nomal[Digit]) >> 6) ? 7 : 0;
    MUN_H = (((1 << 7) & Seg_Digit_Nomal[Digit]) >> 7) ? 7 : 0;
    MUN_J = (((1 << 8) & Seg_Digit_Nomal[Digit]) >> 8) ? 7 : 0;
    MUN_K = (((1 << 9) & Seg_Digit_Nomal[Digit]) >> 9) ? 7 : 0;
    MUN_L = (((1 << 10) & Seg_Digit_Nomal[Digit]) >> 10) ? 7 : 0;

    NUM_2A(MUN_A);
    NUM_2B(MUN_B);
    NUM_2C(MUN_C);
    NUM_2D(MUN_D);
    NUM_2E(MUN_E);
    NUM_2F(MUN_F);
    NUM_2G(MUN_G);
    NUM_2H(MUN_H);
    NUM_2J(MUN_J);
    NUM_2K(MUN_K);
    NUM_2L(MUN_L);
hu's avatar
hu committed
466 467
}

hu's avatar
hu committed
468
static void Seg_Digit_3_Disp(uint8_t Digit)
hu's avatar
hu committed
469 470 471 472 473 474 475 476 477 478 479 480 481
{
    uint8_t MUN_A;
    uint8_t MUN_B;
    uint8_t MUN_C;
    uint8_t MUN_D;
    uint8_t MUN_E;
    uint8_t MUN_F;
    uint8_t MUN_G;
    uint8_t MUN_H;
    uint8_t MUN_J;
    uint8_t MUN_K;
    uint8_t MUN_L;

hu's avatar
hu committed
482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504
    MUN_A = (((1 << 0) & Seg_Digit_Nomal[Digit]) >> 0) ? 7 : 0;
    MUN_B = (((1 << 1) & Seg_Digit_Nomal[Digit]) >> 1) ? 7 : 0;
    MUN_C = (((1 << 2) & Seg_Digit_Nomal[Digit]) >> 2) ? 7 : 0;
    MUN_D = (((1 << 3) & Seg_Digit_Nomal[Digit]) >> 3) ? 7 : 0;
    MUN_E = (((1 << 4) & Seg_Digit_Nomal[Digit]) >> 4) ? 7 : 0;
    MUN_F = (((1 << 5) & Seg_Digit_Nomal[Digit]) >> 5) ? 7 : 0;
    MUN_G = (((1 << 6) & Seg_Digit_Nomal[Digit]) >> 6) ? 7 : 0;
    MUN_H = (((1 << 7) & Seg_Digit_Nomal[Digit]) >> 7) ? 7 : 0;
    MUN_J = (((1 << 8) & Seg_Digit_Nomal[Digit]) >> 8) ? 7 : 0;
    MUN_K = (((1 << 9) & Seg_Digit_Nomal[Digit]) >> 9) ? 7 : 0;
    MUN_L = (((1 << 10) & Seg_Digit_Nomal[Digit]) >> 10) ? 7 : 0;

    NUM_3A(MUN_A);
    NUM_3B(MUN_B);
    NUM_3C(MUN_C);
    NUM_3D(MUN_D);
    NUM_3E(MUN_E);
    NUM_3F(MUN_F);
    NUM_3G(MUN_G);
    NUM_3H(MUN_H);
    NUM_3J(MUN_J);
    NUM_3K(MUN_K);
    NUM_3L(MUN_L);
hu's avatar
hu committed
505 506 507 508 509
}

static void SEG_VehicleSpeed_Num(uint16_t Value, uint8_t Valid)
{

hu's avatar
hu committed
510
    uint32_t VSPEED_FLAG;
hu's avatar
hu committed
511
    uint8_t Dig[3u];
hu's avatar
hu committed
512
    uint8_t Seg_Trip_Display_Reg = 0u;
hu's avatar
hu committed
513 514 515 516 517 518 519 520 521

    if (Valid == GUI_DISP_MODE_BLANK)
    {
        Seg_Digit_1_Disp(10u);
        Seg_Digit_2_Disp(10u);
        Seg_Digit_3_Disp(10u);
    }
    else
    {
hu's avatar
hu committed
522
        VSPEED_FLAG = Value;
hu's avatar
hu committed
523 524 525 526 527
        VSPEED_FLAG = VSPEED_FLAG / 10u;

        if (VSPEED_FLAG > 225u)
            VSPEED_FLAG = 225u;

hu's avatar
hu committed
528 529
        Seg_General_Digit_Display((uint32_t)VSPEED_FLAG, 3u, 2u, Dig, &Seg_Trip_Display_Reg);
        switch (Seg_Trip_Display_Reg)
hu's avatar
hu committed
530
        {
hu's avatar
hu committed
531
        case 0x02: //二位数
hu's avatar
hu committed
532 533
            Dig[2u] = 10u;
            break;
hu's avatar
hu committed
534
        case 0x03: //一位数
hu's avatar
hu committed
535 536 537
            Dig[2u] = 10u;
            Dig[1u] = 10u;
            break;
hu's avatar
hu committed
538
        default:
hu's avatar
hu committed
539 540 541 542 543 544 545 546 547 548 549
            break;
        }

        if (Valid == GUI_DISP_MODE_NORMAL)
        {
            Seg_Digit_1_Disp(Dig[2u]);
            Seg_Digit_2_Disp(Dig[1u]);
            Seg_Digit_3_Disp(Dig[0u]);
        }
        else
        {
hu's avatar
hu committed
550 551 552
            Seg_Digit_1_Disp(11u); //--
            Seg_Digit_2_Disp(11u); //--
            Seg_Digit_3_Disp(11u); //--
hu's avatar
hu committed
553 554 555 556
        }
    }
}
//主气压
hu's avatar
hu committed
557
static void SEG_PRI_Display(uint8_t Value, uint8_t Valid, uint8_t seg_status)
hu's avatar
hu committed
558
{
hu's avatar
hu committed
559 560 561 562 563 564 565 566 567
    uint8_t i;
    static OldValue = 0xff;
    static uint8_t mSEG[PRI_SEG_NUM_MAX] = {0};
    SEG_BUFF_Set(BU98_CHIP1, SEG_REDEFINE_95, seg_status);  // A63
    SEG_BUFF_Set(BU98_CHIP1, SEG_REDEFINE_96, seg_status);  // A64
    SEG_BUFF_Set(BU98_CHIP1, SEG_REDEFINE_114, seg_status); // A82
    SEG_BUFF_Set(BU98_CHIP1, SEG_REDEFINE_115, seg_status); // A83
    SEG_BUFF_Set(BU98_CHIP1, SEG_REDEFINE_116, seg_status); // A84
    SEG_BUFF_Set(BU98_CHIP1, SEG_REDEFINE_117, seg_status); // A85
hu's avatar
hu committed
568

hu's avatar
hu committed
569 570
    if (Valid == GUI_DISP_MODE_BLANK)
    {
hu's avatar
hu committed
571
        for (i = 0; i < PRI_SEG_NUM_MAX; i++)
hu's avatar
hu committed
572
        {
hu's avatar
hu committed
573
            mSEG[i] = 0;
hu's avatar
hu committed
574
        }
hu's avatar
hu committed
575
        OldValue = 0xff;
hu's avatar
hu committed
576
    }
hu's avatar
hu committed
577
    else if (Valid == GUI_DISP_MODE_INVALID)
hu's avatar
hu committed
578
    {
hu's avatar
hu committed
579 580 581 582
        SEG_BUFF_Set(BU98_CHIP1, SEG_REDEFINE_114, 0); // A82
        SEG_BUFF_Set(BU98_CHIP1, SEG_REDEFINE_115, 0); // A83
        SEG_BUFF_Set(BU98_CHIP1, SEG_REDEFINE_116, 0); // A84
        SEG_BUFF_Set(BU98_CHIP1, SEG_REDEFINE_117, 0); // A85
hu's avatar
hu committed
583

hu's avatar
hu committed
584
        for (i = 0; i < PRI_SEG_NUM_MAX; i++)
hu's avatar
hu committed
585
        {
hu's avatar
hu committed
586
            mSEG[i] = 0;
hu's avatar
hu committed
587
        }
hu's avatar
hu committed
588
        OldValue = 0xff;
hu's avatar
hu committed
589 590
    }
    else
hu's avatar
hu committed
591
    {
hu's avatar
hu committed
592
        if (Valid == GUI_DISP_MODE_NORMAL)
hu's avatar
hu committed
593 594 595 596
        {
            // eg: 5 -> 100000-> 11111
            // mSEG[0] = ((((1 << Value) - 1) & ( 1 << 0)) >> 0) ? seg_status : 0;
            if (OldValue != Value)
hu's avatar
hu committed
597
            {
hu's avatar
hu committed
598
                OldValue = Value;
hu's avatar
hu committed
599

hu's avatar
hu committed
600
                for (i = 0; i < PRI_SEG_NUM_MAX; i++)
hu's avatar
hu committed
601
                {
hu's avatar
hu committed
602 603
                    mSEG[i] = ((((1 << Value) - 1) & (1 << i)) >> i);
                    if (mSEG[i])
hu's avatar
hu committed
604
                    {
hu's avatar
hu committed
605
                        mSEG[i] = seg_status;
hu's avatar
hu committed
606 607 608
                    }
                    else
                    {
hu's avatar
hu committed
609
                        mSEG[i] = 0;
hu's avatar
hu committed
610
                    }
hu's avatar
hu committed
611 612
                }
            }
hu's avatar
hu committed
613 614 615
        }
    }

hu's avatar
hu committed
616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632
    SEG_BUFF_Set(BU98_CHIP1, SEG_REDEFINE_97, mSEG[0]);   // A65
    SEG_BUFF_Set(BU98_CHIP1, SEG_REDEFINE_98, mSEG[1]);   // A66
    SEG_BUFF_Set(BU98_CHIP1, SEG_REDEFINE_99, mSEG[2]);   // A67
    SEG_BUFF_Set(BU98_CHIP1, SEG_REDEFINE_100, mSEG[3]);  // A68
    SEG_BUFF_Set(BU98_CHIP1, SEG_REDEFINE_101, mSEG[4]);  // A69
    SEG_BUFF_Set(BU98_CHIP1, SEG_REDEFINE_102, mSEG[5]);  // A70
    SEG_BUFF_Set(BU98_CHIP1, SEG_REDEFINE_103, mSEG[6]);  // A71
    SEG_BUFF_Set(BU98_CHIP1, SEG_REDEFINE_104, mSEG[7]);  // A72
    SEG_BUFF_Set(BU98_CHIP1, SEG_REDEFINE_105, mSEG[8]);  // A73
    SEG_BUFF_Set(BU98_CHIP1, SEG_REDEFINE_106, mSEG[9]);  // A74
    SEG_BUFF_Set(BU98_CHIP1, SEG_REDEFINE_107, mSEG[10]); // A75
    SEG_BUFF_Set(BU98_CHIP1, SEG_REDEFINE_108, mSEG[11]); // A76
    SEG_BUFF_Set(BU98_CHIP1, SEG_REDEFINE_109, mSEG[12]); // A77
    SEG_BUFF_Set(BU98_CHIP1, SEG_REDEFINE_110, mSEG[13]); // A78
    SEG_BUFF_Set(BU98_CHIP1, SEG_REDEFINE_111, mSEG[14]); // A79
    SEG_BUFF_Set(BU98_CHIP1, SEG_REDEFINE_112, mSEG[15]); // A80
    SEG_BUFF_Set(BU98_CHIP1, SEG_REDEFINE_113, mSEG[16]); // A81
hu's avatar
hu committed
633 634
}
//副气压
hu's avatar
hu committed
635
static void SEG_SEC_Display(uint8_t Value, uint8_t Valid, uint8_t seg_status)
hu's avatar
hu committed
636
{
hu's avatar
hu committed
637 638 639 640 641 642 643 644 645
    uint8_t i;
    static OldValue = 0xff;
    static uint8_t mSEG[SEC_SEG_NUM_MAX] = {0};
    SEG_BUFF_Set(BU98_CHIP0, SEG_REDEFINE_68, seg_status); // B5
    SEG_BUFF_Set(BU98_CHIP0, SEG_REDEFINE_69, seg_status); // B6
    SEG_BUFF_Set(BU98_CHIP0, SEG_REDEFINE_70, seg_status); // B7
    SEG_BUFF_Set(BU98_CHIP0, SEG_REDEFINE_71, seg_status); // B8
    SEG_BUFF_Set(BU98_CHIP0, SEG_REDEFINE_72, seg_status); // B9
    SEG_BUFF_Set(BU98_CHIP0, SEG_REDEFINE_90, seg_status); // B27
hu's avatar
hu committed
646 647 648

    if (Valid == GUI_DISP_MODE_BLANK)
    {
hu's avatar
hu committed
649
        for (i = 0; i < SEC_SEG_NUM_MAX; i++)
hu's avatar
hu committed
650
        {
hu's avatar
hu committed
651
            mSEG[i] = 0;
hu's avatar
hu committed
652
        }
hu's avatar
hu committed
653
        OldValue = 0xff;
hu's avatar
hu committed
654 655 656
    }
    else if (Valid == GUI_DISP_MODE_INVALID)
    {
hu's avatar
hu committed
657 658 659 660 661
        SEG_BUFF_Set(BU98_CHIP0, SEG_REDEFINE_70, 0); // B7
        SEG_BUFF_Set(BU98_CHIP0, SEG_REDEFINE_71, 0); // B8
        SEG_BUFF_Set(BU98_CHIP0, SEG_REDEFINE_72, 0); // B9
        SEG_BUFF_Set(BU98_CHIP0, SEG_REDEFINE_90, 0); // B27
        for (i = 0; i < SEC_SEG_NUM_MAX; i++)
hu's avatar
hu committed
662
        {
hu's avatar
hu committed
663
            mSEG[i] = 0;
hu's avatar
hu committed
664
        }
hu's avatar
hu committed
665
        OldValue = 0xff;
hu's avatar
hu committed
666 667
    }
    else
hu's avatar
hu committed
668
    {
hu's avatar
hu committed
669
        if (Valid == GUI_DISP_MODE_NORMAL)
hu's avatar
hu committed
670 671 672
        {
            // eg: 5 -> 100000-> 11111
            if (OldValue != Value)
hu's avatar
hu committed
673
            {
hu's avatar
hu committed
674
                for (i = 0; i < SEC_SEG_NUM_MAX; i++)
hu's avatar
hu committed
675
                {
hu's avatar
hu committed
676 677
                    mSEG[i] = ((((1 << Value) - 1) & (1 << i)) >> i);
                    if (mSEG[i])
hu's avatar
hu committed
678
                    {
hu's avatar
hu committed
679
                        mSEG[i] = seg_status;
hu's avatar
hu committed
680 681 682
                    }
                    else
                    {
hu's avatar
hu committed
683
                        mSEG[i] = 0;
hu's avatar
hu committed
684 685 686 687 688 689
                    }
                }
            }
        }
    }

hu's avatar
hu committed
690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706
    SEG_BUFF_Set(BU98_CHIP0, SEG_REDEFINE_73, mSEG[0]);  // B10
    SEG_BUFF_Set(BU98_CHIP0, SEG_REDEFINE_74, mSEG[1]);  // B11
    SEG_BUFF_Set(BU98_CHIP0, SEG_REDEFINE_75, mSEG[2]);  // B12
    SEG_BUFF_Set(BU98_CHIP0, SEG_REDEFINE_76, mSEG[3]);  // B13
    SEG_BUFF_Set(BU98_CHIP0, SEG_REDEFINE_77, mSEG[4]);  // B14
    SEG_BUFF_Set(BU98_CHIP0, SEG_REDEFINE_78, mSEG[5]);  // B15
    SEG_BUFF_Set(BU98_CHIP0, SEG_REDEFINE_79, mSEG[6]);  // B16
    SEG_BUFF_Set(BU98_CHIP0, SEG_REDEFINE_80, mSEG[7]);  // B17
    SEG_BUFF_Set(BU98_CHIP0, SEG_REDEFINE_81, mSEG[8]);  // B18
    SEG_BUFF_Set(BU98_CHIP0, SEG_REDEFINE_82, mSEG[9]);  // B19
    SEG_BUFF_Set(BU98_CHIP0, SEG_REDEFINE_83, mSEG[10]); // B20
    SEG_BUFF_Set(BU98_CHIP0, SEG_REDEFINE_84, mSEG[11]); // B21
    SEG_BUFF_Set(BU98_CHIP0, SEG_REDEFINE_85, mSEG[12]); // B22
    SEG_BUFF_Set(BU98_CHIP0, SEG_REDEFINE_86, mSEG[13]); // B23
    SEG_BUFF_Set(BU98_CHIP0, SEG_REDEFINE_87, mSEG[14]); // B24
    SEG_BUFF_Set(BU98_CHIP0, SEG_REDEFINE_88, mSEG[15]); // B25
    SEG_BUFF_Set(BU98_CHIP0, SEG_REDEFINE_89, mSEG[16]); // B26
hu's avatar
hu committed
707 708
}
//水温
hu's avatar
hu committed
709
static void SEG_Coolant_Display(uint8_t Value, uint8_t Valid, uint8_t seg_status)
hu's avatar
hu committed
710
{
hu's avatar
hu committed
711 712 713 714 715 716 717
    uint8_t i;
    static uint8_t OldValue = 0;
    static uint8_t mSEG[COOLANT_SEG_NUM_MAX] = {0};
    SEG_BUFF_Set(BU98_CHIP1, SEG_REDEFINE_79, seg_status); // A47
    SEG_BUFF_Set(BU98_CHIP1, SEG_REDEFINE_92, seg_status); // A60
    SEG_BUFF_Set(BU98_CHIP1, SEG_REDEFINE_93, seg_status); // A61
    SEG_BUFF_Set(BU98_CHIP1, SEG_REDEFINE_94, seg_status); // A62
hu's avatar
hu committed
718 719 720

    if (Valid == GUI_DISP_MODE_BLANK)
    {
hu's avatar
hu committed
721
        for (i = 0; i < COOLANT_SEG_NUM_MAX; i++)
hu's avatar
hu committed
722
        {
hu's avatar
hu committed
723
            mSEG[i] = 0;
hu's avatar
hu committed
724
        }
hu's avatar
hu committed
725
        OldValue = 0;
hu's avatar
hu committed
726
    }
hu's avatar
hu committed
727
    else if (Valid == GUI_DISP_MODE_INVALID)
hu's avatar
hu committed
728
    {
hu's avatar
hu committed
729 730 731 732
        SEG_BUFF_Set(BU98_CHIP1, SEG_REDEFINE_92, 0u); // A60
        SEG_BUFF_Set(BU98_CHIP1, SEG_REDEFINE_93, 0u); // A61
        SEG_BUFF_Set(BU98_CHIP1, SEG_REDEFINE_94, 0u); // A62
        for (i = 0; i < COOLANT_SEG_NUM_MAX; i++)
hu's avatar
hu committed
733
        {
hu's avatar
hu committed
734
            mSEG[i] = 0;
hu's avatar
hu committed
735
        }
hu's avatar
hu committed
736
        OldValue = 0;
hu's avatar
hu committed
737 738
    }
    else
hu's avatar
hu committed
739
    {
hu's avatar
hu committed
740
        if (Valid == GUI_DISP_MODE_NORMAL)
hu's avatar
hu committed
741 742 743
        {
            // eg: 5 -> 100000-> 11111
            if (OldValue != Value)
hu's avatar
hu committed
744
            {
hu's avatar
hu committed
745 746
                OldValue = Value;
                for (i = 0; i < COOLANT_SEG_NUM_MAX; i++)
hu's avatar
hu committed
747
                {
hu's avatar
hu committed
748 749
                    mSEG[i] = ((((1 << Value) - 1) & (1 << i)) >> i);
                    if (mSEG[i])
hu's avatar
hu committed
750
                    {
hu's avatar
hu committed
751
                        mSEG[i] = seg_status;
hu's avatar
hu committed
752 753 754
                    }
                    else
                    {
hu's avatar
hu committed
755
                        mSEG[i] = 0;
hu's avatar
hu committed
756 757 758 759 760 761
                    }
                }
            }
        }
    }

hu's avatar
hu committed
762 763 764 765 766 767 768 769 770 771 772 773
    SEG_BUFF_Set(BU98_CHIP1, SEG_REDEFINE_80, mSEG[0]);  // A48
    SEG_BUFF_Set(BU98_CHIP1, SEG_REDEFINE_81, mSEG[1]);  // A49
    SEG_BUFF_Set(BU98_CHIP1, SEG_REDEFINE_82, mSEG[2]);  // A50
    SEG_BUFF_Set(BU98_CHIP1, SEG_REDEFINE_83, mSEG[3]);  // A51
    SEG_BUFF_Set(BU98_CHIP1, SEG_REDEFINE_84, mSEG[4]);  // A52
    SEG_BUFF_Set(BU98_CHIP1, SEG_REDEFINE_85, mSEG[5]);  // A53
    SEG_BUFF_Set(BU98_CHIP1, SEG_REDEFINE_86, mSEG[6]);  // A54
    SEG_BUFF_Set(BU98_CHIP1, SEG_REDEFINE_87, mSEG[7]);  // A55
    SEG_BUFF_Set(BU98_CHIP1, SEG_REDEFINE_88, mSEG[8]);  // A56
    SEG_BUFF_Set(BU98_CHIP1, SEG_REDEFINE_89, mSEG[9]);  // A57
    SEG_BUFF_Set(BU98_CHIP1, SEG_REDEFINE_90, mSEG[10]); // A58
    SEG_BUFF_Set(BU98_CHIP1, SEG_REDEFINE_91, mSEG[11]); // A59
hu's avatar
hu committed
774 775
}
//燃油
hu's avatar
hu committed
776
static void SEG_Fuel_Display(uint8_t Value, uint8_t Valid, uint8_t seg_status)
hu's avatar
hu committed
777
{
hu's avatar
hu committed
778 779 780 781 782 783
    uint8_t i;
    uint8_t mSEG[FUEL_SEG_NUM_MAX] = {0};
    SEG_BUFF_Set(BU98_CHIP0, SEG_REDEFINE_91, seg_status);  // B28
    SEG_BUFF_Set(BU98_CHIP0, SEG_REDEFINE_92, seg_status);  // B29
    SEG_BUFF_Set(BU98_CHIP0, SEG_REDEFINE_93, seg_status);  // B30
    SEG_BUFF_Set(BU98_CHIP0, SEG_REDEFINE_106, seg_status); // B43
hu's avatar
hu committed
784 785 786

    if (Valid == GUI_DISP_MODE_BLANK)
    {
hu's avatar
hu committed
787
        for (i = 0; i < FUEL_SEG_NUM_MAX; i++)
hu's avatar
hu committed
788
        {
hu's avatar
hu committed
789
            mSEG[i] = 0;
hu's avatar
hu committed
790 791 792
        }
    }
    else
hu's avatar
hu committed
793
    {
hu's avatar
hu committed
794
        if (Valid == GUI_DISP_MODE_NORMAL)
hu's avatar
hu committed
795 796 797
        {
            // eg: 5 -> 100000-> 11111
            for (i = 0; i < FUEL_SEG_NUM_MAX; i++)
hu's avatar
hu committed
798
            {
hu's avatar
hu committed
799 800
                mSEG[i] = ((((1 << Value) - 1) & (1 << i)) >> i);
                if (mSEG[i])
hu's avatar
hu committed
801
                {
hu's avatar
hu committed
802
                    mSEG[i] = seg_status;
hu's avatar
hu committed
803 804 805
                }
                else
                {
hu's avatar
hu committed
806
                    mSEG[i] = 0;
hu's avatar
hu committed
807 808 809 810 811
                }
            }
        }
    }

hu's avatar
hu committed
812 813 814 815 816 817 818 819 820 821 822 823
    SEG_BUFF_Set(BU98_CHIP0, SEG_REDEFINE_94, mSEG[0]);   // B31
    SEG_BUFF_Set(BU98_CHIP0, SEG_REDEFINE_95, mSEG[1]);   // B32
    SEG_BUFF_Set(BU98_CHIP0, SEG_REDEFINE_96, mSEG[2]);   // B33
    SEG_BUFF_Set(BU98_CHIP0, SEG_REDEFINE_97, mSEG[3]);   // B34
    SEG_BUFF_Set(BU98_CHIP0, SEG_REDEFINE_98, mSEG[4]);   // B35
    SEG_BUFF_Set(BU98_CHIP0, SEG_REDEFINE_99, mSEG[5]);   // B36
    SEG_BUFF_Set(BU98_CHIP0, SEG_REDEFINE_100, mSEG[6]);  // B37
    SEG_BUFF_Set(BU98_CHIP0, SEG_REDEFINE_101, mSEG[7]);  // B38
    SEG_BUFF_Set(BU98_CHIP0, SEG_REDEFINE_102, mSEG[8]);  // B39
    SEG_BUFF_Set(BU98_CHIP0, SEG_REDEFINE_103, mSEG[9]);  // B40
    SEG_BUFF_Set(BU98_CHIP0, SEG_REDEFINE_104, mSEG[10]); // B41
    SEG_BUFF_Set(BU98_CHIP0, SEG_REDEFINE_105, mSEG[11]); // B42
hu's avatar
hu committed
824 825
}
//转速
hu's avatar
hu committed
826
static void SEG_Tacho_Display(uint8_t Value, uint8_t Valid, uint8_t seg_status)
hu's avatar
hu committed
827
{
hu's avatar
hu committed
828 829 830 831 832 833 834 835 836
    uint8_t i;
    uint8_t mSEG[TACHO_SEG_NUM_MAX] = {0};
    SEG_BUFF_Set(BU98_CHIP1, SEG_REDEFINE_38, seg_status); // A8
    SEG_BUFF_Set(BU98_CHIP1, SEG_REDEFINE_59, seg_status); // A27
    SEG_BUFF_Set(BU98_CHIP1, SEG_REDEFINE_65, seg_status); // A33
    SEG_BUFF_Set(BU98_CHIP1, SEG_REDEFINE_71, seg_status); // A39
    SEG_BUFF_Set(BU98_CHIP1, SEG_REDEFINE_40, seg_status); // A10
    SEG_BUFF_Set(BU98_CHIP1, SEG_REDEFINE_46, seg_status); // A16
    SEG_BUFF_Set(BU98_CHIP1, SEG_REDEFINE_51, seg_status); // A21
hu's avatar
hu committed
837 838 839

    if (Valid == GUI_DISP_MODE_BLANK)
    {
hu's avatar
hu committed
840
        for (i = 0; i < TACHO_SEG_NUM_MAX; i++)
hu's avatar
hu committed
841
        {
hu's avatar
hu committed
842
            mSEG[i] = 0;
hu's avatar
hu committed
843 844 845
        }
    }
    else
hu's avatar
hu committed
846
    {
hu's avatar
hu committed
847
        if (Valid == GUI_DISP_MODE_NORMAL)
hu's avatar
hu committed
848 849 850
        {
            // eg: 5 -> 100000-> 11111
            for (i = 0; i < TACHO_SEG_NUM_MAX; i++)
hu's avatar
hu committed
851
            {
hu's avatar
hu committed
852 853
                mSEG[i] = ((((1 << Value) - 1) & (1 << i)) >> i);
                if (mSEG[i])
hu's avatar
hu committed
854
                {
hu's avatar
hu committed
855
                    mSEG[i] = seg_status;
hu's avatar
hu committed
856 857 858
                }
                else
                {
hu's avatar
hu committed
859
                    mSEG[i] = 1;
hu's avatar
hu committed
860 861 862 863 864
                }
            }
        }
    }

hu's avatar
hu committed
865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891
    SEG_BUFF_Set(BU98_CHIP1, SEG_REDEFINE_58, mSEG[0]);  // A26
    SEG_BUFF_Set(BU98_CHIP1, SEG_REDEFINE_60, mSEG[1]);  // A28
    SEG_BUFF_Set(BU98_CHIP1, SEG_REDEFINE_61, mSEG[2]);  // A29
    SEG_BUFF_Set(BU98_CHIP1, SEG_REDEFINE_62, mSEG[3]);  // A30
    SEG_BUFF_Set(BU98_CHIP1, SEG_REDEFINE_63, mSEG[4]);  // A31
    SEG_BUFF_Set(BU98_CHIP1, SEG_REDEFINE_64, mSEG[5]);  // A32
    SEG_BUFF_Set(BU98_CHIP1, SEG_REDEFINE_66, mSEG[6]);  // A34
    SEG_BUFF_Set(BU98_CHIP1, SEG_REDEFINE_67, mSEG[7]);  // A35
    SEG_BUFF_Set(BU98_CHIP1, SEG_REDEFINE_68, mSEG[8]);  // A36
    SEG_BUFF_Set(BU98_CHIP1, SEG_REDEFINE_69, mSEG[9]);  // A37
    SEG_BUFF_Set(BU98_CHIP1, SEG_REDEFINE_70, mSEG[10]); // A38
    SEG_BUFF_Set(BU98_CHIP1, SEG_REDEFINE_72, mSEG[11]); // A40
    SEG_BUFF_Set(BU98_CHIP1, SEG_REDEFINE_73, mSEG[12]); // A41
    SEG_BUFF_Set(BU98_CHIP1, SEG_REDEFINE_74, mSEG[13]); // A42
    SEG_BUFF_Set(BU98_CHIP1, SEG_REDEFINE_75, mSEG[14]); // A43
    SEG_BUFF_Set(BU98_CHIP1, SEG_REDEFINE_39, mSEG[15]); // A9
    SEG_BUFF_Set(BU98_CHIP1, SEG_REDEFINE_41, mSEG[16]); // A11
    SEG_BUFF_Set(BU98_CHIP1, SEG_REDEFINE_42, mSEG[17]); // A12
    SEG_BUFF_Set(BU98_CHIP1, SEG_REDEFINE_43, mSEG[18]); // A13
    SEG_BUFF_Set(BU98_CHIP1, SEG_REDEFINE_44, mSEG[19]); // A14
    SEG_BUFF_Set(BU98_CHIP1, SEG_REDEFINE_45, mSEG[20]); // A15
    SEG_BUFF_Set(BU98_CHIP1, SEG_REDEFINE_47, mSEG[21]); // A17
    SEG_BUFF_Set(BU98_CHIP1, SEG_REDEFINE_48, mSEG[22]); // A18
    SEG_BUFF_Set(BU98_CHIP1, SEG_REDEFINE_49, mSEG[23]); // A19
    SEG_BUFF_Set(BU98_CHIP1, SEG_REDEFINE_53, mSEG[24]); // A23
    SEG_BUFF_Set(BU98_CHIP1, SEG_REDEFINE_52, mSEG[25]); // A22
    SEG_BUFF_Set(BU98_CHIP1, SEG_REDEFINE_50, mSEG[26]); // A20
hu's avatar
hu committed
892 893
}
//车速
hu's avatar
hu committed
894
static void SEG_VehicleSpeed_Display(uint8_t Value, uint8_t Valid, uint8_t seg_status)
hu's avatar
hu committed
895
{
hu's avatar
hu committed
896 897 898 899 900 901 902 903 904 905 906 907 908 909
    uint8_t i;
    uint8_t mSEG[VEH_SEG_NUM_MAX] = {0};

    SEG_BUFF_Set(BU98_CHIP0, SEG_REDEFINE_154, seg_status); // C42
    SEG_BUFF_Set(BU98_CHIP0, SEG_REDEFINE_133, seg_status); // C23
    SEG_BUFF_Set(BU98_CHIP0, SEG_REDEFINE_128, seg_status); // C18
    SEG_BUFF_Set(BU98_CHIP0, SEG_REDEFINE_123, seg_status); // C13
    SEG_BUFF_Set(BU98_CHIP0, SEG_REDEFINE_118, seg_status); // C8
    SEG_BUFF_Set(BU98_CHIP0, SEG_REDEFINE_113, seg_status); // C3
    SEG_BUFF_Set(BU98_CHIP0, SEG_REDEFINE_151, seg_status); // C39
    SEG_BUFF_Set(BU98_CHIP0, SEG_REDEFINE_146, seg_status); // C34
    SEG_BUFF_Set(BU98_CHIP0, SEG_REDEFINE_141, seg_status); // C29

    if (Value > VEH_SEG_NUM_MAX)
hu's avatar
hu committed
910
    {
hu's avatar
hu committed
911
        Value = VEH_SEG_NUM_MAX;
hu's avatar
hu committed
912 913 914 915
    }

    if (Valid == GUI_DISP_MODE_BLANK)
    {
hu's avatar
hu committed
916
        for (i = 0; i < VEH_SEG_NUM_MAX; i++)
hu's avatar
hu committed
917
        {
hu's avatar
hu committed
918
            mSEG[i] = 0;
hu's avatar
hu committed
919 920 921
        }
    }
    else
hu's avatar
hu committed
922
    {
hu's avatar
hu committed
923
        if (Valid == GUI_DISP_MODE_NORMAL)
hu's avatar
hu committed
924 925 926
        {
            // eg: 5 -> 100000-> 11111
            for (i = 0; i < VEH_SEG_NUM_MAX; i++)
hu's avatar
hu committed
927
            {
hu's avatar
hu committed
928 929
                mSEG[i] = ((((1 << Value) - 1) & (1 << i)) >> i);
                if (mSEG[i])
hu's avatar
hu committed
930
                {
hu's avatar
hu committed
931
                    mSEG[i] = seg_status;
hu's avatar
hu committed
932 933 934
                }
                else
                {
hu's avatar
hu committed
935
                    mSEG[i] = 1;
hu's avatar
hu committed
936 937 938 939 940
                }
            }
        }
    }

hu's avatar
hu committed
941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970
    SEG_BUFF_Set(BU98_CHIP0, SEG_REDEFINE_134, mSEG[0]);  // C24
    SEG_BUFF_Set(BU98_CHIP0, SEG_REDEFINE_132, mSEG[1]);  // C22
    SEG_BUFF_Set(BU98_CHIP0, SEG_REDEFINE_131, mSEG[2]);  // C21
    SEG_BUFF_Set(BU98_CHIP0, SEG_REDEFINE_130, mSEG[3]);  // C20
    SEG_BUFF_Set(BU98_CHIP0, SEG_REDEFINE_129, mSEG[4]);  // C19
    SEG_BUFF_Set(BU98_CHIP0, SEG_REDEFINE_127, mSEG[5]);  // C17
    SEG_BUFF_Set(BU98_CHIP0, SEG_REDEFINE_126, mSEG[6]);  // C16
    SEG_BUFF_Set(BU98_CHIP0, SEG_REDEFINE_125, mSEG[7]);  // C15
    SEG_BUFF_Set(BU98_CHIP0, SEG_REDEFINE_124, mSEG[8]);  // C14
    SEG_BUFF_Set(BU98_CHIP0, SEG_REDEFINE_122, mSEG[9]);  // C12
    SEG_BUFF_Set(BU98_CHIP0, SEG_REDEFINE_121, mSEG[10]); // C11
    SEG_BUFF_Set(BU98_CHIP0, SEG_REDEFINE_120, mSEG[11]); // C10
    SEG_BUFF_Set(BU98_CHIP0, SEG_REDEFINE_119, mSEG[12]); // C9
    SEG_BUFF_Set(BU98_CHIP0, SEG_REDEFINE_117, mSEG[13]); // C7
    SEG_BUFF_Set(BU98_CHIP0, SEG_REDEFINE_116, mSEG[14]); // C6
    SEG_BUFF_Set(BU98_CHIP0, SEG_REDEFINE_115, mSEG[15]); // C5
    SEG_BUFF_Set(BU98_CHIP0, SEG_REDEFINE_114, mSEG[16]); // C4
    SEG_BUFF_Set(BU98_CHIP0, SEG_REDEFINE_112, mSEG[17]); // C2
    SEG_BUFF_Set(BU98_CHIP0, SEG_REDEFINE_111, mSEG[18]); // C1
    SEG_BUFF_Set(BU98_CHIP0, SEG_REDEFINE_153, mSEG[19]); // C41
    SEG_BUFF_Set(BU98_CHIP0, SEG_REDEFINE_152, mSEG[20]); // C40
    SEG_BUFF_Set(BU98_CHIP0, SEG_REDEFINE_150, mSEG[21]); // C38
    SEG_BUFF_Set(BU98_CHIP0, SEG_REDEFINE_149, mSEG[22]); // C37
    SEG_BUFF_Set(BU98_CHIP0, SEG_REDEFINE_148, mSEG[23]); // C36
    SEG_BUFF_Set(BU98_CHIP0, SEG_REDEFINE_147, mSEG[24]); // C35
    SEG_BUFF_Set(BU98_CHIP0, SEG_REDEFINE_145, mSEG[25]); // C33
    SEG_BUFF_Set(BU98_CHIP0, SEG_REDEFINE_144, mSEG[26]); // C32
    SEG_BUFF_Set(BU98_CHIP0, SEG_REDEFINE_143, mSEG[27]); // C31
    SEG_BUFF_Set(BU98_CHIP0, SEG_REDEFINE_142, mSEG[28]); // C30
    SEG_BUFF_Set(BU98_CHIP0, SEG_REDEFINE_140, mSEG[29]); // C28
hu's avatar
hu committed
971 972 973 974 975 976 977 978 979 980 981
}
/******************************************************************************
函数名:Seg_General_Digit_Display
功  能:通用段数字显示程序
参  数:Digit:要显示的数字

        Len  : 需要显示的数字长度
        Blank:首位数字为零消隐位数,从最高位起算
        Reg : 寄存器变量
返回值:无
******************************************************************************/
hu's avatar
hu committed
982
static void Seg_General_Digit_Display(uint32_t Digit, uint8_t Len, uint8_t Blank, uint8_t *DigitBuf, uint8_t *Reg)
hu's avatar
hu committed
983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004
{
    uint8_t i;
    uint8_t ActLen;
    ActLen = 0;
    i = 0;

    //以10进制形式拆分数字并计算实际数字长度
    while (Digit)
    {
        DigitBuf[ActLen] = Digit % 10;
        Digit /= 10;
        ActLen++;
    }

    //数字为0时的特殊处理
    if (ActLen == 0)
    {
        ActLen = 1;
        DigitBuf[0] = 0;
    }

    //对未计算到的数字位作0填充
hu's avatar
hu committed
1005
    for (i = ActLen; i < Len; i++)
hu's avatar
hu committed
1006 1007 1008 1009 1010 1011 1012 1013 1014
        DigitBuf[i] = 0;

    //数字首部按消隐位数做零消隐
    i = (Len - 1);
    while ((DigitBuf[i] == 0) && (i >= (Len - Blank)))
    {
        DigitBuf[i] = 0xFF;
        i--;

hu's avatar
hu committed
1015
        (*Reg) |= (1 << i);
hu's avatar
hu committed
1016 1017 1018 1019
    }
}

static uint8_t wbyTestSeg = 0;
hu's avatar
hu committed
1020 1021
static uint16_t wbyTestNum;
static uint8_t WBY_SET = 0;
hu's avatar
hu committed
1022 1023 1024 1025 1026 1027
/******************************************************************************
Seg_Display_Service   在 20MS任务中
  信号接口:
  信号定义:
  输出信号:
 ******************************************************************************/
hu's avatar
hu committed
1028 1029
void Seg_Display_Service(void)
{
hu's avatar
hu committed
1030
    uint32_t Ign_Time;
hu's avatar
hu committed
1031 1032
    Ign_Time = Common_GetIgnOnTime();
    if (Common_Get_IG_Sts() == COMMON_POWER_ON)
hu's avatar
hu committed
1033
    {
hu's avatar
hu committed
1034
        if (WBY_SET == 1)/*测试用点亮全部断码*/
hu's avatar
hu committed
1035 1036
        {
            Seg_Display_ON();
hu's avatar
hu committed
1037
        }
hu's avatar
hu committed
1038 1039
        else
        {
hu's avatar
hu committed
1040 1041
            SEG_A25_Disp(7u); //左侧弧线
            SEG_C25_Disp(7u); //右侧弧线
hu's avatar
hu committed
1042

hu's avatar
hu committed
1043
            if (Ign_Time < 3100)
hu's avatar
hu committed
1044
            {
hu's avatar
hu committed
1045 1046 1047 1048 1049 1050
                SEG_PRI_Display(GetGaugesCurrentPos(PRIGasGauges), GUI_DISP_MODE_NORMAL, 7u);       // PRI气压格
                SEG_SEC_Display(GetGaugesCurrentPos(SECGasGauges), GUI_DISP_MODE_NORMAL, 7u);       // SEC气压格
                SEG_Coolant_Display(GetGaugesCurrentPos(TempGauges), GUI_DISP_MODE_NORMAL, 7u);     //水温格
                SEG_Fuel_Display(GetGaugesCurrentPos(TempGauges), GUI_DISP_MODE_NORMAL, 7u);        //燃油格
                SEG_Tacho_Display(GetGaugesCurrentPos(RevGauges), GUI_DISP_MODE_NORMAL, 7u);        //转速格
                SEG_VehicleSpeed_Display(GetGaugesCurrentPos(VehGauges), GUI_DISP_MODE_NORMAL, 7u); //车速格
hu's avatar
hu committed
1051 1052

                /*车速数字 暂时没有变化,只是全部点亮*/
hu's avatar
hu committed
1053 1054 1055 1056
                Seg_Digit_1_Disp(12);
                Seg_Digit_2_Disp(12);
                Seg_Digit_3_Disp(12);

hu's avatar
hu committed
1057
                GaugesTimer = 15u;
hu's avatar
hu committed
1058
            }
hu's avatar
hu committed
1059
            else if (GaugesTimer == 0u)
hu's avatar
hu committed
1060
            {
hu's avatar
hu committed
1061
                GaugesTimer = 15u;
hu's avatar
hu committed
1062

hu's avatar
hu committed
1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104
                if (AirPressure_Get_Valid(0))
                {
                    SEG_PRI_Display(AirPressure_Get_CurSeg(0), GUI_DISP_MODE_NORMAL, 7u); // PRI气压格
                }
                else
                {
                    SEG_PRI_Display(AirPressure_Get_CurSeg(0), GUI_DISP_MODE_INVALID, 7u); // PRI气压格
                }
                if (AirPressure_Get_Valid(1))
                {
                    SEG_SEC_Display(AirPressure_Get_CurSeg(1), GUI_DISP_MODE_NORMAL, 7u); // SEC气压格
                }
                else
                {
                    SEG_SEC_Display(AirPressure_Get_CurSeg(1), GUI_DISP_MODE_INVALID, 7u); // SEC气压格
                }

                if (Coolant_Get_Valid())
                {
                    SEG_Coolant_Display(Coolant_Get_CurSeg(), GUI_DISP_MODE_NORMAL, 7u); //水温格
                }
                else
                {
                    SEG_Coolant_Display(Coolant_Get_CurSeg(), GUI_DISP_MODE_INVALID, 7u); //水温格
                }

                SEG_Fuel_Display(Fuel_Get_CurSeg(), GUI_DISP_MODE_NORMAL, 7u);          //燃油格

                SEG_Tacho_Display(Tacho_Get_CurSeg(), GUI_DISP_MODE_NORMAL, 7u);        //转速格

                SEG_VehicleSpeed_Display(Speed_Get_CurSeg(), GUI_DISP_MODE_NORMAL, 7u); //车速格
                wbyTestNum = Common_Get_Disp_V_Speed();
                // Speed_Get_Display_Value()
                SEG_VehicleSpeed_Num(wbyTestNum, GUI_DISP_MODE_NORMAL); //车速值

                // SEG_PRI_Display(wbyTestSeg,GUI_DISP_MODE_NORMAL,7u) ;//PRI气压格
                // SEG_SEC_Display(wbyTestSeg,GUI_DISP_MODE_NORMAL,7u) ;//SEC气压格
                // SEG_Coolant_Display(wbyTestSeg,GUI_DISP_MODE_NORMAL,7u) ;//水温格
                // SEG_Fuel_Display(wbyTestSeg, GUI_DISP_MODE_NORMAL,7u);//燃油格
                // SEG_Tacho_Display(wbyTestSeg,GUI_DISP_MODE_NORMAL,7u);//转速格
                // SEG_VehicleSpeed_Display(wbyTestSeg,GUI_DISP_MODE_NORMAL,7u);//车速格
                // SEG_VehicleSpeed_Num(wbyTestNum,GUI_DISP_MODE_NORMAL);//车速值
hu's avatar
hu committed
1105 1106 1107
            }
            else
            {
hu's avatar
hu committed
1108
                GaugesTimer--;
hu's avatar
hu committed
1109 1110 1111 1112 1113 1114 1115 1116 1117 1118

                /*此处为测试水温走格速度用*/
                if (Coolant_Get_Valid())
                {
                    SEG_Coolant_Display(Coolant_Get_CurSeg(), GUI_DISP_MODE_NORMAL, 7u); //水温格
                }
                else
                {
                    SEG_Coolant_Display(Coolant_Get_CurSeg(), GUI_DISP_MODE_INVALID, 7u); //水温格
                }
hu's avatar
hu committed
1119
            }
hu's avatar
hu committed
1120
        }
hu's avatar
hu committed
1121 1122 1123
    }
    else
    {
hu's avatar
hu committed
1124 1125 1126 1127 1128 1129 1130 1131 1132
        SEG_A25_Disp(0u);                                                      //左侧弧线
        SEG_C25_Disp(0u);                                                      //右侧弧线
        SEG_PRI_Display(AirPressure_Get_CurSeg(0), GUI_DISP_MODE_BLANK, 0u);   // PRI气压格
        SEG_SEC_Display(AirPressure_Get_CurSeg(1), GUI_DISP_MODE_BLANK, 0u);   // SEC气压格
        SEG_Coolant_Display(Coolant_Get_CurSeg(), GUI_DISP_MODE_BLANK, 0u);    //水温格
        SEG_Fuel_Display(Fuel_Get_CurSeg(), GUI_DISP_MODE_BLANK, 0u);          //燃油格
        SEG_Tacho_Display(Tacho_Get_CurSeg(), GUI_DISP_MODE_BLANK, 0u);        //转速格
        SEG_VehicleSpeed_Display(Speed_Get_CurSeg(), GUI_DISP_MODE_BLANK, 0u); //车速格
        SEG_VehicleSpeed_Num(0u, GUI_DISP_MODE_BLANK);                         //车速值
hu's avatar
hu committed
1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144
    }
}

void Seg_Display_ON(void)
{
    BU98_CHIP_NUM_t chip_num;
    BU98_SEG_NUM_t seg_num;

    for (chip_num = BU98_CHIP0; chip_num < BU98_CHIP_MAX; chip_num++)
    {
        for (seg_num = SEG_REDEFINE_1; seg_num < BU98R10_SEG_MAX; seg_num++)
        {
hu's avatar
hu committed
1145
            SEG_BUFF_Set(chip_num, seg_num, 7);
hu's avatar
hu committed
1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157
        }
    }
}
void Seg_Display_OFF(void)
{
    BU98_CHIP_NUM_t chip_num;
    BU98_SEG_NUM_t seg_num;

    for (chip_num = BU98_CHIP0; chip_num < BU98_CHIP_MAX; chip_num++)
    {
        for (seg_num = SEG_REDEFINE_1; seg_num < BU98R10_SEG_MAX; seg_num++)
        {
hu's avatar
hu committed
1158
            SEG_BUFF_Set(chip_num, seg_num, 0);
hu's avatar
hu committed
1159 1160 1161
        }
    }
}