Example #1
0
void ssd1306_writeStringSize2(char *str, uint32_t pos)
{
    uint32_t i = 0, j;

    ssd1306_command(SSD1306_SETLOWCOLUMN | 0x0);  // low col = 0
    ssd1306_command(SSD1306_SETHIGHCOLUMN | 0x0);  // hi col = 0
    ssd1306_command(SSD1306_SETSTARTLINE | 0x0); // line #0

    // for each chr in the string, print it to the display
    while((*str != '\0') && ((i+1)*6*8 < 128*64)){
        if(((*str-0x20) < 96) && (*str >= 0x20)){
            for(j=0; j<5; j++){
                ssd1306_data(font5x8[(*str-0x20)*5+j]);
            }
        }
        else{
            for(j=0; j<5; j++){
                ssd1306_data(0);
            }
        }
        ssd1306_data(0);
        str++;
        i++;
    }
    i = (128*64-i*6*8)/8;
    while(i--){
        ssd1306_data(0);
    }
}
void Piccolino_OLED::invertDisplay(uint8_t i) {
  if (i) {
    ssd1306_command(SSD1306_INVERTDISPLAY);
  } else {
    ssd1306_command(SSD1306_NORMALDISPLAY);
  }
}
Example #3
0
void ssd1306_display(void)
{
	ssd1306_command(SSD1306_SETLOWCOLUMN  | 0x0); // low col = 0
  	ssd1306_command(SSD1306_SETHIGHCOLUMN | 0x0); // hi col = 0
  	ssd1306_command(SSD1306_SETSTARTLINE  | 0x0); // line #0

	uint16_t i=0 ;

	// pointer to OLED data buffer
	uint8_t * p = poledbuff;

	char buff[17] ;
	uint8_t x ;

	// Setup D/C to switch to data mode
	buff[0] = SSD_Data_Mode;

	// loop trough all OLED buffer and
    // send a bunch of 16 data byte in one xmission
    for ( i=0; i<(ssd1306_lcdwidth*ssd1306_lcdheight/8); i+=16 )
	{
    	for (x=1; x<=16; x++)
			buff[x] = *p++;
		fastI2Cwrite(buff,  17);
	}
}
void Adafruit_SSD1306::invertDisplay(uint8_t i) {
  if (i) {
    ssd1306_command(SSD1306_INVERTDISPLAY);
  } else {
    ssd1306_command(SSD1306_NORMALDISPLAY);
  }
}
Example #5
0
void LOOL_OLED::Set_Pos(unsigned char x, unsigned char y){

  ssd1306_command(0xb0+y);
  ssd1306_command(((x&0xf0)>>4)|0x10);
ssd1306_command((x&0x0f)|0x01); 

}
void SSD1306::invert(uint8_t i) {
  if (i) {
    ssd1306_command(SSD1306_INVERTDISPLAY);
  } else {
    ssd1306_command(SSD1306_NORMALDISPLAY);
  }
}
Example #7
0
void LCD_SSD1306::setCursor(byte column, byte line)
{
    m_col = column;
    m_row = line;
    ssd1306_command(0xB0 + m_row);//set page address
    ssd1306_command(m_col & 0xf);//set lower column address
    ssd1306_command(0x10 | (m_col >> 4));//set higher column address
}
Example #8
0
// set cursor back to selected line number
void ssd1306_setLine(unsigned char lineNum)
{
    lineNum = (lineNum % 8)*8;
    lineNum = 64 - lineNum;
//    ssd1306_command(SSD1306_SETSTARTLINE | lineNum);
    ssd1306_command(SSD1306_SETDISPLAYOFFSET);
    ssd1306_command(lineNum);
}
Example #9
0
void ssd1306_set_pagecol(unsigned char page, unsigned char col)
{
	// set col address
	ssd1306_command(0x00 + ((col     ) & 0x0F));	// low  col address
	ssd1306_command(0x10 + ((col >> 4) & 0x0F));	// high col address

	// set page address
	ssd1306_command(0xb0 + ((page    ) & 0x07));
}
void Piccolino_OLED::dim(bool how)
{
    ssd1306_command(SSD1306_SETCONTRAST);

    if(how==ON)
      ssd1306_command(0x25);
    else
      ssd1306_command(0xCF);
}
Example #11
0
void SSD1306::draw8x8(byte* buffer, uint8_t x, uint8_t y)
{
    // send a bunch of data in one xmission
    ssd1306_command(0xB0 + y);//set page address
    ssd1306_command(x & 0xf);//set lower column address
    ssd1306_command(0x10 | (x >> 4));//set higher column address

    Wire.beginTransmission(_i2caddr);
    Wire.write(0x40);
    Wire.write(buffer, 8);
    Wire.endTransmission();
}
// startscrolldiagleft
// Activate a diagonal scroll for rows start through stop
// Hint, the display is 16 rows tall. To scroll the whole display, run:
// display.scrollright(0x00, 0x0F) 
void Adafruit_SSD1306::startscrolldiagleft(uint8_t start, uint8_t stop){
	ssd1306_command(SSD1306_SET_VERTICAL_SCROLL_AREA);	
	ssd1306_command(0X00);
	ssd1306_command(SSD1306_LCDHEIGHT);
	ssd1306_command(SSD1306_VERTICAL_AND_LEFT_HORIZONTAL_SCROLL);
	ssd1306_command(0X00);
	ssd1306_command(start);
	ssd1306_command(0X00);
	ssd1306_command(stop);
	ssd1306_command(0X01);
	ssd1306_command(SSD1306_ACTIVATE_SCROLL);
}
// startscrolldiagright
// Activate a diagonal scroll for rows start through stop
// Hint, the display is 16 rows tall. To scroll the whole display, run:
// display.scrollright(0x00, 0x0F) 
void ESP_SSD1306::startscrolldiagright(uint8_t start, uint8_t stop){
  ssd1306_command(SSD1306_SET_VERTICAL_SCROLL_AREA);  
  ssd1306_command(0X00);
  ssd1306_command(SSD1306_LCDHEIGHT);
  ssd1306_command(SSD1306_VERTICAL_AND_RIGHT_HORIZONTAL_SCROLL);
  ssd1306_command(0X00);
  ssd1306_command(start);
  ssd1306_command(0X00);
  ssd1306_command(stop);
  ssd1306_command(0X01);
  ssd1306_command(SSD1306_ACTIVATE_SCROLL);
}
Example #14
0
void ssd1306_clear_row_column(unsigned char row, unsigned char column_start, unsigned char column_end)
{
    unsigned char x;
    unsigned char y;

    ssd1306_command(0xB0 + row);
    ssd1306_command(0x01);
    ssd1306_command(0x10);

    for (x = column_start; x < column_end; x++) {
        ssd1306_data(0x00);
    }
}
Example #15
0
void ssd1306_clear_row(unsigned char row)
{
    unsigned char x;
    unsigned char y;

    ssd1306_command(0xB0 + row);
    ssd1306_command(0x01);
    ssd1306_command(0x10);

    for (x = 0; x < WIDTH; x++) {
        ssd1306_data(0x00);
    }
}
void Adafruit_SSD1306::display(void) {
  ssd1306_command(SSD1306_COLUMNADDR);
  ssd1306_command(0);   // Column start address (0 = reset)
  ssd1306_command(SSD1306_LCDWIDTH-1); // Column end address (127 = reset)

  ssd1306_command(SSD1306_PAGEADDR);
  ssd1306_command(0); // Page start address (0 = reset)
  #if SSD1306_LCDHEIGHT == 64
    ssd1306_command(7); // Page end address
  #endif
  #if SSD1306_LCDHEIGHT == 32
    ssd1306_command(3); // Page end address
  #endif
  #if SSD1306_LCDHEIGHT == 16
    ssd1306_command(1); // Page end address
  #endif

    // I2C
    for (uint16_t i=0; i<(SSD1306_LCDWIDTH*SSD1306_LCDHEIGHT/8); i++) {
      // send a bunch of data in one xmission
      Wire.beginTransmission(_i2caddr);
      WIRE_WRITE(0x40);
      for (uint8_t x=0; x<16; x++) {
  WIRE_WRITE(buffer[i]);
  i++;
      }
      i--;
      Wire.endTransmission();
    }
}
Example #17
0
// clear everything
void LOOL_OLED::clearDisplay(unsigned char m) {
  ssd1306_command(0xb0+m);
  ssd1306_command(0x00);
  ssd1306_command(0x10); 
 
    for(int x=0;x<128;x++)
    {
        Wire.beginTransmission(_i2caddr);
        Wire.write(0x40);
        Wire.write(0x00);//Wire.write(0x00);Wire.write(0x00);Wire.write(0x00);Wire.write(0x00);Wire.write(0x00);
        Wire.endTransmission();
    }

}
Example #18
0
void ssd1306_displayBlock(SSD1306 *p, int row, int col, int col_count, int col_offset /* = 0 */)
{
    if (!p) return;

    /* for now always transmit whole image */
    uint8_t rows = p->height;
    uint8_t cols = p->width;

    /* devide by 8 -- black/white display 8 Bits = 1 Byte = 8 Pixels */
    uint8_t pagecount = rows >> 3;
    uint8_t pagestart = row >> 3;
    uint8_t pageend = pagestart + pagecount - 1;
    uint8_t colstart = col;
    uint8_t colend = col + col_count - 1;

    ssd1306_command(p, SSD1306_MEMORYMODE);
    ssd1306_command(p, SSD1306_MEMORY_MODE_VERT);

    ssd1306_command(p, SSD1306_PAGEADDRESS);
    ssd1306_command(p, pagestart);
    ssd1306_command(p, pageend);

    ssd1306_command(p, SSD1306_COLADDRESS);
    ssd1306_command(p, colstart);
    ssd1306_command(p, colend);

    int length = col_count * pagecount;

    ssd1306_data(p, p->bitmap, length);
}
void SSD1306::display(void) {
  ssd1306_command(SSD1306_SETLOWCOLUMN | 0x0);  // low col = 0
  ssd1306_command(SSD1306_SETHIGHCOLUMN | 0x0);  // hi col = 0
  ssd1306_command(SSD1306_SETSTARTLINE | 0x0); // line #0

  for (uint16_t i=0; i<(SSD1306_LCDWIDTH*SSD1306_LCDHEIGHT/8); i++) {
    ssd1306_data(buffer[i]);
  }
  // i wonder why we have to do this (check datasheet)
  if (SSD1306_LCDHEIGHT == 32) {
    for (uint16_t i=0; i<(SSD1306_LCDWIDTH*SSD1306_LCDHEIGHT/8); i++) {
      ssd1306_data(0);
    }
  }
}
Example #20
0
void ssd1306_fill(unsigned char color)
{
    unsigned char x;
    unsigned char y;

    for (y = 0; y < SEGMENTS; y++) {
        ssd1306_command(0xB0 + y);
        ssd1306_command(0x01);
        ssd1306_command(0x10);

        for (x = 0; x < WIDTH; x++) {
            ssd1306_data(color);
        }
    }
}
Example #21
0
void Adafruit_SSD1306::display(void) {
  ssd1306_command(SSD1306_COLUMNADDR);
  ssd1306_command(0);   // Column start address (0 = reset)
  ssd1306_command(SSD1306_LCDWIDTH-1); // Column end address (127 = reset)

  ssd1306_command(SSD1306_PAGEADDR);
  ssd1306_command(0); // Page start address (0 = reset)
  #if SSD1306_LCDHEIGHT == 64
    ssd1306_command(7); // Page end address
  #endif
  #if SSD1306_LCDHEIGHT == 32
    ssd1306_command(3); // Page end address
  #endif
  #if SSD1306_LCDHEIGHT == 16
    ssd1306_command(1); // Page end address
  #endif

  if (sid != -1)
  {
    // SPI
    *csport |= cspinmask;
    *dcport |= dcpinmask;
    *csport &= ~cspinmask;

    for (uint16_t i=0; i<(SSD1306_LCDWIDTH*SSD1306_LCDHEIGHT/8); i++) {
      fastSPIwrite(buffer[i]);
      //ssd1306_data(buffer[i]);
    }
    *csport |= cspinmask;
  }
  else
  {
    // save I2C bitrate
#if !defined(__SAM3X8E__) && !defined(__ESP8266_EX__)
    uint8_t twbrbackup = TWBR;
    TWBR = 12; // upgrade to 400KHz!
#endif

    //Serial.println(TWBR, DEC);
    //Serial.println(TWSR & 0x3, DEC);

    // I2C
    for (uint16_t i=0; i<(SSD1306_LCDWIDTH*SSD1306_LCDHEIGHT/8); i++) {
      // send a bunch of data in one xmission
      Wire.beginTransmission(_i2caddr);
      WIRE_WRITE(0x40);
      for (uint8_t x=0; x<16; x++) {
  WIRE_WRITE(buffer[i]);
  i++;
      }
      i--;
      Wire.endTransmission();
    }
#if !defined(__SAM3X8E__) && !defined(__ESP8266_EX__)
    TWBR = twbrbackup;
#endif
  }
}
Example #22
0
// clear everything
void LOOL_OLED::clearDisplay() {
	for(uint8_t i=0;i<8;i++)
	{
  ssd1306_command(0xb0+i);
  ssd1306_command(0x00);
  ssd1306_command(0x10); 
 
    for(int x=0;x<128;x++)
    {
        Wire.beginTransmission(_i2caddr);
        Wire.write(0x40);
        Wire.write(0x00);//Wire.write(0x00);Wire.write(0x00);Wire.write(0x00);Wire.write(0x00);Wire.write(0x00);
        Wire.endTransmission();
    }
  }
}
Example #23
0
void LOOL_OLED::display(void) {
  int x=50,y=5;
  ssd1306_command(0xb0+y);
  ssd1306_command(((x&0xf0)>>4)|0x10);
ssd1306_command((x&0x0f)|0x01); 

      Wire.beginTransmission(_i2caddr);
      Wire.write(0x40);
      Wire.write(0x00);
      Wire.write(0x42);
      Wire.write(0x61);
      Wire.write(0x51);
      Wire.write(0x49);
      Wire.write(0x46);
      Wire.endTransmission();

}
// Dim the display
// dim = true: display is dimmed
// dim = false: display is normal
void Adafruit_SSD1306::dim(bool dim) {
  uint8_t contrast;

  if (dim) {
    contrast = 0; // Dimmed display
  } else {
    if (_vccstate == SSD1306_EXTERNALVCC) {
      contrast = 0x9F;
    } else {
      contrast = 0xCF;
    }
  }
  // the range of contrast to too small to be really useful
  // it is useful to dim the display
  ssd1306_command(SSD1306_SETCONTRAST);
  ssd1306_command(contrast);
}
// startscrollright
// Activate a right handed scroll for rows start through stop
// Hint, the display is 16 rows tall. To scroll the whole display, run:
// display.scrollright(0x00, 0x0F) 
void ESP_SSD1306::startscrollright(uint8_t start, uint8_t stop){
  ssd1306_command(SSD1306_RIGHT_HORIZONTAL_SCROLL);
  ssd1306_command(0X00);
  ssd1306_command(start);
  ssd1306_command(0X00);
  ssd1306_command(stop);
  ssd1306_command(0X00);
  ssd1306_command(0XFF);
  ssd1306_command(SSD1306_ACTIVATE_SCROLL);
}
// startscrollleft
// Activate a right handed scroll for rows start through stop
// Hint, the display is 16 rows tall. To scroll the whole display, run:
// display.scrollright(0x00, 0x0F) 
void Adafruit_SSD1306::startscrollleft(uint8_t start, uint8_t stop){
	ssd1306_command(SSD1306_LEFT_HORIZONTAL_SCROLL);
	ssd1306_command(0X00);
	ssd1306_command(start);
	ssd1306_command(0X00);
	ssd1306_command(stop);
	ssd1306_command(0X01);
	ssd1306_command(0XFF);
	ssd1306_command(SSD1306_ACTIVATE_SCROLL);
}
Example #27
0
void display(void)
{
    unsigned char obuf[32];
    int i, x, page, blk;

    ssd1306_command(0xb0 | page); // line #0
    ssd1306_command(SSD1306_SETHIGHCOLUMN | 0x0);  // hi col = 0
    ssd1306_command(SSD1306_SETLOWCOLUMN | 0x0);  // low col = 0
    
    for (page = 0; page < 8; page++) {
	for (blk = 0; blk < (128/16); blk++) {
	    obuf[0] = 0x40;
	    for (i = 0; i < 16; i++) {
		obuf[i + 1] = buffer[page * 128 + blk * 16 + i];
	    }
	    i2c_writeblock(obuf, 16 + 1);
	}
    }
}
Example #28
0
void ssd1306_startScrollRight(SSD1306 *p, int start, int stop)
{
    if (!p) return;

    ssd1306_command(p, SSD1306_RIGHT_HORIZONTAL_SCROLL);
    ssd1306_command(p, 0X00);
    ssd1306_command(p, (unsigned char)start);
    ssd1306_command(p, 0X00);
    ssd1306_command(p, (unsigned char)stop);
    ssd1306_command(p, 0X01);
    ssd1306_command(p, 0XFF);
    ssd1306_command(p, SSD1306_ACTIVATE_SCROLL);
}
void SSD1306_96x16::Flush()
{
  ssd1306_command(SSD1306_SETLOWCOLUMN | 0x0);  // low col = 0
  ssd1306_command(SSD1306_SETHIGHCOLUMN | 0x0);  // hi col = 0
  ssd1306_command(SSD1306_SETSTARTLINE | 0x0); // line #0

    // save I2C bitrate
    uint8_t twbrbackup = TWBR;
    TWBR = 12; // upgrade to 400KHz!

    //Serial.println(TWBR, DEC);
    //Serial.println(TWSR & 0x3, DEC);

    // I2C
    for (uint16_t i=0; i<(WIDTH*HEIGHT/8); i++) {
      // send a bunch of data in one xmission
      Wire.beginTransmission(_i2caddr);
      Wire.write(0x40);
      for (uint8_t x=0; x<16; x++) {
		Wire.write(buffer[i]);
		i++;
      }
      i--;
      Wire.endTransmission();
    }
    // i wonder why we have to do this (check datasheet)
    if (HEIGHT == 32) {
      for (uint16_t i=0; i<(WIDTH*HEIGHT/8); i++) {
	// send a bunch of data in one xmission
		Wire.beginTransmission(_i2caddr);
		Wire.write(0x40);
		for (uint8_t x=0; x<16; x++) {
			Wire.write((uint8_t)0x00);
			i++;
		}
		i--;
		Wire.endTransmission();
      }
    }
    TWBR = twbrbackup;
}
void Piccolino_OLED::clearLine(byte line)
{
    ssd1306_command(SSD1306_SETLOWCOLUMN | 0x0);  // low col = 0
    ssd1306_command(SSD1306_SETHIGHCOLUMN | 0x0);  // hi col = 0
    ssd1306_command(SSD1306_SETSTARTLINE | 0x0); // line #0

    // save I2C bitrate
    uint8_t twbrbackup = TWBR;
    TWBR = 18; // upgrade to 400KHz!

    // send a bunch of data in one xmission
    ssd1306_command(0xB0 + line);//set page address
    ssd1306_command(0);//set lower column address
    ssd1306_command(0x10);//set higher column address

    for(byte j = 0; j < 8; j++){
        Wire.beginTransmission(_i2caddr);
        Wire.write(0x40);
        for (byte k = 0; k < 16; k++) {
            Wire.write(0);
        }
        Wire.endTransmission();
    }

    TWBR = twbrbackup;
}