void menu() { switch(State3) { case Waitfor: if (holder == 0) { LCD_ClearScreen(); LCD_DisplayString(1,"Press * for 1P Press # for 2P"); counter2++; if (z == '*') { holder = 1; srand(counter2); i = rand() % 5; a = rand() % 4; LCD_ClearScreen(); } if (z == '#') { playertwochecker = 1; holder = 1; srand(counter2); i = rand() % 5; a = rand() % 4; LCD_ClearScreen(); } } break; } }
/********************************************************************* * Function: bool LCD_Initialize(void); * * Overview: Initializes the LCD screen. Can take several hundred * milliseconds. * * PreCondition: none * * Input: None * * Output: true if initialized, false otherwise * ********************************************************************/ bool LCD_Initialize ( void ) { LCD_DATA_LAT &= 0xFF00 ; LCD_DATA_TRIS &= 0xFF00 ; // Control signal data pins LCD_RWSignal_Clear ( ) ; // LCD R/W signal LCD_RSSignal_Clear ( ) ; // LCD RS signal LCD_EnableSignal_Clear ( ) ; // LCD E signal // Control signal pin direction LCD_RSSignal_Output ( ) ; LCD_RWSignal_Output ( ) ; LCD_EnableSignal_Output ( ) ; LCD_EnableSignal_Set ( ) ; LCD_Wait ( LCD_STARTUP ) ; LCD_Wait ( LCD_STARTUP ) ; LCD_SendCommand ( LCD_COMMAND_SET_MODE_8_BIT , LCD_F_INSTR + LCD_STARTUP ) ; LCD_SendCommand ( LCD_COMMAND_CURSOR_OFF , LCD_F_INSTR ) ; LCD_SendCommand ( LCD_COMMAND_ENTER_DATA_MODE , LCD_S_INSTR ) ; LCD_ClearScreen ( ) ; return true ; }
void CpuTemperatureView(void) { uint16_t i,y; MEASUREMENT_VIEW_struct * viewMem = cpu_temp_getViewMem(); LCD_ClearScreen(); LCD_SetPenColor(1); LCD_SetFont(1); LCD_PrintXY(40,0,"CPU:"); LCD_PrintXY(80,0,viewMem->cur_value); LCD_SetFont(0); LCD_PrintXY(0,0, "60-"); LCD_PrintXY(0,18,"50-"); LCD_PrintXY(0,37,"40-"); LCD_PrintXY(0,56,"30-"); LCD_DrawLine(15,0,15,63); for(i=16;i<128;i++) { y = viewMem->Mem[127-i]; if(y > 290) { y = ((y - 290) / 5); y = 64 - y; LCD_PutPixel(i,y,1); LCD_PutPixel(i,y+1,1); } } }
int lcdDisplayTick(task* t){ //actions switch(t->state){ case lcd_init: LCD_init(); //initialize LCD LCD_ClearScreen(); //clear screen of any artifacts break; case s1: //LCD_ClearScreen(); //clear screen of any artifacts LCD_DisplayString(1,motionSensorMsg); //display motion sensor message break; default: break; } //transitions switch(t->state){ case lcd_init: t->state = s1; break; case s1: t->state = s1; break; default: break; } }
void DemoCpuTemperature(void) { uint16 i,y; LCD_ClearScreen(); LCD_SetPenColor(1); LCD_SetFont(1); LCD_PrintXY(40,0,"CPU:"); LCD_PrintXY(80,0,TempString); LCD_SetFont(0); LCD_PrintXY(0,0, "60-"); LCD_PrintXY(0,18,"50-"); LCD_PrintXY(0,37,"40-"); LCD_PrintXY(0,56,"30-"); LCD_DrawLine(15,0,15,63); for(i=16;i<128;i++) { y = DemoMem[127-i]; if(y > 290) { y = ((y - 290) / 5); y = 64 - y; LCD_PutPixel(i,y,1); LCD_PutPixel(i,y+1,1); } } }
int main(void) { char strClearLine[15] = "ID: "; /* Init System, IP clock and multi-function I/O */ SYS_Init(); /* Init UART0 for printf */ UART0_Init(); printf("CPU @ %dHz\n", SystemCoreClock); /* Init SPI0 and LCD */ LCD_Init(); LCD_EnableBackLight(); LCD_ClearScreen(); LCD_Print(0, "SPI Sample Code "); LCD_Print(1, "For Flash Test"); LCD_Print(2, "Press INT button"); /* Init P3.2 */ GPIO_Init(); SPIFLASH_Init(); sprintf(g_strBuf, "ID:%x ", SPIFLASH_ReadId()&0xFFFFUL); LCD_Print(3, strClearLine); LCD_Print(3, g_strBuf); while (!g_isPress); SpiTest(); return 1; }
void StatusView2(void) { char a[20]; MEASUREMENT_VIEW_struct * AbgasMem = pt100_getViewMem(); LCD_ClearScreen(); LCD_SetFont(0); LCD_SetPenColor(1); LCD_PrintXY(0,0,"PufferKontrollSystem"); LCD_DrawLine(0,21,127,21); LCD_DrawLine(0,42,127,42); LCD_DrawLine(63,21,63,63); LCD_PrintXY(2,23,"Abgas"); LCD_PrintXY(2,32, AbgasMem->cur_value); LCD_PrintXY(66,23,"Verlust"); double abgasverlust = get_abgasverlust(); sprintf(a, "%4u",abgasverlust); LCD_PrintXY(66,32, a); }
void DemoFont(void) { LCD_ClearScreen(); LCD_SetFont(0); LCD_PrintXY(0,0, "Font 0"); LCD_SetFont(1); LCD_PrintXY(0,8, "Font 1"); LCD_SetFont(2); LCD_PrintXY(0,23,"Font 2"); LCD_SetFont(3); LCD_PrintXY(0,39,"Font 3"); }
void LCD_DisplayString( unsigned char column, const unsigned char* string) { LCD_ClearScreen(); unsigned char c = column; while(*string) { LCD_Cursor(c++); LCD_WriteData(*string++); } }
int lcdDisplayTick(task* t){ //actions switch(t->state){ case lcd_init: LCD_init(); //initialize LCD LCD_ClearScreen(); //clear screen of any artifacts break; case s1: //LCD_ClearScreen(); //clear screen of any artifacts //LCD_DisplayString(1,motionSensorMsg); //display motion sensor message LCD_Cursor(14); if(fanMode) { LCD_WriteData(1); } else if(led_fan && !kill && enable && temp) { LCD_WriteData(2); } else { LCD_WriteData(' '); } LCD_Cursor(12); if(enable) { LCD_WriteData(3); } else { LCD_WriteData(4); } break; default: break; } //transitions switch(t->state){ case lcd_init: t->state = s1; break; case s1: t->state = s1; break; default: break; } return 0; }
//-------------------------------------------------------------------------------------------------- // Name: Demo Functions // Function: // // Parameter: // Return: //-------------------------------------------------------------------------------------------------- void DemoLogo(void) { LCD_ClearScreen(); LCD_DrawBitmap(0,0,bmp_raspi); LCD_SetFont(0); LCD_PrintXY(70,4 ,"Raspi-LCD"); LCD_PrintXY(75,14,"Project"); LCD_PrintXY(68,32,"powered by"); LCD_PrintXY(70,42,"Emsystech"); LCD_PrintXY(62,52,"Engineering"); }
void DemoText(void) { LCD_ClearScreen(); LCD_SetFont(1); LCD_PrintXY(30,0,"Raspi-LCD"); LCD_PrintXY(0,12,"www.emsystech.de"); LCD_SetFont(0); LCD_PrintXY(8,29,"128 x 64 Pixel (BW)"); LCD_PrintXY(6,38,"White LED Backlight"); LCD_PrintXY(4,47,"8 Lines with 21 Char "); LCD_PrintXY(4,56,"in the smallest Font "); }
void AbgasTemperatureView(void) { uint16_t i,y; MEASUREMENT_VIEW_struct * viewMem = pt100_getViewMem(); LCD_ClearScreen(); LCD_SetPenColor(1); LCD_SetFont(0); LCD_PrintXY(30,0,"ABGAS:"); LCD_PrintXY(80,0,viewMem->cur_value); LCD_SetFont(0); int max = roundUp(viewMem->max); int min = roundDown(viewMem->min); int diff = max-min; int span; if(!diff) { span = 10; if(min) min -= 10; }else { span = diff/3; } if(span < 10) span = 10; char dummy[10]; sprintf(dummy,"%4u-",min+(span*3)); LCD_PrintXY(0,0, dummy); sprintf(dummy,"%4u-",min+(span*2)); LCD_PrintXY(0,18,dummy); sprintf(dummy,"%4u-",min+(span*1)); LCD_PrintXY(0,37,dummy); sprintf(dummy,"%4u-",min); LCD_PrintXY(0,56,dummy); LCD_DrawLine(27,0,27,63); diff = (span*3); for(i=27;i<128;i++) { y = viewMem->Mem[127-i]; y = 64 - ((double)(y-min)*(double)(64.0/diff)); LCD_PutPixel(i,y,1); LCD_PutPixel(i,y+1,1); } }
void StatusView1(void) { char a[20]; /* (2000x4187x80-MW)/(3600x1000) = …KWh (Was noch in den Puffer geht); Erklärung hierzu: 2000 = Puffervolumen; 4187 = Ws/(kg*K); spezifische Wärmekapazität wasser in Wattsekunde/(kg*Kelvin) 80 = Maximaltemperatur des Puffers; MW = Mittelwertberechnung der 8 Temperaturen; Heizwert von 1 kg Holz = 3,5 KWh/kg ((2000x4187x80-MW)/(3600x1000))/3,5 = … kg (das ergibt die Holzmenge, die man nachlegen kann) – wird angezeigt am Display; */ MEASUREMENT_VIEW_struct * CPUTempMem = cpu_temp_getViewMem(); MEASUREMENT_VIEW_struct * O2Mem = lambda_getViewMem(); MEASUREMENT_VIEW_struct * BrennerMem = k_sonde_getViewMem(); MEASUREMENT_VIEW_struct * PufferMem = ds12b20_getViewMem(); double KWh = (PUFFERVOLUMEN * SPEZ_WAERMEKAP_WASSER * MAX_PUFFER_TEMP - ds18b20_getAverage()) / (3600 * 1000); double kg = KWh / HEIZWERT_HOLZ; LCD_ClearScreen(); LCD_SetFont(0); LCD_SetPenColor(1); LCD_PrintXY(0,0,"PufferKontrollSystem"); LCD_DrawLine(0,21,127,21); LCD_DrawLine(0,42,127,42); LCD_DrawLine(63,21,63,63); LCD_PrintXY(2,23,"Brenner"); LCD_PrintXY(2,32, BrennerMem->cur_value); LCD_PrintXY(66,23,"Puffer"); LCD_PrintXY(66,32, PufferMem->cur_value); LCD_PrintXY(2,44,"O2"); LCD_PrintXY(2,53,O2Mem->cur_value); LCD_PrintXY(66,44,"nachlegen"); LCD_PrintfXY(66,53,"%3.1f kg", kg); }
void Display_Initiate_Ingame () { LCD_ClearScreen(); LCD_DisplayString(1, "Score: Enemies:"); LCD_Cursor(8); // score tens LCD_WriteData(points/10 + '0'); LCD_Cursor(9); // score one LCD_WriteData(points%10 + '0'); LCD_Cursor(26); //enemy ones LCD_WriteData(enemy_count + '0'); Display_Star(12); LCD_Cursor(0); return; }
/** * @brief Main routine. * @param None. * @return None. */ int32_t main(void) { SYS_UnlockReg(); SYS->P5_MFP = (SYS->P5_MFP & 0x00FFFCFC) | 0x03; /* P5.1 -> XTAL2, P5.0 -> XTAL1 */ CLK->PWRCON = CLK_PWRCON_XTL12M | 4 | 8 ; SYS_Init(); /* SPI test */ LCD_Init(); LCD_EnableBackLight(); LCD_ClearScreen(); LCD_Print(0, "Welcome! Nuvoton"); LCD_Print(1, "This is LB board"); LCD_Print(2, "Mini51"); LCD_Print(3, "TEST"); // backlight control pin P5.4 GPIO_SetMode(P5,1<<4,GPIO_PMD_OUTPUT); /* INT button triggers P3.2 */ GPIO_SetMode(P3,(1<<2),GPIO_PMD_OPEN_DRAIN); GPIO_EnableInt(P3, 2, GPIO_INT_FALLING); NVIC_EnableIRQ(EINT0_IRQn); /* Enable interrupt de-bounce function and select de-bounce sampling cycle time */ GPIO_SET_DEBOUNCE_TIME(GPIO_DBNCECON_DBCLKSRC_HCLK,GPIO_DBNCECON_DBCLKSEL_16); GPIO_ENABLE_DEBOUNCE(P3,1<<2); /* Reset and stop TIMER0, TIMER1 counting first */ TIMER1->TCSR = TIMER_TCSR_CRST_Msk; /* Enable TIMER0, TIMER1, NVIC */ NVIC_EnableIRQ(TMR1_IRQn); /* To Configure TCMPR values based on Timer clock source and pre-scale value */ TIMER_SET_PRESCALE_VALUE(TIMER1,0); /* Start TIMER1 counting and setting*/ TIMER_Open(TIMER1,TIMER_PERIODIC_MODE,SystemCoreClock/1000); TIMER_EnableInt(TIMER1); while(1) ; // loop forever }
void lcdTick(){ LCD_ClearScreen(); switch(gameStatus){ case intro: LCD_DisplayString(4," WHACKAMOLE!"); displayIntro(); break; case highscore: LCD_DisplayString(3, " HIGHSCORE: " ); LCD_Cursor(24); if(currHighScore > 9){ unsigned char temp = currHighScore/10; LCD_WriteData(temp+'0'); temp = currHighScore % 10; LCD_WriteData(temp+'0'); } else LCD_WriteData(currHighScore + '0'); break; case resetHighScore: LCD_DisplayString(3, " RESETTING ...HIGHSCORE... " ); break; case play: LCD_DisplayString(3, " HIT MOLES!"); LCD_DisplayString(17, " Score: "); LCD_Cursor(30); LCD_WriteData(0 +'0'); break; case gameOver: LCD_DisplayString(3, " GAME OVER!"); LCD_DisplayString(17, " YOUR SCORE: "); LCD_Cursor(30); if(currScore > 9){ unsigned char temp = currScore/10; LCD_WriteData(temp+'0'); temp = currScore % 10; LCD_WriteData(temp+'0'); } else LCD_WriteData(currScore + '0'); break; } LCD_Cursor(40); }
void DemoVector(void) { LCD_ClearScreen(); LCD_SetFillColor(1); LCD_DrawRect(110,20,120,60,1); LCD_DrawLine(0,0,127,0); LCD_DrawLine(0,0,127,16); LCD_DrawLine(0,0,127,32); LCD_DrawLine(0,0,127,48); LCD_DrawLine(0,0,127,63); LCD_SetPenColor(1); LCD_DrawCircle(63,31,31); LCD_DrawCircle(8,50,5); LCD_DrawEllipse(80,40, 30,10); LCD_SetFillColor(0); LCD_DrawRect(12,20,40,40,3); LCD_SetFillColor(-1); LCD_DrawRect(30,50,60,60,1); }
int main( void ) { /* Configure the hardware for use by this demo. */ prvSetupHardware(); //xTaskCreate( vuIP_Task, ( signed char * ) "uIP", mainBASIC_WEB_STACK_SIZE, ( void * ) NULL, mainUIP_TASK_PRIORITY, NULL ); //make a task for UART char ip_address[32]; LCD_Init(); LCD_ClearScreen(); sprintf(ip_address , "IP Address: %d.%d.%d.%d",configIP_ADDR0,configIP_ADDR1,configIP_ADDR2,configIP_ADDR3); LCD_PrintText(ip_address); //xTaskCreate( vUARTTask, ( signed char * ) "UART_Modem", mainBASIC_WEB_STACK_SIZE, ( void * ) NULL, mainUIP_TASK_PRIORITY, NULL ); /* Start the scheduler so the created tasks start executing. */ xTaskCreate( vLEDTask, ( signed char * ) "LED_TOGGOLE", mainBASIC_WEB_STACK_SIZE, ( void * ) NULL, mainUIP_TASK_PRIORITY, NULL ); xTaskCreate( vLCDTask, ( signed char * ) "LCD_DISPLAY", mainBASIC_WEB_STACK_SIZE, ( void * ) NULL, mainUIP_TASK_PRIORITY, NULL ); xTaskCreate( vuIP_Task, ( signed char * ) "uIP", mainBASIC_WEB_STACK_SIZE, ( void * ) NULL, mainUIP_TASK_PRIORITY+1, NULL ); //xTaskCreate( vUSBTask, ( signed char * ) "USB_Device", mainBASIC_WEB_STACK_SIZE, ( void * ) NULL, mainUIP_TASK_PRIORITY, NULL ); xTaskCreate( usb_host_main, ( signed char * ) "USB_Device", mainBASIC_WEB_STACK_SIZE, ( void * ) NULL, mainUIP_TASK_PRIORITY+3, NULL ); //xTaskCreate( vZigbeeTask, ( signed char * ) "Zigbee", mainBASIC_WEB_STACK_SIZE, ( void * ) NULL, mainUIP_TASK_PRIORITY, NULL ); vTaskStartScheduler(); /* If all is well we will never reach here as the scheduler will now be running the tasks. If we do reach here then it is likely that there was insufficient heap memory available for a resource to be created. */ for( ;; ); return 0; }
void InitialView(char *str, uint8_t pos) { uint8_t i; char a[] ={0x7F, 0}; LCD_ClearScreen(); LCD_SetFont(1); LCD_SetPenColor(1); LCD_PrintXY(0,0,"Initialisierung..."); LCD_PrintXY(0, 20, str); for(i=0; i<pos; i++) LCD_PrintXY(0+10*i, 40, a); LCD_WriteFramebuffer(); }
void ConfigView(void) { char a[20]; LCD_ClearScreen(); LCD_SetFont(0); LCD_SetPenColor(1); LCD_PrintXY(0,0,"Konfiguration"); LCD_DrawLine(0,21,127,21); LCD_DrawLine(0,42,127,42); LCD_DrawLine(63,21,63,63); LCD_PrintXY(2,23,"Puffer :"); LCD_PrintfXY(64,23, "%dl", app_config_get_puffer_volume()); LCD_PrintXY(2,33,"Licht :"); LCD_PrintfXY(64,33, "%ds", app_config_get_light_on_time()); //LCD_SetFont(0); }
void LCD_Init() { pinMode(2, OUTPUT); pinMode(3, OUTPUT); pinMode(4, OUTPUT); pinMode(PK_0,OUTPUT); pinMode(PK_1,OUTPUT); pinMode(PK_2,OUTPUT); pinMode(PK_3,OUTPUT); pinMode(PK_4,OUTPUT); pinMode(PK_5,OUTPUT); pinMode(PK_6,OUTPUT); pinMode(PK_7,OUTPUT); //POWER SETTINGS LCD_SetRegister(0x10,0x1300); //powerControl1 LCD_SetRegister(0x11,0x3c03); //powerControl2 LCD_SetRegister(0x13,0x0070); //powerControl3 LCD_SetRegister(0x14,0x0020); //powerControl4 //LCD INITIALIZATION LCD_SetRegister(0x01,0x011b);//driverOutputControl //SM=0,GS=0,SS=1,NL=10101->176*220 LCD_SetRegister(0x02,0x0700);//drivingWaveformControl //FLD[1:0]=01,B/C=0,EOR=0,NW[5:0]=000000 LCD_SetRegister(0x03,0x1030);//Entry Mode LCD_SetRegister(0x0c,0x0000);//display interface selection:16-bit RGB //DISPLAY ON LCD_SetRegister(0x07,0x0017); //GON=1,DTE=0,D[1:0]=11 LCD_ClearScreen(); }
/*---------------------------------------------------------------------------------------------------------*/ int32_t main(void) { /* Init system, IP clock and multi-function I/O */ SYS_Init(); /* Init UART0 for printf */ UART0_Init(); /* Init GPIO P2.0 (output) and P3.2 (EINT0) */ GPIO_Init(); /* Init SPI0 and LCD */ LCD_Init(); LCD_EnableBackLight(); LCD_ClearScreen(); LCD_Print(0, "Boot from LDROM"); LCD_Print(1, "Press SW_INT "); while (1) { if (g_u8IsPress) { g_u8IsPress = FALSE; /* Switch to boot from APROM */ SYS_UnlockReg(); FMC->ISPCON = FMC_ISPCON_BS_APROM; _SYS_RESET_CPU(); while (1); } else { /* LED blanking for 1000ms */ P2->DOUT ^= 1; SYS_SysTickDelay(300000); SYS_SysTickDelay(200000); } } }
void O2View(void) { uint16_t i,y; if(lambda_fehler()) { O2_ErrorView(); return; } else if(!lambda_run()) { O2_StatusView(); return; } MEASUREMENT_VIEW_struct * viewMem = lambda_getViewMem(); LCD_ClearScreen(); LCD_SetPenColor(1); LCD_SetFont(0); LCD_PrintXY(40,0,"O2:"); LCD_PrintXY(80,0,viewMem->cur_value); LCD_SetFont(0); LCD_PrintXY(0,0, "25-"); LCD_PrintXY(0,18,"15-"); LCD_PrintXY(0,37," 5-"); LCD_PrintXY(0,56," 0-"); LCD_DrawLine(15,0,15,63); for(i=16;i<128;i++) { y = viewMem->Mem[127-i]; if(y < 25) { y = 64 - ((double)(y)*(double)(64.0/25)); LCD_PutPixel(i,y,1); LCD_PutPixel(i,y+1,1); } } }
void DS18B20View(void) { char a[20]; int i, count; DS18B20_struct *ds18b20_dev; LCD_ClearScreen(); LCD_SetFont(0); LCD_SetPenColor(1); LCD_PrintXY(0,0,"DS18B20"); LCD_DrawLine(0,21,127,21); count = ds18b20_getDeviceCount() ; for(i=0; i<count;i++) { ds18b20_dev = ds18b20_getDevice(i); if(ds18b20_dev->crc) LCD_PrintfXY(0,23+(8*i), "%s: %5.1f",ds18b20_dev->_deviceid, ds18b20_dev->tempGrad); else LCD_PrintfXY(0,23+(8*i), "%s: Fehler",ds18b20_dev->_deviceid); } }
void DemoBubbles(void) { LCD_ClearScreen(); LCD_SetPenColor(1); if(DemoMem[200]) { if(DemoMem[201] > 16) DemoMem[201]--; else DemoMem[200] = 0; } else { if(DemoMem[201] <48) DemoMem[201]++; else DemoMem[200] = 1; } DemoMem[202] = ((63 - DemoMem[201]) < DemoMem[201]) ? (63 - DemoMem[201]) : DemoMem[201]; DemoMem[202] = (DemoMem[202] > 20) ? 20 : DemoMem[202]; LCD_DrawEllipse(28,DemoMem[201],20+20-DemoMem[202],DemoMem[202]); if(DemoMem[203]) { if(DemoMem[204] > 14) DemoMem[204]--; else DemoMem[203] = 0; } else { if(DemoMem[204] <50) DemoMem[204]++; else DemoMem[203] = 1; } DemoMem[205] = ((63 - DemoMem[204]) < DemoMem[204]) ? (63 - DemoMem[204]) : DemoMem[204]; DemoMem[205] = (DemoMem[205] > 20) ? 20 : DemoMem[205]; LCD_DrawEllipse(65,DemoMem[204],22+10-DemoMem[205],DemoMem[205]); if(DemoMem[206]) { if(DemoMem[207] > 10) DemoMem[207]--; else DemoMem[206] = 0; } else { if(DemoMem[207] <54) DemoMem[207]++; else DemoMem[206] = 1; } DemoMem[208] = ((63 - DemoMem[207]) < DemoMem[207]) ? (63 - DemoMem[207]) : DemoMem[207]; DemoMem[208] = (DemoMem[208] > 15) ? 15 : DemoMem[208]; LCD_DrawEllipse(102,DemoMem[207],15+20-DemoMem[208],DemoMem[208]); }
void O2_ErrorView(void) { uint16_t i,y; LCD_ClearScreen(); LCD_SetPenColor(1); LCD_SetFont(0); LCD_PrintXY( 0,0, "Lambda Fehler!"); LCD_SetFont(0); LCD_PrintXY(0, 0, "W | S | U | U | S | C"); LCD_PrintXY(0, 9, "D | P | H | L | O | J"); LCD_DrawLine(0,18,127,18); LCD_PrintXY(0,19, " | | | | | "); if(lambda_get_single_error(WATCHDOG)) LCD_PrintXY(0,19, "X"); if(lambda_get_single_error(SPI_ERROR)) LCD_PrintXY(24,19, "X"); if(lambda_get_single_error(UBAT_HIGH)) LCD_PrintXY(48,19, "X"); if(lambda_get_single_error(UBAT_LOW)) LCD_PrintXY(72,19, "X"); if(lambda_get_single_error(SONDE_OVERHEAT)) LCD_PrintXY(96,19, "X"); if(lambda_get_single_error(CJ_ERROR)) LCD_PrintXY(120,19, "X"); LCD_PrintXY(0,35, "DIAHG|IA/IP|UN|VM"); LCD_PrintXY(0,44, "DIAHD|IA/IP|UN|VM"); LCD_DrawLine(0,53,127,53); LCD_PrintXY(0,54, " | | | "); if(lambda_get_single_cjerror(DIAHG_DIAHD_ERROR)) LCD_PrintXY(12,54, "X"); if(lambda_get_single_cjerror(IA_IP_ERROR)) LCD_PrintXY(54,54, "X"); if(lambda_get_single_cjerror(UN_ERROR)) LCD_PrintXY(78,54, "X"); if(lambda_get_single_cjerror(VM_ERROR)) LCD_PrintXY(96,54, "X"); }
/********************************************************************* * Function: bool LCD_Initialize(void); * * Overview: Initializes the LCD screen. Can take several hundred * milliseconds. * * PreCondition: none * * Input: None * * Output: true if initialized, false otherwise * ********************************************************************/ bool LCD_Initialize(void) { LATC |= 0x00FF; TRISC &= 0x0F00; TRISB &= 0xFC7F; // Control signal data pins LATBbits.LATB8 = 0; // LCD R/W signal LATBbits.LATB9 = 0; // LCD RS signal LATBbits.LATB7 = 0; // LCD E signal // Control signal pin direction TRISBbits.TRISB8 = 0; TRISBbits.TRISB9 = 0; TRISBbits.TRISB7 = 0; LATC |= 0x0038; LATBbits.LATB7 = 1; Nop(); Nop(); Nop(); LATBbits.LATB7 = 0; LCD_Wait(LCD_STARTUP); LCD_Wait(LCD_STARTUP); LCD_SendCommand(LCD_COMMAND_SET_MODE_8_BIT, LCD_F_INSTR + LCD_STARTUP); LCD_SendCommand(LCD_COMMAND_CURSOR_ON, LCD_F_INSTR); LCD_SendCommand(LCD_COMMAND_ENTER_DATA_MODE, LCD_S_INSTR); LCD_ClearScreen(); return true; }
int lcd_tick(int state){ static unsigned short lcd_hold_time = 0; switch(state){// lcd actions case st_lcd_start: state = st_lcd_init; break; case st_lcd_init: if(!QueueIsEmpty(lcd_command_queue)){ state = st_lcd_write; } else { state = st_lcd_wait; } break; case st_lcd_wait: if(!QueueIsEmpty(lcd_command_queue)){ state = st_lcd_write; } else { state = st_lcd_wait; } break; case st_lcd_write: if( lcd_command_queue->buffer[lcd_command_queue->front] == lcd_write_locked || lcd_command_queue->buffer[lcd_command_queue->front] == lcd_write_unlocked || lcd_command_queue->buffer[lcd_command_queue->front] == lcd_write_invalid || lcd_command_queue->buffer[lcd_command_queue->front] == lcd_write_added || lcd_command_queue->buffer[lcd_command_queue->front] == lcd_write_add_exist || lcd_command_queue->buffer[lcd_command_queue->front] == lcd_write_add_full || lcd_command_queue->buffer[lcd_command_queue->front] == lcd_write_removed || lcd_command_queue->buffer[lcd_command_queue->front] == lcd_write_remove_empty){ state = st_lcd_hold; lcd_hold_time = 0; } else { state = st_lcd_wait; } QueueDequeue(lcd_command_queue); break; case st_lcd_hold: if(lcd_hold_time < 20){ lcd_hold_time++; state = st_lcd_hold; } else { state = st_lcd_write; QueueEnqueue(lcd_command_queue, lcd_write_ready); } break; default: state = st_lcd_start; break; }//end lcd transitions switch(state){ case st_lcd_init: LCD_init(); break; case st_lcd_write: if(lcd_command_queue->buffer[lcd_command_queue->front] == lcd_write_ready){ LCD_ClearScreen(); if(isTagDBEmpty()){ LCD_DisplayString(1, (const unsigned char*)"No Valid Keys"); LCD_DisplayString(17, (const unsigned char*)"Add w/ Master"); } else { LCD_DisplayString(1, (const unsigned char*)"Scan Key Tag"); if(current_lock_position == locked){ LCD_DisplayString(17, (const unsigned char*)"to Unlock"); } else if(current_lock_position == unlocked){ LCD_DisplayString(17, (const unsigned char*)"to Lock"); } else { LCD_DisplayString(17, (const unsigned char*)"malfunction"); } } } else if(lcd_command_queue->buffer[lcd_command_queue->front] == lcd_write_locked){ LCD_ClearScreen(); LCD_DisplayString(1, (const unsigned char*)"Locked by"); LCD_DisplayString(17, (const unsigned char*)"Key# "); LCD_DisplayString(22, (const unsigned char*)tag_id); } else if(lcd_command_queue->buffer[lcd_command_queue->front] == lcd_write_unlocked){ LCD_ClearScreen(); LCD_DisplayString(1, (const unsigned char*)"Unlocked by"); LCD_DisplayString(17, (const unsigned char*)"Key# "); LCD_DisplayString(22, (const unsigned char*)tag_id); } else if(lcd_command_queue->buffer[lcd_command_queue->front] == lcd_write_invalid){ LCD_ClearScreen(); LCD_DisplayString(1, (const unsigned char*)"Key Tag"); LCD_DisplayString(17, (const unsigned char*)"Not Authorized"); } else if(lcd_command_queue->buffer[lcd_command_queue->front] == lcd_write_master){ LCD_ClearScreen(); LCD_DisplayString(1, (const unsigned char*)"Master Key"); LCD_DisplayString(17, (const unsigned char*)"Add or Remove"); } else if(lcd_command_queue->buffer[lcd_command_queue->front] == lcd_write_add){ LCD_ClearScreen(); LCD_DisplayString(1, (const unsigned char*)"Scan the Tag"); LCD_DisplayString(17, (const unsigned char*)"to be Added"); } else if(lcd_command_queue->buffer[lcd_command_queue->front] == lcd_write_remove){ LCD_ClearScreen(); LCD_DisplayString(1, (const unsigned char*)valid_tag_db[current_remove_option]); LCD_DisplayString(17, (const unsigned char*)"Remove?"); } else if(lcd_command_queue->buffer[lcd_command_queue->front] == lcd_write_malfunction){ LCD_ClearScreen(); LCD_DisplayString(1, (const unsigned char*)"Malfunction"); LCD_DisplayString(17, (const unsigned char*)"Check Lock"); } else if(lcd_command_queue->buffer[lcd_command_queue->front] == lcd_write_add_exist){ LCD_ClearScreen(); LCD_DisplayString(1, (const unsigned char*)"Key Tag Already"); LCD_DisplayString(17, (const unsigned char*)"Added"); } else if(lcd_command_queue->buffer[lcd_command_queue->front] == lcd_write_added){ LCD_ClearScreen(); LCD_DisplayString(1, (const unsigned char*)"Key# "); LCD_DisplayString(6, (const unsigned char*)tag_id); LCD_DisplayString(17, (const unsigned char*)"Added"); } else if(lcd_command_queue->buffer[lcd_command_queue->front] == lcd_write_add_full){ LCD_ClearScreen(); LCD_DisplayString(1, (const unsigned char*)"Over Max # Keys"); LCD_DisplayString(17, (const unsigned char*)"Cannot Add"); } else if(lcd_command_queue->buffer[lcd_command_queue->front] == lcd_write_removed){ LCD_ClearScreen(); LCD_DisplayString(1, (const unsigned char*)"Key Tag Removed"); } else if(lcd_command_queue->buffer[lcd_command_queue->front] == lcd_write_remove_empty){ LCD_ClearScreen(); LCD_DisplayString(1, (const unsigned char*)"No Valid Keys"); LCD_DisplayString(17, (const unsigned char*)"to Remove"); } break; default: break; }//end lcd actions return state; }
void LCD_DisplayStringLong(/*unsigned char column,*/ const unsigned const* displayString){ LCD_ClearScreen(); //unsigned char c = column; }