Ejemplo n.º 1
0
/** Initialise the OLED display
 *
 */
void oledInit() {
  i2cConfig();
  // Initialise the LCD
  writeBegin();
  writeCommand(0xAF); // Turn display on
  writeEnd();
  }
Ejemplo n.º 2
0
/** Clear the display
 */
void oledClear(bool invert) {
  writeBegin();
  setPosition(0, 0);
  // Fill in the whole display
  for(int index = 0; index < (WIDTH * LINES); index++)
    writeData(invert?0xff:0x00);
  writeEnd();
  }
Ejemplo n.º 3
0
/** Write a character to the display
 */
void oledWriteCh(int x, int y, char ch, bool invert) {
  // Make sure the character is valid
  if((ch<0x20)||(ch>0x7f))
    ch = 0x20;
  // Do the write
  writeBegin();
  setPosition(y, x);
  // Write the character
  writeData(invert?0xff:0x00);
  writeGlyph(x + 1, y, BASE_FONT + (ch - 0x20) * (FONT_WIDTH - 2), FONT_WIDTH - 2, 1, invert);
  writeData(invert?0xff:0x00);
  writeEnd();
  }
Ejemplo n.º 4
0
/** Clear a region of the display
 */
void oledClearRect(int y, int height, bool invert) {
  // Do the clear
  writeBegin();
  while(height) {
    setPosition(y, 0);
    // Fill the line
    for(int index=0; index<WIDTH; index++)
      writeData(invert?0xff:0x00);
    // Step to the next line
    height--;
    }
  writeEnd();
  }
Ejemplo n.º 5
0
/** Write a string to the display
 */
void oledWriteStr(int x, int y, const char *str, bool invert) {
  writeBegin();
  while (*str) {
    // Make sure the character is valid
    char ch = *str;
    if((ch<0x20)||(ch>0x7f))
      ch = 0x20;
    // Set the position
    setPosition(y, x);
    // Write the character
    writeData(invert?0xff:0x00);
    writeGlyph(x + 1, y, BASE_FONT + (ch - 0x20) * (FONT_WIDTH - 2), FONT_WIDTH - 2, 1, invert);
    writeData(invert?0xff:0x00);
    // Move to the next character (and position)
    str++;
    x += FONT_WIDTH;
    }
  writeEnd();
  }
Ejemplo n.º 6
0
boost::uint64_t Writer::write(  boost::uint64_t targetNumPointsToWrite,
                                boost::uint64_t startingPosition)
{
    if (!isInitialized())
    {
        throw pdal_error("stage not initialized");
    }

    boost::uint64_t actualNumPointsWritten = 0;

    UserCallback* callback = getUserCallback();
    do_callback(0.0, callback);

    const Schema& schema = getPrevStage().getSchema();
    
    if (m_writer_buffer == 0)
    {
        boost::uint64_t capacity(targetNumPointsToWrite);
        if (capacity == 0)
        {
            capacity = m_chunkSize;
        } else
        {
            capacity = (std::min)(static_cast<boost::uint64_t>(m_chunkSize), targetNumPointsToWrite) ;
        }
        m_writer_buffer = new PointBuffer (schema, capacity);
        
    }
    
    boost::scoped_ptr<StageSequentialIterator> iter(getPrevStage().createSequentialIterator(*m_writer_buffer));
    
    if (startingPosition)
        iter->skip(startingPosition);
        
    if (!iter) throw pdal_error("Unable to obtain iterator from previous stage!");

    // if we don't have an SRS, try to forward the one from the prev stage
    if (m_spatialReference.empty()) m_spatialReference = getPrevStage().getSpatialReference();

    writeBegin(targetNumPointsToWrite);

    iter->readBegin();



    //
    // The user has requested a specific number of points: proceed a
    // chunk at a time until we reach that number.  (If that number
    // is 0, we proceed until no more points can be read.)
    //
    // If the user requests an interrupt while we're running, we'll throw.
    //
    while (true)
    {
        // have we hit the end already?
        if (iter->atEnd()) break;

        // rebuild our PointBuffer, if it needs to hold less than the default max chunk size
        if (targetNumPointsToWrite != 0)
        {
            const boost::uint64_t numRemainingPointsToRead = targetNumPointsToWrite - actualNumPointsWritten;

            const boost::uint64_t numPointsToReadThisChunk64 = std::min<boost::uint64_t>(numRemainingPointsToRead, m_chunkSize);
            // this case is safe because m_chunkSize is a uint32
            const boost::uint32_t numPointsToReadThisChunk = static_cast<boost::uint32_t>(numPointsToReadThisChunk64);

            // we are reusing the buffer, so we may need to adjust the capacity for the last (and likely undersized) chunk
            if (m_writer_buffer->getCapacity() < numPointsToReadThisChunk)
            {
                m_writer_buffer->resize(numPointsToReadThisChunk);
            }
        }

        // read...
        iter->readBufferBegin(*m_writer_buffer);
        const boost::uint32_t numPointsReadThisChunk = iter->readBuffer(*m_writer_buffer);
        iter->readBufferEnd(*m_writer_buffer);

        assert(numPointsReadThisChunk == m_writer_buffer->getNumPoints());
        assert(numPointsReadThisChunk <= m_writer_buffer->getCapacity());

        // have we reached the end yet?
        if (numPointsReadThisChunk == 0) break;

        // write...
        writeBufferBegin(*m_writer_buffer);
        const boost::uint32_t numPointsWrittenThisChunk = writeBuffer(*m_writer_buffer);
        assert(numPointsWrittenThisChunk == numPointsReadThisChunk);
        writeBufferEnd(*m_writer_buffer);

        // update count
        actualNumPointsWritten += numPointsWrittenThisChunk;

        do_callback(actualNumPointsWritten, targetNumPointsToWrite, callback);

        if (targetNumPointsToWrite != 0)
        {
            // have we done enough yet?
            if (actualNumPointsWritten >= targetNumPointsToWrite) break;
        }

        // reset the buffer, so we can use it again
        m_writer_buffer->setNumPoints(0);
    }

    iter->readEnd();
    
    writeEnd(actualNumPointsWritten);

    assert((targetNumPointsToWrite == 0) || (actualNumPointsWritten <= targetNumPointsToWrite));

    do_callback(100.0, callback);

    
    return actualNumPointsWritten;
}
Ejemplo n.º 7
0
void RayGroup::write(int indent,FILE* fp){
	writeBegin(indent,fp);
	for(int i=0;i<sNum;i++){shapes[i]->write(indent+2,fp);}
	writeEnd(indent,fp);
}
Ejemplo n.º 8
0
/** Write an arbitrary glyph to the display
 */
void oledWriteGlyph(int x, int y, const uint8_t *glyph, int width, int height, bool invert) {
  writeBegin();
  writeGlyph(x, y, glyph, width, height, invert);
  writeEnd();
  }