示例#1
0
文件: console.c 项目: AreaScout/vice
static void console_out_character(console_private_t *pcp, const unsigned char ch)
{
    cursor(pcp, CS_SUSPEND);

    if (!pcp->bMarkMode) {
        if (pcp->bIsMarked) {
            unmark_window(pcp);
            pcp->bIsMarked = FALSE;
        }
    }

    if (ch >= 32) {
        pcp->pchWindowBuffer[CALC_POS(pcp, pcp->xPos, pcp->yPos)] = ch;
        draw_current_character(pcp);
        move_forwards(pcp);
    } else {
        /* do we have a backspace? */
        if (ch == 8) {
            move_backwards(pcp);
            pcp->pchWindowBuffer[CALC_POS(pcp, pcp->xPos, pcp->yPos)] = ' ';
            draw_current_character(pcp);
        }

        /* do we have a return? */
        if ( (ch == 13) || (ch == '\n')) {
            pcp->xPos = 0;
            move_downwards(pcp);
        }
    }

    cursor(pcp, CS_RESUME);
}
void pulse_fine_forward(){
    move_forwards(10);
    current_pulse_delay = 200;
    start_pulse_timer(40);
    pulse_fn = pulse_fine_forward;
    is_pulsing = true;
}
示例#3
0
void final_move_to_depo_fn(){
    if (just_entered_state){
        desperation = 0;
        // pulse_forward();
        move_forwards(9);
        debug_red->led_on();
        debug_blue->led_on();
        start_timer(MAIN_STATE_TIMER, 300);
    }
    // check_pulse();
    if (respond_to_timer(SECONDARY_TIMER, GETTING_CLOSER_TO_DEPO)){
        // set in finding_depo_to_skip
        return;
    }
    if (!depository_found()){
        if (direction_of_interest == DIR_LEFT){
            if (respond_to_timer(MAIN_STATE_TIMER, SEARCH_RIGHT_A_BIT)) {
                direction_of_interest == DIR_RIGHT;
                return;
            }
        } 
        if (direction_of_interest == DIR_RIGHT){
            if (respond_to_timer(MAIN_STATE_TIMER, SEARCH_LEFT_A_BIT)) {
                direction_of_interest == DIR_LEFT;
                return;
            }
        }
    } 
    // if (respond_to_tape_on(tape_f, GETTING_CLOSER_TO_DEPO))return;
    if (respond_to_any_bumper_bumped(GETTING_CLOSER_TO_DEPO)) return;
    // if (respond_to_any_bumper_bumped(LIFTING_HOPPER)) return;
}
void pulse_forward(){ // be able to pass in the interval?
    // Serial.println("pulse_forward");
    move_forwards(10);
    current_pulse_delay = 120;
    start_pulse_timer(80);
    pulse_fn = pulse_forward;
    is_pulsing = true;
}
示例#5
0
void getting_closer_to_depo_fn(){
    if (just_entered_state){
        move_forwards(10);
        start_timer(MAIN_STATE_TIMER, 400);
        debug_green->led_on();
    }
    if (respond_to_timer(MAIN_STATE_TIMER, LIFTING_HOPPER)) {
        times_hopper_lifted = 0;
        return;
    }
}
示例#6
0
void moving_forward_fn(){
    if (just_entered_state){
        Serial.println("moving_forward_fn");
        start_timer(MAIN_STATE_TIMER, 1000);
        debug_blue->led_on();
        move_forwards(10);
        // stop_moving();
        // pivot_left(10);
        // pivot_right(10);
    }
    // if (respond_to_key(ROTATING_LEFT)) return;
    if (respond_to_timer(MAIN_STATE_TIMER, NULL_STATE)) return;
    // if (respond_to_any_bumper_bumped(NULL_STATE)) return;
}
示例#7
0
void null_state_fn(){
    if (just_entered_state){
        Serial.println("null_state_fn");
        debug_red->led_on();
        debug_green->led_on();
        debug_blue->led_on();
        move_forwards(8);
    }
    // Serial.println(digitalRead(BUMPER_R_PIN));
    // change_state_to(ROTATING_RIGHT);
    // change_state_to(MOVING_FORWARD);
    // change_state_to(PULSE_ARC_BACK);
    // change_state_to(PULSE_ROTATE_RIGHT);
    // change_state_to(PULSE_FORWARD);
    // change_state_to(EXTENDING_BUTTON_PRESSER);
    // change_state_to(LIFTING_HOPPER);
    change_state_to(FIRST_ROTATE_TO_FIND_SERVER);
    // change_state_to(MOVING_FW_TO_ALIGN_WITH_SERVER);
    // change_state_to(SEARCH_RIGHT_A_BIT);
    // change_state_to(FINDING_DEPO_TO_SKIP);
    // change_state_to(CENTERED_ON_SERVER_TAPE);
    // change_state_to(FINAL_ALIGN_TO_SERVER);
    // if (respond_to_key(LIFTING_HOPPER)) return;
    // if (respond_to_key(FIRST_ROTATE_TO_FIND_SERVER)) return;
    // if (respond_to_any_bumper_bumped( MOVING_FORWARD)) return;
    // if (respond_to_bumper_bumped(bumper_r, MOVING_FORWARD)) return;
    // if (respond_to_bumper_bumped(bumper_l, ROTATING_RIGHT)) return;
    // if (respond_to_bumper_bumped(bumper_r, FIRST_ROTATE_TO_FIND_SERVER)) return;
    // if (respond_to_bumper_bumped(bumper_l, EXTENDING_BUTTON_PRESSER)) return;
    // if (respond_to_both_bumpers_bumped( bumper_l, bumper_r, MOVE_FORWARD)) return;
    // if (respond_to_key(NULL_STATE)) return;
    // if (respond_to_depository_found(DEPO_BEACON_SENSED)) return;
    // if (respond_to_server_found(SERVER_BEACON_SENSED)) return;
    // if (respond_to_tape_on(tape_f, TAPE_F_SENSED)) return;
    // if (respond_to_tape_on(tape_c, TAPE_C_SENSED)) return;
}