int menu_button_handler(unsigned char MsgOptions) { char refresh = 0; if(menu_current() == app_menu) { tHostMsg* pOutgoingMsg; app_menu = NULL; BPL_AllocMessageBuffer(&pOutgoingMsg); pOutgoingMsg->Type = IdleUpdate; RouteMsg(&pOutgoingMsg); } else { if(MsgOptions < MENU_ITEMS) { refresh = menu_handle_button(&(menu_current()->items[MsgOptions])); } else if(MsgOptions == MENU_BUTTON_EXIT) { if(istop()) { tHostMsg* pOutgoingMsg; /* Only save stuff if it's been changed */ /* save all of the non-volatile items */ // FIXME SAVE STUFF!! //BPL_AllocMessageBuffer(&pOutgoingMsg); //pOutgoingMsg->Type = PariringControlMsg; //pOutgoingMsg->Options = PAIRING_CONTROL_OPTION_SAVE_SPP; //RouteMsg(&pOutgoingMsg); //SaveLinkAlarmEnable(); //SaveRstNmiConfiguration(); //SaveIdleBufferInvert(); //SaveDisplaySeconds(); //SaveTimeFormat(); /* go back to the normal idle screen */ BPL_AllocMessageBuffer(&pOutgoingMsg); pOutgoingMsg->Type = IdleUpdate; RouteMsg(&pOutgoingMsg); } else { menu_pop(); refresh = 1; } } } return refresh; }
int main(void) { /* LEDS */ DDRB=0xFF; /* uart*/ uart_init(); // kbd_init(); scheduler_init(); /* ajoute la scrutation du clavier */ // scheduler_add_periodical_event(kbd_get_pressed, 100); /* envoie les caracteres du clavier vers l'uart */ // kbd_register_event(menu_control); /* creation du device */ fdevopen( (int (*)(char)) uart0_send, (int (*)(void))uart0_recv, 0); // se place sur le 1er fils menu_goto(menu_down(menu_current())); menu_print(); sei(); while(1); return 0; }
static adv_error cmd_offvideo_test(int userkey) { adv_crtc* crtc; adv_crtc crtc_save; adv_bool modify = 0; crtc = menu_current(); if (!crtc) return -1; crtc_save = *crtc; modify = test_exe_crtc(userkey, crtc); if (!modify) { sound_warn(); return 0; } menu_modify(); if (strcmp(crtc->name, DEFAULT_TEXT_MODE)==0) { if (!crtc_clock_check(&the_monitor, crtc) && crtc_clock_check(&the_monitor, &crtc_save)) { *crtc = crtc_save; sound_error(); return 0; } text_reset(); } return 0; }
bool tm_window_rep::get_menu_widget (int which, string menu, widget& w) { object xmenu= call ("menu-expand", eval ("'" * menu)); //cout << "xmenu= " << xmenu << "\n"; if (menu_cache->contains (xmenu)) { //if (menu_current[which] == xmenu) cout << "Same " << menu << "\n"; if (menu_current[which] == xmenu) return false; menu_current (which)= xmenu; //cout << "Cached " << menu << "\n"; w= menu_cache [xmenu]; return true; } menu_current (which)= xmenu; //cout << "Compute " << menu << "\n"; object umenu= eval ("'" * menu); w= make_menu_widget (umenu); if (menu_caching) menu_cache (xmenu)= w; return true; }
void menu_print(void) { int8_t brother; // affiche le pere printf("*****************************************\r\n"); printf("%s\r\n",menu_txt(menu_up(menu_current()))); menu_init_brother_list(); while( (brother=menu_get_next_brother_in_list()) != -1 ) { if(menu_current() == brother) printf("-> %s%s\r\n",(menu_is_leaf(brother)?"* ":"> "),menu_txt(brother)); else printf(" %s%s\r\n",(menu_is_leaf(brother)?"* ":"> "),menu_txt(brother)); } }
static void cmd_del(void) { adv_crtc* crtc; crtc = menu_current(); if (!crtc) return; menu_remove(crtc); }
static void cmd_select(void) { adv_crtc* crtc; crtc = menu_current(); if (!crtc) return; crtc->user_flags = crtc->user_flags ^ MODE_FLAGS_USER_BIT0; menu_modify(); }
static adv_error cmd_onvideo_calib(void) { adv_mode mode; adv_crtc* crtc; unsigned speed; char buffer[128]; mode_reset(&mode); if (the_mode_index == MODE_FLAGS_INDEX_TEXT) { error_set("Command supported only in graphics mode"); return -1; } crtc = menu_current(); if (!crtc) return -1; if (!crtc_is_fake(crtc) && !crtc_clock_check(&the_monitor, crtc)) return -1; if (video_mode_generate(&mode, crtc, the_mode_index)!=0) { return -1; } if (text_mode_set(&mode) != 0) { text_reset(); return -1; } video_write_lock(); draw_graphics_palette(); /* draw_graphics_out_of_screen(0); */ draw_graphics_clear(); speed = draw_graphics_speed(0, 0, video_size_x(), video_size_y()); draw_graphics_calib(0, 0, video_size_x(), video_size_y()); snprintf(buffer, sizeof(buffer), " %.2f MB/s", speed / (double)(1024*1024)); draw_string(0, 0, buffer, DRAW_COLOR_WHITE); video_write_unlock(0, 0, 0, 0, 0); video_wait_vsync(); do { target_idle(); os_poll(); } while (inputb_get()==INPUTB_NONE); return 0; }
void DrawMenu() { const struct menu * const menu = menu_current(); FillMyBuffer(STARTING_ROW,PHONE_IDLE_BUFFER_ROWS,0x00); DrawCommonMenuIcons(); DrawItem(&(menu->items[0]), BUTTON_ICON_A_F_ROW,LEFT_BUTTON_COLUMN); DrawItem(&(menu->items[1]), BUTTON_ICON_B_E_ROW,LEFT_BUTTON_COLUMN); DrawItem(&(menu->items[2]), BUTTON_ICON_C_D_ROW,LEFT_BUTTON_COLUMN); DrawItem(&(menu->items[3]), BUTTON_ICON_A_F_ROW,RIGHT_BUTTON_COLUMN); DrawItem(&(menu->items[4]), BUTTON_ICON_B_E_ROW,RIGHT_BUTTON_COLUMN); }
static void cmd_copy(void) { adv_crtc* crtc; adv_crtc copy; crtc = menu_current(); if (!crtc) return; copy = *crtc; crtc_name_set(©, "duplicated"); menu_insert(©); }
static void cmd_rename(void) { adv_crtc* crtc; char buffer[128]; crtc = menu_current(); if (!crtc) return; sncpy(buffer, sizeof(buffer), ""); if (cmd_input_string(" Name : ", buffer, MODE_NAME_MAX)!=0) return; crtc_name_set(crtc, buffer); menu_modify(); }
void menu_config_buttons(void) { struct menu const *m = menu_current(); int i; for(i = 0; i < MENU_ITEMS; ++i) { EnableButtonAction(IDLE_MODE, index2buttonindex[i], m->items[i].ButtonPressType, MenuButtonMsg, index2buttonmsgoption[i]); } EnableButtonAction(IDLE_MODE, SW_C_INDEX, BUTTON_STATE_IMMEDIATE, MenuButtonMsg, MENU_BUTTON_EXIT); }
void menu_control(uint8_t c) { if(c == '0') menu_goto(menu_left(menu_current())); else if(c=='8') menu_goto(menu_right(menu_current())); else if(c=='*') { menu_goto(menu_up(menu_current())); if(menu_current() == 0) menu_goto(menu_down(menu_current())); } else if(c=='#') { if(menu_is_leaf(menu_current())) menu_action(); else menu_goto(menu_down(menu_current())); } menu_print(); }
static adv_error cmd_onvideo_animate(void) { adv_mode mode; adv_crtc* crtc; unsigned i; int counter; mode_reset(&mode); if (the_mode_index == MODE_FLAGS_INDEX_TEXT) { error_set("Command supported only in graphics mode"); return -1; } crtc = menu_current(); if (!crtc) return -1; if (!crtc_is_fake(crtc) && !crtc_clock_check(&the_monitor, crtc)) return -1; if (video_mode_generate(&mode, crtc, the_mode_index)!=0) { return -1; } if (text_mode_set(&mode) != 0) { text_reset(); return -1; } update_init(2); draw_graphics_palette(); for(i=0;i<3;++i) { update_start(); video_clear(update_x_get(), update_y_get(), video_size_x(), video_size_y(), 0); update_stop(update_x_get(), update_y_get(), video_size_x(), video_size_y(), 1); } counter = update_page_max_get(); while (!inputb_hit()) { os_poll(); update_start(); draw_graphics_animate(update_x_get(), update_y_get(), video_size_x(), video_size_y(), counter - update_page_max_get() + 1, 1); ++counter; draw_graphics_animate(update_x_get(), update_y_get(), video_size_x(), video_size_y(), counter, 0); update_stop(update_x_get(), update_y_get(), video_size_x(), video_size_y(), 1); } update_done(); do { target_idle(); os_poll(); } while (inputb_get()==INPUTB_NONE); return 0; }
static adv_error cmd_onvideo_test(void) { adv_crtc* crtc; adv_mode mode; adv_bool done; adv_crtc crtc_save; adv_bool dirty = 1; adv_bool crtc_save_modified; mode_reset(&mode); crtc = menu_current(); if (!crtc) return -1; if (!crtc_is_fake(crtc) && !crtc_clock_check(&the_monitor, crtc)) return -1; if (video_mode_generate(&mode, crtc, the_mode_index)!=0) { return -1; } if (text_mode_set(&mode) != 0) { text_reset(); return -1; } crtc_save = *crtc; crtc_save_modified = the_modes_modified; done = 0; while (!done) { int userkey; adv_bool modify = 0; adv_crtc last_crtc = *crtc; adv_mode last_mode = mode; adv_bool vm_last_modified = the_modes_modified; if (dirty) { video_write_lock(); test_draw(1, 1, &mode); video_write_unlock(0, 0, 0, 0, 0); dirty = 0; } video_wait_vsync(); target_idle(); os_poll(); userkey = inputb_get(); switch (userkey) { case INPUTB_ESC : done = 1; /* restore */ *crtc = crtc_save; the_modes_modified = crtc_save_modified; break; case INPUTB_ENTER : done = 1; break; } if (!done) { modify = test_exe_crtc(userkey, crtc); if (modify) { the_modes_modified = 1; dirty = 1; if ((crtc_is_fake(crtc) || crtc_clock_check(&the_monitor, crtc)) && video_mode_generate(&mode, crtc, the_mode_index)==0) { if (text_mode_set(&mode) != 0) { text_reset(); /* abort */ *crtc = crtc_save; the_modes_modified = crtc_save_modified; return -1; } } else { /* restore */ mode = last_mode; *crtc = last_crtc; the_modes_modified = vm_last_modified; dirty = 1; sound_error(); } } else { sound_warn(); } } } return 0; }