static void ssd1306_write_byte(uint8_t chData, uint8_t chCmd) 
{
    uint8_t cmd = 0x00;
    
    if (chCmd) {
        cmd = 0x40;
    } else {
        cmd = 0x00;
    }
i2c_smbus_write_byte_data(ssd1306_client, cmd, chData);
}
void ssd1306_display_on(void)
{
    ssd1306_write_byte(0x8D, SSD1306_CMD);  
    ssd1306_write_byte(0x14, SSD1306_CMD);  
    ssd1306_write_byte(0xAF, SSD1306_CMD);  
}
   
/**
  * @brief  OLED turns off
  *         
  * @param  None
  *         
  * @retval  None
**/
void ssd1306_display_off(void)
{
    ssd1306_write_byte(0x8D, SSD1306_CMD);  
    ssd1306_write_byte(0x10, SSD1306_CMD); 
    ssd1306_write_byte(0xAE, SSD1306_CMD);  
}
void ssd1306_refresh_gram(void)
{
    uint8_t i, j;
    
    for (i = 0; i < 8; i ++) {  
        ssd1306_write_byte(0xB0 + i, SSD1306_CMD);    
        ssd1306_write_byte(0x02, SSD1306_CMD); 
        ssd1306_write_byte(0x10, SSD1306_CMD);     
        for (j = 0; j < 128; j ++) {
            ssd1306_write_byte(s_chDispalyBuffer[j][i], SSD1306_DAT); 
        }
    }   
}
void ssd1306_clear_screen(uint8_t chFill)  
{ 
    memset(s_chDispalyBuffer,chFill, sizeof(s_chDispalyBuffer));
    ssd1306_refresh_gram();
}
/**
  * @brief  Draws a piont on the screen
  *         
  * @param  chXpos: Specifies the X position
  * @param  chYpos: Specifies the Y position
  * @param  chPoint: 0: the point turns off    1: the piont turns on 
  *         
  * @retval None
**/
void ssd1306_draw_point(uint8_t chXpos, uint8_t chYpos, uint8_t chPoint)
{
    uint8_t chPos, chBx, chTemp = 0;
    
    if (chXpos > 127 || chYpos > 63) {
        return;
    }
    chPos = 7 - chYpos / 8; // 
    chBx = chYpos % 8;
    chTemp = 1 << (7 - chBx);
    
    if (chPoint) {
        s_chDispalyBuffer[chXpos][chPos] |= chTemp;
        
    } else {
        s_chDispalyBuffer[chXpos][chPos] &= ~chTemp;
    }
}
      
/**
  * @brief  Fills a rectangle
  *         
  * @param  chXpos1: Specifies the X position 1 (X top left position)
  * @param  chYpos1: Specifies the Y position 1 (Y top left position)
  * @param  chXpos2: Specifies the X position 2 (X bottom right position)
  * @param  chYpos3: Specifies the Y position 2 (Y bottom right position)
  *         
  * @retval 
**/

