Exemple #1
0
//控制电机转向
extern void motor_ctrl(const uchar d)
{
	switch(d)
	{
		case 'D':
			direction = 0xAA;
			set_orientation(1);
			break;
		case 'U':
			direction = 0x55;
			set_orientation(0);
			break;
		case 'L':
			direction = 0x66;
			speed = speed_limit;
			break;
		case 'R':
			direction = 0x99;
			speed = speed_limit;
			break;
		case 's':
			direction = 0x00;
			speed = 0;
			break;
	}
}
Exemple #2
0
void main() {
    /* Disable JTAG in software, so that it does not interfere with Port C */
    MCUCR |= _BV(JTD);
    MCUCR |= _BV(JTD);


    init_stdio_uart1();

    init_lcd();
    set_orientation(East);



    scanswitch_init();

    button_map bmap;
    bmap.left 	= 0;
    bmap.right 	= 0;
    bmap.up 	= 0;
    bmap.down 	= 0;
    bmap.center = 0;
    bmap.wheel_d= 0;
    bmap.has_pressed_button=0;

    init_miniUI();

    display_menu_at("test;tes2;tes3",1, 10,10,2);
}
Exemple #3
0
int main() {
    _delay_ms(100);  //little delay for the rfm12 to initialize properly
    rfm12_init();    //init the RFM12
    _delay_ms(100);
    init_lcd();
    init_timer();
    sei(); 
    set_orientation(East);
    put_string((char*)"Initialising...\n");
    
    char random[120] = "hello aaron rowland, this is a string which should ";
    char test[26] = "0123456789012345678901234";
    int i = 23456;

    char Rpacket[150];
    SendPacket(THISDEVICE, random);
    // while(1) {
    //     if(RecievePacket(Rpacket)) {
    //         put_string("PACKET RECEIVED!!!!!\n");
    //         put_string(Rpacket);
    //     }
    // }
    return 0;

}
Exemple #4
0
Tooltip::Tooltip(int x, int y, int width, int height) : label(nullptr), color(96, 96, 96, 255), text_color(255, 255, 255, 255)
{
	set_position(x, y);
	set_size(width, height);
	set_position(0, 0);
	set_orientation(0);
    label = new Label();	
}
Exemple #5
0
Tooltip::Tooltip() : label(nullptr), color(96, 96, 96, 255), text_color(255, 255, 255, 255)
{
	set_position(0, 0);
	set_size(100, 50);
	set_position(0, 0);
	set_orientation(0);		
	label = new Label();
}
Exemple #6
0
void CameraObject::rotate (DTfloat angle_x, DTfloat angle_y)
{
    Matrix3 roty, rotx;
    roty = Matrix3::set_rotation_y(angle_y);
    rotx = Matrix3::set_rotation_x(angle_x);

    Matrix3 o = orientation() * roty * rotx;
    set_orientation(o);
}
Exemple #7
0
int main(void) {
	init_lcd();
	set_orientation(North);
	rectangle r = {get_width() * 0.2, get_width() * 0.8, get_height() * 0.2, get_height() * 0.8};
	do {
		fill_rectangle(r, YELLOW);
		_delay_ms(1);
	} while(1);
}
Exemple #8
0
Edit::Edit() : color(160, 160, 160, 255), character_limit(10),
    cursor(true), cursor_x(0), cursor_y(0), zoom_factor(0), multilined(false)
{
	set_position(0, 0);
	set_size(200, 20); // 150, 20
	set_orientation(0);
	
	label = new Label();
}
Exemple #9
0
Tooltip::Tooltip(const std::string& text) : label(nullptr), color(96, 96, 96, 255), text_color(255, 255, 255, 255)
{
	label = new Label();
	set_text(text);
	set_position(0, 0);
	set_size(100, 100);
	set_position(0, 0);
	set_orientation(0);	
}
Exemple #10
0
void ingame_camera::set_to_ideal(level_graph const& level, agent const& player)
{
	vec_t player_pos = level.get_agent_position(player);
	vec_t player_dir = level.get_agent_direction(player);
	orient_t player_orient = lookat_orientation(player_dir, player.up);

	set_position(calc_ideal_position(player_pos, player_orient));
	set_orientation(calc_ideal_orientation(player_pos, player_orient));
}
Exemple #11
0
void CameraObject::look_at (const Vector3 &to, const Vector3 &up)
{
    Matrix3 m;	
    Vector3 delta;
    
    delta = translation() - to;
    
    m = Matrix3::set_orientation(delta, up);
    set_orientation(m);
}
// data: [azimuth/pitch/roll]
void Orientation::set_orientation( string data ) {
    string token[3];
    float values[3];
    for (int i = 0; i < 3; i++){
        data = data.substr(myStrGetTok(data, token[i], 0, '/') + 1);
        values[i] = (float)::atof(token[i].c_str());
    }

    set_orientation( values[0], values[1], values[2] );
}
Exemple #13
0
Mesh::Mesh(const char *filename){
  // Check whether the provided file exists.
  ifstream ifile(filename);
  if(!ifile){
    std::cerr << "File " << filename << " does not exist." << std::endl;
    exit(EXIT_FAILURE);
  }

  vtkXMLUnstructuredGridReader *reader = vtkXMLUnstructuredGridReader::New();
  reader->SetFileName(filename);
  reader->Update();

  vtkUnstructuredGrid *ug = reader->GetOutput();

  NNodes = ug->GetNumberOfPoints();
  NElements = ug->GetNumberOfCells();

  // Get the coordinates of each mesh vertex. There is no z coordinate in 2D,
  // but VTK treats 2D and 3D meshes uniformly, so we have to provide memory
  // for z as well (r[2] will always be zero and we ignore it).
  for(size_t i=0;i<NNodes;i++){
    double r[3];
    ug->GetPoints()->GetPoint(i, r);
    coords.push_back(r[0]);
    coords.push_back(r[1]);
  }
  assert(coords.size() == 2*NNodes);

  // Get the metric at each vertex.
  for(size_t i=0;i<NNodes;i++){
    double *tensor = ug->GetPointData()->GetArray("Metric")->GetTuple4(i);
    metric.push_back(tensor[0]);
    metric.push_back(tensor[1]);
    assert(tensor[1] == tensor[2]);
    metric.push_back(tensor[3]);
  }
  assert(metric.size() == 3*NNodes);

  // Get the 3 vertices comprising each element.
  for(size_t i=0;i<NElements;i++){
    vtkCell *cell = ug->GetCell(i);
    for(int j=0;j<3;j++){
      ENList.push_back(cell->GetPointId(j));
    }
  }
  assert(ENList.size() == 3*NElements);

  reader->Delete();

  create_adjacency();
  find_surface();
  set_orientation();
  precompute_surfaceNodes();
  precompute_cornerNodes();
}
Exemple #14
0
Terminal::Terminal() {
    dock_hint = GdkRectangle{0, 0, 0, 0};
    vte = vte_terminal_new();
    char *argv[] = { vte_get_user_shell(), NULL };
    vte_terminal_spawn_sync(VTE_TERMINAL(vte), VTE_PTY_DEFAULT, NULL, argv, NULL,
                            (GSpawnFlags)0, NULL,
                            NULL, &child_pid, NULL, NULL);
    set_orientation(Gtk::ORIENTATION_VERTICAL);
    scrollbox.set_orientation(Gtk::ORIENTATION_HORIZONTAL);
    scrollbar.set_orientation(Gtk::ORIENTATION_VERTICAL);

    eventbox.add(label);
    eventbox.signal_button_press_event().connect(mem_fun(this, &Terminal::header_button_press));

    VteRegex *regex = vte_regex_new_for_match("(https?://|www\\.)[^\\s]*", -1, PCRE2_MULTILINE, NULL);
    vte_terminal_match_add_regex(VTE_TERMINAL(vte), regex, 0);
    vte_terminal_set_scrollback_lines(VTE_TERMINAL(vte), 10000);
    g_signal_connect(vte, "bell", G_CALLBACK(Terminal::vte_beep), this);
    g_signal_connect(vte, "child-exited", G_CALLBACK(Terminal::vte_child_exited), this);
    g_signal_connect(vte, "button-press-event", G_CALLBACK(Terminal::vte_click), this);
    g_signal_connect(vte, "focus-in-event", G_CALLBACK(Terminal::vte_got_focus), this);
    g_signal_connect(vte, "focus-out-event", G_CALLBACK(Terminal::vte_lost_focus), this);
    g_signal_connect(vte, "selection-changed", G_CALLBACK(Terminal::vte_selection_changed), this);
    g_signal_connect(vte, "window-title-changed", G_CALLBACK(Terminal::vte_title_changed), this);

    searchbar.add(searchentry);
    searchbar.connect_entry(searchentry);
    searchentry.signal_focus_out_event().connect(mem_fun(this, &Terminal::searchentry_lost_focus));
    searchentry.signal_key_release_event().connect(mem_fun(this, &Terminal::searchentry_keypress));

    pack_start(eventbox, false, false, 0);
    pack_start(scrollbox, true, true, 0);
    pack_start(searchbar, false, false, 0);
    gtk_box_pack_start(GTK_BOX(scrollbox.gobj()), vte, true, true, 0);
    scrollbox.pack_start(scrollbar, false, false, 0);
    gtk_range_set_adjustment(GTK_RANGE(scrollbar.gobj()), gtk_scrollable_get_vadjustment(GTK_SCROLLABLE(vte)));
    show_all_children();

    find_label.terminal = this;
    find_label.set_alignment(0.0, 0.5);
    find_window->list_box.prepend(find_label);

    std::vector<Gtk::TargetEntry> listTargets;
    listTargets.push_back(Gtk::TargetEntry("SvanTerminal", Gtk::TARGET_SAME_APP, 0));

    eventbox.drag_source_set(listTargets);

    drag_dest_set(listTargets);
    eventbox.signal_drag_begin().connect(sigc::mem_fun(this, &Terminal::on_my_drag_begin));
    eventbox.signal_drag_failed().connect(sigc::mem_fun(this, &Terminal::on_my_drag_failed));
    eventbox.signal_drag_end().connect(sigc::mem_fun(this, &Terminal::on_my_drag_end));
    signal_drag_motion().connect(sigc::mem_fun(this, &Terminal::on_my_drag_motion));
    signal_drag_drop().connect(sigc::mem_fun(this, &Terminal::on_my_drag_drop));
    signal_drag_leave().connect(sigc::mem_fun(this, &Terminal::on_my_drag_leave));
}
Exemple #15
0
int main(void) {
	init_lcd();
	set_orientation(South);
	rectangle r = {
		20, 20 + RECT_WIDTH - 1,
		20, 20 + RECT_HEIGHT - 1
	};
	Box b = {r, 1, 1};
	rectangle clear = {0, 0, 0, 0};
	do {
		if(b.vx > 0 && (b.r.right * SCALE) >= (get_width() - SCALE)) {
			b.vx = - b.vx;
		} else if(b.vx < 0 && (b.r.left * SCALE) <= 0) {
			b.vx = - b.vx;
		}
		if(b.vy > 0 && (b.r.bottom * SCALE) >= get_height()) {
			b.vy = - b.vy;
		} else if(b.vy < 0 && (b.r.top * SCALE) <= 0) {
			b.vy = - b.vy;
		}
		if(b.vx > 0) {
			clear.left = b.r.left * SCALE;
			clear.right = (b.r.left + 1) * SCALE;
			clear.top = b.r.top * SCALE;
			clear.bottom = b.r.bottom * SCALE;
			fill_rectangle(clear, BLACK);
		} else if(b.vx < 0) {
			clear.right = b.r.right * SCALE;
			clear.left = (b.r.right - 1) * SCALE;
			clear.top = b.r.top * SCALE;
			clear.bottom = b.r.bottom * SCALE;
			fill_rectangle(clear, BLACK);
		}
		if(b.vy > 0) {
			clear.left = b.r.left * SCALE;
			clear.right = b.r.right * SCALE;
			clear.top = b.r.top * SCALE;
			clear.bottom = (b.r.top + 1) * SCALE;
			fill_rectangle(clear, BLACK);
		} else if(b.vy < 0) {
			clear.left = b.r.left * SCALE;
			clear.right = b.r.right * SCALE;
			clear.bottom = b.r.bottom * SCALE;
			clear.top = (b.r.bottom - 1) * SCALE;
			fill_rectangle(clear, BLACK);
		}
		b.r.left += b.vx;
		b.r.right += b.vx;
		b.r.top += b.vy;
		b.r.bottom += b.vy;
		fill_rectangle_indexed_scale(b.r, pic, SCALE);
		_delay_ms(50);
	} while(1);
}
void RigidBody::Rotate(MATRIX3x3& R){
/**
  \brief Arbitrary rotation in body frame, parameterized by a matrix

  Warning: Matrix R should be a valid (unitary, with norm = 1) rotation matrix

  \param[in] R Rotation matrix
*/
  rb_A_I_to_e = R*rb_A_I_to_e;
  set_orientation(rb_A_I_to_e);
}
//_____________________________________________________________________________
// Convienience constructor.
ContactGeometry::ContactGeometry(const Vec3& location, const Vec3& orientation, 
    PhysicalFrame& body) : ModelComponent()
{
    setNull();
    constructProperties();

    _body = &body;
    set_body_name(body.getName());
    set_location(location);
    set_orientation(orientation);
}
void RigidBody::Rotate_I_z(double phi){
/**
  Rotation around center of mass along the z
  axis in external coordinate system (lab frame)

  \param[in] phi The rotation angle, in radians
*/

  MATRIX3x3 R; R.Rx(phi);
  rb_A_I_to_e = R * rb_A_I_to_e;
  set_orientation(rb_A_I_to_e);
}
void RigidBody::Rotate(QUATERNION& quat){
/**
  \brief Arbitrary rotation in body frame, parameterized by a quaternion

  \param[in] quaternion Rotation quaternion
*/

  MATRIX3x3 R;
  QUATERNION_TO_MATRIX(quat,R);
  rb_A_I_to_e = R*rb_A_I_to_e;
  set_orientation(rb_A_I_to_e);
}
Exemple #20
0
void CameraObject::orbit (DTfloat angle_x, DTfloat angle_y, const Vector3 &around_pt)
{
    Matrix3 roty, rotx;
    roty = Matrix3::set_rotation_y(angle_y);
    rotx = Matrix3::set_rotation_x(angle_x);
        
    Matrix3 o = orientation();
    Vector3 offset = o.inversed() * (translation() - around_pt);
    o = o * roty * rotx;
    
    set_translation(o * offset + around_pt);
    set_orientation(o);
}
Exemple #21
0
Menubar::Menubar() : color(106, 106, 106, 255), submenu_color(106, 106, 106, 255),
// outline
outline(false),
outline_width(1.0),
outline_color(0, 0, 0, 255),
outline_antialiased(false),
// highlight
highlight(true),
highlight_color(0, 51, 102, 255)
{
	set_position(0, 0);
	set_size(300, 20); // menubar_width / menu_width = how_many_menu_can_fit  
	set_orientation(0);	
}                             
void RigidBody::Rotate_e_z(double phi){
/**
  Rotation around center of mass along the y
  axis in body-fixed coordinate system (body frame)

  \param[in] phi The rotation angle, in radians
*/

  VECTOR ux,uy,uz;
  rb_A_I_to_e.get_vectors(ux,uy,uz);
  MATRIX3x3 R; R.Rotation(phi*ux);
  rb_A_I_to_e = R * rb_A_I_to_e;
  set_orientation(rb_A_I_to_e);
}
Exemple #23
0
void RoomSurface::init(Ogre::Vector3 normal, Ogre::Real x_size, Ogre::Real z_size,
                       CreateVisualActor create_visual_actor) {
  create_visual_actor_ = create_visual_actor == CREATE_VISUAL_ACTOR;

  init();

  normal.normalise();
  normal_ = normal;

  // ***Important***
  // The surface is constructed from a "flat" rectangle sitting in the xz-plane, hence
  // we define its size by the x- and z- sizes. Once the surface has been rotated to have the
  // passed-in normal the x_size and z_size will not actually correspond to the surfaces'
  // x and z dimensions in world space.
  StaticBox::set_size(Ogre::Vector3(x_size, kSurfaceThickness, z_size));

  // Rotate the box to correspond to the passed-in normal
  set_orientation(surfaceOrientationForNormal(normal));
}
Exemple #24
0
void third_person_cam::update(level_graph const& level, agent const& player, float_t dtime)
{
	vec_t player_pos = level.get_agent_position(player);
	vec_t player_dir = level.get_agent_direction(player);
	orient_t player_orient = lookat_orientation(player_dir, player.up);

	vec_t ideal_pos = calc_ideal_position(player_pos, player_orient);
	orient_t ideal_orientation = calc_ideal_orientation(player_pos, player_orient);

	vec_t cur_pos = get_position();
	// Let's try, moving proportionally to distance, such that in 1 second we would move the whole way (if happened in single step)
	float const cam_move = dtime * move_speed_factor;
	set_position(cur_pos + (ideal_pos - cur_pos) * std::min(cam_move, 1.0f));

	orient_t cur_orientation = get_orientation();
	float const cam_slerp = dtime * slerp_speed_factor;
	orient_t interpolated = cur_orientation.slerp(std::min(cam_slerp, 1.0f), ideal_orientation);
	set_orientation(interpolated);
}
VR_Window::VR_Window()
{
    set_orientation( Gtk::ORIENTATION_HORIZONTAL );

    pc_file_open = false;

    vrender = new VRender;
    volume_origin = make_float3( 0.5, 0, 0 );

    cloud = new Cloud;

    cloud->world.resolution = make_float3( RENDER_RESOLUTION, RENDER_RESOLUTION, RENDER_RESOLUTION );
    printf("\n World Resolution: %f x %f x %f", cloud->world.resolution.x, cloud->world.resolution.y, cloud->world.resolution.z );

    cloud->world.size = make_uint3( MAX_VOLUME_SIDE, MAX_VOLUME_SIDE, MAX_VOLUME_SIDE );
    printf("\n World Size: %d x %d x %d", cloud->world.size.x, cloud->world.size.y, cloud->world.size.z );

    cloud->world.count = cloud->world.size.x * cloud->world.size.y * cloud->world.size.z;
    printf("\n World Count: %d",cloud->world.count);

    cloud->world.dimension = make_float3( cloud->world.resolution.x * (float)cloud->world.size.x,
                                          cloud->world.resolution.y * (float)cloud->world.size.y,
                                          cloud->world.resolution.z * (float)cloud->world.size.z );
    printf("\n World Dimension: %f x %f x %f", cloud->world.dimension.x, cloud->world.dimension.y, cloud->world.dimension.z );

    cloud->world.min.x = 1000.f * volume_origin.x - 0.5 * cloud->world.dimension.x;
    cloud->world.min.y = 1000.f * volume_origin.y - 0.5 * cloud->world.dimension.y;
    cloud->world.min.z = 1000.f * volume_origin.z - 0.5 * cloud->world.dimension.z;
    printf("\n World Minimum: %f %f %f", cloud->world.min.x, cloud->world.min.y, cloud->world.min.z );

    cloud->world.max.x = cloud->world.min.x + cloud->world.dimension.x;
    cloud->world.max.y = cloud->world.min.y + cloud->world.dimension.y;
    cloud->world.max.z = cloud->world.min.z + cloud->world.dimension.z;
    printf("\n World Maximum: %f %f %f\n", cloud->world.max.x, cloud->world.max.y, cloud->world.max.z );

    adaptive_world_sizing = false;
    socket_timer_idx = 0;
    memset( socket_timer, 0, TIMER_SIZE * sizeof(double) );

    numKinects = 1;
}
Exemple #26
0
void init_lcd()
{
    /* Enable extended memory interface with 10 bit addressing */
    XMCRB = _BV(XMM2) | _BV(XMM1);
    XMCRA = _BV(SRE);
    DDRC |= _BV(RESET);
    DDRB |= _BV(BLC);
    _delay_ms(1);
    PORTC &= ~_BV(RESET);
    _delay_ms(20);
    PORTC |= _BV(RESET);
    _delay_ms(120);
    write_cmd(DISPLAY_OFF);
    write_cmd(SLEEP_OUT);
    _delay_ms(60);
    write_cmd_data(INTERNAL_IC_SETTING,          0x01);
    write_cmd(POWER_CONTROL_1);
        write_data16(0x2608);
    write_cmd_data(POWER_CONTROL_2,              0x10);
    write_cmd(VCOM_CONTROL_1);
        write_data16(0x353E);
    write_cmd_data(VCOM_CONTROL_2, 0xB5);
    write_cmd_data(INTERFACE_CONTROL, 0x01);
        write_data16(0x0000);
    write_cmd_data(PIXEL_FORMAT_SET, 0x55);     /* 16bit/pixel */
    set_orientation(West);
    clear_screen();
    display.x = 0;
    display.y = 0;
    display.background = BLACK;
    display.foreground = WHITE;
    write_cmd(DISPLAY_ON);
    _delay_ms(50);
    write_cmd_data(TEARING_EFFECT_LINE_ON, 0x00);
    EICRB |= _BV(ISC61);
    PORTB |= _BV(BLC);
}
Exemple #27
0
/**
 * Called once on initialization - Initialize the io functions and the controller state.
 */
void init(State* state) {
    init_lcd();
    init_adc();
    DDRA = (1 << 3) | (1 << 4) | (1 << 5); //Setup up digital input ports as input
    PORTA = (1 << 3) | (1 << 4) | (1 << 5); //Enable pull up resistors on input ports
    set_orientation(North);

    rectangle r2 = {5, 45, 5, 45}; //The three squares denoting digital inputs
    rectangle r3 = {5, 45, 50, 90};
    rectangle r4 = {5, 45, 95, 135};
    state->r2 = r2; //Initialize the state.
    state->r3 = r3;
    state->r4 = r4;
    rectangle r5 = {get_width() - 50, get_width() - 5, 5, 45}; //The three squares denoting digital outputs
    rectangle r6 = {get_width() - 50, get_width() - 5, 50, 90};
    rectangle r7 = {get_width() - 50, get_width() - 5, 95, 135};
    state->r5 = r5;
    state->r6 = r6;
    state->r7 = r7;
    state->x10 = (get_width() / 4); //Computes the x positions of the analogue bars
    state->x11 = state->x10 + (get_width() / 6);
    state->x21 = state->x11 + (get_width() / 6);
    state->x31 = state->x21 + (get_width() / 6);
}
Exemple #28
0
SceneObject &SceneObject::rotate(float dir, float up, float tilt)
{
	set_orientation(get_orientation() * Quaternionf(up, dir, tilt, angle_degrees, order_YXZ));
	return *this;
}
Exemple #29
0
Menubar::Menubar(int x, int y, int width, int height)
{
	set_position(x, y);
	set_size(width, height);
	set_orientation(0);
}
Exemple #30
0
Menubar::Menubar(int x, int y)
{
	set_position(x, y);
	set_size(300, 20);
	set_orientation(0);	
}