Example #1
0
/* Check scanned tokens for compliance with config file rules. Return zero
 * if config file complies, non-zero otherwise. Rules are:
 *
 * Global:
 *  1 - no keywords are allowed outside of a section
 *
 * Configuration sections:
 *  2 - may not contain number assignments
 *  3 - must contain certain keywords according to type (see keyword_table)
 *  4 - may not contain certain keywords according to type (see keyword_table)
 *  5 - keywords may be specified at most once
 *  6 - must contain at least one keyword assignment
 *  7 - section name must be unique in the configuration file
 *  8 - defaultboot:default must point to a valid section
 *
 * Menu sections:
 *  9  - must contain at least one number assignment
 *  10 - numbers in number assignment have to be unique in the section
 *  11 - referenced sections must be present
 *  12 - must contain certain keywords according to type (see keyword_table)
 *  13 - may not contain certain keywords according to type (see keyword_table)
 *  14 - keywords may be specified at most once
 *  15 - menu name must be unique in the configuration file
 *  16 - optional default position must be a valid position
 * */
int
scan_check(struct scan_token* scan)
{
	int i;
	int rc;

	i = 0;
	while (scan[i].id != scan_id_empty) {
		switch (scan[i].id) {
		case scan_id_section_heading:
			rc = check_section(scan, &i);
			if (rc)
				return rc;
			break;
		case scan_id_menu_heading:
			rc = check_menu(scan, &i);
			if (rc)
				return rc;
			break;
		default:
			/* Rule 1 */
			error_reason("Line %d: %s not allowed outside of "
				     "section", scan[i].line,
				     scan_id_name(scan[i].id));
			return -1;
		}
	}
	return 0;
}
Example #2
0
void input_tick(void) {
    All * a = global_a;
#line 51
    int count = 0;
    bool any = 0;
    for (int ti = 0; ti < 11; ti += 1) {
        double mx = land_touch_x(ti);
        double my = land_touch_y(ti);
#line 57
        bool holding = land_touch_down(ti);
        bool clicked = holding && land_touch_delta(ti);
        bool released = ! land_touch_down(ti) && land_touch_delta(ti);
#line 61
        if (! holding && ! released) {
            continue;
        }
        if (check_pause_button(mx, my)) {
            if (clicked) {
                input_toggle_pause();
            }
#line 66
            return ;
        }
#line 69
        if (check_title_button(mx, my)) {
            a->show_map = 0;
            main_switch_to_title(0);
#line 71
            return ;
        }
#line 74
        if (check_menu(mx, my, released)) {
            break;
        }
        if (a->overview) {
            overview_click(game->overview, mx, my, clicked, released);
            break;
        }
        if (a->editor) {
            editor_click(mx, my, clicked, released);
            break;
        }
        if (! land_touch_down(ti)) {
            continue;
        }
#line 87
        any = 1;
        count++;
#line 90
        double rr = land_display_width() / 8 * 0.8;
        if (a->dpad == 2 || a->dpad == 3) {
            rr *= 1.5;
        }
        double dx = 0, dy = 0;
#line 96
        if (a->dpad > 3) {
            double p = 0.97;
            if (a->dpad == 4 || (a->dpad == 5 && count == 1)) {
                dx = mx - a->swipex;
                dy = my - a->swipey;
                a->swipex = a->swipex * p + mx * (1 - p);
                a->swipey = a->swipey * p + my * (1 - p);
            }
            if (! a->swipe) {
                a->swipe = 1;
#line 107
                if (a->dpad == 4) {
                    if (land_get_time() < a->swipet + 0.25) {
                        // double tap
                        if (! a->swipej) {
                            a->swipej = 1;
                        }
#line 111
                        else {
                            // after heaving, just push
                            // (so can lift+push, not lift+jump)
#line 115
                            a->swipej = 0;
                        }
                    }
#line 115
                    else {
#line 117
                        a->swipex = mx;
                        a->swipey = my;
                        a->swipej = 0;
                        dx = 0;
                        dy = 0;
                    }
                }
#line 122
                else if (a->dpad == 5) {
                    a->swipex = mx;
                    a->swipey = my;
                    a->swipej = 0;
                    dx = 0;
                    dy = 0;
                }
                a->swipet = land_get_time();
            }
#line 129
            else {
#line 131
                if (a->dpad == 5) {
                    if (count == 1) {
                        a->swipej = 0;
                    }
#line 134
                    if (count > 1) {
                        a->swipej = 1;
                    }
                }
            }
#line 137
            if (a->swipej) {
                a->jump = 1;
            }
        }
#line 138
        else {
#line 140
            double rx = rr;
            if (a->dpad == 1 || a->dpad == 3) {
                rx = land_display_width() - rr;
            }
#line 143
            double ry = land_display_height() - rr;
            if (a->dpad == 1 || a->dpad == 3) {
                rx = land_display_width() - rr;
            }
#line 146
            dx = mx - rx;
            dy = my - ry;
        }
        // move control
        //                  c
        //                 b d
        //                a   e
        //               9     f
        //              8       0
        //               7     1
        //                6   2
        //                 5 3
        //                  4
#line 160
        bool move = 0;
        if (a->dpad == 4 || (a->dpad == 5 && count == 1)) {
            if (dx * dx + dy * dy > rr * rr / 256) {
                move = 1;
            }
        }
#line 164
        if (a->dpad < 4) {
            if ((fabs(dx) < rr && fabs(dy) < rr)) {
                if (dx * dx + dy * dy > rr * rr / 16) {
                    move = 1;
                }
            }
        }
#line 169
        if (move) {
            double ang = atan2(dy, dx);
            // we use 16 subdivisions, the main directions get 12
            // out of that and the diagonals 4
            ang += pi / 16;
            if (ang < 0) {
                ang += pi * 2;
            }
#line 176
            int i = ang * 8 / pi;
            if (i <= 3 || i >= 0xd) {
                a->right = 1;
            }
#line 179
            if (i >= 1 && i <= 7) {
                a->down = 1;
            }
#line 181
            if (i >= 5 && i <= 0xb) {
                a->left = 1;
            }
#line 183
            if (i >= 9) {
                a->up = 1;
            }
#line 185
            a->swipet = land_get_time();
        }
        // jump control
        if (a->dpad == 4 || a->dpad == 5) {
#line 188
            ;
        }
#line 188
        else {
#line 191
            double rx = land_display_width() - rr;
            double ry = land_display_height() - rr;
            if (a->dpad == 1 || a->dpad == 3) {
                rx = rr;
            }
#line 195
            dx = mx - rx;
            dy = my - ry;
            if (dx * dx + dy * dy < rr * rr) {
                a->jump = 1;
            }
        }
    }
#line 200
    if (! any) {
        if (a->dpad == 5) {
            a->swipej = 0;
        }
#line 203
        if (a->dpad == 4) {
            if (a->swipe) {
                a->swipet = land_get_time();
            }
        }
#line 206
        a->swipe = 0;
    }
}
Example #3
0
/**
 *   \brief This is main...
*/
int
main(void)
{
    lcd_init();

    key_init();

    uart_init();

    eeprom_init();

    temp_init();

    timer_init();

    sei();

    lcd_symbol_set(LCD_SYMBOL_RAVEN);
    lcd_symbol_set(LCD_SYMBOL_IP);

    /* Start with main menu */
    read_menu(0);
    /* and draw it */
    lcd_puts_P(menu.text);

    timer_start();

    for (;;){
        /* Make sure interrupts are always on */
        sei();

        /* The one second timer has fired. */
        if(timer_flag){
            timer_flag = false;
            /* Check if main menu needs toggled. */
            check_main_menu();
            /* Update LCD with temp data. */
            if(temp_flag){
                menu_display_temp();
            }
            /* Auto send temp data to 1284p. */
            if(auto_temp){
                menu_send_temp();
            }
            /* If ping mode, send 4 ping requests and then stop. */
            if(ping_mode){
                if((PING_ATTEMPTS == count) && !timeout_flag){
                    count = 0;
                    timeout_count = 0;
                    menu_stop_ping();
                }
                else if(timeout_flag){
                    timeout_flag = false;
                    timeout_count++;
                    /* Display timeout message if all PING_ATTEMPTS were not successful. */
                    if(PING_ATTEMPTS == timeout_count){
                        lcd_puts_P(PSTR("PINGS FAILED"));
                    }
                }
                else{
                    count = menu_send_ping();
                }
            }
        }

        /* Check for button press and deal with it */
        if (is_button()){
            /* Dispatch the button pressed */
            switch (get_button()){
                case KEY_UP:
                    read_menu(menu.up);
                    lcd_puts_P(menu.text);
                    break;
                case KEY_DOWN:
                    read_menu(menu.down);
                    lcd_puts_P(menu.text);
                    break;
                case KEY_LEFT:
                    read_menu(menu.left);
                    lcd_puts_P(menu.text);
                    break;
                case KEY_RIGHT:
                    /*
                     * Check to see if we should show another menu or
                     * run a function
                     */
                    if (!menu.enter_func){
                        /* Just another menu to display */
                        read_menu(menu.right);
                        lcd_puts_P(menu.text);
                        break;
                    }
                    /* Drop through here */
                case KEY_ENTER:
                    /* Call the menu function on right or enter buttons */
                    if (menu.enter_func){
                        menu.enter_func(menu.state);
                        if (menu.state){
                            /*
                             * We just called a selection menu (not a test),
                             * so re-display the text for this menu level
                             */
                            lcd_puts_P(menu.text);
                        }
                        /* After enter key, check the right button menu and display. */
                        read_menu(menu.right);
                        lcd_puts_P(menu.text);
                    }
                    break;
                default:
                    break;
            }
            /* After button press, check for menus... */
            check_menu();
        }
        /* Process any progress frames */
        uart_serial_rcv_frame(false);
    } /* end for(). */
} /* end main(). */