Example #1
0
	BackBuffer& LG::BackBuffer::operator<<( char datum )
	{
		if(	_y_buffer_pointer < 0				||
			_x_buffer_pointer < 0				||
			_y_buffer_pointer > getHeight()-1	||
			_x_buffer_pointer > getWidth()-1	||
			datum == 0							)
			return *this;

		if(datum == 0)
			datum = 32;
		Pixel new_one;
		new_one.character = datum;
		new_one.fore_color = _fore_pointer;
		new_one.back_color = _back_pointer;

		getBackBuffer()[_y_buffer_pointer][_x_buffer_pointer] = new_one;
		if(++_x_buffer_pointer >= getWidth())
		{
			_x_buffer_pointer = 0;
			_y_buffer_pointer++;
		}

		return *this;
	}
Example #2
0
	void BackBuffer::fill(const Pixel& pixel)
	{
		Buffer& buf = getBackBuffer();
		for(int r=0; r < buf.getLength() ;r++)
			for(int c=0; c < buf[r].getLength() ; c++)
				buf[r][c] = pixel;
	}
Example #3
0
	int LG::BackBuffer::getWidth() const
	{
		int min = 99999999;
		const Buffer& back = getBackBuffer();
		for(int n=0; n < back.getLength() ;n++)
			if(back[n].getLength() < min)
				min = back[n].getLength();

		return min;
	}
Example #4
0
void FileReader::run()
{
    while (!threadShouldExit())
    {
        if (m_shouldFillBackBuffer.compareAndSetBool(false, true))
        {
            readAndFillBufferCache(*getBackBuffer());
        }
        
        wait(30);
    }
}
Example #5
0
	void LG::BackBuffer::draw()
	{
		Buffer& front = getFrontBuffer(),
			& back = getBackBuffer();

		for(int h=0; h < back.getLength() ;h++)
			for(int w=0; w < back[h].getLength() ;w++)
			{
				Pixel& new_p = back[h][w],
					& old_p = front[h][w];
				bool is_new_one_korean = (new_p.character & 0x80) == 0x80;

				//	HiddenPixel 조사:
				//		HiddenPixel이란:
				//			2BYTE문자는 앞과 뒤 바이트(= 픽셀)이 한 몸으로 이루어져 있기 때문에,
				//			둘 중 하나만 찍히면 제대로 출력이 되지 않는다.
				//			그런데 새로 갱신된 문자가 하필히면 앞 바이트가 동일하게 된 경우는
				//			뒷 문자만 cout 출력이 되므로 제대로 된 출력이 안된다.
				//
				//		해결방법:
				//			픽셀이 같으면 뛰어넘는 코드에서, 2BYTE 문자라고 추정되는 경우(sign bit이 1)
				//			next pixel 까지도 검색을 한번에 수행한다.
				//			둘 중 하나라도 갱신이 필요한 경우는 둘 모두를 출력한다.
				if(is_new_one_korean && w < back[h].getLengthLastIndex())
				{
					Pixel&	next_new = back[h][w+1],
						next_old = front[h][w+1];
					if(	next_new != next_old	||
						new_p != old_p			)
					{
						Core::setCursorTo(w, h);
						Core::setColor(new_p.fore_color, new_p.back_color);
						std::cout << new_p.character << next_new.character;						
						next_old = next_new;
						old_p = new_p;
					}
					w++;
				}
				else if(new_p != old_p)
				{
					Core::setCursorTo(w, h);
					Core::setColor(new_p.fore_color, new_p.back_color);
					std::cout << new_p.character;
				}
			}

			_swapBuffer();

			Core::setColor(LIGHTGRAY, BLACK);
			Core::setCursorTo(0, back.getLength());	//	means height
	}
Example #6
0
	int LG::BackBuffer::getHeight() const
	{
		return getBackBuffer().getLength();
	}
Example #7
0
bool PrintPlanner::queueMove(const Vec3& target) {
  BlockBuffer* backBuffer = getBackBuffer();

  // Prepare the distance between the current location and the target, and normalize a unit vector for determining incremental extruder positions
  Vec3 direction = target - _position;
  float distance = direction.mag();
  Vec3 unit = direction.normalized();

  // Determine the fastest movement profile that this move can use
  int moveProfileIndex;
  for(moveProfileIndex = 0;
      moveProfileIndex < MOVEMENT_PROFILE_MAX &&
        _config.movementProfiles[moveProfileIndex].minimumDistance > distance;
      moveProfileIndex++) {}

  if(moveProfileIndex == MOVEMENT_PROFILE_MAX) {
    printf("Error: No movement profile short enough to accomodate move\n");
    return false;
  } else {
    printf("Using movement profile %i\n", moveProfileIndex);
  }
  MovementProfile* profile = &_config.movementProfiles[moveProfileIndex];

  PositionProfile vars;

  // Cache some indices for quick lookups
  int constSpeedDuration = (distance - profile->minimumDistance) / profile->maxVelocity;
  int decelStart         = profile->intervals[2] + constSpeedDuration;
  int thirdJerkUpper     = decelStart + profile->intervals[3];
  int fourthJerkLower    = decelStart + profile->intervals[4];
  int totalBlocks        = decelStart + profile->intervals[5];

  int blockIndex = 0;
  for(int i = 0; i < totalBlocks; i++) {
    // Is this block buffer full?
    if(blockIndex >= BLOCK_BUFFER_LENGTH) {
      // Commit this block buffer and move to the next one
      backBuffer->numberOfBlocks = blockIndex;
      commitBackBuffer();
      backBuffer = getBackBuffer();
    }

    // Determine whether our acceleration is ramping up, ramping down, or staying constant for this block
    float jerkDirection = 0;
    if(i < profile->intervals[0] || i >= fourthJerkLower) {
      jerkDirection = 1.0f;
    } else if(
      (i >= profile->intervals[1] && i < profile->intervals[2]) ||
      (i >= decelStart            && i < thirdJerkUpper)
    ) {
      jerkDirection = -1.0f;
    }

    // Iterate our position profile
    ComputeStep(_config, jerkDirection, vars);
    printf("\t[%i] ", i); vars.debug();

    // Using our unit vector, project the new extruder location
    Vec3 newPosition = _position + (unit * vars.d);

    // Determine the new location of the steppers
    float heights[NUMBER_OF_AXES];
    _solver.getHeightsAt(newPosition, heights);
    for(int j = STEPPER_A; j <= STEPPER_C; j++) {
      float delta = heights[j] - _stepperPosition[j];
      if(fabs(_stepperProgress[j] + delta) >= (_config.zUnitsPerStep * 2)) {
        printf("ERROR: Speed too fast for stepper %i (will lag behind)\n", i);
      }
      _stepperProgress[j] += delta;
      _stepperPosition[j] = heights[j];
      if       (_stepperProgress[j] >=  _config.zUnitsPerStep) {
        backBuffer->blocks[i].step[j]    = true;
        backBuffer->blocks[i].forward[j] = true;
        _stepperProgress[j] -= _config.zUnitsPerStep;
        printf("\t\tStepper %i moves forward\n", j);
      } else if(_stepperProgress[j] <= -_config.zUnitsPerStep) {
        backBuffer->blocks[i].step[j]    = true;
        backBuffer->blocks[i].forward[j] = false;
        _stepperProgress[j] += _config.zUnitsPerStep;
        printf("\t\tStepper %i moves backward\n", j);
      } else {
        backBuffer->blocks[i].step[j]    = false;
      }
    }
    blockIndex++;
  }
  backBuffer->numberOfBlocks = blockIndex;
  commitBackBuffer();

  return true;
}