Hexiwear OLED Display Driver

Dependents:   Hexi_OLED_TextImage_Example Hexi_OLED_Text_Example Hexi_OLED_Image_Example security-console-app ... more

Revision:
6:0060ffa3f4dc
Parent:
5:a5b4b36a1aed
Child:
7:9961c525e249
--- a/Hexi_OLED_SSD1351.cpp	Fri Aug 26 18:13:10 2016 +0000
+++ b/Hexi_OLED_SSD1351.cpp	Fri Aug 26 19:56:07 2016 +0000
@@ -97,8 +97,7 @@
     rst = 1 ;
     wait_ms(1);
     PowerON();
-
-    isFontInitialized = 0 ;
+    
     currentChar_width  = 0,
     currentChar_height = 0;
     colorMask = COLOR_WHITE;
@@ -106,16 +105,16 @@
     oled_text_properties.alignParam = OLED_TEXT_ALIGN_CENTER;
     oled_text_properties.background = NULL;
     oled_text_properties.font       = OpenSans_10x15_Regular;
-    oled_text_properties.fontColor  = COLOR_RED;
-    
+    oled_text_properties.fontColor  = COLOR_WHITE;
+    SetTextProperties(&oled_text_properties);
+        
     oled_dynamic_area.areaBuffer = NULL;
     oled_dynamic_area.height = 0;
     oled_dynamic_area.width = 0;
     oled_dynamic_area.xCrd = 0;
     oled_dynamic_area.yCrd = 0;
    
-
-
+   
     for (int i=0;i<39;i++) 
     {
        SendCmd(seq[i].cmd, seq[i].type);
@@ -128,8 +127,9 @@
 
 SSD1351::~SSD1351(void)
 {
-
-  //Run Free  and zero pointers. 
+  //TO_DO
+  //Run Free and zero pointers. 
+  
 }
 
 
@@ -205,10 +205,10 @@
 
 
 oled_status_t SSD1351::DrawBox (
-                            uint16_t xCrd,
-                            uint16_t yCrd,
-                            uint16_t width,
-                            uint16_t height,
+                            int8_t xCrd,
+                            int8_t yCrd,
+                            uint8_t width,
+                            uint8_t height,
                             uint16_t color
                           )
 {
@@ -301,8 +301,8 @@
 
 
 oled_status_t SSD1351::DrawPixel (
-                               int16_t xCrd,
-                               int16_t yCrd,
+                               int8_t xCrd,
+                               int8_t yCrd,
                               uint16_t color
                             )
 {
@@ -333,8 +333,8 @@
 
 oled_status_t SSD1351::DrawScreen (
                                    const uint8_t* image,
-                                          uint8_t xCrd,
-                                          uint8_t yCrd,
+                                          int8_t xCrd,
+                                          int8_t yCrd,
                                           uint8_t width,
                                           uint8_t height,
                                 oled_transition_t transition
@@ -403,7 +403,6 @@
 
   OLED_SwapMe( selectedFont_color );
 
-  isFontInitialized = 1;
   return OLED_STATUS_SUCCESS;
 }
 
@@ -499,7 +498,7 @@
 
 
 
-oled_status_t SSD1351::AddText( const uint8_t* text,uint8_t xCrd, uint8_t yCrd )
+oled_status_t SSD1351::AddText( const uint8_t* text,int8_t xCrd, int8_t yCrd )
 {
     uint16_t
         chrCnt = 0;
@@ -787,7 +786,7 @@
 }
 
 
-oled_status_t SSD1351::AddImage ( const uint8_t* image, uint8_t xCrd, uint8_t yCrd )
+oled_status_t SSD1351::AddImage ( const uint8_t* image, int8_t xCrd, int8_t yCrd )
 {
   oled_status_t
     status = OLED_STATUS_SUCCESS;
@@ -837,7 +836,7 @@
   return status;
 }
 
-oled_status_t SSD1351::DrawImage ( const uint8_t* image, uint8_t xCrd, uint8_t yCrd  )
+oled_status_t SSD1351::DrawImage ( const uint8_t* image, int8_t xCrd, int8_t yCrd  )
 {
   
   oled_status_t
@@ -908,8 +907,8 @@
 
  //Formerly Known as GuiDriver_UpdateScreen
 void SSD1351::UpdateBuffer (
-                                uint8_t xCrd,
-                                uint8_t yCrd,
+                                int8_t xCrd,
+                                int8_t yCrd,
                                 uint8_t width,
                                 uint8_t height,
                                 const uint8_t* image
@@ -928,7 +927,7 @@
 } 
 
 
-oled_status_t SSD1351::Label ( const uint8_t* text,uint8_t xCrd, uint8_t yCrd )
+oled_status_t SSD1351::Label ( const uint8_t* text,int8_t xCrd, int8_t yCrd )
 {
 
   if ( NULL == text )
@@ -949,7 +948,7 @@
 }
 
 
-oled_status_t SSD1351::TextBox(const uint8_t* text,uint8_t xCrd, uint8_t yCrd,uint8_t width,uint8_t height)
+oled_status_t SSD1351::TextBox(const uint8_t* text, int8_t xCrd, int8_t yCrd,uint8_t width,uint8_t height)
 {
 
   if ( NULL == text )
@@ -1009,8 +1008,8 @@
  */
 oled_status_t SSD1351::TopDown(
                                 const uint8_t* image,
-                                       uint8_t xCrd,
-                                       uint8_t yCrd,
+                                       int8_t xCrd,
+                                       int8_t yCrd,
                                        uint8_t width,
                                        uint8_t height
                             )
@@ -1070,8 +1069,8 @@
 
 oled_status_t SSD1351::DownTop(
                                 const uint8_t* image,
-                                      uint8_t xCrd,
-                                      uint8_t yCrd,
+                                      int8_t xCrd,
+                                      int8_t yCrd,
                                       uint8_t width,
                                       uint8_t height
                             )
@@ -1139,8 +1138,8 @@
 
 oled_status_t SSD1351::LeftRight(
                                  const uint8_t* image,
-                                        uint8_t xCrd,
-                                        uint8_t yCrd,
+                                        int8_t xCrd,
+                                        int8_t yCrd,
                                         uint8_t width,
                                         uint8_t height
                               )
@@ -1169,7 +1168,8 @@
     return OLED_STATUS_INIT_ERROR;
   }
 
-  Transpose( (oled_pixel_t)transImage, (const oled_pixel_t)image, width, height );
+ // Transpose( (oled_pixel_t)transImage, (const oled_pixel_t)image, width, height );
+ Transpose( transImage,(oled_pixel_t)image, width, height );
 
   SendCmd( OLED_CMD_SET_REMAP, CMD_BYTE );
   SendCmd( OLED_REMAP_SETTINGS | REMAP_VERTICAL_INCREMENT, DATA_BYTE );
@@ -1227,8 +1227,8 @@
  */
 oled_status_t SSD1351::RightLeft(
                                  const uint8_t* image,
-                                        uint8_t xCrd,
-                                        uint8_t yCrd,
+                                        int8_t xCrd,
+                                        int8_t yCrd,
                                         uint8_t width,
                                         uint8_t height
                               )
@@ -1254,7 +1254,8 @@
     return OLED_STATUS_INIT_ERROR;
   }
 
-  Transpose( (oled_pixel_t)transImage, (const oled_pixel_t)image, width, height );
+  //Transpose( (oled_pixel_t)transImage, (const oled_pixel_t)image, width, height );
+  Transpose(transImage, (oled_pixel_t)image, width, height );
 
   SendCmd( OLED_CMD_SET_REMAP, CMD_BYTE );
   SendCmd( OLED_REMAP_SETTINGS | REMAP_VERTICAL_INCREMENT, DATA_BYTE );
@@ -1312,8 +1313,8 @@
  * @return      [description]
  */
 void SSD1351::SetBorders(
-                        uint8_t xCrd,
-                        uint8_t yCrd,
+                        int8_t xCrd,
+                        int8_t yCrd,
                         uint8_t width,
                         uint8_t height
                       )
@@ -1417,12 +1418,6 @@
   const uint8_t*
     pChBitMap = selectedFont + offset;
 
-  if ( 0 == isFontInitialized )
-  {
-    // default font
-     SetFont( OpenSans_10x15_Regular, COLOR_WHITE );
-  }
-
   // allocate space for char image
   *chrBuf = (oled_pixel_t)AllocateDynamicArea( currentChar_height * currentChar_width );