Esempio n. 1
0
void status_ad(void) {
	top_off_status_display();
	menu_next(UP);
	menu_prev(DOWN);
	menu_submenu_next(SET);
	menu_top(ESC);
}
Esempio n. 2
0
void menu_screen(lmLedMatrix *matrix, double elapsed) {
    if (encoder.value / ENCODER_EDGE > 1) {
        menu_next();
#ifdef DEBUG
        printf("next ->\n");
#endif
        encoder.value = 0;
    } else if (encoder.value / ENCODER_EDGE < -1) {
        menu_previous();
#ifdef DEBUG
        printf("previous ->\n");
#endif
        encoder.value = 0;
    }

    lm_matrix_clear(matrix);

    menu_t current = menus[current_menu];

    if (next_direction == NOTHING) {
        current_x = 0; // Nothing to do
    } else {
        menu_t next = menus[next_menu];

        move_menu(elapsed, next_direction);
        next.screen(matrix, (int16_t) round(next_x), 0, elapsed, next.user_data);
    }

    current.screen(matrix, (int16_t) round(current_x), 0, elapsed, current.user_data);

    lm_matrix_swap_buffers(matrix);
}
Esempio n. 3
0
void status_temp(void) {
	ui_temp_status_display();
	menu_next(UP);
	menu_prev(DOWN);
	menu_submenu_next(SET);
	menu_top(ESC);
}
Esempio n. 4
0
void status_outputs(void) {
	ui_outputs_status_display();
	menu_next(UP);
	menu_prev(DOWN);
	menu_submenu_next(SET);
	menu_top(ESC);
}
Esempio n. 5
0
void status_rotate (void) {

    uint8_t curRotate;
    curRotate = seconds/10;

    if (curRotate != oldRotate) {
        hd44780_clear();
        oldRotate = curRotate;
    }

 	switch (seconds/10) {
 		case 0:
 		case 3:
				ui_outputs_status_display();
				break;
		case 1:
		case 4:
				top_off_status_display();
				break;
 		default:
				ui_temp_status_display();
				break;
 	}
	menu_next(UP);
	menu_prev(DOWN);
	menu_submenu_next(SET);
}
Esempio n. 6
0
void fsm_right_button(){
    switch (g_state) {
        case STATE_MENU:
			if(menu_next()){
                play_melody(MENU_SOUND);
			}
			_delay_ms(50);
  
            if(menu_get_index() == 0){
                if(menu_get_arrow_position == 2){
                    oled_print_pong();
                }
                else if(menu_get_arrow_position() == 3){
                    oled_print_game_over();
                }
            }
            else if(menu_get_index() == 4){
                g_state = STATE_CALIBRATE;
            }
            else if(menu_get_index() == 6){
                g_state = STATE_DEBUG;
            }
            else if(menu_get_index() == 7){
                g_game_melody = menu_get_arrow_position();
                play_melody(g_game_melody);
            }
            else if(menu_get_index() == 2){
                new_game(JOYSTICK);
            }
            else if(menu_get_index() == 3){
                new_game(PLAYSTATION);
            }
            break;
        case STATE_GAME: // Send pulse to solenoid
            set_bit(DDRD, PD4);
            _delay_ms(200);
            clear_bit(DDRD,PD4);
            break;
        case STATE_GAME_OVER:
			break;
		case STATE_CALIBRATE:
			joy_calibrate();
            break;
        case STATE_DEBUG:
            if(menu_get_arrow_position() == 1){
                send_state(STATE_DEBUG);
                printf("Debug Mode\n");
            }
            break;
        case STATE_PID:
            
            break;
        default:
            break;
    }
}
Esempio n. 7
0
void ui_menu_0(void) {
	PGM_P p;
	hd44780_outdata(menu_menuid() + 0x30);
	memcpy_P(&p, &MENU0_STRS[menu_menuid()], sizeof(PGM_P));
	hd44780_outstrn_P(p);
	menu_next(UP);
	menu_prev(DOWN);
	menu_top(ESC);
	menu_submenu_next(SET);
}
Esempio n. 8
0
void fsm_joy_right(){
    switch (g_state) {
        case STATE_MENU:
            if(menu_next()){
                play_melody(MENU_SOUND);
			}
            if(menu_get_index() == 0){
                if(menu_get_arrow_position == 2){
                    oled_print_pong();
                }
                else if(menu_get_arrow_position() == 3){
                    oled_print_game_over();
                }
            }
            else if(menu_get_index() == 4){
                g_state = STATE_CALIBRATE;
            }
			else if(menu_get_index() == 6){
				g_state = STATE_DEBUG;
			}
			else if(menu_get_index() == 7){
				g_game_melody = menu_get_arrow_position();
				play_melody(g_game_melody);
			}
			else if(menu_get_index() == 2){
				new_game(JOYSTICK);
			}
			else if(menu_get_index() == 3){
				new_game(PLAYSTATION);
			}
            break;
        case STATE_GAME:
            break;
        case STATE_GAME_OVER:
			break;
		case STATE_CALIBRATE:
            break;
        case STATE_DEBUG:
			if(menu_get_arrow_position() == 1){
				send_state(STATE_DEBUG);
				printf("Debug Mode\n");
			}
            break;
        case STATE_PID:
            
            break;
        default:
            break;
    }
}
Esempio n. 9
0
int menu_handle_button(const struct menu_item *i)
{
	tHostMsg* pOutgoingMsg;
    switch(i->type)
	{
	case menu_msg:
		BPL_AllocMessageBuffer(&pOutgoingMsg);
		pOutgoingMsg->Type = i->u.imsg.msg;
		pOutgoingMsg->Options = i->u.imsg.Options;
		RouteMsg(&pOutgoingMsg);
		break;
	case menu_menu:
		if((i->flags & MENU_ITEM_MENU_PUSH) == MENU_ITEM_MENU_PUSH)
		{
			menu_push(i->u.imenu.menuptr);
		} else if((i->flags & MENU_ITEM_MENU_NEXT) == MENU_ITEM_MENU_NEXT)
		{
			menu_next(i->u.imenu.menuptr);
		}
		break;
	case menu_action:
		if(i->u.iaction.action)
		{
			i->u.iaction.action();
		}
		break;
	case menu_icon_action:
		if(i->u.iiconaction.action)
		{
			i->u.iiconaction.action();
		}
		break;
	case menu_text_action:
		if(i->u.itext.action)
		{
			i->u.itext.action(i->u.itext.id);
		}
	default:
		break;
	}
    if((i->flags & MENU_FLAG_UPDATE) == MENU_FLAG_UPDATE)
	{
		return 1;
	}
        return 0;
}
Esempio n. 10
0
static void ex_tab(void *none, Keyarg *arg)
{
  log_msg("EXCMD", "TAB");
  if (ex.cmd.cmds && ex_cmd_state() & EX_EXEC)
    return;

  char *line = menu_next(ex.menu, arg->arg);
  if (!line)
    return;

  char *instr = escape_shell(line);
  int len = strlen(instr);
  int slen = strlen(ex.line);
  int st = compl_cur_pos() - 1;
  int ed = 0;

  if (st == -1)
    st = 0;
  if (ex.line[st] == ' ')
    st++;

  bool quote = false;
  char ch;
  while ((ch = ex.line[st+ed])) {
    if ((ch == '|' || ch == ' ') && !quote)
      break;
    if (ch == '\'' || ch == '\"')
      quote = !quote;
    ed++;
  }

  if (slen + len >= ex.maxpos)
    ex.line = realloc(ex.line, ex.maxpos = (2*ex.maxpos)+len);

  str_ins(ex.line, instr, st, ed);
  ex.curofs = st + len;
  ex.curpos = st + cell_len(instr);
  ex.state = EX_CYCLE;

  free(line);
  free(instr);
}
Esempio n. 11
0
/**
 * Navigate state.
 * Navigates the menu structure using the following buttons:
 *  - up => go to previous item
 *  - down => go to next item
 *  - left => go to parent item
 *  - right => go to child item
 */
static QState mmi_navigate(struct mmi_ao *me)
{
    switch (Q_SIG(me)) {
    case Q_ENTRY_SIG:
        update_screen(me);
        return Q_HANDLED();
    case Q_EXIT_SIG:
        return Q_HANDLED();
    case SIG_ENCODER:
        switch (menu_cur->typ) {
        case MENU_TYP_PARAM:
            if (modify_param(menu_cur->param, Q_PAR(me), me->shift)) {
                print_param(menu_cur->param);
                if (menu_cur->cmd != CMD_NONE)
                    QActive_post((QActive *) me, SIG_MMI_CMD, menu_cur->cmd);
            }
            break;
        default:
            break;
        }
        return Q_HANDLED();
    case SIG_MMI_CMD:
        return execute_cmd(me, Q_PAR(me));
    case SIG_MMI_SHOW_MSG:
        return Q_TRAN(mmi_show_msg);
    case SIG_KEY_PRESS:
        switch (Q_PAR(me)) {
        case KEY_UP:
            // Go to previous item
            if (menu_prev())
                update_screen(me);
            break;
        case KEY_DOWN:
            // Go to next item
            if (menu_next())
                update_screen(me);
            break;
        case KEY_LEFT:
            // Go to parent item
            if (menu_parent())
                update_screen(me);
            break;
        case KEY_RIGHT:
            // Go to sub item
            if (menu_sub())
                update_screen(me);
            break;
        case KEY_ENTER:
            me->shift = 1;
            switch (menu_cur->typ) {
            case MENU_TYP_CMD:
                // Execute command
                if (menu_cur->cmd)
                    QActive_post((QActive *) me, SIG_MMI_CMD, menu_cur->cmd);
                break;
            case MENU_TYP_SUB:
                // Go to sub item
                if (menu_sub())
                    update_screen(me);
                break;
            default:
                break;
            }
            break;
        }
        return Q_HANDLED();
    case SIG_KEY_RELEASE:
        switch (Q_PAR(me)) {
        case KEY_ENTER:
            me->shift = 0;
        default:
            break;
        }
        return Q_HANDLED();
    case SIG_PROG_START:
        return Q_TRAN(mmi_busy);
        break;
    }

    return Q_SUPER(&QHsm_top);
}