void PAGE_TxConfigureEvent()
{
    switch(cp->enable) {
#if HAS_TOUCH
    case CALIB_TOUCH:
        calibrate_touch();
        break;
#endif
    case CALIB_STICK:
        calibrate_sticks();
        break;
    case CALIB_STICK_TEST:
    default: break;
    }
}
Beispiel #2
0
void md_init_no_logo(void)
{
u08 force_setup;

    cli();    // disable interrupts
    hw_init();

#ifdef MOUSE_UART3
sbi(PORTD, 7); cbi(DDRD, 7);   //!!!! mouse uart
sbi(PORTD, 6); sbi(DDRD, 6);   //!!!! mouse uart
#endif

    sei();    // enable interrupts - the Donkey is off and running

    #ifdef TIME_CLOCK
       if(1) {   //!!! for time clock maximum wrap test
          time.hours= 23;
          time.mins = 59;
          time.secs = 00;
          time.month = 12;
          time.day  = 31;
          time.year = 2007;
          time.weekday = 6;
          time.adjust = 0;
       } 
    #endif

#ifdef PANEL_CODE
    lcd_init();          // initialize LCD hardware
    lcd_set_stdout();    // make printf() use bitmapped chars
#endif

#ifdef VCHAR_CODE
//  vchar_init();        // initialize vector characters
//  vchar_set_stdout();  // make printf use vector chars
#endif

    lcd_backlight(0xFF);

    force_setup = 0;
    user_input_init();

#ifdef CKSUM_CODE
    check_flash(DELAY_FLAG);   // verify FLASH checksum - can also add HALT_FLAG
#endif

#ifdef CKPT_CODE
    check_point(0);   // see if last run produced a system RAM checkpoint dump to eeprom
#endif

void contrast_demo(void);
//contrast_demo();

//zadc_demo(2);
//sketch_a_etch();

//void gps_demo(void);
//gps_demo();

//fill_screen(BLACK);
//arc(80,40, 20, 30,170, 10);
//arc(80,40, 10, 40,160, 1);
//wait_until_touched();
//wait_while_touched();


#ifdef USER_INPUT
    delay_ms(10);  // allow some time to pass
	               // might be needed for first get_touch?

    if(get_touch(1) || MouseRB || MouseLB) {   // if screen touched on powerup,  force setup menus
       lcd_clear();
       force_setup = 1;
       set_charsize(3);
       lcd_textPS(0, 0, "Setup");
       set_charsize(1);
//     wait_while_touched();        // not a good idea.  touch cal could be off
       delay_ms(2000);
    }

    calibrate_touch(force_setup);   // calibrate touch screen if not already done 

    misc_setup(force_setup);        // setup backlight, etc, if not already done

    #ifdef UART0   // do com0 setup menu, if not already done or forced setup
       com_setup(0, force_setup);     
    #endif

    #ifdef UART1   // do com1 setup menu, if not already done or forced setup
       com_setup(1, force_setup);
    #endif
#endif   // no user input device: set default com port parameters


// if library build then do donkey splash screen for 2.5 seconds

#ifdef LIBRARY_BUILD
  lcd_clear();
#endif

#ifdef MENU_CODE
 MenuBeep = 1; 
#endif


}
static int input_callback(int fd, short revents, void *data) {
    struct input_event ev;
    int ret;
    int fake_key = 0;

    ret = ev_get_input(fd, revents, &ev);
    if (ret)
        return -1;

    input_device dev;
    dev.fd = fd;
    if(!dev.touch_calibrated)
        dev.touch_calibrated = calibrate_touch(&dev);

    if (ev.type == EV_SYN) {
        if (ev.code == SYN_MT_REPORT) {
            dev.saw_mt_report = 1;
            if (!dev.saw_mt_tracking_id) {
                if (dev.saw_pos_x && dev.saw_pos_y) {
                    dev.saw_pos_x = 0;
                    dev.saw_pos_y = 0;
                } else
                    handle_release(&dev, &ev);
            }
        }
    } else if (ev.type == EV_REL) {
        if (ev.code == REL_Y) {
            // accumulate the up or down motion reported by
            // the trackball.  When it exceeds a threshold
            // (positive or negative), fake an up/down
            // key event.
            rel_sum += ev.value;
            if (rel_sum > 3) {
                fake_key = 1;
                ev.type = EV_KEY;
                ev.code = KEY_DOWN;
                ev.value = 1;
                rel_sum = 0;
            } else if (rel_sum < -3) {
                fake_key = 1;
                ev.type = EV_KEY;
                ev.code = KEY_UP;
                ev.value = 1;
                rel_sum = 0;
            }
        }
    } else if (ev.type == EV_ABS) {
        switch(ev.code){
            case ABS_MT_SLOT:
                dev.slot_current = ev.value;
                break;
            case ABS_MT_TRACKING_ID:
                dev.saw_mt_tracking_id = 1;
                dev.tracking_id = ev.value;
                if (dev.tracking_id == -1 && dev.slot_current == 0)
                    handle_release(&dev, &ev);
                break;
            case ABS_MT_POSITION_X:
                dev.saw_pos_x = 1;
                if (dev.slot_current != 0) break;
                if(dev.touch_start.x == 0)
                    dev.touch_start.x = dev.touch_pos.x;
                float touch_rel = (float)ev.value / ((float)dev.touch_max.x - (float)dev.touch_min.x);
                dev.touch_pos.x = touch_rel * gr_fb_width();
                if (dev.touch_start.x == 0) break; //first touch.
                diff_x += dev.touch_pos.x - dev.touch_start.x;
                if (abs(diff_x) > abs(diff_y) && dev.touch_pos.y < (gr_fb_height() - virtualkey_h)) {
                    if(diff_x > min_x_swipe_px) {
                        dev.slide_right = 1;
                    } else if (diff_x < -min_x_swipe_px) {
                        dev.slide_left = 1;
                    }
                }
                break;
            case ABS_MT_POSITION_Y:
                dev.saw_pos_y = 1;
                if (dev.slot_current != 0) break;
                if(dev.touch_start.y == 0)
                    dev.touch_start.y = dev.touch_pos.y;
                touch_rel = (float)ev.value / ((float)dev.touch_max.y - (float)dev.touch_min.y);
                dev.touch_pos.y = touch_rel * gr_fb_height();
#ifdef USE_VIRTUAL_KEY
                ui_get_virtualkey_pressed(&dev);
#endif
                if (dev.touch_start.y == 0) break; //first touch.
                diff_y += dev.touch_pos.y - dev.touch_start.y;
                if (abs(diff_y) >= abs(diff_x) && dev.touch_pos.y < (gr_fb_height() - virtualkey_h)) {
                    if (diff_y > min_y_swipe_px) {
                        ev.type = EV_KEY;
                        ev.code = KEY_VOLUMEDOWN;
                        ev.value = 2;
                        reset_touch(&dev);
                    } else if (diff_y < -min_y_swipe_px) {
                        ev.type = EV_KEY;
                        ev.code = KEY_VOLUMEUP;
                        ev.value = 2;
                        reset_touch(&dev);
                    }
                }
                break;
            default:
                break;
        }
    } else if (ev.type == EV_KEY) {
        if (dev.saw_mt_report && dev.saw_mt_tracking_id && ev.code == BTN_TOUCH && ev.value == 0)
            handle_release(&dev, &ev);
    } else {
        rel_sum = 0;
    }

    if (ev.type != EV_KEY || ev.code > KEY_MAX)
        return 0;

    if (ev.value == 2) {
        boardEnableKeyRepeat = 0;
    }

    pthread_mutex_lock(&key_queue_mutex);
    if (!fake_key) {
        // our "fake" keys only report a key-down event (no
        // key-up), so don't record them in the key_pressed
        // table.
        key_pressed[ev.code] = ev.value;
    }
    const int queue_max = sizeof(key_queue) / sizeof(key_queue[0]);
    if (ev.value > 0 && key_queue_len < queue_max) {
        key_queue[key_queue_len++] = ev.code;

        if (boardEnableKeyRepeat) {
            struct timeval now;
            gettimeofday(&now, NULL);

            key_press_time[ev.code] = (now.tv_sec * 1000) + (now.tv_usec / 1000);
            key_last_repeat[ev.code] = 0;
        }

        pthread_cond_signal(&key_queue_cond);
    }
    pthread_mutex_unlock(&key_queue_mutex);

    if (ev.value > 0 && device_reboot_now(key_pressed, ev.code)) {
        reboot_main_system(ANDROID_RB_RESTART, 0, 0);
    }

    return 0;
}