int main(void) { int menu_select; int value; HASH_NODE* hash_table[HASH_BUCKET]; hash_init(hash_table); for(;;) { menu_select = print_menu(); switch(menu_select) { case 1: printf("Insert value>"); scanf("%d",&value); hash_insert(hash_table,value); break; case 2: printf("Can't select this menu\n"); break; case 3: printf("Insert value>"); scanf("%d",&value); HASH_NODE* node = hash_search(hash_table,value); printf("Result:"); if(node==NULL) { printf("Not Found:%d\n",value); } else { printf("Found:%d at %p\n",value,node); } break; case 4: printf("HASH>\n"); hash_print(hash_table); break; case 5: return 0; break; default: printf("Please select 1 to 5\n"); break; } } return 1; }
int main (void) { SystemInit(); /* initialize clocks */ debug_frmwrk_init(); do{ user_switch_init(); }while(int_flag != 1); print_menu(); i2c_lpc_init(I2C_SPEED_100); test_i2c_at24c256_flash(); while(1); }
int main() { int selected_option = NONE_OPTION; pre_init(); do { print_menu(); selected_option = get_opt(); perform_effect(selected_option); } while(selected_option != EXIT_OPTION); return 0; }
void serial_init( ) { // Set the baud rate to 9600 bits per second. Each byte takes ten bit // times, so you can get at most 960 bytes per second at this speed. serial_set_baud_rate(USB_COMM, 9600); // Start receiving bytes in the ring buffer. serial_receive_ring(USB_COMM, receive_buffer, sizeof(receive_buffer)); memset( my_received_buffer, 0, sizeof(my_received_buffer)); serial_print_string( "USB Serial Initialized" ); serial_print_string( "" ); print_menu(); }
void menu(void) { srand(time(NULL)); Window win; clear(); start_color(); init_pair(1,COLOR_BLUE,COLOR_BLACK); init_pair(2,COLOR_RED,COLOR_BLACK); attron(COLOR_PAIR(1)); print_score(win); print_logo(win); print_menu(win); attroff(COLOR_PAIR(1)); refresh(); }
void menu_down(){ ///\fn void menu_down() ///\brief Deplasarea in jos in menu. /// ///Implementarea deplasarii in jos in cadrul menu-ului pentru selectarea optiunii dorite. if(highlighted_item < menu[current_menu].nr_items-1) highlighted_item ++; else highlighted_item = 0; print_menu(); Sleep(50); }
/** **************************************************************************************** * @briefend of test option * **************************************************************************************** */ void endtest_bridge(short int *idx) { short int index2 = 0; char bchoice; printf_string("\n\r\n\rPress m for Engineering Examples Menu or x to exit : "); while(1){ if (index2 == 1) break; bchoice = uart_receive_byte(); switch (bchoice){ case 'm' : print_menu(); index2 = 1; break; case 'x' : (*idx)=1; index2 = 1; break; default : ; break; }; }; }
/*********************************************************************//** * @brief c_entry: Main program body * @param[in] None * @return int **********************************************************************/ int c_entry (void) { /* Initialize debug via UART0 * – 115200bps * – 8 data bit * – No parity * – 1 stop bit * – No flow control */ debug_frmwrk_init(); // print welcome screen print_menu(); /* In this example: * Suppose that the RTC need periodically adjust after each 5 second. * And the time counter need by incrementing the counter by 2 instead of 1 * We will observe timer counter after calibration via serial display */ // Init RTC module RTC_Init(LPC_RTC); /* Enable rtc (starts increase the tick counter and second counter register) */ RTC_ResetClockTickCounter(LPC_RTC); RTC_Cmd(LPC_RTC, ENABLE); //Set current time = 0 RTC_SetTime (LPC_RTC, RTC_TIMETYPE_SECOND, 0); /* Setting Timer calibration * Calibration value = 5s; * Direction = Forward calibration * So after each 5s, calibration logic can periodically adjust the time counter by * incrementing the counter by 2 instead of 1 */ RTC_CalibConfig(LPC_RTC, 5, RTC_CALIB_DIR_FORWARD); RTC_CalibCounterCmd(LPC_RTC, ENABLE); /* Set the CIIR for second counter interrupt*/ RTC_CntIncrIntConfig (LPC_RTC, RTC_TIMETYPE_SECOND, ENABLE); /* Enable RTC interrupt */ NVIC_EnableIRQ(RTC_IRQn); /* Loop forever */ while(1); return 1; }
/*********************************************************************//** * @brief c_entry: Main CAN program body * @param[in] none * @return none **********************************************************************/ void c_entry(void) { /* Initialize debug via UART0 * – 115200bps * – 8 data bit * – No parity * – 1 stop bit * – No flow control */ debug_frmwrk_init(); print_menu(); /* Initialize CAN1 peripheral * Note: Self-test mode doesn't require pin selection */ CAN_Init(_USING_CAN_NO, 125000); //Enable self-test mode CAN_ModeConfig(_USING_CAN_NO, CAN_SELFTEST_MODE, ENABLE); //Enable Interrupt CAN_IRQCmd(_USING_CAN_NO, CANINT_RIE, ENABLE); CAN_IRQCmd(_USING_CAN_NO, CANINT_TIE1, ENABLE); //Enable CAN Interrupt NVIC_EnableIRQ(CAN_IRQn); CAN_SetAFMode(CAN_ACC_BP); CAN_InitMessage(); _DBG_("Transmitted buffer:"); PrintMessage(&TXMsg); /** To test Bypass Mode: we send infinite messages to CAN2 and check * receive process via COM1 */ CAN_SendMsg(_USING_CAN_NO, &TXMsg); #if (_USING_CAN_NO == CAN_1) LPC_CAN1->CMR |=(1<<4); //Self Reception Request #else LPC_CAN2->CMR |=(1<<4); #endif while (1); }
/*********************************************************************//** * @brief c_entry: Main program body * @param[in] None * @return int **********************************************************************/ int c_entry (void) { /* Initialize debug via UART0 * – 115200bps * – 8 data bit * – No parity * – 1 stop bit * – No flow control */ debug_frmwrk_init(); // print welcome screen print_menu(); /* Initialize and configure RTC */ RTC_Init(LPC_RTC); RTC_ResetClockTickCounter(LPC_RTC); RTC_SetTime (LPC_RTC, RTC_TIMETYPE_SECOND, 0); /* Set alarm time = 5s. * So, after each 5s, RTC will generate and wake-up system * out of Deep PowerDown mode. */ RTC_SetAlarmTime (LPC_RTC, RTC_TIMETYPE_SECOND, 5); RTC_CntIncrIntConfig (LPC_RTC, RTC_TIMETYPE_SECOND, DISABLE); /* Set the AMR for 5s match alarm interrupt */ RTC_AlarmIntConfig (LPC_RTC, RTC_TIMETYPE_SECOND, ENABLE); RTC_ClearIntPending(LPC_RTC, RTC_INT_ALARM); _DBG_("Press '1' to enter system in Deep PowerDown mode"); while(_DG !='1'); RTC_Cmd(LPC_RTC, ENABLE); NVIC_EnableIRQ(RTC_IRQn); _DBG_("Enter Deep PowerDown mode..."); _DBG_("Wait 5s, RTC will wake-up system...\n\r"); // Enter target power down mode CLKPWR_DeepPowerDown(); while(1); return 1; }
/*********************************************************************//** * @brief c_entry: Main program body * @param[in] None * @return int **********************************************************************/ int c_entry (void) { /* Initialize debug via UART0 * – 115200bps * – 8 data bit * – No parity * – 1 stop bit * – No flow control */ debug_frmwrk_init(); // print welcome screen print_menu(); // Init WDT, IRC OSC, interrupt mode, timeout = 2000000 us = 2s WDT_Init(WDT_CLKSRC_IRC, WDT_MODE_INT_ONLY); _DBG_("Press '1' to enter system in Deep Sleep mode"); while(_DG !='1'); NVIC_EnableIRQ(WDT_IRQn); WDT_Start(WDT_TIMEOUT); _DBG_("Enter Deep Sleep mode!"); _DBG_("Wait 2s for WDT wake-up system..."); /*---------- Disable and disconnect the main PLL0 before enter into Deep-Sleep * or Power-Down mode <according to errata.lpc1768-16.March.2010> ------------ */ LPC_SC->PLL0CON &= ~(1<<1); /* Disconnect the main PLL (PLL0) */ LPC_SC->PLL0FEED = 0xAA; /* Feed */ LPC_SC->PLL0FEED = 0x55; /* Feed */ while ((LPC_SC->PLL0STAT & (1<<25)) != 0x00); /* Wait for main PLL (PLL0) to disconnect */ LPC_SC->PLL0CON &= ~(1<<0); /* Turn off the main PLL (PLL0) */ LPC_SC->PLL0FEED = 0xAA; /* Feed */ LPC_SC->PLL0FEED = 0x55; /* Feed */ while ((LPC_SC->PLL0STAT & (1<<24)) != 0x00); /* Wait for main PLL (PLL0) to shut down */ /*------------Then enter into PowerDown mode ----------------------------------*/ // Enter target power down mode CLKPWR_DeepSleep(); SystemInit(); debug_frmwrk_init(); _DBG_("\n\rSystem wake-up!\n\r"); while(1); return 1; }
int main() { unsigned int maxSize = 10; pqueue_t pq = pqueue_empty(maxSize); bool exit = false; char *option = NULL; unsigned int *u = calloc(1,sizeof(unsigned int)); unsigned int v; do { option = print_menu(); switch(*option) { case ADD: printf("\nPor favor ingrese el nodo: "); if(!pqueue_is_full(pq)) { scanf("%u",&v); *u = v; pqueue_enqueue(pq, *u); printf("\nExito.\n"); } else { printf("La cola esta llena\n"); } break; case SHOW: if(!pqueue_is_empty(pq)) { *u = pqueue_fst(pq); printf("\nEl maximo es: %u\n",*u); } else { printf("La cola está vacia\n"); } break; case POP: if(!pqueue_is_empty(pq)) { pqueue_dequeue(pq); printf("\nSe elimino correctamente\n"); } break; case EXIT: exit = true; break; } free(option); option = NULL; } while(!exit); pq = pqueue_destroy(pq); }
int c_entry(void) { // Init LED port LED_Init(); /* * Initialize debug via UART */ debug_frmwrk_init(); // print welcome screen print_menu(); // Read back TimeOut flag to determine previous timeout reset if (WDT_ReadTimeOutFlag()){ _DBG_(info1); // Clear WDT TimeOut WDT_ClrTimeOutFlag(); } else{ _DBG_(info2); } // Initialize WDT, IRC OSC, interrupt mode, timeout = 2000000 microsecond WDT_Init(WDT_CLKSRC_IRC, WDT_MODE_RESET); // Start watchdog with timeout given WDT_Start(WDT_TIMEOUT); // set timer 100 ms Timer_Wait(100); while (1){ // Wait for 100 millisecond while ( !(TIM_GetIntStatus(LPC_TIM0,0))); TIM_ClearIntPending(LPC_TIM0,0); //turn on led FIO_ByteSetValue(2, 0, LED_PIN); // Wait for 100 millisecond while ( !(TIM_GetIntStatus(LPC_TIM0,0))); TIM_ClearIntPending(LPC_TIM0,0); //turn off led FIO_ByteClearValue(2, 0, LED_PIN); } return 0; }
void Vga_init ( struct vga_t *x, int cpuid, bit32u_t pmem_base ) { ASSERT ( x != NULL ); x->fd = Open2_fmt ( O_WRONLY | O_CREAT | O_TRUNC, S_IRUSR | S_IWUSR, "/tmp/vga%d", cpuid ); x->base_y = 0; #ifdef ENABLE_CURSES init_curses ( ); print_menu ( ); x->subwin = create_subwin ( ); #endif }
/** **************************************************************************************** * @brief Main routineof the DA14580 Peripheral Examples Functions * DA14580 Peripherals Udage Examples * - UART * - SPI Flash * - Boot From SPI flash * - EEPROM * - Timers * - Battery Level Indication - ADC * - Quadrature * - Buzzer * Due to HW Development Kit limitations, user must select one of the follwoing configuartion for UART, SPI, I2C. * Addicional Hardware (SPI, EEPROM boadrs) or Hardware modification may needed for some tof the tests. * More information in the file periph_setup.h, Application Notes, and User Guide for DA14580 * - UART only ( No HW modifications on rev C2 motherboard, No additional hardware) * - SPI Flash with UART (HW modifications & additional Hardware needed , SPI_DI_PIN on the additional SPI / EEPROM daughterboard ) * - Boot From SPI Flash with UART (HW modifications & additional Hardware needed, (UART TX) ) * - Boot From SPI Flash without UART (Additional Hardware needed) * - Boot From EEPROM with UART (Additional Hardware needed) * **************************************************************************************** */ int main (void) { short int index = 0; char mchoice; periph_init(); printf_string("\n\rDA14580 Peripheral Examples\n\r"); printf_string( "---------------------------\n\r"); printf_string("Before running the tests:\n\r"); printf_string(" 1) Make sure you have connected the appropriate peripheral(s).\n\r"); printf_string(" 2) Select the associated hardware configuration in 'periph_setup.h'.\n\r"); printf_string(" 3) Build.\n\r"); printf_string("Please, refer to DA14580 Peripheral Examples User Manual\n\r"); printf_string("for detailed instructions.\n\r"); print_menu(); while(1){ if (index==1) break; mchoice = uart_receive_byte(); switch (mchoice){ case 'u': uart_test(); endtest_bridge(&index); break; #ifdef SPI_ENABLED case 'f': spi_test(); endtest_bridge(&index); break; #endif //SPI_ENABLED #ifdef EEPROM_ENABLED case 'e': i2c_test(); endtest_bridge(&index); break; #endif //EEPROM_ENABLED #ifdef QUADEC_ENABLED case 'q': quad_decoder_test(); endtest_bridge(&index); break; #endif //QUADEC_ENABLED #ifdef BUZZER_ENABLED case 't': timer0_test(); endtest_bridge(&index); break; case 'p': timer2_test(); endtest_bridge(&index); break; #endif //BUZZER_ENABLED case 'b': batt_test(); endtest_bridge(&index); break; case 'x': index=1;break; default: print_input(); continue; }; }; printf_string("\n\r End of tests\n\r"); while(1); }
int main() { int menu; ListNode *head=NULL; setvbuf(stdout, NULL, _IONBF, 0); ListNode* init_bank = (ListNode*) malloc(sizeof(ListNode)); init_bank->bank = (Bank*) malloc(sizeof(Bank)); init_bank->bank->amount = 50000; init_bank->bank->name = NULL; head = add_to_list(head, init_bank); printf("============= Initial Bank =============== \n"); print_all_item(head); do { print_menu(); menu = input_menu(); switch (menu) { case 1: head = loan(head); break; case 2: head = repay(head); break; case 3: print_all_item(head); break; case 0: break; default: break; } printf("\n"); } while (menu != 0); //delete_list(head); free(head->bank); free(head); head = NULL; printf("Bye\n"); return 0; }
pj_status_t gui_start(gui_menu *menu) { while (!console_quit) { unsigned i; char input[10], *p; gui_menu *choice; puts("M E N U :"); puts("---------"); for (i=0; i<menu->submenu_cnt; ++i) { char menu_id[4]; pj_ansi_sprintf(menu_id, "%u", i); print_menu("", menu_id, menu->submenus[i]); } puts(""); printf("Enter the menu number: "); if (!fgets(input, sizeof(input), stdin)) break; p = input; choice = menu; while (*p && *p!='\r' && *p!='\n') { unsigned d = (*p - '0'); if (d < 0 || d >= choice->submenu_cnt) { puts("Invalid selection"); choice = NULL; break; } choice = choice->submenus[d]; ++p; } if (choice && *p!='\r' && *p!='\n') { puts("Invalid characters entered"); continue; } if (choice && choice->handler) (*choice->handler)(); } return PJ_SUCCESS; }
int main() { int option = 0; TREE *tree; tree = Tree_create(); /* Resgatar os dados do arquivo ao iniciar o programa */ resgatar_dados_arquivo(&(tree->root)); while(option != 6) { print_menu(); inserir_inteiro(&option); switch(option) { case 1: menu_cadastrar(&(tree->root)); break; case 2: menu_consultar(tree->root); break; case 3: menu_excluir(tree->root); break; case 4: menu_mostrar_relacao(tree->root); break; case 5: menu_gerar_relatorio(tree->root); break; case 6: destroy_all(tree->root); exit(EXIT_SUCCESS); break; default: printf("\nOpcao invalida!\n"); break; } } destroy_all(tree->root); return 0; }
int main() { //freopen("eg4-6(12412).in", "r", stdin); stu_num = 0; while (1) { print_menu(); int choice; scanf("%d", &choice); switch (choice) { case 1:add(); break; case 2:Remove(); break; case 3:query(); break; case 4:printf("Showing the ranklist hurts students' self-esteem. Don't do that."); break; case 5:statistics(); break; default:return 0; } } return 0; }
static void qctrl_get(int id) { qctrl.id = id; if (ioctl(fd, VIDIOC_QUERYCTRL, &qctrl) == 0) { deal_qctrl(&qctrl); if (qctrl.type == V4L2_CTRL_TYPE_MENU) { int idx; struct v4l2_querymenu menu; for (idx = qctrl.minimum; idx <= qctrl.maximum; idx++) { menu.id = qctrl.id; menu.index = idx; if (ioctl(fd, VIDIOC_QUERYMENU, &menu)==0) { print_menu(&menu); } } } } }
/*********************************************************************//** * @brief c_entry: Main program body * @param[in] None * @return int **********************************************************************/ int c_entry (void) { /* Initialize debug via UART0 * – 115200bps * – 8 data bit * – No parity * – 1 stop bit * – No flow control */ debug_frmwrk_init(); // print welcome screen print_menu(); //Use P0.0 to test System Tick interrupt GPIO_SetDir(1, (1<<28), 1); //Set P0.0 as output _DBG("Remapping Vector Table at address: "); _DBH32(VTOR_OFFSET); _DBG_(""); NVIC_SetVTOR(VTOR_OFFSET); /* Copy Vector Table from 0x00000000 to new address * In ROM mode: Vector Interrupt Table is initialized at 0x00000000 * In RAM mode: Vector Interrupt Table is initialized at 0x10000000 * Aligned: 256 words */ #if(__RAM_MODE__==0)//Run in ROM mode memcpy(VTOR_OFFSET, 0x00000000, 256*4); #else memcpy(VTOR_OFFSET, 0x10000000, 256*4); #endif _DBG_("If Vector Table remapping is successful, LED P1.28 will blink by using SysTick interrupt"); //Initialize System Tick with 100ms time interval SYSTICK_InternalInit(100); //Enable System Tick interrupt SYSTICK_IntCmd(ENABLE); //Enable System Tick Counter SYSTICK_Cmd(ENABLE); while(1); return 1; }
/*Menu is the method for showing some interface for the end user to interact with*/ void menu() { int option = 0; /*We Print the Menu navigation chart*/ print_menu(); scanf("%i",&option); /*If for selecting where we go in the program*/ if (option ==1) { /*Call are function for reading in the files*/ read_files(); } else if (option == 2) { /*Debug method for printing out the text files left it in as it can be useful later*/ print_linkedlists(); } else if (option == 3) { /*This method is used to print out the finished, unfinished and not started competitors*/ entrants_pos(e_times,e_entrants,e_courses,e_nodes); } else if (option == 4) { /*The function below is for getting the progress of 1 specific competitor*/ printf("Please enter the competitor number of the competitor you would like to query\n\n"); int i = 0; scanf("%i",&i); queary_entrant(i,e_courses,c_competitors); } else if (option == 5) { /*Sort method for the list of competitors*/ queary_entrant(-1,e_courses,c_competitors); comp_sort(c_competitors); } else if (option == 6) { /*Add another time for the components to be taken into account*/ add_time(); } menu(); }
int main(int ac, char **av) { FILE *base; if (ac < 1) { if ((base = fopen ("arch/x86/Kconfig", "r")) == NULL) { //Kernel < 2.6.24 with old arch conf_parse("arch/i386/Kconfig"); } else { conf_parse("arch/i386/Kconfig"); fclose(base); } } else conf_parse(av[1]); print_menu(&rootmenu); return 0; }
void main( void ) { init_uart(); while(1) { print_menu(); switch(read_uart()) { case '1': write_eeprom(1); break; case '2': read_eeprom(1); break; case '3': clear_eeprom(); break; case '4': write_eeprom(0); read_eeprom(0); break; default: writeln_uart("wrong input\r\n"); break; } } }
void print_menu(struct menu *menu) { struct menu *child; struct symbol *sym; for (child = menu->list; child; child = child->next) { sym = child->sym; if (menu_has_help(menu)) { if (sym && sym->name) { printf("%s\n{{{\n", sym->name); printf("%s", _(menu_get_help(menu))); //_( == gettext printf("}}}\n"); } } print_menu(child); } }
void disp_menu(SDL_Surface *screen) { TTF_Font *font; if (TTF_Init() < 0) { fprintf(stderr, "TTF error : %s\n", TTF_GetError()); exit(EXIT_FAILURE); } font = TTF_OpenFont(MENU_FONT, FONT_SIZE); if (!font) { fprintf(stderr, "TTF error : %s\n", TTF_GetError()); exit(EXIT_FAILURE); } print_menu(screen, font); SDL_Flip(screen); TTF_CloseFont(font); TTF_Quit(); }
static void print_menu(const char *indent, char *menu_id, gui_menu *menu) { char child_indent[16]; unsigned i; pj_ansi_snprintf(child_indent, sizeof(child_indent), "%s ", indent); printf("%s%s: %s\n", indent, menu_id, menu->title); for (i=0; i<menu->submenu_cnt; ++i) { char child_id[10]; pj_ansi_sprintf(child_id, "%s%u", menu_id, i); if (!menu->submenus[i]) puts(""); else print_menu(child_indent, child_id, menu->submenus[i]); } }
int c_entry() { uint8_t ch; // int retval = 0; UART_Init(); // baudrate: 115200 print_menu(); while(1) { _PRINT_("\r\n>"); ch = _GET_C; _PRINT_C(ch); _PRINT_(""); // new line switch(ch) { case 'u': case 'U': _PRINT_("Upload User Application Firmware"); if (0 == uploadApp()) runNewApp(); break; case 'a': case 'A': _PRINT_("Read Current App Version ID..."); break; case 'b': case 'B': _PRINT_("Read Current Bootloader Version ID..."); break; case 'q': case 'Q': goto end_program; default: continue; } } end_program: while(1); }
void stat_menu(t_game *g) { int press; print_menu(g); press = getch(); if (press == 'c' && g->start) g->stat = 1; else if (press == 'n') { if (!g->start) g->start = 1; else ft_restart(g); g->stat = 1; } else if (press == 's') g->stat = 4; else if (press == 27) ft_del_game(&g); }
static int run_menu(const menu_opt_t menu[], const int entries) { int ret, exit_menu = 0; do { print_menu(menu, entries); ret = read_opt(); if (ret == CTRL_C) exit_menu = 1; else { printf("%c\n", ret); ret = process_menu_otpion(menu, entries, ret); if (CTRL_C == ret || ret == USER_CANCEL) exit_menu = 1; else exit_menu = !ret; } } while (!exit_menu); return ret; }