Exemplo n.º 1
0
Arquivo: kitt.c Projeto: built/kitt
int main(void)
{
    configure_teensy();
    configure_LEDs();
    configure_usb();

    int16_t lastcmd = '\0', cmd = '\0';

    while (1)
    {
        wait_for_usb_connection();

        while (1)
        {
            cmd = usb_serial_getchar();

            if(is_valid_control_key(cmd))
            {
                if(cmd == '+') adjust_speed(-10); // Speed up == less time.
                else if(cmd == '-') adjust_speed(10);
            }

            if( is_valid_cmd(cmd) )
            {
                lastcmd = cmd;
            }

            if(lastcmd == 'k') knight_rider();
            else if(lastcmd == 's') step();
            else if(lastcmd == 'f') follow();
            else if(lastcmd == '0') nop();
            else demo();
        }
    }
}
Exemplo n.º 2
0
XCamReturn
AiqAwbHandler::analyze (X3aResultList &output)
{
    ia_aiq  *ia_handle = NULL;
    ia_aiq_awb_results *awb_ret = NULL;
    ia_err ia_error = ia_err_none;

    XCAM_UNUSED (output);

    AnalyzerHandler::HanlderLock lock(this);

    if (!ensure_ia_parameters ()) {
        XCAM_LOG_ERROR ("AIQ AE ensure ia parameters failed");
        return XCAM_RETURN_ERROR_PARAM;
    }

    ia_handle = _aiq_compositor->get_handle ();
    XCAM_ASSERT (ia_handle);
    ia_error = ia_aiq_awb_run (ia_handle, &_input, &awb_ret);
    XCAM_FAIL_RETURN (ERROR, ia_error == ia_err_none, XCAM_RETURN_ERROR_AIQ, "AIQ run AWB failed");

    _result = *awb_ret;
    if (!_started) {
        _history_result = _result;
        _started = true;
    }
    adjust_speed (_history_result);
    _history_result = _result;

    return XCAM_RETURN_NO_ERROR;
}
Exemplo n.º 3
0
// Initialize and start the stepper motor subsystem
void stepper_init() {  
  // Configure directions of interface pins
  STEPPING_DDR |= (STEPPING_MASK | DIRECTION_MASK);
  STEPPING_PORT = (STEPPING_PORT & ~(STEPPING_MASK | DIRECTION_MASK)) | INVERT_MASK;
  
  // waveform generation = 0100 = CTC
  TCCR1B &= ~(1<<WGM13);
  TCCR1B |= (1<<WGM12);
  TCCR1A &= ~(1<<WGM11);
  TCCR1A &= ~(1<<WGM10);

  // output mode = 00 (disconnected)
  TCCR1A &= ~(3<<COM1A0);
  TCCR1A &= ~(3<<COM1B0);

  // Configure Timer 2
  TCCR2A = 0; // Normal operation
  TCCR2B = 0; // Disable timer until needed.
  TIMSK2 |= (1<<TOIE2); // Enable Timer2 interrupt flag
  
  adjust_speed(MINIMUM_STEPS_PER_MINUTE);
  clear_vector(stepper_position);
  stepper_set_position( CONFIG_X_ORIGIN_OFFSET, 
                        CONFIG_Y_ORIGIN_OFFSET, 
                        CONFIG_Z_ORIGIN_OFFSET );
  acceleration_tick_counter = 0;
  current_block = NULL;
  stop_requested = false;
  stop_status = STATUS_OK;
  busy = false;
  
  // start in the idle state
  // The stepper interrupt gets started when blocks are being added.
  stepper_go_idle();  
}
Exemplo n.º 4
0
/** 
 * userspace_adjust_speeds:
 * @cpufreq_objs:	List with with CPU Freq objects
 *
 * Returns:		Result of the call (TRUE/FALSE)
 *
 * calculates current cpu load and traverses all existing interfaces 
 */
gboolean userspace_adjust_speeds(GSList *cpufreq_objs)
{
	GSList *it = NULL;

	HAL_DEBUG(("Adjusting speeds..."));

	if ((calc_cpu_load(DEFAULT_CONSIDER_NICE) < 0)) {
		HAL_DEBUG(("calc_cpu_load failed. Cannot adjust speeds"));
		return TRUE;
	}

	for (it = cpufreq_objs; it != NULL; it = g_slist_next(it)) {
		struct cpufreq_obj *obj = it->data;
		adjust_speed(obj->iface);
	}

	return TRUE;
}
Exemplo n.º 5
0
LRESULT APIENTRY MainWndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
    switch (uMsg)
    {
        case WM_CREATE:
            create_toolbar(hwnd);
            create_term(hwnd);
            create_sysmenu(hwnd);

            return 0;

        case WM_SIZE:
            SendMessage(wndTB, TB_AUTOSIZE, 0, 0);
            get_def_size(LOWORD(lParam), HIWORD(lParam));
            return 0;

        case WM_DESTROY:
            PostQuitMessage(0);
            return 0;

        case WM_COMMAND:
            switch (LOWORD(wParam))
            {
            case BUT_OPEN:
                open_file();
                break;
            case BUT_REWIND:
            but_rewind:
                if (play_state==-1)
                    break;
                EnterCriticalSection(&vt_mutex);
                replay_pause();
                tr.tv_sec=0;
                tr.tv_usec=0;
                set_prog();
                replay_seek();
                LeaveCriticalSection(&vt_mutex);
                play_state=1;
                replay_resume();
                do_replay();
                break;
            case BUT_PAUSE:
                if (play_state==1)
                    goto but_unpause;
            but_pause:
                CancelWaitableTimer(timer);
                replay_pause();
                set_buttons(1);
                break;
            case BUT_PLAY:
                if (play_state>1)
                    goto but_pause;
            but_unpause:
                replay_resume();
                do_replay();
                set_buttons(1);
                break;
            case BUT_SELSTART:
                if (play_state==-1)
                    break;
                get_pos();
                selstart=tr;
                set_prog_sel();
                break;
            case BUT_SELEND:
                if (play_state==-1)
                    break;
                selend=tr;
                set_prog_sel();
                break;
            case BUT_EXPORT:
                if (play_state==-1)
                    break;
                if (tcmp(selstart, selend)>=0)
                    break;
                export_file();
                break;
            }
            return 0;

        case WM_SYSCOMMAND:
            switch (LOWORD(wParam))
            {
            default:
                return DefWindowProc(hwnd, uMsg, wParam, lParam);
            case BUT_FONT:
                choose_font();
            }
            return 0;

        case WM_HSCROLL:
            if ((HANDLE)lParam==wndSpeed)
                speed_scrolled();
            else if ((HANDLE)lParam==wndProg)
                prog_scrolled();
            return 0;

        case WM_KEYDOWN:
            switch (wParam)
            {
            case VK_ADD:
            case 'F':
                adjust_speed(+1);
                break;
            case VK_SUBTRACT:
            case 'S':
                adjust_speed(-1);
                break;
            case '1':
                SendMessage(wndSpeed, TBM_SETPOS, 1, 2);
                speed_scrolled();
                break;
            case 'Q':
                DestroyWindow(wndMain);
                break;
            case 'O':
                open_file();
                break;
            case VK_SPACE:
                switch (play_state)
                {
                case -1:
                    open_file();
                    break;
                case 0:
                    play_state=2;
                    goto but_rewind;
                case 1:
                    goto but_unpause;
                case 2:
                case 3:
                    goto but_pause;
                }
                break;
            case 'R':
                goto but_rewind;
                break;
            case VK_RIGHT:
                adjust_pos(+10);
                break;
            case VK_LEFT:
                adjust_pos(-10);
                break;
            case VK_UP:
                adjust_pos(+60);
                break;
            case VK_DOWN:
                adjust_pos(-60);
                break;
            case VK_PRIOR:
                adjust_pos(+600);
                break;
            case VK_NEXT:
                adjust_pos(-600);
                break;
            }
            return 0;

        case WM_SIZING:
            constrain_size((LPRECT)lParam);
            return 1;

        default:
            return DefWindowProc(hwnd, uMsg, wParam, lParam);
    }
    return 0;
}