Hexiwear / Hexi_OLED_SSD1351

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

Files at this revision

API Documentation at this revision

Comitter:
khuang
Date:
Fri Aug 26 19:56:07 2016 +0000
Parent:
5:a5b4b36a1aed
Child:
7:9961c525e249
Commit message:
Added OpenSans Font. Added proper licensing text. Changed a xCrd,yCrd, width, height variables to correct types. Moved SetTextProperties Init inside constructor.

Changed in this revision

Hexi_OLED_SSD1351.cpp Show annotated file Show diff for this revision Revisions of this file
Hexi_OLED_SSD1351.h Show annotated file Show diff for this revision Revisions of this file
OLED_info.h Show annotated file Show diff for this revision Revisions of this file
OLED_types.h Show annotated file Show diff for this revision Revisions of this file
OpenSans_Font/OpenSans_Font.c Show annotated file Show diff for this revision Revisions of this file
OpenSans_Font/OpenSans_Font.h Show annotated file Show diff for this revision Revisions of this file
--- 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 );
 
--- a/Hexi_OLED_SSD1351.h	Fri Aug 26 18:13:10 2016 +0000
+++ b/Hexi_OLED_SSD1351.h	Fri Aug 26 19:56:07 2016 +0000
@@ -91,10 +91,10 @@
    * @return        status flag
    */
   oled_status_t 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
                             );
 
@@ -114,8 +114,8 @@
    * @return       status flag
    */
   oled_status_t DrawPixel (
-                                 int16_t xCrd,
-                                 int16_t yCrd,
+                                 int8_t xCrd,
+                                 int8_t yCrd,
                                 uint16_t color
                               );
 
@@ -132,8 +132,8 @@
    */
   oled_status_t 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
@@ -196,7 +196,7 @@
    * @param yCrd    y-coordinate for the given text
    * @return        status flag
    */
-  oled_status_t AddText( const uint8_t* text,uint8_t xCrd, uint8_t yCrd );
+  oled_status_t AddText( const uint8_t* text,int8_t xCrd, int8_t yCrd );
     /**
    * Add text to the main screen buffer. Used with SetDynamicArea() Function.
    * @param  text text to add
@@ -233,7 +233,7 @@
    * @param  yCrd       image y-coordinate
    * @return            status flag
    */
-  oled_status_t AddImage ( const uint8_t* image, uint8_t xCrd, uint8_t yCrd );
+  oled_status_t AddImage ( const uint8_t* image, int8_t xCrd, int8_t yCrd );
 
   /**
    * Send image to OLED GRAM.Used with SetDynamicArea() Function for positioning image. 
@@ -248,7 +248,7 @@
    * @param  yCrd       image y-coordinate
    * @return            status flag
    */
-  oled_status_t DrawImage ( const uint8_t* image, uint8_t xCrd, uint8_t yCrd );
+  oled_status_t DrawImage ( const uint8_t* image, int8_t xCrd, int8_t yCrd );
 
   /**
    * Dim OLED screen on
@@ -294,8 +294,8 @@
    * @param  image      image for buffer
    */
   void UpdateBuffer (
-                                uint8_t xCrd,
-                                uint8_t yCrd,
+                                int8_t xCrd,
+                                int8_t yCrd,
                                 uint8_t width,
                                 uint8_t height,
                                 const uint8_t* image
@@ -310,8 +310,8 @@
    */
 
   oled_status_t Label(const uint8_t* text,
-                            uint8_t xCrd, 
-                            uint8_t yCrd );
+                            int8_t xCrd, 
+                            int8_t yCrd );
 
   /**
   * Create a text box of width,height at position x,y. Recommended for Dynamic Text.
@@ -324,8 +324,8 @@
   */
   
   oled_status_t TextBox(const uint8_t* text,
-                              uint8_t xCrd, 
-                              uint8_t yCrd,
+                              int8_t xCrd, 
+                              int8_t yCrd,
                               uint8_t width,
                               uint8_t height);
 
@@ -342,7 +342,6 @@
   const uint8_t* selectedFont;
 
   uint8_t
-    isFontInitialized,
     currentChar_width,
     currentChar_height,
     screenBuf[OLED_GRAM_SIZE];
@@ -360,11 +359,11 @@
   
   //Internal Functions
   void Transpose( oled_pixel_t transImage, const oled_pixel_t image, uint8_t width, uint8_t height );
-  oled_status_t TopDown   ( const uint8_t* image, uint8_t xCrd, uint8_t yCrd, uint8_t width, uint8_t height );
-  oled_status_t DownTop   ( const uint8_t* image, uint8_t xCrd, uint8_t yCrd, uint8_t width, uint8_t height );
-  oled_status_t LeftRight ( const uint8_t* image, uint8_t xCrd, uint8_t yCrd, uint8_t width, uint8_t height );
-  oled_status_t RightLeft ( const uint8_t* image, uint8_t xCrd, uint8_t yCrd, uint8_t width, uint8_t height );
-  void SetBorders( uint8_t xCrd, uint8_t yCrd, uint8_t width, uint8_t height );
+  oled_status_t TopDown   ( const uint8_t* image, int8_t xCrd, int8_t yCrd, uint8_t width, uint8_t height );
+  oled_status_t DownTop   ( const uint8_t* image, int8_t xCrd, int8_t yCrd, uint8_t width, uint8_t height );
+  oled_status_t LeftRight ( const uint8_t* image, int8_t xCrd, int8_t yCrd, uint8_t width, uint8_t height );
+  oled_status_t RightLeft ( const uint8_t* image, int8_t xCrd, int8_t yCrd, uint8_t width, uint8_t height );
+  void SetBorders( int8_t xCrd, int8_t yCrd, uint8_t width, uint8_t height );
   oled_status_t CreateTextBackground();
   void WriteCharToBuf( uint16_t charToWrite, oled_pixel_t* chrBuf );
   oled_status_t AddCharToTextArea( oled_pixel_t chrPtr, uint8_t chrWidth, uint8_t chrHeight, oled_pixel_t copyAddr, uint8_t imgWidth );
--- a/OLED_info.h	Fri Aug 26 18:13:10 2016 +0000
+++ b/OLED_info.h	Fri Aug 26 19:56:07 2016 +0000
@@ -1,5 +1,5 @@
 /** OLED Screen Info  
- *  This file contains OLED screen SSD1351-related info.
+ *  This file contains OLED screen SSD1351-related defines and macros. 
  * 
  * Redistribution and use in source and binary forms, with or without modification,
  * are permitted provided that the following conditions are met:
@@ -33,8 +33,6 @@
  * Project HEXIWEAR, 2015
  */
  
-
-
 #ifndef HG_OLED_INFO
 #define HG_OLED_INFO
 
--- a/OLED_types.h	Fri Aug 26 18:13:10 2016 +0000
+++ b/OLED_types.h	Fri Aug 26 19:56:07 2016 +0000
@@ -105,8 +105,8 @@
 
 typedef struct
 {
-         uint8_t xCrd;
-         uint8_t yCrd;
+         int8_t xCrd;
+         int8_t yCrd;
          uint8_t width;
          uint8_t height;
     oled_pixel_t areaBuffer;
--- a/OpenSans_Font/OpenSans_Font.c	Fri Aug 26 18:13:10 2016 +0000
+++ b/OpenSans_Font/OpenSans_Font.c	Fri Aug 26 19:56:07 2016 +0000
@@ -10,6 +10,8 @@
 
 #include "OpenSans_Font.h"
 
+/*  Max Width of Character  = 12px
+ *  Max Height of Character = 18px */
 const uint8_t OpenSans_12x18_Regular[] = {
    0x00,
    0x00,
@@ -211,7 +213,9 @@
    0x00,0x00,0x00,0x07,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x07,0x00,0x00,0x00,0x00,0x00  // Code for char num 127
         };
 
-const uint8_t OpenSans_10x15_Regular[] = {
+/*  Max Width of Character  = 10px
+ *  Max Height of Character = 15px  */
+ const uint8_t OpenSans_10x15_Regular[] = {
    0x00,
    0x00,
    0x20,0x00,
--- a/OpenSans_Font/OpenSans_Font.h	Fri Aug 26 18:13:10 2016 +0000
+++ b/OpenSans_Font/OpenSans_Font.h	Fri Aug 26 19:56:07 2016 +0000
@@ -14,13 +14,11 @@
 #include <stdint.h>
 
 /** Max Width of Character  = 12px
- *  Max Height of Character = 18px
- */
+ *  Max Height of Character = 18px */
 extern const uint8_t OpenSans_12x18_Regular[];
 
 /** Max Width of Character  = 10px
- *  Max Height of Character = 15px
- */
+ *  Max Height of Character = 15px */
 extern const uint8_t OpenSans_10x15_Regular[];
 
 #endif