Test for STM32F4

Dependents:   Nucleo_SSD1331

Fork of RGB_OLED_SSD1331 by Juergen M

Revision:
4:1707ca53e7d5
Parent:
3:af00512c9694
Child:
5:9de43186f5ea
--- a/src/SSD1331.cpp	Thu Nov 12 23:23:33 2015 +0000
+++ b/src/SSD1331.cpp	Thu Nov 12 23:53:58 2015 +0000
@@ -69,6 +69,7 @@
     init();
 };
 
+//------------------------------------------------------------------------------------
 void SSD1331::sendCmd(uint8_t cmd)
 {
     _dc = 0;
@@ -77,6 +78,7 @@
     _cs = 1;
 }
 
+//------------------------------------------------------------------------------------
 void SSD1331::sendCmd(uint8_t cmd, uint8_t arg1)
 {
     _dc = 0;
@@ -85,7 +87,8 @@
     _spiPort.write(arg1);
     _cs = 1;
 }
-    
+
+//------------------------------------------------------------------------------------    
 void SSD1331::sendCmd(uint8_t cmd, uint8_t arg1, uint8_t arg2)
 {
     _dc = 0;
@@ -96,6 +99,7 @@
     _cs = 1;
 }    
 
+//------------------------------------------------------------------------------------
 void  SSD1331::sendCmd(uint8_t *cmd, uint8_t count)
 {
     if(!cmd) return;
@@ -107,6 +111,7 @@
     _cs = 1;
 }
 
+//------------------------------------------------------------------------------------
 void  SSD1331::sendData(uint16_t data)
 {
     _dc = HIGH;
@@ -116,16 +121,7 @@
     _cs = HIGH;
 }
 
-int SSD1331::_getc() 
-{
-    return -1;
-}
-
-int SSD1331::_putc( int c )
-{  
-    return -1;
-}
-
+//------------------------------------------------------------------------------------
 void SSD1331::init(void)
 {
     // initialize sequence
@@ -198,42 +194,38 @@
 //    sendCmd(CMD_NORMAL_BRIGHTNESS_DISPLAY_ON);//set display on
 }
 
+//------------------------------------------------------------------------------------
 void SSD1331::drawPixel(uint8_t x, uint8_t y, uint16_t color)
 {
     if ((x >= RGB_OLED_WIDTH) || (y >= RGB_OLED_HEIGHT))
         return;
         
     //                      set column point               set row point
-    uint8_t cmd[7] = {CMD_SET_COLUMN_ADDRESS, x, x,  CMD_SET_ROW_ADDRESS, y, y,   0x00};
+    uint8_t cmd[6] = { CMD_SET_COLUMN_ADDRESS, x, x,  CMD_SET_ROW_ADDRESS, y, y };
     sendCmd(cmd, 6);
 
     //fill 16bit colour
     sendData(color);
 }
 
-//-------------------------------------------------------------------------
-void SSD1331::drawLine(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1, uint16_t color)
+//------------------------------------------------------------------------------------
+void SSD1331::drawLine(uint8_t x0, uint8_t y0, uint8_t x1, uint8_t y1, uint16_t color)
 {
-    if (x0 >= RGB_OLED_WIDTH)  x0 = RGB_OLED_WIDTH - 1;
+    if (x0 >= RGB_OLED_WIDTH)  x0 = RGB_OLED_WIDTH  - 1;
     if (y0 >= RGB_OLED_HEIGHT) y0 = RGB_OLED_HEIGHT - 1;
-    if (x1 >= RGB_OLED_WIDTH)  x1 = RGB_OLED_WIDTH - 1;
+    if (x1 >= RGB_OLED_WIDTH)  x1 = RGB_OLED_WIDTH  - 1;
     if (y1 >= RGB_OLED_HEIGHT) y1 = RGB_OLED_HEIGHT - 1;
-
-    sendCmd(CMD_DRAW_LINE);//draw line
-    sendCmd(x0);//start column
-    sendCmd(y0);//start row
-    sendCmd(x1);//end column
-    sendCmd(y1);//end row
-    sendCmd((uint8_t)((color>>11)&0x1F));//R
-    sendCmd((uint8_t)((color>>5)&0x3F));//G
-    sendCmd((uint8_t)(color&0x1F));//B
+    
+    uint8_t cmd[8] = { CMD_DRAW_LINE, x0, y0, x1, y1, (uint8_t)((color>>11)&0x1F), (uint8_t)((color>>5)&0x3F), (uint8_t)(color&0x1F) };
+    sendCmd(cmd, 8);
 }
 
+//------------------------------------------------------------------------------------
 void SSD1331::drawFrame(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1, uint16_t outColor, uint16_t fillColor)
 {
-    if (x0 >= RGB_OLED_WIDTH)  x0 = RGB_OLED_WIDTH - 1;
+    if (x0 >= RGB_OLED_WIDTH)  x0 = RGB_OLED_WIDTH  - 1;
     if (y0 >= RGB_OLED_HEIGHT) y0 = RGB_OLED_HEIGHT - 1;
-    if (x1 >= RGB_OLED_WIDTH)  x1 = RGB_OLED_WIDTH - 1;
+    if (x1 >= RGB_OLED_WIDTH)  x1 = RGB_OLED_WIDTH  - 1;
     if (y1 >= RGB_OLED_HEIGHT) y1 = RGB_OLED_HEIGHT - 1;
 
     sendCmd(CMD_FILL_WINDOW);//fill window
@@ -251,6 +243,7 @@
     sendCmd((uint8_t)(fillColor&0x1F));//B
 }
 
+//------------------------------------------------------------------------------------
 void SSD1331::copyWindow(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1,uint16_t x2, uint16_t y2)
 {
     sendCmd(CMD_COPY_WINDOW);//copy window
@@ -262,6 +255,7 @@
     sendCmd(y2);//new row
 }
 
+//------------------------------------------------------------------------------------
 void SSD1331::dimWindow(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1)
 {
     sendCmd(CMD_DIM_WINDOW);//copy area
@@ -271,6 +265,7 @@
     sendCmd(y1);//end row
 }
 
+//------------------------------------------------------------------------------------
 void SSD1331::clearWindow(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1)
 {
     sendCmd(CMD_CLEAR_WINDOW);//clear window
@@ -280,6 +275,7 @@
     sendCmd(y1);//end row
 }
 
+//------------------------------------------------------------------------------------
 void SSD1331::setScolling(ScollingDirection direction, uint8_t rowAddr, uint8_t rowNum, uint8_t timeInterval)
 {
     uint8_t scolling_horizontal = 0x0;
@@ -309,6 +305,7 @@
     sendCmd(CMD_ACTIVE_SCROLLING);
 }
 
+//------------------------------------------------------------------------------------
 void SSD1331::enableScolling(bool enable)
 {
     if(enable)
@@ -317,12 +314,26 @@
         sendCmd(CMD_DEACTIVE_SCROLLING);
 }
 
+//------------------------------------------------------------------------------------
 void SSD1331::setDisplayMode(DisplayMode mode)
 {
     sendCmd(mode);
 }
 
+//------------------------------------------------------------------------------------
 void SSD1331::setDisplayPower(DisplayPower power)
 {
     sendCmd(power);
 }
+
+//------------------------------------------------------------------------------------
+int SSD1331::_getc() 
+{
+    return -1;
+}
+
+//------------------------------------------------------------------------------------
+int SSD1331::_putc( int c )
+{  
+    return -1;
+}
\ No newline at end of file