void OLED_Status(void) { static uint8_t OLEDDelay = 0; char line[22], smag[5]; uint16_t tmp0; OLEDDelay++; if (OLEDDelay >= 30) { OLEDDelay = 0; sprintf(line, "MAG : WARN ",(int16_t)heading); if (cfg.mag_calibrated == 1) { sprintf(smag, "%4d",(int16_t)heading); line[6] = smag[0]; line[7] = smag[1]; line[8] = smag[2]; line[9] = smag[3]; } i2c_OLED_LCDsetLine(1); i2c_OLED_LCDprintChar(line); sprintf(line, "VBAT: --,-V AGL:-----"); if (FEATURE_VBAT) { line[6] = digit100(vbat); line[7] = digit10(vbat); line[9] = digit1(vbat); } if (EstAlt < 0) line[16] = '-'; else line[16] = ' '; tmp0 = abs((uint32_t)EstAlt/100); line[17] = digit10000(tmp0); line[18] = digit1000(tmp0); line[19] = digit100(tmp0); line[20] = digit10(tmp0); i2c_OLED_LCDsetLine(2); i2c_OLED_LCDprintChar(line); if (FEATURE_GPS) { sprintf(line, "LAT : .-+-.------- "); line[6] = Real_GPS_coord[LAT]<0?'S':'N'; line[8] = '0' + Real_GPS_coord[LAT] / 1000000000; line[9] = '0' + Real_GPS_coord[LAT] / 100000000 - (Real_GPS_coord[LAT]/1000000000) * 10; line[10] = '0' + Real_GPS_coord[LAT] / 10000000 - (Real_GPS_coord[LAT]/100000000) * 10; line[12] = '0' + Real_GPS_coord[LAT] / 1000000 - (Real_GPS_coord[LAT]/10000000) * 10; line[13] = '0' + Real_GPS_coord[LAT] / 100000 - (Real_GPS_coord[LAT]/1000000) * 10; line[14] = '0' + Real_GPS_coord[LAT] / 10000 - (Real_GPS_coord[LAT]/100000) * 10; line[15] = '0' + Real_GPS_coord[LAT] / 1000 - (Real_GPS_coord[LAT]/10000) * 10; line[16] = '0' + Real_GPS_coord[LAT] / 100 - (Real_GPS_coord[LAT]/1000) * 10; line[17] = '0' + Real_GPS_coord[LAT] / 10 - (Real_GPS_coord[LAT]/100) * 10; line[18] = '0' + Real_GPS_coord[LAT] - (Real_GPS_coord[LAT]/10) * 10; i2c_OLED_LCDsetLine(3); i2c_OLED_LCDprintChar(line); sprintf(line, "LON : .-+-.------- "); line[6] = Real_GPS_coord[LON]<0?'W':'E'; line[8] = '0' + Real_GPS_coord[LON] / 1000000000; line[9] = '0' + Real_GPS_coord[LON] / 100000000 - (Real_GPS_coord[LON]/1000000000) * 10; line[10] = '0' + Real_GPS_coord[LON] / 10000000 - (Real_GPS_coord[LON]/100000000) * 10; line[12] = '0' + Real_GPS_coord[LON] / 1000000 - (Real_GPS_coord[LON]/10000000) * 10; line[13] = '0' + Real_GPS_coord[LON] / 100000 - (Real_GPS_coord[LON]/1000000) * 10; line[14] = '0' + Real_GPS_coord[LON] / 10000 - (Real_GPS_coord[LON]/100000) * 10; line[15] = '0' + Real_GPS_coord[LON] / 1000 - (Real_GPS_coord[LON]/10000) * 10; line[16] = '0' + Real_GPS_coord[LON] / 100 - (Real_GPS_coord[LON]/1000) * 10; line[17] = '0' + Real_GPS_coord[LON] / 10 - (Real_GPS_coord[LON]/100) * 10; line[18] = '0' + Real_GPS_coord[LON] - (Real_GPS_coord[LON]/10) * 10; i2c_OLED_LCDsetLine(4); i2c_OLED_LCDprintChar(line); sprintf(line, "SAT : %d FIX : %d ",GPS_numSat,f.GPS_FIX); i2c_OLED_LCDsetLine(5); i2c_OLED_LCDprintChar(line); } else { sprintf(line, "LAT : .---.------- "); i2c_OLED_LCDsetLine(3); i2c_OLED_LCDprintChar(line); sprintf(line, "LON : .---.------- "); i2c_OLED_LCDsetLine(4); i2c_OLED_LCDprintChar(line); sprintf(line, "SAT : - FIX : - "); i2c_OLED_LCDsetLine(5); i2c_OLED_LCDprintChar(line); } } }
int main(void) { // Chip_GPIO_SetPinDIROutput(LPC_GPIO_PORT, 0, 5); //lcd1 Chip_GPIO_SetPinDIROutput(LPC_GPIO_PORT, 0, 6); //lcd2 //second from left Chip_GPIO_SetPinDIROutput(LPC_GPIO_PORT, 0, 7); //lcd3 Chip_GPIO_SetPinDIROutput(LPC_GPIO_PORT, 0, 17); //lcd4 last from left Chip_GPIO_SetPinDIROutput(LPC_GPIO_PORT, 0, 10); //a Chip_GPIO_SetPinDIROutput(LPC_GPIO_PORT, 0, 11); //b Chip_GPIO_SetPinDIROutput(LPC_GPIO_PORT, 0, 12); //c Chip_GPIO_SetPinDIROutput(LPC_GPIO_PORT, 0, 13); //d Chip_GPIO_SetPinDIROutput(LPC_GPIO_PORT, 0, 14); //e Chip_GPIO_SetPinDIROutput(LPC_GPIO_PORT, 0, 15); //f Chip_GPIO_SetPinDIROutput(LPC_GPIO_PORT, 0, 16); //g // Chip_GPIO_SetPinState(LPC_GPIO_PORT, 0, 5, true); Chip_GPIO_SetPinState(LPC_GPIO_PORT, 0, 6, false); Chip_GPIO_SetPinState(LPC_GPIO_PORT, 0, 7, false); Chip_GPIO_SetPinState(LPC_GPIO_PORT, 0, 17, false); char tab[3] = {'7','2','4'}; //////// write a digit while(1) { //first digit //second lcd from left switch(tab[0]-48) { case 0: Chip_GPIO_SetPinState(LPC_GPIO_PORT, 0, 6, true); digit0(); _delay_ms(1); Chip_GPIO_SetPinState(LPC_GPIO_PORT, 0, 6, false); break; case 1: Chip_GPIO_SetPinState(LPC_GPIO_PORT, 0, 6, true); digit1(); _delay_ms(1); Chip_GPIO_SetPinState(LPC_GPIO_PORT, 0, 6, false); break; case 2: Chip_GPIO_SetPinState(LPC_GPIO_PORT, 0, 6, true); digit2(); _delay_ms(1); Chip_GPIO_SetPinState(LPC_GPIO_PORT, 0, 6, false); break; case 3: Chip_GPIO_SetPinState(LPC_GPIO_PORT, 0, 6, true); digit3(); _delay_ms(1); Chip_GPIO_SetPinState(LPC_GPIO_PORT, 0, 6, false); break; case 4: Chip_GPIO_SetPinState(LPC_GPIO_PORT, 0, 6, true); digit4(); _delay_ms(1); Chip_GPIO_SetPinState(LPC_GPIO_PORT, 0, 6, false); break; case 5: Chip_GPIO_SetPinState(LPC_GPIO_PORT, 0, 6, true); digit5(); _delay_ms(1); Chip_GPIO_SetPinState(LPC_GPIO_PORT, 0, 6, false); break; case 6: Chip_GPIO_SetPinState(LPC_GPIO_PORT, 0, 6, true); digit6(); _delay_ms(1); Chip_GPIO_SetPinState(LPC_GPIO_PORT, 0, 6, false); break; case 7: Chip_GPIO_SetPinState(LPC_GPIO_PORT, 0, 6, true); digit7(); _delay_ms(1); Chip_GPIO_SetPinState(LPC_GPIO_PORT, 0, 6, false); break; case 8: Chip_GPIO_SetPinState(LPC_GPIO_PORT, 0, 6, true); digit8(); _delay_ms(1); Chip_GPIO_SetPinState(LPC_GPIO_PORT, 0, 6, false); break; case 9: Chip_GPIO_SetPinState(LPC_GPIO_PORT, 0, 6, true); digit9(); _delay_ms(1); Chip_GPIO_SetPinState(LPC_GPIO_PORT, 0, 6, false); break; default: //error while(1) { Chip_GPIO_SetPinState(LPC_GPIO_PORT, 0, 6, true); e_rr(); _delay_ms(1); Chip_GPIO_SetPinState(LPC_GPIO_PORT, 0, 6, false); Chip_GPIO_SetPinState(LPC_GPIO_PORT, 0, 7, true); err_(); _delay_ms(1); Chip_GPIO_SetPinState(LPC_GPIO_PORT, 0, 7, false); Chip_GPIO_SetPinState(LPC_GPIO_PORT, 0, 17, true); err_(); _delay_ms(1); Chip_GPIO_SetPinState(LPC_GPIO_PORT, 0, 17, false); } } //second digit //third lcd from left switch(tab[1]-48) { case 0: Chip_GPIO_SetPinState(LPC_GPIO_PORT, 0, 7, true); digit0(); _delay_ms(1); Chip_GPIO_SetPinState(LPC_GPIO_PORT, 0, 7, false); break; case 1: Chip_GPIO_SetPinState(LPC_GPIO_PORT, 0, 7, true); digit1(); _delay_ms(1); Chip_GPIO_SetPinState(LPC_GPIO_PORT, 0, 7, false); break; case 2: Chip_GPIO_SetPinState(LPC_GPIO_PORT, 0, 7, true); digit2(); _delay_ms(1); Chip_GPIO_SetPinState(LPC_GPIO_PORT, 0, 7, false); break; case 3: Chip_GPIO_SetPinState(LPC_GPIO_PORT, 0, 7, true); digit3(); _delay_ms(1); Chip_GPIO_SetPinState(LPC_GPIO_PORT, 0, 7, false); break; case 4: Chip_GPIO_SetPinState(LPC_GPIO_PORT, 0, 7, true); digit4(); _delay_ms(1); Chip_GPIO_SetPinState(LPC_GPIO_PORT, 0, 7, false); break; case 5: Chip_GPIO_SetPinState(LPC_GPIO_PORT, 0, 7, true); digit5(); _delay_ms(1); Chip_GPIO_SetPinState(LPC_GPIO_PORT, 0, 7, false); break; case 6: Chip_GPIO_SetPinState(LPC_GPIO_PORT, 0, 7, true); digit6(); _delay_ms(1); Chip_GPIO_SetPinState(LPC_GPIO_PORT, 0, 7, false); break; case 7: Chip_GPIO_SetPinState(LPC_GPIO_PORT, 0, 7, true); digit7(); _delay_ms(1); Chip_GPIO_SetPinState(LPC_GPIO_PORT, 0, 7, false); break; case 8: Chip_GPIO_SetPinState(LPC_GPIO_PORT, 0, 7, true); digit8(); _delay_ms(1); Chip_GPIO_SetPinState(LPC_GPIO_PORT, 0, 7, false); break; case 9: Chip_GPIO_SetPinState(LPC_GPIO_PORT, 0, 7, true); digit9(); _delay_ms(1); Chip_GPIO_SetPinState(LPC_GPIO_PORT, 0, 7, false); break; default: while(1) { Chip_GPIO_SetPinState(LPC_GPIO_PORT, 0, 6, true); e_rr(); _delay_ms(1); Chip_GPIO_SetPinState(LPC_GPIO_PORT, 0, 6, false); Chip_GPIO_SetPinState(LPC_GPIO_PORT, 0, 7, true); err_(); _delay_ms(1); Chip_GPIO_SetPinState(LPC_GPIO_PORT, 0, 7, false); Chip_GPIO_SetPinState(LPC_GPIO_PORT, 0, 17, true); err_(); _delay_ms(1); Chip_GPIO_SetPinState(LPC_GPIO_PORT, 0, 17, false); } } //third digit // fourth lcd from left switch(tab[2]-48) { case 0: Chip_GPIO_SetPinState(LPC_GPIO_PORT, 0, 17, true); digit0(); _delay_ms(1); Chip_GPIO_SetPinState(LPC_GPIO_PORT, 0, 17, false); break; case 1: Chip_GPIO_SetPinState(LPC_GPIO_PORT, 0, 17, true); digit1(); _delay_ms(1); Chip_GPIO_SetPinState(LPC_GPIO_PORT, 0, 17, false); break; case 2: Chip_GPIO_SetPinState(LPC_GPIO_PORT, 0, 17, true); digit2(); _delay_ms(1); Chip_GPIO_SetPinState(LPC_GPIO_PORT, 0, 17, false); break; case 3: Chip_GPIO_SetPinState(LPC_GPIO_PORT, 0, 17, true); digit3(); _delay_ms(1); Chip_GPIO_SetPinState(LPC_GPIO_PORT, 0, 17, false); break; case 4: Chip_GPIO_SetPinState(LPC_GPIO_PORT, 0, 17, true); digit4(); _delay_ms(1); Chip_GPIO_SetPinState(LPC_GPIO_PORT, 0, 17, false); break; case 5: Chip_GPIO_SetPinState(LPC_GPIO_PORT, 0, 17, true); digit5(); _delay_ms(1); Chip_GPIO_SetPinState(LPC_GPIO_PORT, 0, 17, false); break; case 6: Chip_GPIO_SetPinState(LPC_GPIO_PORT, 0, 17, true); digit6(); _delay_ms(1); Chip_GPIO_SetPinState(LPC_GPIO_PORT, 0, 17, false); break; case 7: Chip_GPIO_SetPinState(LPC_GPIO_PORT, 0, 17, true); digit7(); _delay_ms(1); Chip_GPIO_SetPinState(LPC_GPIO_PORT, 0, 17, false); break; case 8: Chip_GPIO_SetPinState(LPC_GPIO_PORT, 0, 17, true); digit8(); _delay_ms(1); Chip_GPIO_SetPinState(LPC_GPIO_PORT, 0, 17, false); break; case 9: Chip_GPIO_SetPinState(LPC_GPIO_PORT, 0, 17, true); digit9(); _delay_ms(1); Chip_GPIO_SetPinState(LPC_GPIO_PORT, 0, 17, false); break; default: while(1) { Chip_GPIO_SetPinState(LPC_GPIO_PORT, 0, 6, true); e_rr(); _delay_ms(1); Chip_GPIO_SetPinState(LPC_GPIO_PORT, 0, 6, false); Chip_GPIO_SetPinState(LPC_GPIO_PORT, 0, 7, true); err_(); _delay_ms(1); Chip_GPIO_SetPinState(LPC_GPIO_PORT, 0, 7, false); Chip_GPIO_SetPinState(LPC_GPIO_PORT, 0, 17, true); err_(); _delay_ms(1); Chip_GPIO_SetPinState(LPC_GPIO_PORT, 0, 17, false); } } } return 0 ; }