Пример #1
0
// Constructs a new ElementImage.
ElementImage::ElementImage(const String& tag) : Element(tag), geometry(this), dimensions(-1, -1)
{
	ResetCoords();
	geometry_dirty = false;
	texture_dirty = true;
}
Пример #2
0
// Called when attributes on the element are changed.
void ElementImage::OnAttributeChange(const Rocket::Core::AttributeNameList& changed_attributes)
{
	// Call through to the base element's OnAttributeChange().
	Rocket::Core::Element::OnAttributeChange(changed_attributes);

	float dirty_layout = false;

	// Check for a changed 'src' attribute. If this changes, the old texture handle is released,
	// forcing a reload when the layout is regenerated.
	if (changed_attributes.find("src") != changed_attributes.end())
	{
		texture_dirty = true;
		dirty_layout = true;
	}

	// Check for a changed 'width' attribute. If this changes, a layout is forced which will
	// recalculate the dimensions.
	if (changed_attributes.find("width") != changed_attributes.end() ||
		changed_attributes.find("height") != changed_attributes.end())
	{
		dirty_layout = true;
	}

	// Check for a change to the 'coords' attribute. If this changes, the coordinates are
	// recomputed and a layout forced.
	if (changed_attributes.find("coords") != changed_attributes.end())
	{
		if (HasAttribute("coords"))
		{
			StringList coords_list;
			StringUtilities::ExpandString(coords_list, GetAttribute< String >("coords", ""));

			if (coords_list.size() != 4)
			{
				Rocket::Core::Log::Message(Log::LT_WARNING, "Element '%s' has an invalid 'coords' attribute; coords requires 4 values, found %d.", GetAddress().CString(), coords_list.size());
				ResetCoords();
			}
			else
			{
				for (size_t i = 0; i < 4; ++i)
					coords[i] = atoi(coords_list[i].CString());

				// Check for the validity of the coordinates.
				if (coords[0] < 0 || coords[2] < coords[0] ||
					coords[1] < 0 || coords[3] < coords[1])
				{
					Rocket::Core::Log::Message(Log::LT_WARNING, "Element '%s' has an invalid 'coords' attribute; invalid coordinate values specified.", GetAddress().CString());
					ResetCoords();
				}
				else
				{
					// We have new, valid coordinates; force the geometry to be regenerated.
					geometry_dirty = true;
					using_coords = true;
				}
			}
		}
		else
			ResetCoords();

		// Coordinates have changes; this will most likely result in a size change, so we need to force a layout.
		dirty_layout = true;
	}

	if (dirty_layout)
		DirtyLayout();
}
Пример #3
0
void loop() {
  
  //Start timer, this is used to lift and lower the drill.
  timer.run();
  
  // send data only when you receive data:
	if (Serial.available() > 0) {
		// read the incoming byte:
		incomingString = Serial.read();
                
				// If incoming is "q"
                if (incomingString == 101){
                  dirA = 'F';
                  dirB = 'F';
                }
				// If incoming is "e"
                else if (incomingString == 113){
                  dirA = 'F';
                  dirB = 'R';
                }
				// If incoming is "w"
                else if (incomingString == 119){
                  dirA = 'F';
                  dirB = 'N';
                }
				// If incoming is "z"
                else if (incomingString == 99){
                  dirA = 'R';
                  dirB = 'F';
                }
				// If incoming is "c"
                else if (incomingString == 122){
                  dirA = 'R';
                  dirB = 'R';
                }
				// If incoming is "x"
                else if (incomingString == 120){
                  dirA = 'R';
                  dirB = 'N';
                }
				// If incoming is "a"
                else if (incomingString == 100){
                  dirA = 'N';
                  dirB = 'F';
                }
				// If incoming is "d"
                else if (incomingString == 97){
                  dirA = 'N';
                  dirB = 'R';
                }
				// If incoming is "s"
                else if (incomingString == 115){
                  dirA = 'N';
                  dirB = 'N';
                }
				// If incoming is "r"
                else if (incomingString == 114){
                  ResetCoords();
                  dirA = 'N';
                  dirB = 'N';
                }
				// If incoming is "f"
                else if (incomingString == 102){
                  LiftDrill();
                  Serial.print("Drill is up");
                  Serial.print("\n");
                  dirA = 'N';
                  dirB = 'N';
                }
				// If incoming is "v"
                else if (incomingString == 118){
                  LowerDrill();
                  Serial.print("Drill is down");
                  Serial.print("\n");
                  dirA = 'N';
                  dirB = 'N';
                }

				//Calculate steps according to selected direction and last step
                Step(dirA, dirB);
				//Write data to ShiftRegister
                WriteData(Output);
                
				//Write coordinates to LCD
                outgoingString = "";
                outgoingString = outgoingString + "X: ";
                outgoingString = outgoingString + CoordX;
                outgoingString = outgoingString + "   Y: ";
                outgoingString = outgoingString + CoordY;
                //Write coordintes to Serial port
                Serial.print("Position");
                Serial.print(outgoingString);
                Serial.print("\n");
                Serial.print("\n");
	}

  // LCD Part of code
  // set the cursor to column 0, line 1
  // (note: line 1 is the second row, since counting begins with 0):
  lcd.setCursor(0, 1);
  // print the number of seconds since reset:
  lcd.print("X: ");
  lcd.setCursor(3, 1);
  lcd.print(CoordX);
  lcd.setCursor(8, 1);
  lcd.print("Y: ");
  lcd.setCursor(11, 1);
  lcd.print(CoordY);
}