static int8_t motor_update() { uint8_t steps = 0; /* Motion along axes X and Y takes precedence over motion along axis Z, when * no submersion is requested on the latter. Also, only motion along axes X * and Y may be combined with one another. */ if((new_pos.x != cur_pos.x || new_pos.y != cur_pos.y) && new_pos.z <= cur_pos.z) { /* Relative offset from #cur_pos on axes X and Y. */ int16_t rel_x = (int16_t)new_pos.x - (int16_t)cur_pos.x; int16_t rel_y = (int16_t)new_pos.y - (int16_t)cur_pos.y; /* Enable lines for PWM propagation to motor Y and set its speed. */ if(rel_y) { setup_axis(AXIS_Y, rel_y); /* @c rel_y is used only for its sign. */ } /* Enable lines for PWM propagation to motor X and set its speed. Motor * X may only be set-up after motor Y, as noted in #setup_axis(). */ if(rel_x) { setup_axis(AXIS_X, rel_x); /* @c rel_x is used only for its sign. */ } rel_x = abs(rel_x); rel_y = abs(rel_y); if(rel_x > 0 && rel_y > 0) { /* Request the common amount of steps between @c rel_x and * @c rel_y. */ steps = rel_x >= rel_y ? GRID_TO_STEP(rel_y) : GRID_TO_STEP(rel_x); } else { /* If one of @c rel_x and @c rel_y is @c 0, then calculate the * amount of steps solely based on the other (non-zero) value. */ steps = rel_x > 0 ? GRID_TO_STEP(rel_x) : GRID_TO_STEP(rel_y); } /* Configure motion along axis Z. */ } else if(new_pos.z != cur_pos.z) { int16_t rel_z = (int16_t)new_pos.z - cur_pos.z; setup_axis(AXIS_Z, rel_z); /* @c rel_z is used only for its sign. */ steps = GRID_TO_STEP(abs(rel_z)); motor_status |= _BV(MTR_IS_Z); } else { /* Already at #new_pos. */ motor_status &= ~_BV(MTR_IS_Z); return -1; } setup_lock(steps); motor_start(); return 0; }
static void gnome_control_center_init (GnomeControlCenter *self) { GError *err = NULL; GnomeControlCenterPrivate *priv; GdkScreen *screen; priv = self->priv = CONTROL_CENTER_PRIVATE (self); #ifdef HAVE_CHEESE if (gtk_clutter_init (NULL, NULL) != CLUTTER_INIT_SUCCESS) { g_critical ("Clutter-GTK init failed"); return; } #endif /* HAVE_CHEESE */ priv->monitor_num = -1; self->priv->small_screen = SMALL_SCREEN_UNSET; /* load the user interface */ priv->builder = gtk_builder_new (); if (!gtk_builder_add_from_file (priv->builder, UIDIR "/shell.ui", &err)) { g_critical ("Could not build interface: %s", err->message); g_error_free (err); return; } /* connect various signals */ priv->window = W (priv->builder, "main-window"); gtk_window_set_hide_titlebar_when_maximized (GTK_WINDOW (priv->window), TRUE); screen = gtk_widget_get_screen (priv->window); g_signal_connect (screen, "monitors-changed", G_CALLBACK (monitors_changed_cb), self); g_signal_connect (priv->window, "configure-event", G_CALLBACK (main_window_configure_cb), self); g_signal_connect (priv->window, "notify::application", G_CALLBACK (application_set_cb), self); g_signal_connect_swapped (priv->window, "delete-event", G_CALLBACK (g_object_unref), self); g_signal_connect_after (priv->window, "key_press_event", G_CALLBACK (window_key_press_event), self); priv->notebook = W (priv->builder, "notebook"); /* Main scrolled window */ priv->scrolled_window = W (priv->builder, "scrolledwindow1"); gtk_widget_set_size_request (priv->scrolled_window, FIXED_WIDTH, -1); priv->main_vbox = W (priv->builder, "main-vbox"); g_signal_connect (priv->notebook, "notify::page", G_CALLBACK (notebook_page_notify_cb), priv); g_signal_connect (gtk_builder_get_object (priv->builder, "home-button"), "clicked", G_CALLBACK (home_button_clicked_cb), self); /* keep a list of custom widgets to unload on panel change */ priv->custom_widgets = g_ptr_array_new_with_free_func ((GDestroyNotify) g_object_unref); /* load the available settings panels */ setup_model (self); /* load the panels that are implemented as plugins */ load_panel_plugins (self); /* setup search functionality */ setup_search (self); setup_lock (self); /* store default window title and name */ priv->default_window_title = g_strdup (gtk_window_get_title (GTK_WINDOW (priv->window))); priv->default_window_icon = g_strdup (gtk_window_get_icon_name (GTK_WINDOW (priv->window))); notebook_page_notify_cb (GTK_NOTEBOOK (priv->notebook), NULL, priv); }