Test for STM32F4

Dependents:   Nucleo_SSD1331

Fork of RGB_OLED_SSD1331 by Juergen M

Revision:
9:5a7bf0ce8518
Parent:
8:ff74bd4d94d6
Child:
10:ef7440718431
--- a/include/SSD1331.h	Tue Nov 17 08:43:15 2015 +0000
+++ b/include/SSD1331.h	Tue Nov 17 19:45:22 2015 +0000
@@ -143,46 +143,180 @@
 
 enum DisplayMode{
     //reset the above effect and turn the data to ON at the corresponding gray level.
-    NormalDisplay   = 0xA4,
+    DM_NormalDisplay   = 0xA4,
     //forces the entire display to be at "GS63"
-    DisplayOn       = 0xA5,
+    DM_DisplayOn       = 0xA5,
     //forces the entire display to be at gray level "GS0"
-    DisplayOff      = 0xA6,
+    DM_DisplayOff      = 0xA6,
     //swap the gray level of display data
-    InverseDisplay  = 0xA7
+    DM_InverseDisplay  = 0xA7
 };
 
-enum DisplayPower{
-    DimMode         = 0xAC,
-    SleepMode       = 0xAE,
-    NormalMode      = 0xAF
+enum PowerMode{
+    PM_SleepMode       = 0xAE
+    PM_NormalMode      = 0xAF
 };
 
 enum ScollingDirection{
-    Horizontal      = 0x00,
-    Vertical        = 0x01,
-    Diagonal        = 0x02
+    SD_Horizontal      = 0x00,
+    SD_Vertical        = 0x01,
+    SD_Diagonal        = 0x02
+};
+
+enum ScrollInterval{
+    SI_6_Frames   = 0x00,
+    SI_10_Frames  = 0x01,
+    SI_100_Frames = 0x02,
+    SI_200_Frames = 0x03
 };
 
-
+/** The SSD1331 class drives via the SPI port oled displays with the SSD1331 chip such as the RGB oled from Seeedstudio
+ *
+ *  The class supports various drawinf and scrolling fuctions
+ *
+ *
+ * Example:
+ * @code
+ * // Draw a line at the rgb old of Seeedstudio
+ *
+ * #include "mbed.h"
+ * #include "SSD1331.h"
+ *
+ * int main() {
+ *     SSD1331 oled(P0_15, NC, P0_4, P0_9, NC, P0_10);
+ *     oled.drawLine(0, 0, 95, 0, Yellow);
+ * }
+ * @endcode
+ */
 class SSD1331 : public mbed::Stream, public virtual SGL 
 {
     public:
+        /** Create a SPI master connected to the specified pins
+        *
+        *
+        *  mosi or miso can be specfied as NC if not used
+        *
+        *  @param cs   Chip select pin
+        *  @param rst  Reset pin
+        *  @param dc   Data / #Command pin 
+        *  @param mosi SPI Master Out, Slave In pin
+        *  @param miso SPI Master In,  Slave Out pin
+        *  @param sclk SPI Clock pin  
+        */
         SSD1331(PinName cs, PinName rst, PinName dc, PinName mosi, PinName miso, PinName sclk);
 
+        /** Draws a pixel in a given color on the screen. Larger coordinates than the screen will be set to RGB_OLED_XMAX and RGB_OLED_YMAX
+        *
+        *  @param x     Position x
+        *  @param y     Position y
+        *  @param color 16bit Color of the pixel
+        */
         virtual void drawPixel(uint8_t x, uint8_t y, uint16_t color);
+        
+        /** Draws a line from one position to another position. Larger coordinates than the screen will be set to RGB_OLED_XMAX and RGB_OLED_YMAX
+        *
+        *  @param x0      Start Position x 
+        *  @param y0      Start Position y
+        *  @param x1      End Position x
+        *  @param y1      End Position y 
+        *  @param color   16bit Color of the pixel
+        */
         virtual void drawLine(uint8_t x0, uint8_t y0, uint8_t x1, uint8_t y1, uint16_t color);
-        virtual void drawRect(uint8_t left_x, uint8_t top_y, uint8_t width, uint8_t height, uint16_t color);
-        void drawFrame(uint8_t x0, uint8_t y0, uint8_t x1, uint8_t y1, uint16_t outColor, uint16_t fillColor);
+        
+        /** Draws a rectangle with no filling. Larger coordinates than the screen will be set to RGB_OLED_XMAX and RGB_OLED_YMAX
+        *
+        *  @param left      Position x
+        *  @param top       Position y
+        *  @param width     Width of the rectangle
+        *  @param height    Height of the rectangle
+        *  @param color     16bit Color of the rectangle lines
+        */
+        virtual void drawRect(uint8_t left, uint8_t top, uint8_t width, uint8_t height, uint16_t color);
+        
+        /** Draws a filled rectangle with a seperate border line. Larger coordinates than the screen will be set to RGB_OLED_XMAX and RGB_OLED_YMAX
+        *
+        *  @param left_x        Position x
+        *  @param top_y         Position y
+        *  @param right_x       Position x
+        *  @param bottom_y      Position y
+        *  @param frameColor    16bit Color of the rectangle lines
+        *  @param fillColor     16bit Color of the filling
+        */
+        void drawRect(uint8_t left_x, uint8_t top_y, uint8_t righ_x, uint8_t bottom_y, uint16_t borderColor, uint16_t fillColor);
+        
+        /** Copys an area from a given position to a certain position. Larger coordinates than the screen will be set to RGB_OLED_XMAX and RGB_OLED_YMAX
+        *
+        *  @param x0      Position x top left corner
+        *  @param y0      Position y top left corner
+        *  @param x1      Position x bottom right corner
+        *  @param y1      Position y bottom right corner
+        *  @param x2      New Position x topleft corner
+        *  @param y2      New Position y topleft corner
+        */
         void copyArea(uint8_t x0, uint8_t y0, uint8_t x1, uint8_t y1, uint8_t x2, uint8_t y2);
+        
+        /** Dims an area from a given start position to a given end position. Larger coordinates than the screen will be set to RGB_OLED_XMAX and RGB_OLED_YMAX
+        *
+        *  @param x0      Position x top left corner
+        *  @param y0      Position y top left corner
+        *  @param x1      Position x bottom right corner
+        *  @param y1      Position y bottom right corner
+        */
         void dimArea(uint8_t x0, uint8_t y0, uint8_t x1, uint8_t y1);
+        
+        /** Clears an area from a given start position to a given end position. Larger coordinates than the screen will be set to RGB_OLED_XMAX and RGB_OLED_YMAX
+        *
+        *  @param x0      Position x top left corner
+        *  @param y0      Position y top left corner
+        *  @param x1      Position x bottom right corner
+        *  @param y1      Position y bottom right corner
+        */
         void clearArea(uint8_t x0, uint8_t y0, uint8_t x1, uint8_t y1);
+        
+        /** Moves an area from a given start position to a given end position. Larger coordinates than the screen will be set to RGB_OLED_XMAX and RGB_OLED_YMAX
+        *
+        *  @param x0      Position x top left corner
+        *  @param y0      Position y top left corner
+        *  @param x1      Position x bottom right corner
+        *  @param y1      Position y bottom right corner
+        */
         void moveArea(uint8_t x0, uint8_t y0, uint8_t x1, uint8_t y1, uint8_t x2, uint8_t y2);
+        
+        /** Fills the screen with a given color. Larger coordinates than the screen will be set to RGB_OLED_XMAX and RGB_OLED_YMAX
+        *
+        *  @param x0      Position x top left corner
+        *  @param y0      Position y top left corner
+        *  @param x1      Position x bottom right corner
+        *  @param y1      Position y bottom right corner
+        */
         virtual void fillScreen(uint16_t color);
-        void setScolling(ScollingDirection direction, uint8_t rowAddr, uint8_t rowNum, uint8_t timeInterval);
+        
+        /** Sets the direction and starts the scrolling of the display content.
+        *
+        *  @param direction    Direction of the scrolling SD_Horizontal, SD_Vertical or SD_Diagonal
+        *  @param rowAddr      Position y top left corner
+        *  @param rowNum       Position x bottom right corner
+        *  @param interval     Speed of the scrolling either 6, 10 100 or 200 frames
+        */
+        void setScolling(ScollingDirection direction, uint8_t rowAddr, uint8_t rowNum, ScrollInterval interval);
+        
+        /** Enables or disables the scrolling
+        *
+        *  @param enable   Set true or flase for enabling or disabling the scrolling
+        */
         void enableScolling(bool enable);
+        
+        /** Sets the display mode of the oled screen
+        *
+        *  @param mode      DM_NormalDisplay, DM_DisplayOn, DM_DisplayOff or DM_InverseDisplay
+        */
         void setDisplayMode(DisplayMode mode);
-        void setDisplayPower(DisplayPower power);
+        
+        /** Sets the power mode of the display
+        *
+        *  @param mode   PM_SleepMode or PM_NormalMode
+        */
+        void setPowerMode(PowerMode mode);
         
     protected:
          // Stream implementation functions