예제 #1
0
void SSD1308::writeString(uint8_t row, uint8_t col, uint16_t len, const char * text)
{
  uint16_t index = 0;
  setPageAddress(row, MAX_PAGE);
  const uint8_t col_addr = FONT_WIDTH*col;
  setColumnAddress(col_addr, MAX_COL);

  while ((col+index) < CHARS && (index < len)) {
     // write first line, starting at given position
     writeChar(text[index++]);
  }

  // write remaining lines
  // write until the end of memory
  // then wrap around again from the top.
  if (index + 1 < len) {
    setPageAddress(row + 1, MAX_PAGE);
    setColumnAddress(0, MAX_COL);
    bool wrapEntireScreen = false;
    while (index + 1 < len) {
       writeChar(text[index++]);
       // if we've written the last character space on the screen, 
       // reset the page and column address so that it wraps around from the top again
       if (!wrapEntireScreen && (row*CHARS + col + index) > 127) {
         setPageAddress(0, MAX_PAGE);
         setColumnAddress(0, MAX_COL);
         wrapEntireScreen = true;
       }
    }
  }
}
예제 #2
0
void SSD1308::fillDisplay()
{
  setPageAddress(0, MAX_PAGE);      // all pages
  setColumnAddress(0, MAX_COL); // all columns

  uint8_t b = 0;
  for (uint8_t page = 0; page < PAGES; page++)
  {
    for (uint8_t col = 0; col < COLUMNS; col++)
    {
      sendData(b++);
    }
  }
}
예제 #3
0
void SSD1308::clearDisplay()
{
  setDisplayOff();
  setPageAddress(0, 7);     // all pages
  setColumnAddress(0, 127); // all columns
  for (uint8_t page = 0; page < 8; page++)
  {
    for (uint8_t col = 0; col < 128; col++)
    {
      sendData(0x0);
    }
  }
  setDisplayOn();
}
예제 #4
0
void CI2cOledDrv::clearDisplay()
{
	int i=0;

	//this->ctlIO();

	setPageAddress(0x00,0x07);
	setColumnAddress(0x00,0x7F);

	//for(i=0;i<OLDE_COLS*OLDE_PAGES;i++)
	//{
	//	writeDataChar(' ',m_fd);
	//}
	char buf[OLDE_COLS*8*OLDE_PAGES+1];
	buf[0]=OLED_RS_DATA;
	for(i=1;i<OLDE_COLS*8*OLDE_PAGES+1;i++)
	{
		buf[i]=0x0;
	}
	if( write(m_fd,buf,OLDE_COLS*8*OLDE_PAGES+1) != (OLDE_COLS*8*OLDE_PAGES+1) )
	{
		printf("Error writeing to i2c slave1\n");
	}
}
예제 #5
0
void CI2cOledDrv::startDisplay()
{
	setMemoryAdressingMode(ADDR_MODE_HORIZONTAL);
	setPageAddress(0x00,0x07);
	setColumnAddress(0x00,0x7F);
}