menu_t* parse_dreh_event(menu_t* menu) { switch (event(POP,DREH_E)) { case IDLE: break; case DREH_CW: menu = menu_handler(menu->next); break; case DREH_CCW: menu = menu_handler(menu->previous); break; case DREH_PUSH: menu = menu_handler(menu->enter); break; } return menu; }
/***************************************************************************** ** Function name: UART_IRQHandler ** ** Descriptions: UART interrupt handler ** ** parameters: None ** Returned value: None ** *****************************************************************************/ void UART_IRQHandler(void) { uint8_t IIRValue, LSRValue; uint8_t Dummy = Dummy; IIRValue = LPC_UART->IIR; IIRValue >>= 1; /* skip pending bit in IIR */ IIRValue &= 0x07; /* check bit 1~3, interrupt identification */ if (IIRValue == IIR_RLS) /* Receive Line Status */ { LSRValue = LPC_UART->LSR; /* Receive Line Status */ if (LSRValue & (LSR_OE | LSR_PE | LSR_FE | LSR_RXFE | LSR_BI)) { /* There are errors or break interrupt */ /* Read LSR will clear the interrupt */ UARTStatus = LSRValue; Dummy = LPC_UART->RBR; /* Dummy read on RX to clear interrupt, then bail out */ return; } if (LSRValue & LSR_RDR) /* Receive Data Ready */ { /* If no error on RLS, normal ready, save into the data buffer. */ /* Note: read RBR will clear the interrupt */ UARTBuffer[UARTCount++] = LPC_UART->RBR; menu_handler(UARTBuffer[UARTCount-1]); if (UARTCount == BUFSIZE) { UARTCount = 0; /* buffer overflow */ } } } else if (IIRValue == IIR_RDA) /* Receive Data Available */ { /* Receive Data Available */ UARTBuffer[UARTCount++] = LPC_UART->RBR; menu_handler(UARTBuffer[UARTCount-1]); if (UARTCount == BUFSIZE) { UARTCount = 0; /* buffer overflow */ } } else if (IIRValue == IIR_CTI) /* Character timeout indicator */ { /* Character Time-out indicator */ UARTStatus |= 0x100; /* Bit 9 as the CTI error */ } else if (IIRValue == IIR_THRE) /* THRE, transmit holding register empty */ { /* THRE interrupt */ LSRValue = LPC_UART->LSR; /* Check status in the LSR to see if valid data in U0THR or not */ if (LSRValue & LSR_THRE) { UARTTxEmpty = 1; } else { UARTTxEmpty = 0; } } return; }
void main_menu() { int y=yres/2-210; ico_button *list=make_conditional_buttons(xres-51,y); list=make_default_buttons(xres-51,y,list); input_manager *inm=new input_manager(screen,eh,list); inm->allow_no_selections(); inm->clear_current(); time_marker old_time; screen->add_dirty(0,0,xres-1,yres-1); int eoff=0,coff=0; event ev; #ifdef __MAC__ int command = 0; #endif int state=0,stop_menu=0; time_marker start; eh->flush_screen(); do { time_marker new_time; if (eh->event_waiting()) { do { eh->get_event(ev); } while (ev.type==EV_MOUSE_MOVE && eh->event_waiting()); inm->handle_event(ev,NULL,eh); #ifdef __MAC__ if ((ev.type==EV_KEY || ev.type==EV_KEYRELEASE) && ev.key==JK_COMMAND) command = (ev.type == EV_KEY); if (ev.type==EV_KEY && ev.key=='q' && command) eh->push_event(new event(ID_QUIT,NULL)); #else if (ev.type==EV_KEY && ev.key==JK_ESC) eh->push_event(new event(ID_QUIT,NULL)); #endif menu_handler(ev,inm); start.get_time(); eh->flush_screen(); } if (new_time.diff_time(&start)>22) { if (volume_window) start.get_time(); else { if (!current_demo) { void *d=make_find_symbol("demos"); if (DEFINEDP(symbol_value(d))) current_demo=symbol_value(d); } if (current_demo) { demo_man.set_state(demo_manager::PLAYING,lstring_value(CAR(current_demo))); stop_menu=1; current_demo=CDR(current_demo); } } } if (volume_window) stop_menu=0; // can't exit with colume window open else if (main_net_cfg && main_net_cfg->restart_state()) stop_menu=1; else if (the_game->state==RUN_STATE) stop_menu=1; else if (ev.type==EV_MESSAGE) { if (ev.message.id==ID_START_GAME || ev.message.id==ID_RETURN) stop_menu=1; else if (ev.message.id==ID_QUIT) { #ifdef __MAC__ stop_menu=1; #else if (confirm_quit()) stop_menu=1; else { ev.type=EV_SPURIOUS; start.get_time(); } #endif } } } while (!stop_menu); delete inm; if (ev.type==EV_MESSAGE && ev.message.id==ID_QUIT) // propogate the quit message the_game->end_session(); }
/********************** Function implementations *************************/ void menu_task(void *pvParameters) { menu_t *menu; INT8U i; //setup menus init_menus(); menu = menu_handler(SYSTEM_START_MENU); red_led( FALSE ); yellow_led( FALSE ); green_led( FALSE ); //setup initial system parameters parameter(PUSH,PAN_SETPOINT_P,0); parameter(PUSH,TILT_SETPOINT_P,0); parameter(PUSH,PAN_PWM_P,0); parameter(PUSH,TILT_PWM_P,0); parameter(PUSH,NEXT_POS_P,0); parameter(PUSH,SAVE_POS_P,0); // position(NEW,0); parameter(PUSH,PAN_CURRENT_P,-150); parameter(PUSH,TILT_CURRENT_P,860); position(SAVE,1); parameter(PUSH,PAN_CURRENT_P,150); parameter(PUSH,TILT_CURRENT_P,-2600); position(SAVE,2); exit_freemode(); deactivate_regulator(); deactivate_automode(); while(TRUE) { //handle inputs menu = parse_dreh_event(menu); if(menu->type.is_input) { for(i = 0 ; i < NUMBER_OF_FIELDS ; i++) { if(menu->field[i].dreh_input) parameter(ADD, menu->field[i].parameter, DREH_TO_DEG(counter(RESET,DREH_C)) ); if(menu->field[i].adc_input) parameter(PUSH, menu->field[i].parameter, ADC_TO_DEG(get_adc()) ); if(menu->field[i].numpad_input) if(event(PEEK,NUMPAD_E)) parameter(PUSH, menu->field[i].parameter, CHAR_TO_NUMBER(event(POP,NUMPAD_E) )); } } //update display buffer display_buffer_write_string(0,0,menu->text.topline); display_buffer_write_string(0,1,menu->text.bottomline); for(i=0 ; i < NUMBER_OF_FIELDS ; i++) { if(menu->field[i].show) display_buffer_write_decimal( menu->field[i].begin.x, menu->field[i].begin.y, menu->field[i].size, NUMBER_OF_DECIMALS, parameter(POP,menu->field[i].parameter)); } //handle task states if(state(POP,AUTO_WAIT_S)) { //check if wait time has lapsed if(counter(POP,TIME_C) > TIME_TO_WAIT_ON_HIT) { //change to next position and resume regulation if(parameter(ADD,NEXT_POS_P,1) > NUMBER_OF_POSITIONS) parameter(PUSH,NEXT_POS_P,1); position(GOTO,parameter(POP,NEXT_POS_P)); state(PUSH,AUTO_WAIT_S,FALSE); red_led( FALSE ); activate_automode(); activate_regulator(); } else red_led( TRUE ); } YIELD(YIELD_TIME_MENU_T) } }
void main_menu() { image *Earth=cash.img(earth); image *Emap=cash.img(earth_mask); char name[20]; ico_button *buts[MENU_TICONS]; long maxx=0,maxy=0; int i=0; for (;i<MENU_TICONS;i++) { sprintf(name,"icon%04d.pcx",i*3+1); menu_icons[i*3]=cash.reg("art/icons.spe",name,SPEC_IMAGE,1); sprintf(name,"icon%04d.pcx",i*3+2); menu_icons[i*3+1]=cash.reg("art/icons.spe",name,SPEC_IMAGE,1); sprintf(name,"icon%04d.pcx",i*3+2); menu_icons[i*3+2]=cash.reg("art/icons.spe",name,SPEC_IMAGE,1); long x=WINDOW_FRAME_LEFT+(i%9)*cash.img(menu_icons[0])->width(); long y=WINDOW_FRAME_TOP+(i/9)*cash.img(menu_icons[0])->height(); if (x>maxx) maxx=x; if (y>maxy) maxy=y; buts[i]=new ico_button(x,y,menu_icons_ids[i], menu_icons[i*3],menu_icons[i*3], menu_icons[i*3+1],menu_icons[i*3+2],NULL); } buts[0]->next=buts[1]; int b1,b2,b3,b4; if (DEFINEDP(symbol_value)) { if (symbol_value(l_difficulty)==l_extreme) { b1=18; b2=10; b3=12; b4=14; } else if (symbol_value(l_difficulty)==l_hard) { b1=14; b2=18; b3=10; b4=12; } else if (symbol_value(l_difficulty)==l_easy) { b1=10; b2=12; b3=14; b4=18; } else { b1=12; b2=14; b3=18; b4=10; } } else { b1=12; b2=14; b3=18; b4=10; } buts[b1]->next=buts[b2]; buts[b2]->next=buts[b3]; buts[b3]->next=buts[b4]; buts[1]->next=new ico_switch_button(buts[0]->X(), buts[0]->Y()+cash.img(menu_icons[0])->height()*2, ID_NULL, buts[b1],buts[17]); buts[17]->next=buts[8]; buts[1]->set_xy(buts[0]->X(), buts[0]->Y()+cash.img(menu_icons[0])->height()*1); buts[12]->set_xy(buts[0]->X(), buts[0]->Y()+cash.img(menu_icons[0])->height()*2); buts[17]->set_xy(buts[0]->X(), buts[0]->Y()+cash.img(menu_icons[0])->height()*3); buts[8]->set_xy(buts[0]->X(), buts[0]->Y()+cash.img(menu_icons[0])->height()*4); ico_win=eh->new_window(-1,yres/2-80,-1,-1,buts[0],"Menu"); // pmenu *main_pm=new pmenu(0,0,game_sub,screen,eh); time_marker old_time; screen->add_dirty(0,0,319,199); // create sphere map mask_line *p=make_mask_lines(Emap,Earth->width()); int eoff=0,coff=0; event ev; // main_pm->draw(screen,eh,1); long x=84,y=60; Cell *v=find_symbol("earth_x"); if (v && DEFINEDP(v)) x=lnumber_value(symbol_value(v)); v=find_symbol("earth_y"); if (v && DEFINEDP(v)) y=lnumber_value(symbol_value(v)); int state=0,stop_menu=0; time_marker start; do { time_marker new_time; if (state || new_time.diff_time(&old_time)>0.15) { old_time.get_time(); scan_map(screen,x,y,Earth,NULL,p,Emap->height(),eoff,coff); if (state) { eoff+=8; coff+=4; } else { eoff+=2; coff+=1; } if (eoff>=320) eoff-=320; if (coff>=320) coff-=320; eh->flush_screen(); } if (eh->event_waiting()) { eh->get_event(ev); start.get_time(); // reset time till demo starts up menu_handler(ev,ico_win); if (ev.type==EV_MOUSE_BUTTON && ev.mouse_button && ev.mouse_move.x>=x && ev.mouse_move.y>=y && ev.mouse_move.x<=x+Emap->width() && ev.mouse_move.y<=y+Emap->height()) { state=1; } else if (ev.type==EV_MOUSE_BUTTON && !ev.mouse_button) state=0; eh->flush_screen(); } if (new_time.diff_time(&start)>10) { if (!current_demo) { void *d=make_find_symbol("demos"); if (DEFINEDP(d)) current_demo=symbol_value(d); } if (current_demo) { if (set_demo_mode(DEMO_PLAY,lstring_value(CAR(current_demo)),eh)) stop_menu=1; current_demo=CDR(current_demo); } } } while (!stop_menu && (ev.type!=EV_MESSAGE || (ev.message.id!=ID_START_GAME && ev.message.id!=ID_QUIT))); for (i=0;i<MENU_TICONS;i++) { ifield *ic=ico_win->inm->unlink(menu_icons_ids[i]); if (i) delete ic; else delete buts[i]; } eh->close_window(ico_win); for (int xx=0;xx<Emap->height();xx++) jfree(p[xx].remap); jfree(p); if (ev.message.id==ID_QUIT) // propogate the quit message the_game->end_session(); // delete main_pm; }