int main(){ int s; char buf_n[16]; while (scanf("%d%s", &s, buf_n) && s){ LCD_Display(buf_n, s); printf("\n"); } }
int main(void) { if (init_system() != 0) return(-1); indexed_file_count = build_file_index(files); printf("Indexed files: %d\n", indexed_file_count); IOWR(BUTTON_PIO_BASE, 2, 0xf); IOWR(BUTTON_PIO_BASE, 3, 0x0); alt_irq_register( BUTTON_PIO_IRQ, (void*)0, button_ISR ); IOWR(LED_PIO_BASE, 0, 0x00); player_state = PLAYER_STATE_DEFAULT; int length; data_file file; while(1){ if ((cur_file_index_update == 1) || (player_state_update == 1)) { if (cur_file_index_update) file = files[cur_file_index]; switch (player_state){ case PLAYER_STATE_PLAYING: LCD_File_Buffering(file.Name); length = 1 + ceil(file.FileSize/(BPB_BytsPerSec*BPB_SecPerClus)); build_cluster_chain(cluster_chain, length, &file); LCD_Display(file.Name, player_mode); play(&file, buffer, cluster_chain, player_mode); player_state = PLAYER_STATE_USER_INPUT; case PLAYER_STATE_USER_INPUT: LCD_Display(file.Name, player_mode); } player_state_update = 0; cur_file_index_update = 0; } } return(0); }
void init_music(){ int clusterLength, secCount; search_for_filetype("WAV", &returnData,0,1); printLCD(returnData.Name, "Buffering..."); clusterLength = 1+ ceil( (float) returnData.FileSize / bytePerCluster); build_cluster_chain(cc, clusterLength, &returnData); play_type = IORD(SWITCH_PIO_BASE, 0) & 0x07; LCD_Display(returnData.Name, play_type); }
int main(void) { LED_Init(); SW_Init(); LCD_Configuration(); if (Mode_Judgement() == USER_BOOT_MODE) { /* if SW0 is turned on, enter user boot mode */ LED_On(LED3); /* enter user boot mode */ LCD_Display("User Boot Mode", ""); /* enter user boot mode */ LCD_Display("RAM transferring", "......"); Copy_Routine(FLASH_API_RAM, FLASH_API_ROM, SIZE_FLASH_API); /* copy flash API to RAM */ LCD_Display("Flash swapping", "......"); if (FC_SUCCESS == Flash_Swap()) { /* swap the flash content */ /* Do nothing */ } else { LED_On(LED1 | LED2 | LED3); /* if have any error, turn on all leds */ LCD_Display("Error", ""); /* if have any error, display error information */ } } else { /* if SW1 is turned off, enter normal mode */ #if defined ( __CC_ARM ) /* RealView Compiler */ ResetSP(); /* reset SP */ #elif defined ( __ICCARM__ ) /* IAR Compiler */ asm("MOV R0, #0"); /* reset SP */ asm("LDR SP, [r0]"); #endif SCB->VTOR = DEMO_START_ADDR; /* redirect vector table */ startup = CODE_START; startup(); /* jump to code start address to run */ } return 0; }
bool LCD_Init ( LCD display ) { lcd = display; /* * TODO: * The function should clear only the appropriate bits, not the whole PORT */ if ( lcd.PORT == &PORTA ) { TRISA = 0x00; } else if ( lcd.PORT == &PORTB ) { TRISB = 0x00; } else if ( lcd.PORT == &PORTC ) { TRISC = 0x00; } #if defined(_16F877) || defined(_16F877A) else if ( lcd.PORT == &PORTD ) { TRISD = 0x00; } else if ( lcd.PORT == &PORTE ) { TRISE = 0x00; } #endif else { return false; } // Give some time to the LCD to start function properly __delay_ms(20); // Send reset signal to the LCD LCD_Write(0x03); __delay_ms(5); LCD_Write(0x03); __delay_ms(16); LCD_Write(0x03); // Specify the data lenght to 4 bits LCD_Write(0x02); // Set interface data length to 8 bits, number of display lines to 2 and font to 5x8 dots LCD_Cmd(0x28); // Set cursor to move from left to right LCD_Cmd(0x06); LCD_Display(true, false, false); // Turn on display and set cursor off LCD_Clear(); return true; }
void STATE_menu() { INT_T0_clean(); LCD_AccessSelection(LCD_AccessSelection_DDRAM1); LCD_Display(0x00); LCD_setDefault(); LCD_FontSize(1, 1); LCD_PositionString(0x0A, 0x00, TEXT_name); LCD_PositionString(0x10, 0x60, TEXT_roll); LCD_PositionString(0x04, 0xD0, "狀態"); LCD_DisplaySelection(LCD_DisplaySelection_DDRAM1); STATE_STATE = 0x00; }
void STATE_roll_connect() { if (!INT_T0_check()) { LCD_DisplaySelection(LCD_DisplaySelection_DDRAM1); LCD_AccessSelection(LCD_AccessSelection_DDRAM1); LCD_Display(0x00); LCD_PositionString(0x07, 0x30, "連線中,請稍候"); LCD_PositionString(0x1C, 0xD0, TEXT_back); PROTOCOL_action(1); } if (PROTOCOL_action(0) != 0) { STATE_roll_state = STATE_roll_type_show; } INT_T0_initial(); }
/********************************************************** **Name: PowerOnMusic **Function: Power on music **Input: none **Output: none **********************************************************/ void PowerOnMusic(void) { BeepOn((u16*)MusicTab_PowerOn); //Power on music LCD_DisplayAll(); //display all LCD seg DispSeg_915=1;DispSeg_RFM=1;DispSeg_MHz=1; while(1) { if((gw_BeepTimer==0)&&(gw_ToneBuf[gb_BeepOnCount+1]==0)) break; LCD_Display(); } DispSeg_915=0;DispSeg_RFM=0;DispSeg_MHz=0; Clr_LCD(); //Clear LCD display }
void STATE_status() { LCD_AccessSelection(LCD_AccessSelection_DDRAM1); LCD_Display(0x00); LCD_setDefault(); LCD_PositionString(0x10, 0x00, "狀態"); LCD_PositionString(0x04, 0x40, "訊號"); LCD_PositionString(0x0E, 0x40, GPRS_getSignalQuality()); LCD_PositionString(0x04, 0x60, "電信"); LCD_PositionString(0x0E, 0x60, GPRS_getOperatorSlelction()); LCD_PositionString(0x04, 0x80, "位址"); LCD_PositionString(0x0E, 0x80, GPRS_getIPAddress()); LCD_PositionString(0x04, 0xD0, "連線"); LCD_PositionString(0x1C, 0xD0, TEXT_back); LCD_DisplaySelection(LCD_DisplaySelection_DDRAM1); }
void LCD_Op5() // 返回键操作 { //0000 1 D C B LCD_W_Cmd(0x0c);//显示on,光标off, 光标闪烁off Delayms(1); LCD_Display(); if(POS >= 8) // 配置闹钟,则不需要重新保存时间 Alarm_Save(); else Time_Save(); POS = 0; TR0 = 1; // 重新开始时钟 }
void STATE_config_main() { LCD_AccessSelection(LCD_AccessSelection_DDRAM1); LCD_Display(0x00); LCD_setDefault(); LCD_PositionString(0x10, 0x00, "組態設定"); LCD_PositionString(0x04, 0x40, "帳號"); LCD_PositionString(0x04, 0x60, "密碼"); LCD_PositionString(0x04, 0x80, "伺服器"); LCD_PositionString(0x0E, 0x40, CONFIGURATION_get(STATE_config_type_account)); LCD_PositionString(0x0E, 0x60, CONFIGURATION_get(STATE_config_type_password)); LCD_PositionString(0x0E, 0x80, CONFIGURATION_get(STATE_config_type_server)); LCD_PositionString(0x04, 0xD0, "儲存"); LCD_PositionString(0x10, 0xD0, "重設"); LCD_PositionString(0x1C, 0xD0, TEXT_back); LCD_DisplaySelection(LCD_DisplaySelection_DDRAM1); }
uint8_t Flash_Swap(void) { uint32_t reg_value = 0U; Copy_Routine(DEMO_A_RAM, DEMO_A_FLASH, SIZE_DEMO_A); /* copy A to RAM */ Copy_Routine(DEMO_B_RAM, DEMO_B_FLASH, SIZE_DEMO_B); /* copy B to RAM */ if (FC_SUCCESS == FC_EraseBlock((uint32_t) DEMO_A_FLASH)) { /* erase A */ /* Do nothing */ } else { return ERROR; } if (FC_SUCCESS == Write_Flash(DEMO_A_FLASH, DEMO_B_RAM, SIZE_DEMO_B)) { /* write B to A */ /* Do nothing */ } else { return ERROR; } if (FC_SUCCESS == FC_EraseBlock((uint32_t) DEMO_B_FLASH)) { /* erase B */ /* Do nothing */ } else { return ERROR; } if (FC_SUCCESS == Write_Flash(DEMO_B_FLASH, DEMO_A_RAM, SIZE_DEMO_A)) { /* write A to B */ /* Do nothing */ } else { return ERROR; } delay(0x7FFFFF); LED_Off(LED3); /* complete and restart */ delay(0x2FFFFF); LCD_Display("Finished", "Restart......"); /* wait for Key SW0 to release */ while (SW_Get(SW0) == 1U) { } reg_value = SCB->AIRCR; /* software reset */ reg_value = (uint32_t) 0x05FA0001; SCB->AIRCR = reg_value; return SUCCESS; }
void main() { WDTCTL=WDTPW+WDTHOLD; ADC10_init(); LCD_Init(); while(1) { ADC10CTL0 |= ENC + ADC10SC; // Sampling and conversion start // _bis_SR_register(CPUOFF + GIE); // LPM0 with interrupts enabled __delay_cycles(1000); //-----ADC转换完成中断唤醒CPU后才执行以下代码----- temp = ADC10MEM; //读取AD采样值 IntDeg= temp*4225/1024 - 2777; //转换为摄氏度,并10倍处理 // IntDeg=-123; //由于难以获得负温,直接给负值以测试LCD显示 LCD_Display(); //调用LCD显示函数 } }
int main() { struct Timer fps; time_t current; struct tm *current_tm; struct Banner date_banner = { .string = date_string, .offset = 0 }; if (LCD_Init() != 0) { printf("Error initializing LCD\n"); return 1; } LCD_SetBacklight(1); for (;;) { timer_start(&fps); current = time(NULL); current_tm = localtime(¤t); string_print_date(date_string, current_tm); LCD_Clear(); draw_clock_frame(); draw_time(current_tm); update_banner(&date_banner); draw_banner(&date_banner, 0); draw_banner(&date_banner, 38); LCD_Display(); if (timer_get_msecs(&fps) < 1000 / FRAMES_PER_SECOND) { usleep(1000 * ( 1000 / FRAMES_PER_SECOND ) - timer_get_msecs(&fps)); } } return 0; }
/********************************************************** **Name: MenuConfig **Function: Menu config & display **Input: none **Output: none **********************************************************/ void MenuConfig(void) { u8 KeyValue=KeyScan(); //Get key value if(gb_SystemMode==C_SysMode_EntrySet) //Parameter select mode { RFParameterSelect(KeyValue); } else if(gb_SystemMode==C_SysMode_Modem) { ModemSelect(KeyValue); //Modem select mode } else { WorkModeSelect(KeyValue); //Work mode } DisplayRFParameter(); LCD_Display(); //Display }
void STATE_roll_show() { INT_T0_clean(); LCD_AccessSelection(LCD_AccessSelection_DDRAM1); LCD_Display(0x00); LCD_setDefault(); LCD_FontSize(1, 1); if (PROTOCOL_action(0) == 1) { LCD_PositionString(0x0C, 0x00, TEXT_healthRecode); LCD_PositionString(0x08, 0x30, "姓名:"); LCD_PositionString(0x14, 0x30, CLIENT_getName()); LCD_PositionString(0x08, 0x90, "里程累計:"); LCD_PositionString(0x1D, 0x90, CLIENT_getPoint()); LCD_PositionString(0x1C, 0xD0, "返回"); } else { LCD_PositionString(0x07, 0x30, "指紋辨識失敗"); LCD_PositionString(0x07, 0x50, ",請重新點名"); LCD_PositionString(0x1C, 0xD0, "返回"); } LCD_DisplaySelection(LCD_DisplaySelection_DDRAM1); }
/** * @brief Main program. * @param None * @retval None */ void COMP_PulseWidthMeasurement(void) { /*!< At this stage the microcontroller clock setting is already configured, this is done through SystemInit() function which is called from startup file (startup_stm32f30x.s) before to branch to application main. To reconfigure the default setting of SystemInit() function, refer to system_stm32f30x.c file */ /* Initialize the TFT-LCD */ STM32303C_LCD_Init(); /* Clear the TFT-LCD */ LCD_Clear(LCD_COLOR_WHITE); /* DAC Channel1 configuration */ DAC_Config(); /* COMP1 Configuration */ COMP_Config(); /* TIM2 Configuration in input capture mode */ TIM_Config(); /* Displays PulseWidthMeasurement message on line 0 */ LCD_DisplayStringLine(LINE(0), (uint8_t *)MESSAGE1); /* Infinite loop */ while (1) { if (DisplayActive != 0) { /* Compute the pulse width in us */ MeasuredPulse = (uint32_t)(((uint64_t) Capture * 1000000) / ((uint32_t)SystemCoreClock)); /* Display measured pulse width on LCD */ LCD_Display(MeasuredPulse); DisplayActive = 0; } } }
void LCD_Init() //LCD初始化设定 { unsigned char i = 0; //显示模式设置 0011 1000, 16*2显示,5*7点阵,8位数据接口 LCD_W_Cmd(0x38); Delayms(1); //0000 1 D C B LCD_W_Cmd(0x0c);//显示on,光标off, 光标闪烁off Delayms(1); //0000 01 N S LCD_W_Cmd(0x06);//读写操作后指针加/减 写入字符后整屏是否左移 Delayms(1); // 01H 数据指针清零,显示清零 02H 数据指针清零 LCD_W_Cmd(0x01); //清除LCD的显示内容 Delayms(10); Time_Load(); // 载入时间数据 //显示数据 LCD_Display(); }
//Get the current switch value and display the paly mode & song to LCD static void DisplayStatusLCD() { _swstate = _swstate & 0x07; LCD_Display(_fileinfo.Name, _swstate); }
int main() { //Initialize Functions SD_card_init(); init_mbr(); init_bs(); init_audio_codec(); //Setup Push Buttons init_button_pio(); // Initialize Variables bytePerCluster = BPB_BytsPerSec * BPB_SecPerClus; //play_music(0 , 1); //play_music(0 , 2); //play_music(0 , 3); //play_music(5 , 4); stop_flag = 1; file_number = 0; init_music(); delay_cnt = 0; delay_flag = 0; while(1){ if(stop_flag == 0){ if(edge_capture == 0x01){ //stop music stop_flag = 1; } else if(edge_capture == 0x02){ // play music delay_cnt = 0; delay_flag = 0; play_type = IORD(SWITCH_PIO_BASE, 0) & 0x07; LCD_Display(returnData.Name, play_type); play_music(play_type); } else if(edge_capture == 0x04){ printf("File Number is %d\n",file_number); init_music(); usleep(250000); } else if(edge_capture == 0x08){ if(file_number < 2 ) file_number = 0; else file_number -= 2; init_music(); } } } return 0; }
void main(void) { CAN_TxStatus_TypeDef status = CAN_TxStatus_Failed; /* Transmit Parameters */ CAN_Id_TypeDef Tx_IDE = CAN_Id_Standard; CAN_RTR_TypeDef Tx_RTR = CAN_RTR_Data; uint8_t Tx_DLC = 0; uint8_t Tx_Data[8] = {0}; uint32_t Tx_Id = 0; /* Clock configuration --------------------------------------*/ CLK_Config(); /* GPIO Configuration ---------------------------------------*/ GPIO_Config(); /* Configure LCD mounted on STM8-128 EVAL board -------------*/ LCD_Config(); /* CAN configuration ----------------------------------------*/ CAN_Config(); /* Enable Interrupts*/ enableInterrupts(); /* Infinite loop*/ while(1) { while(Key_status != Key_NoPressed) { if(Key_Pressed_Number == 0x0) { Key_Pressed_Number = 0x03; } else { Key_Pressed_Number--; } /* Sender Display*/ LED_Display(Key_Pressed_Number); LCD_Display(Key_Pressed_Number); Delay(TIME); /* Transmit Parameters*/ Tx_Id = 0x321; Tx_IDE = CAN_Id_Standard; Tx_RTR = CAN_RTR_Data; Tx_DLC = 1; Tx_Data[0] = Key_Pressed_Number; /* Sender send Frame */ status = CAN_Transmit(Tx_Id,Tx_IDE,Tx_RTR,Tx_DLC,Tx_Data); /* while key is not pressed, loop*/ Key_status= Key_NoPressed; } } }