uint8_t LCD_DisplayMenu() { int8_t keycount=0; LCD_Clear(); LCD_GoToLine(1); LCD_DisplayString(" Settings "); do { if (util_IsBitCleared(Button, cancel)) { return (-1); } if(util_IsBitCleared(Button, up)) { keycount++; _delay_ms(100); } if(util_IsBitCleared(Button, down)) { keycount--; _delay_ms(100); } if((keycount>=menusize)||(keycount <= -menusize)) { keycount=0; } if(keycount<0) { //make menu index circular. i.e decrement from first //option shows the last option on the menu keycount += menusize; } LCD_GoToLine(2); LCD_DisplayString(" "); //clear second line //set cursor at the center of of line 2 depending on string size. LCD_SetCursor(2,(14-strlen(settings[keycount]))/2); LCD_Printf("<%s>", settings[keycount]); _delay_ms(100); //make menu visible or else will overwrite at fast speed }while(util_IsBitSet(Button,select)); do { if (util_IsBitCleared(Button, cancel)) { return (-1); ; } }while(util_IsBitSet(Button, select)); return (keycount); }
void LCD_4bit_test() { UART_TxString("\n\r LCD DataBus:(PD4-PD7) RS-PB.0 RW-PB.1 EN-PB.2 "); UART_Printf("\n\r Make connections and hit 'k' to test "); while(UART_RxChar()!='k'); LCD_SetUp(PB_0,PB_1,PB_2,P_NC,P_NC,P_NC,P_NC,PD_4,PD_5,PD_6,PD_7); LCD_Init(2,16); DELAY_ms(100); LCD_DisplayString("Explore Embedded"); LCD_DisplayString("Lcd 4-bit Mode"); while(1); }
int main() { /*Connect RS->PB0, RW->PB1, EN->PB2 and data bus to PORTC.4 to PORTC.7*/ LCD_SetUp(PB_0,PB_1,PB_2,P_NC,P_NC,P_NC,P_NC,PC_4,PC_5,PC_6,PC_7); LCD_Init(2,16); LCD_DisplayString("Explore Embedded"); LCD_DisplayString("Lcd 4-bit Mode"); while(1); return (0); }
//触摸屏校准代码 //得到四个校准参数 void touch_adjust(void) { u16 tempVal[4][2]={0}; u16 adjPointX[4]={20,340,20,340}; u16 adjPointY[4]={20,20,220,220}; u8 i; LCD_Clear(White);//清屏 LCD_SetBackColor(White); LCD_SetTextColor(Black); LCD_DisplayString(24,110,"点击屏幕上红点进行校准"); DelayMS(1000); LCD_Clear(White);//清屏 LCD_SetTextColor(Red); penPoint.keyState=Up; AG: i=0; do { LCD_DrawCircle(adjPointX[i],adjPointY[i],1); LCD_DrawCircle(adjPointX[i],adjPointY[i],2); LCD_DrawCircle(adjPointX[i],adjPointY[i],3); LCD_DrawCircle(adjPointX[i],adjPointY[i],4); if(penPoint.keyState==Down) { if(GetTouchValue()) { tempVal[i][0]=penPoint.x; tempVal[i][1]=penPoint.y; LCD_Clear(White);//清屏 DelayMS(100); i++; } } penPoint.keyState=Up; }while(i<4); if(IsOk(tempVal)==0)goto AG; penConfig.xfac=(float)(340-20)/(tempVal[1][0]-tempVal[0][0]); penConfig.yfac=(float)(220-20)/(tempVal[3][1]-tempVal[0][1]); penConfig.xoff=20-penConfig.xfac*tempVal[0][0]; penConfig.yoff=20-penConfig.yfac*tempVal[0][1]; LCD_Clear(White);//清屏 LCD_DisplayString(24,110,"屏幕校准成功"); save_adjdata(); DelayMS(1000); LCD_Clear(White);//清屏 }
int main() { SystemInit(); /*Connect RS, RW, EN and data bus to PORT0.4 to PORT0.7*/ LCD_SetUp(P2_0,P2_1,P2_2,P_NC,P_NC,P_NC,P_NC,P1_24,P1_25,P1_26,P1_27); LCD_Init(2,16); LCD_DisplayString("Explore Embedded"); LCD_DisplayString("Lcd 4-bit Mode"); while(1); }
int main() { SystemInit(); /*Connect RS->P1_27, RW->P1_28, EN->P1_29 and data bus(D4:D7 - P1_16:P1_23)*/ LCD_SetUp(P1_27,P1_28,P1_29,P1_16,P1_17,P1_18,P1_19,P1_20,P1_21,P1_22,P1_23); LCD_Init(2,16); LCD_DisplayString("Explore Embedded"); LCD_DisplayString("Lcd 8-bit Mode"); while(1); }
/** * @brief Calibration of External crystal oscillator manually * @param None * @retval : None */ void ManualClockCalibration(void) { UpDownIntOnOffConfig(ENABLE); RightLeftIntExtOnOffConfig(ENABLE); SelIntExtOnOffConfig(DISABLE); LCD_Clear(Blue2); BKP_TamperPinCmd(DISABLE); BKP_RTCOutputConfig(BKP_RTCOutputSource_CalibClock); LCD_DisplayString(Line1,Column5,"Calibration"); LCD_DisplayString(Line3,Column0,"LSE/64 is available"); LCD_DisplayString(Line4,Column0,"on PC13.Measure the"); LCD_DisplayString(Line5,Column0,"the frequency and"); LCD_DisplayString(Line6,Column0,"press Sel to proceed"); while(ReadKey()!=SEL) { } LCD_Clear(Blue2); BKP_RTCOutputConfig(BKP_RTCOutputSource_None); LCD_DisplayString(Line1,Column4,"Please enter"); LCD_DisplayString(Line2,Column2,"Calibration Value"); LCD_DisplayCount(Line4,Column6,1,ArrayTime[0]+0x30); LCD_DisplayCount(Line4,Column7,0,ArrayTime[1]+0x30); LCD_DisplayCount(Line4,Column8,0,ArrayTime[2]+0x30); LCD_DisplayString(Line6,Column6,"(0-121)"); LCD_SetBackColor(Green); SelIntExtOnOffConfig(ENABLE); }
/** * @brief Displays the Date(DD/MM/YY and DAY ) on LCD * @param None * @retval :None */ void DisplayDate(void) { s_DateStructVar.Year=(BKP_ReadBackupRegister(BKP_DR4)); s_DateStructVar.Month=(BKP_ReadBackupRegister(BKP_DR2)); s_DateStructVar.Day=(BKP_ReadBackupRegister(BKP_DR3)); LCD_DisplayChar(Line5,Column5,(s_DateStructVar.Day/10) + 0x30); LCD_DisplayChar(Line5,Column6,(s_DateStructVar.Day%10) + 0x30); LCD_DisplayString(Line5,Column8,MonthsNames[s_DateStructVar.Month-1]); LCD_DisplayChar(Line5,Column12,((s_DateStructVar.Year/1000) + 0x30)); LCD_DisplayChar(Line5,Column13,((s_DateStructVar.Year/100)%10) + 0x30); LCD_DisplayChar(Line5,Column14,((s_DateStructVar.Year/10)%10) + 0x30); LCD_DisplayChar(Line5,Column15,(s_DateStructVar.Year%10) + 0x30); switch(WeekDay(s_DateStructVar.Year,s_DateStructVar.Month,s_DateStructVar.Day)) { case 0: LCD_DisplayString(Line6,Column8,"Sun"); break; case 1: LCD_DisplayString(Line6,Column8,"Mon"); break; case 2: LCD_DisplayString(Line6,Column8,"Tue"); break; case 3: LCD_DisplayString(Line6,Column8,"Wed"); break; case 4: LCD_DisplayString(Line6,Column8,"Thu"); break; case 5: LCD_DisplayString(Line6,Column8,"Fri"); break; case 6: LCD_DisplayString(Line6,Column8,"Sat"); break; } }
static void prvSetupHardware(void) { ErrorStatus OSC4MStartUpStatus01; /* ST provided routine. */ /* MRCC system reset */ MRCC_DeInit(); /* Wait for OSC4M start-up */ OSC4MStartUpStatus01 = MRCC_WaitForOSC4MStartUp(); if(OSC4MStartUpStatus01 == SUCCESS) { /* Set HCLK to 60MHz */ MRCC_HCLKConfig(MRCC_CKSYS_Div1); /* Set CKTIM to 60MHz */ MRCC_CKTIMConfig(MRCC_HCLK_Div1); /* Set PCLK to 30MHz */ MRCC_PCLKConfig(MRCC_CKTIM_Div2); /* Enable Flash Burst mode */ CFG_FLASHBurstConfig(CFG_FLASHBurst_Enable); /* Set CK_SYS to 60 MHz */ MRCC_CKSYSConfig(MRCC_CKSYS_OSC4MPLL, MRCC_PLL_Mul_15); } /* GPIO pins optimized for 3V3 operation */ MRCC_IOVoltageRangeConfig(MRCC_IOVoltageRange_3V3); /* GPIO clock source enable */ MRCC_PeripheralClockConfig(MRCC_Peripheral_GPIO, ENABLE); /* EXTIT clock source enable */ MRCC_PeripheralClockConfig(MRCC_Peripheral_EXTIT, ENABLE); /* TB clock source enable */ MRCC_PeripheralClockConfig(MRCC_Peripheral_TB, ENABLE); /* Initialize the demonstration menu */ LCD_Init(); LCD_DisplayString(Line1, ( unsigned char * ) "www.FreeRTOS.org", BlackText); LCD_DisplayString(Line2, ( unsigned char * ) " STR750 Demo ", BlackText); EIC_IRQCmd(ENABLE); }
void lcdout_Tick(){ //Actions switch(lcdout_state){ case lcdout_INIT: break; case lcdout_RUN: lcd_output[11] = speed; lcd_output[27] = pattern; if (selected == 0) { lcd_output[0] = '*'; lcd_output[16] = ' '; } else if (selected == 1) { lcd_output[0] = ' '; lcd_output[16] = '*'; } LCD_DisplayString(1,lcd_output); break; default: break; } //Transitions switch(lcdout_state){ case lcdout_INIT: lcdout_state = lcdout_RUN; break; case lcdout_RUN: lcdout_state = lcdout_RUN; break; default: lcdout_state = lcdout_INIT; break; } }
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; } }
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 prvLCDTask( void * pvParameters ) { xQueueHandle *pxLCDQueue; xLCDMessage xReceivedMessage; portCHAR *pcString; /* To test the parameter passing mechanism, the queue on which messages are received is passed in as a parameter even though it is available as a file scope variable anyway. */ pxLCDQueue = ( xQueueHandle * ) pvParameters; LCD_Init(); for( ;; ) { /* Wait for a message to arrive. */ if( xQueueReceive( *pxLCDQueue, &xReceivedMessage, portMAX_DELAY ) ) { /* Where is the string we are going to display? */ pcString = *xReceivedMessage.ppcMessageToDisplay; LCD_DisplayString(xReceivedMessage.xRow, pcString, BlackText); /* The delay here is just to ensure the LCD task does not starve out lower priority tasks as writing to the LCD can take a long time. */ vTaskDelay( mainLCD_DELAY ); } } }
void LCD_DisplayInt(uint16_t LineNumber, uint16_t ColumnNumber, int Number) { //here the LineNumber and the ColumnNumber are NOT pixel numbers!!! char lcd_buffer[15]; sprintf(lcd_buffer,"%d",Number); LCD_DisplayString(LineNumber, ColumnNumber, (uint8_t *) lcd_buffer); }
/* start the main program */ void main() { /* Initilize the lcd before displaying any thing on the lcd */ LCD_Init(8,2,16); /* Display "hello, world" on first line*/ LCD_DisplayString("hello, world"); /*Go to second line and display "good morning" */ LCD_GoToNextLine(); LCD_DisplayString("good morning"); while(1); }
/*..........................................................................*/ void BSP_init(void) { SystemInit(); /* initialize STM32 system (clock, PLL and Flash) */ /* initialize LEDs, Key Button, and LCD on STM3210X-EVAL board */ STM_EVAL_LEDInit(LED1); STM_EVAL_LEDInit(LED2); STM_EVAL_LEDInit(LED3); STM_EVAL_LEDInit(LED4); STM3210C_LCD_Init(); /* initialize the LCD */ LCD_Clear(White); /* clear the LCD */ LCD_SetBackColor(Grey); LCD_SetTextColor(Black); LCD_DisplayString(Line0, 0, " Quantum Leaps "); LCD_DisplayString(Line1, 0, " DPP example "); LCD_DisplayString(Line2, 0, "QP/C(Vanilla) "); LCD_DisplayString(Line2, 14*16, QF_getVersion()); LCD_SetBackColor(White); LCD_DisplayString(Line5, 0, "DPP:"); LCD_SetBackColor(Black); LCD_SetTextColor(Yellow); LCD_DisplayString(Line9, 0, " state-machine.com "); LCD_SetBackColor(Blue); LCD_SetTextColor(White); LCD_DisplayString(Line5, 4*16, "0 ,1 ,2 ,3 ,4 "); if (QS_INIT((void *)0) == 0) { /* initialize the QS software tracing */ Q_ERROR(); } }
/** * @brief Sets the RTC Date(DD/MM/YYYY) * @param DD,MM,YYYY * @retval : None */ void SetDate(uint8_t Day, uint8_t Month, uint16_t Year) { uint32_t DateTimer; RightLeftIntExtOnOffConfig(DISABLE); UpDownIntOnOffConfig(DISABLE); /*Check if the date entered by the user is correct or not, Displays an error message if date is incorrect */ if((( Month==4 || Month==6 || Month==9 || Month==11) && Day ==31) \ || (Month==2 && Day==31)|| (Month==2 && Day==30)|| \ (Month==2 && Day==29 && (CheckLeap(Year)==0))) { LCD_Clear(Red); LCD_SetBackColor(Red); LCD_DisplayString(Line3,Column2,"INCORRECT DATE"); LCD_DisplayString(Line6,Column1,"PLEASE RECONFIGURE"); DateTimer=RTC_GetCounter(); while((RTC_GetCounter()-DateTimer)<2) { } } /* if date entered is correct then set the date*/ else { if(AlarmDate==0) { BKP_WriteBackupRegister(BKP_DR2,Month); BKP_WriteBackupRegister(BKP_DR3,Day); BKP_WriteBackupRegister(BKP_DR4,Year); DisplayDateFlag=1; } else { s_AlarmDateStructVar.Day = Day; s_AlarmDateStructVar.Month = Month; s_AlarmDateStructVar.Year = Year; BKP_WriteBackupRegister(BKP_DR8,Month); BKP_WriteBackupRegister(BKP_DR9,Day); BKP_WriteBackupRegister(BKP_DR10,Year); AlarmDate=0; } } }
void LCD_DisplayFloat(uint16_t LineNumber, uint16_t ColumnNumber, float Number, int DigitAfterDecimalPoint) { //here the LineNumber and the ColumnNumber are NOT pixel numbers!!! char lcd_buffer[15]; sprintf(lcd_buffer,"%.*f",DigitAfterDecimalPoint, Number); //6 digits after decimal point, this is also the default setting for Keil uVision 4.74 environment. LCD_DisplayString(LineNumber, ColumnNumber, (uint8_t *) lcd_buffer); }
void LCD_test() { UART_TxString("\n\r LCD DataBus: P2 Control: RS-P0.0 RW-P0.1 E-P0.2 "); UART_Printf("\n\r Make connections and hit 'k' to test "); while(UART_RxChar()!='k'); LCD_Init(8,2,16); DELAY_ms(100); LCD_DisplayString("Explore Embedded!"); while(1); }
int TickFct_USART(int state){ unsigned char doorClosed = (~PIND & 0x10) >> 4; switch(state){ case usartInit: state = usartLocked; USART_Send(0x01, 1); break; case usartLocked: if(lockedFlag){ state = usartLocked; } else{ state = usartUnlocked; USART_Send(0x00, 1); LCD_DisplayString(1, "Unlocking..."); delay_ms(5000); LCD_DisplayString(1, "Press A to Lock C to Change Pin"); } break; case usartUnlocked: if(lockedFlag){ state = usartLocked; USART_Send(0x01, 1); LCD_DisplayString(1, "Locking..."); delay_ms(5000); if(!doorClosed && lockedFlag ){ LCD_DisplayString(1, "ALARM! Enter Pin: "); } else{ LCD_DisplayString(1, "A for Keypad B for Bluetooth"); } } else{ state = usartUnlocked; } break; default: state = usartInit; break; } return state; }
void restart_game() { LCD_DisplayString(1,(unsigned char*)""); player = PLAYER_TOP; LCD_Cursor(player); LCD_WriteData('@'); LCD_Cursor(0); obs1=LCD_TOP_RIGHT; obs2=(LCD_BOT_RIGHT - 8); gameover = OFF; pause = OFF; }
/** * @brief Displays Alarm on TFT LCD * @param None * @retval : None */ void DisplayAlarm(void) { SelIntExtOnOffConfig(DISABLE); RightLeftIntExtOnOffConfig(DISABLE); UpDownIntOnOffConfig(DISABLE); TimeDateDisplay=1; LCD_Clear(Red); LCD_SetTextColor(Yellow); LCD_SetBackColor(Red); LCD_DisplayString(Line4,Column8,"ALARM"); }
int main() { /*Connect RS->PB0, RW->PB1, EN->PB2 and data bus to PORTB.4 to PORTB.7*/ LCD_SetUp(PB_0,PB_1,PB_2,P_NC,P_NC,P_NC,P_NC,PB_4,PB_5,PB_6,PB_7); LCD_Init(1,16); LCD_DisplayString("Explore Lcd 1x16"); while(1); return (0); }
/** ****************************************************************************** ** ** Function Name : LCD_DisplayStringCentered ** ** Description : Display a string centered on the specified row. ** ** Passed Parameters : None ** ** Modified Data : None ** ** Return Value : None ** ****************************************************************************** */ void LCD_DisplayStringCentered( uint8 row, uint8 *string ) { uint8 len = strlen( (char *)string ); if( len <= 40 ) { // if the string is less than one line, center it ... uint8 i; LCD_Cursor( row, 1 ); for( i=0; i<40; i++ ) LCD_DisplayCharacter( row, ' ' ); LCD_DisplayString( row,( ( 40 - len ) / 2 )+1,string ); } else { // if the string is more than one line, display first 20 characters uint8 temp[41]; strncpy((char *)temp, (char *)string, 40 ); temp[40] = 0; LCD_DisplayString( row,1,temp ); } }
/* start the main program */ void main() { unsigned char eeprom_address=0x00, write_char = 'X', read_char; /* Initialize the lcd before displaying any thing on the lcd */ LCD_Init(4,2,16); while(1) { LCD_GoToLine(1); // Move the cursor to first line LCD_DisplayString("Eeprom Write: "); //Display the message on first line LCD_DisplayChar(write_char); //Display the char to be written EEPROM_WriteByte(eeprom_address,write_char); // Write the data at memoryLocation 0x00 LCD_GoToLine(2); // Move the cursor to Second line LCD_DisplayString("Eeprom Read: "); //Display the message on first line read_char = EEPROM_ReadByte(eeprom_address); // Read the data from memoryLocation 0x00 LCD_DisplayChar(read_char); //Display the read data } }
void Display_Gameover() { LCD_DisplayString(5, "GAME OVER Score: "); LCD_Cursor(3); LCD_WriteData(0b00001000); LCD_Cursor(15); LCD_WriteData(0b00001000); LCD_Cursor(28); LCD_WriteData(points/10 + '0'); LCD_Cursor(29); LCD_WriteData(points%10 + '0'); LCD_Cursor(0); return; }
static void vPrintTask( void *pvParameters ) { LCDMessage xMessage; for( ;; ) { /* Wait until a message arrives. */ while( xQueueReceive( xLCDQueue, ( void * ) &xMessage, portMAX_DELAY ) != pdPASS ); /* The message contains the text to display, and the line on which the text should be displayed. */ LCD_Clear(); LCD_DisplayString( xMessage.ucLine, xMessage.pucString, BlackText ); } }
//Function Definitions void toggle_pause() { pause = pause ? 0 : 1; if(pause) { for(int i=0; i<8; i++) { LCD_Cursor(i+5); LCD_WriteData(pause_message[i]); } } else { LCD_DisplayString(1,(unsigned char*)" "); LCD_Cursor(player); LCD_WriteData('@'); move_obstacles(); } }
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; }
int main(void) { DDRB = 0xFF; PORTB = 0x00; DDRA = 0xFF; PORTA = 0x00; DDRD = 0xFF; PORTD = 0x00; DDRC = 0xF0; PORTC = 0x0F; // PC7..4 outputs init 0s, PC3..0 inputs init 1s TimerSet(200); TimerOn(); LCD_init(); LCD_DisplayString(1,"Congratulations!"); state = start; while(1) { while (!TimerFlag); TimerFlag = 0; Tick(); } }