Beispiel #1
0
int main() {
  closure = pi_default_closure();
  pi_gpio_setup(closure);

  pi_gpio_pin_t gpioe = PIN_ENABLE;
  pi_gpio_pin_t gpioa1 = PIN_COIL_A1;
  pi_gpio_pin_t gpioa2 = PIN_COIL_A2;
  pi_gpio_pin_t gpiob1 = PIN_COIL_B1;
  pi_gpio_pin_t gpiob2 = PIN_COIL_B2;

  pin_enable = pi_gpio_claim_output(closure, gpioe, PI_GPIO_HIGH);
  pin_coil_a1 = pi_gpio_claim_output(closure, gpioa1, PI_GPIO_LOW);
  pin_coil_a2 = pi_gpio_claim_output(closure, gpioa2, PI_GPIO_LOW);
  pin_coil_b1 = pi_gpio_claim_output(closure, gpiob1, PI_GPIO_LOW);
  pin_coil_b2 = pi_gpio_claim_output(closure, gpiob2, PI_GPIO_LOW);

  move_forward(5, 356);
  move_backward(30, 45);

  pi_gpio_write(pin_enable, PI_GPIO_LOW);
  pi_gpio_release(pin_enable);
  pi_gpio_release(pin_coil_a1);
  pi_gpio_release(pin_coil_a2);
  pi_gpio_release(pin_coil_b1);
  pi_gpio_release(pin_coil_b2);

  pi_gpio_teardown(closure);

  return 0;
}
Beispiel #2
0
void Legs::move_according_state(){
    /*
    Given the current state, update the moviment.
    */
    switch (get_current_state()) {
        case FORWARD:
        move_forward();
        break;
        case BACKWARD:
        move_backward();
        break;
        case LEFT:
        turn_left();
        break;
        case RIGHT:
        turn_right();
        break;
        case BYELEFT:
        bye_bye_left();
        break;
        case BYERIGHT:
        bye_bye_right();
        break;
        case STOP:
        zero_pos();
        break;
        default:
        zero_pos();
        break;
    }

}
Beispiel #3
0
 static range<I> rotate_right(I begin, I end)
 {
     I lm1 = prev(end);
     iterator_value_t<I> tmp = iter_move(lm1);
     I fp1 = move_backward(begin, lm1, end).second;
     *begin = std::move(tmp);
     return {fp1, end};
 }
Beispiel #4
0
static void
move_to_bottom (void)
{
    while ((*currentpoint != '\0') && (*currentpoint != CHAR_NODE_END))
        currentpoint++;
    currentpoint--;
    move_backward (1);
}
Beispiel #5
0
 static range<I> rotate_right(I begin, I end)
 {
     I lm1 = prev(end);
     auto tmp = std::move(*lm1);
     I fp1 = move_backward(begin, lm1, end).second;
     *begin = std::move(tmp);
     return {fp1, end};
 }
Beispiel #6
0
 inline void linear_insert(I begin, I end, C &pred, P &proj)
 {
     iterator_value_t<I> val = iter_move(end);
     if(pred(proj(val), proj(*begin)))
     {
         move_backward(begin, end, end + 1);
         *begin = std::move(val);
     }
     else
         detail::unguarded_linear_insert(end, std::move(val), pred, proj);
 }
Beispiel #7
0
void			process(t_env *e)
{
	if (e->input->a == 1)
		move_left(e);
	else if (e->input->d == 1)
		move_right(e);
	if (e->input->w == 1)
		move_forward(e);
	else if (e->input->s == 1)
		move_backward(e);
}
Beispiel #8
0
void perform_action(gamestate_t *gs, int action)
{
	switch(action)
	{
		case 0: noop(gs); qbLog("Noop"); break;
		case 1: turn_left(gs); qbLog("turn left"); break;
		case 2: turn_right(gs); qbLog("turn right"); break;
		case 3: move_forward(gs); qbLog("move forward"); break;
		case 4: move_backward(gs); qbLog("move backward"); break;
		case 5: jump(gs); qbLog("jump"); break;
		case 6: shoot(gs); qbLog("shoot"); break;
	}
}
Beispiel #9
0
int			loop_event(t_app *app)
{
	if (app->player.move_forward == 1)
		move_forward(app);
	if (app->player.move_backward == 1)
		move_backward(app);
	if (app->player.turn_left == 1)
		turn_left(app);
	if (app->player.turn_right == 1)
		turn_right(app);
	refresh(app);
	return (0);
}
void loop()
{
    if (Serial.available() > 0)
    {
        int command = Serial.read();
        Serial.print(command, DEC);
        Serial.print(" ");
        switch (command)
        {
            case 1:
            move_stop();
            delay(500);
            move_forward();
            break;
            case 2:
            move_stop();
            delay(500);
            turn_left();
            break;
            case 3:
            move_stop();
            delay(500);
            turn_right();
            break;
            case 4:
            move_stop();
            delay(500);
            move_backward();
            break;
            case 5:
            move_stop();
            break;
            case 6:
            front_led_control(true);
            break;
            case 7:
            front_led_control(false);
            break;
            case 8:
            rear_led_control(true);
            break;
            case 9:
            rear_led_control(false);
            break;
            default:
            move_stop();
            front_led_control(false);
            rear_led_control(false);
        }
    }
}
Beispiel #11
0
int		key_press(int keycode, t_env *e)
{
	if (keycode == KEY_ALPHA_Q)
		move_leftward(e->map, 1);
	else if (keycode == KEY_ALPHA_W)
		move_forward(e->map, 1);
	else if (keycode == KEY_ALPHA_E)
		move_rightward(e->map, 1);
	else if (keycode == KEY_ALPHA_A)
		turn_left(e->map, 1);
	else if (keycode == KEY_ALPHA_S)
		move_backward(e->map, 1);
	else if (keycode == KEY_ALPHA_D)
		turn_right(e->map, 1);
	return (0);
}
Beispiel #12
0
static void
help_prev_link (gboolean move_up)
{
    const char *new_item;

    new_item = select_prev_link (selected_item);
    selected_item = new_item;
    if ((selected_item == NULL) || (selected_item < currentpoint))
    {
        if (move_up)
            move_backward (1);
        else if ((link_area != NULL) && (link_area->data != NULL))
            selected_item = ((Link_Area *) link_area->data)->link_name;
        else
            selected_item = NULL;
    }
}
Beispiel #13
0
int		key_release(int keycode, t_env *e)
{
	if (keycode == KEY_ESC)
		exit(0);
	else if (keycode == KEY_ALPHA_Q)
		move_leftward(e->map, 0);
	else if (keycode == KEY_ALPHA_W)
		move_forward(e->map, 0);
	else if (keycode == KEY_ALPHA_E)
		move_rightward(e->map, 0);
	else if (keycode == KEY_ALPHA_A)
		turn_left(e->map, 0);
	else if (keycode == KEY_ALPHA_S)
		move_backward(e->map, 0);
	else if (keycode == KEY_ALPHA_D)
		turn_right(e->map, 0);
	else if (keycode == KEY_ALPHA_M)
		e->map->is_minimap = !e->map->is_minimap;
	return (0);
}
Beispiel #14
0
static cb_ret_t
help_execute_cmd (unsigned long command)
{
    cb_ret_t ret = MSG_HANDLED;

    switch (command)
    {
    case CK_Help:
        help_help (whelp);
        break;
    case CK_Index:
        help_index (whelp);
        break;
    case CK_Back:
        help_back (whelp);
        break;
    case CK_Up:
        help_prev_link (TRUE);
        break;
    case CK_Down:
        help_next_link (TRUE);
        break;
    case CK_PageDown:
        move_forward (help_lines - 1);
        break;
    case CK_PageUp:
        move_backward (help_lines - 1);
        break;
    case CK_HalfPageDown:
        move_forward (help_lines / 2);
        break;
    case CK_HalfPageUp:
        move_backward (help_lines / 2);
        break;
    case CK_Top:
        move_to_top ();
        break;
    case CK_Bottom:
        move_to_bottom ();
        break;
    case CK_Enter:
        help_select_link ();
        break;
    case CK_LinkNext:
        help_next_link (FALSE);
        break;
    case CK_LinkPrev:
        help_prev_link (FALSE);
        break;
    case CK_NodeNext:
        help_next_node ();
        break;
    case CK_NodePrev:
        help_prev_node ();
        break;
    case CK_Quit:
        dlg_stop (whelp);
        break;
    default:
        ret = MSG_NOT_HANDLED;
    }

    return ret;
}
Beispiel #15
0
static int
help_event (Gpm_Event * event, void *vp)
{
    Widget *w = WIDGET (vp);
    GSList *current_area;
    Gpm_Event local;

    if (!mouse_global_in_widget (event, w))
        return MOU_UNHANDLED;

    if ((event->type & GPM_UP) == 0)
        return MOU_NORMAL;

    local = mouse_get_local (event, w);

    /* The event is relative to the dialog window, adjust it: */
    local.x -= 2;
    local.y -= 2;

    if ((local.buttons & GPM_B_RIGHT) != 0)
    {
        currentpoint = history[history_ptr].page;
        selected_item = history[history_ptr].link;
        history_ptr--;
        if (history_ptr < 0)
            history_ptr = HISTORY_SIZE - 1;

        send_message (w->owner, NULL, MSG_DRAW, 0, NULL);
        return MOU_NORMAL;
    }

    /* Test whether the mouse click is inside one of the link areas */
    for (current_area = link_area; current_area != NULL; current_area = g_slist_next (current_area))
    {
        Link_Area *la = (Link_Area *) current_area->data;

        /* Test one line link area */
        if (local.y == la->y1 && local.x >= la->x1 && local.y == la->y2 && local.x <= la->x2)
            break;

        /* Test two line link area */
        if (la->y1 + 1 == la->y2)
        {
            /* The first line */
            if (local.y == la->y1 && local.x >= la->x1)
                break;
            /* The second line */
            if (local.y == la->y2 && local.x <= la->x2)
                break;
        }
        /* Mouse will not work with link areas of more than two lines */
    }

    /* Test whether a link area was found */
    if (current_area != NULL)
    {
        Link_Area *la = (Link_Area *) current_area->data;

        /* The click was inside a link area -> follow the link */
        history_ptr = (history_ptr + 1) % HISTORY_SIZE;
        history[history_ptr].page = currentpoint;
        history[history_ptr].link = la->link_name;
        currentpoint = help_follow_link (currentpoint, la->link_name);
        selected_item = NULL;
    }
    else if (local.y < 0)
        move_backward (help_lines - 1);
    else if (local.y >= help_lines)
        move_forward (help_lines - 1);
    else if (local.y < help_lines / 2)
        move_backward (1);
    else
        move_forward (1);

    /* Show the new node */
    send_message (w->owner, NULL, MSG_DRAW, 0, NULL);

    return MOU_NORMAL;
}
Beispiel #16
0
void
msg_list_window::add_msgs_page(const msgs_filter* f, bool if_results _UNUSED_)
{
  m_filter = new msgs_filter(*f);
  QFont body_font;
  QFont list_font;
  QByteArray headerview_setup;

  msgs_page* current = m_pages->current_page();
  // current may be null if we're instantiating the first page
  if (current) {
    body_font = m_msgview->font();
    list_font = m_qlist->font();
    if (m_qlist->sender_recipient_swapped())
      m_qlist->swap_sender_recipient(false);    
    headerview_setup = m_qlist->header()->saveState();
  }

  // new splitter
  QStackedWidget* stackw = m_pages->stacked_widget();
  QSplitter* l=new QSplitter(Qt::Vertical, this);
  stackw->addWidget(l);

  m_qlist = new mail_listview(l);
  m_qlist->set_threaded(display_vars.m_threaded);
  m_qlist->m_msg_window=this;
  if (current)
    m_qlist->setFont(list_font);
  m_qlist->init_columns();
  if (current)
    m_qlist->header()->restoreState(headerview_setup);

  if (!m_filter->m_fetched)
    m_filter->fetch(m_qlist);
  else
    m_filter->make_list(m_qlist);
  msg_list_postprocess();

  m_msgview = new message_view(l, this);

  if (current)
    m_msgview->setFont(body_font);

  connect(m_msgview, SIGNAL(on_demand_show_request()), this, SLOT(display_msg_contents()));
  connect(m_msgview, SIGNAL(popup_body_context_menu()), this, SLOT(body_menu()));
  connect(m_msgview, SIGNAL(page_back()), this, SLOT(move_backward()));
  connect(m_msgview, SIGNAL(page_forward()), this, SLOT(move_forward()));

  m_qAttch = new attch_listview(l);
  connect(m_qAttch, SIGNAL(itemDoubleClicked(QTreeWidgetItem*,int)),
	  this, SLOT(attch_selected(QTreeWidgetItem*,int)));
  connect(m_qAttch, SIGNAL(init_progress(const QString)),
	  this, SLOT(install_progressbar(const QString)));
  connect(m_qAttch, SIGNAL(progress(int)), this, SLOT(show_progress(int)));
  connect(m_qAttch, SIGNAL(finish_progress()), this, SLOT(uninstall_progressbar()));
  connect(this, SIGNAL(abort_progress()), m_qAttch, SLOT(download_aborted()));

  // splitter for 3 panes: list of messages / body / attachments list
  static const int splitter_default_sizes[3] = {100,400,25};
  QList<int> lsizes;
  if (current) {
    lsizes = current->m_page_splitter->sizes();
    // don't allow any zero size for panels. This is necessary to avoid having the
    // attachment list being almost invisible to the user
    for (int i=0; i<3; i++) {
      if (lsizes.at(i)==0) {
	lsizes.replace(i, splitter_default_sizes[i]);
      }
    }
  }
  else {
    for (int i=0; i<3; i++) {
      int sz;
      QString key;
      key.sprintf("display/msglist/panel%d_size", i+1);
      if (get_config().exists(key)) {
	sz=get_config().get_number(key);
	if (sz==0)
	  sz=splitter_default_sizes[i];
      }
      else
	sz=splitter_default_sizes[i];
      lsizes.append(sz);
    }
  }

  /* avoid changing the listview's height each time the attachments view
     is shown or hidden */
  l->setStretchFactor(l->indexOf(m_qlist), 0);
  l->setStretchFactor(l->indexOf(m_msgview), 1);
  l->setStretchFactor(l->indexOf(m_qAttch), 0);

  l->setSizes(lsizes);
  m_qAttch->hide();
  m_wSearch=NULL;

  connect(m_qlist,SIGNAL(selection_changed()), this,SLOT(mails_selected()));

  connect(m_qlist,SIGNAL(doubleClicked(const QModelIndex&)),
	  this,SLOT(mail_reply_all()));

  connect(m_qlist, SIGNAL(clicked(const QModelIndex&)),
	  this, SLOT(action_click_msg_list(const QModelIndex&)));

  connect(m_qlist, SIGNAL(scroll_page_down()), m_msgview, SLOT(page_down()));

  if (m_pages->next_page()) {
    // we're in the middle of a page list, and asked to go forward.
    // let's remove all the pages that are after the current position
    m_pages->cut_pages(m_pages->next_page());
  }
  int max_pages=get_config().get_number("msg_window_pages");
  if (max_pages<2) max_pages=2;
  if (m_pages->count() >= max_pages) {
    free_msgs_page();
    if (m_pages->count() >= max_pages) {
      // Still no room for a new page? OK, forget it
      DBG_PRINTF(5,"not enough pages!");
      return;
    }
  }

  // allocate and use a new page
  msgs_page* page = new msgs_page();
  page->m_page_filter = m_filter;
  page->m_page_msgview = m_msgview;
  page->m_page_attach = m_qAttch;
  page->m_page_qlist = m_qlist;
  page->m_page_current_item = NULL;
  page->m_page_splitter = l;
  page->m_msgs_window = this;
  page->m_query_lvitem_id = m_query_lv->current_id();
  m_pages->add_page(page);
  m_pages->raise_page(page);
  m_tags_box->reset_tags();
  enable_forward_backward();
}
Beispiel #17
0
static void
help_mouse_callback (Widget * w, mouse_msg_t msg, mouse_event_t * event)
{
    int x, y;
    GSList *current_area;

    if (msg != MSG_MOUSE_CLICK)
        return;

    if ((event->buttons & GPM_B_RIGHT) != 0)
    {
        /* Right button click */
        help_back (whelp);
        return;
    }

    /* Left bytton click */

    /* The event is relative to the dialog window, adjust it: */
    x = event->x - 1;
    y = event->y - 1;

    /* Test whether the mouse click is inside one of the link areas */
    for (current_area = link_area; current_area != NULL; current_area = g_slist_next (current_area))
    {
        Link_Area *la = (Link_Area *) current_area->data;

        /* Test one line link area */
        if (y == la->y1 && x >= la->x1 && y == la->y2 && x <= la->x2)
            break;

        /* Test two line link area */
        if (la->y1 + 1 == la->y2)
        {
            /* The first line || The second line */
            if ((y == la->y1 && x >= la->x1) || (y == la->y2 && x <= la->x2))
                break;
        }
        /* Mouse will not work with link areas of more than two lines */
    }

    /* Test whether a link area was found */
    if (current_area != NULL)
    {
        Link_Area *la = (Link_Area *) current_area->data;

        /* The click was inside a link area -> follow the link */
        history_ptr = (history_ptr + 1) % HISTORY_SIZE;
        history[history_ptr].page = currentpoint;
        history[history_ptr].link = la->link_name;
        currentpoint = help_follow_link (currentpoint, la->link_name);
        selected_item = NULL;
    }
    else if (y < 0)
        move_backward (help_lines - 1);
    else if (y >= help_lines)
        move_forward (help_lines - 1);
    else if (y < help_lines / 2)
        move_backward (1);
    else
        move_forward (1);

    /* Show the new node */
    send_message (w->owner, NULL, MSG_DRAW, 0, NULL);
}