displaying on SSD1306, 128x64 pixels OLED

Dependencies:   microbit

Files at this revision

API Documentation at this revision

Comitter:
bvirk
Date:
Tue Feb 25 20:59:35 2020 +0000
Parent:
11:77aaf68a180b
Commit message:
doc removed from cpp files

Changed in this revision

Display.cpp Show annotated file Show diff for this revision Revisions of this file
Display.h Show annotated file Show diff for this revision Revisions of this file
OLED.cpp Show annotated file Show diff for this revision Revisions of this file
OLED.h Show annotated file Show diff for this revision Revisions of this file
doc/microbitOLED.md Show annotated file Show diff for this revision Revisions of this file
diff -r 77aaf68a180b -r b4d5e007640e Display.cpp
--- a/Display.cpp	Tue Feb 25 18:22:01 2020 +0000
+++ b/Display.cpp	Tue Feb 25 20:59:35 2020 +0000
@@ -1,102 +1,46 @@
 #include "MicroBit.h"
 #include "Display.h"
 
-/**
-  * When constructed from MicroBit's  MicroBitDisplay of a not yet initialized 
-  * MicroBit object - that must be done before using the Display instance.
-  *
-  * @param uDpl is e.g. MicroBit's  MicroBitDisplay
-  */
 Display::Display(MicroBitDisplay & uDpl) : uDisplay(uDpl)  {
     clearStick();
     }
 
-/**
-  * Clears the display and its buffer 
-  */
 void Display::clear() {
     uDisplay.image.clear();
     clearStick();
     }
 
-/**
-  * The stick's length is represented by the count of digits being 1.
-  * @param size in range [0,24]
-  */
 void Display::setStick(uint8_t length) {
      curLength = length;
      paintStick(&Display::lessCurLength);
      }   
 
-/**
-  * Set a single dot
-  *
-  * @param position in [0,24] for showing that single dot.
-  */
 void Display::setFlag(uint8_t position) {
     showbit = position;
     paintStick(&Display::orPoint);
     }
 
-/**
-  * Puts a bitpattern in a row
-  *
-  * @param rowNr in [0,4] for selected row
-  * @param rowContent in [0,31] to be shown binary
-  */
 void Display::toRow(uint8_t rowNr, uint8_t rowContent) {
     this->rowNr=rowNr;
     showbit=rowContent;
     paintStick(&Display::bitplot);
     }
 
-/**
-  * 25 bits showed in the display as a whole.
-  *
-  * @param bits25 contains the 25 bit to be showed
-  */
 void Display::toRows(uint32_t bits25) {    
     showbit=bits25;
     paintStick(&Display::simplePlot);
     }
 
-/**
-  * Vertdecimal is intended for showing a single number in [00000,99999],
-  * vertical read from top to bottom.
-  *
-  * @param r0 bottom row - row 0 
-  * @param r1 row 1
-  * @param r2 row 2
-  * @param r3 row 3 
-  * @param r4 top row - row 4
-  */
 void Display::vertDecimal(uint8_t r0,uint8_t r1,uint8_t r2,uint8_t r3,uint8_t r4) {
     vertDecimal(r0,r1,r2,r3,r4,false);
     }
 
-/**
-  * Vertdecimal is intended for showing a single number in [00000,99999],
-  * vertical read from top to bottom.
-  * 
-  * @param r0 bottom row - row 0 
-  * @param r1 row 1
-  * @param r2 row 2
-  * @param r3 row 3 
-  * @param r4 top row - row 4
-  * @param leftDotOn turns left dot on. leftdot is not used to represent a digit in base 10 numbers.
-  */
 void Display::vertDecimal(uint8_t r0,uint8_t r1,uint8_t r2,uint8_t r3,uint8_t r4, bool b15On) {
     Ledrows lr(r0,r1,r2,r3,r4,b15On);
     showbit = lr.all;
     paintStick(&Display::simplePlot);
     }
 
-/**
-  * Binary Clock, hours in top rows (4 for multiplum of 10, 3 for remainer)
-  * minuts in bottom rows (1 for multiplum of 10, 0 for remainer)
-  *
-  * @param minuts of the day
-  */
 void Display::vertClock(uint16_t minuts) {
     uint8_t hours = minuts/60;
     minuts -= 60*hours;
@@ -105,13 +49,6 @@
     vertDecimal(minuts-10*m1,m1,16,hours-10*h1,h1,false);
 }
     
-/**
-  * Binary Clock, hours in row 4 (top row)
-  * minuts in rows 3 and 2  (3 for multiplum of 10, 2 for remainer)
-  * seconds in rows 1 and 0 (1 for multiplum of 10, 0 for remainer) 
-  *
-  * @param second of the day
-  */
 void Display::vertSecClock(uint32_t seconds) {
     uint8_t hours = seconds/3600;
     uint8_t minuts = (seconds - 3600*hours)/60;
diff -r 77aaf68a180b -r b4d5e007640e Display.h
--- a/Display.h	Tue Feb 25 18:22:01 2020 +0000
+++ b/Display.h	Tue Feb 25 20:59:35 2020 +0000
@@ -5,8 +5,9 @@
 #define microbitOLED_Display
 
 /**
-  * Constructer takes five 5bit and a being true 'showing left column' 
-  * parameters for the led display.
+  * Constructs display by parameters to the '5 rows'.
+  * Takes five 5bit values in range [0,31] and a bool \n 
+  * value for 'showing left bit column' 
   */
 struct Ledrows {
     union {
@@ -25,17 +26,18 @@
 
 
 /**
-  * Use Microbit 5x5 led display in various output communications
+  * Use Microbit 5x5 led display in various output communications.
   * It deals with display in DISPLAY_MODE_BLACK_AND_WHITE mode 
   */
 class Display { 
 
     /**
-      * Representation the 25 leds, counting from right bottom and continuing 
-      * from right on each row above. Light on is the pixel value 1 or true
-      * Writting to the display is writting to this buffer AND the display  only
-      * if a value is changed - this demands clearing the display is clearing this 
-      * buffer prior uDisplay.image.clear();;
+      * Representation the 25 leds.
+      * The physical leds are counted from right bottom and continuing \n 
+      * from right on each row above. Light in a led corresponds to 1 stick.\n 
+      * Writting to the display is writting to this buffer AND the display  \n 
+      * only if a value is changed - this demands clearing the display is \n 
+      * nullifying this stick prior uDisplay.image.clear();
       */
     bool stick[25];
     MicroBitDisplay & uDisplay;
@@ -47,8 +49,11 @@
 public:
 
     /**
-      * When constructed from MicroBit's  MicroBitDisplay of a not yet initialized 
-      * MicroBit object - that must be done before using the Display instance.
+      * Display hold a refference to a MicroBitDisplay object. 
+      * When constructed from MicroBit's  MicroBitDisplay of a not yet initialized \n 
+      * MicroBit object - that must be done before using the Display instance.\n 
+      *
+      * @param uDpl reference to a MicroBitDisplay object.
       */
     Display(MicroBitDisplay & uDpl);
     
@@ -59,19 +64,20 @@
     
     /**
       * The stick's length is represented by the count of digits being 1.
+      *
       * @param size in range [0,24]
       */
     void setStick(uint8_t size);
     
     /**
-      * Set a single dot
+      * Set a single dot.
       *
       * @param position in [0,24] for showing that single dot.
       */
     void setFlag(uint8_t position);
     
     /**
-      * Puts a bitpattern in a row
+      * Puts a bitpattern in a row.
       *
       * @param rowNr in [0,4] for selected row
       * @param rowContent in [0,31] to be shown binary
@@ -86,8 +92,12 @@
     void toRows(uint32_t allBits);
 
     /**
-      * Vertdecimal is intended for showing a single number in [00000,99999],
-      * vertical read from top to bottom.
+      * Vertdecimal shows a single number in [00000,99999].
+      * The parameters goes from top to bottom, whereas a obvious \n  
+      * perception is reading the disply number from top bottom. \n   
+      * Nothing restrict the rows to hold values less teen \n 
+      * but if some are greather than 31 the value or proberbly \n
+      * bitwise ored og cleared by other numbers
       *
       * @param r0 bottom row - row 0 
       * @param r1 row 1
@@ -98,9 +108,10 @@
     void vertDecimal(uint8_t r0,uint8_t r1,uint8_t r2,uint8_t r3,uint8_t r4); 
   
     /**
-      * Vertdecimal is intended for showing a single number in [00000,99999],
-      * vertical read from top to bottom.
-      *
+      * Vertdecimal shows a single number in [00000,99999].
+      * The parameters goes from top to bottom, whereas a obvious \n  
+      * perception is reading the disply number from top bottom. \n   
+      * It os possible to turn on left column on the display
       * 
       * @param r0 bottom row - row 0 
       * @param r1 row 1
@@ -112,7 +123,8 @@
     void vertDecimal(uint8_t r0,uint8_t r1,uint8_t r2,uint8_t r3,uint8_t r4, bool leftDotOn);
 
     /**
-    * Binary Clock, hours in top rows (4 for multiplum of 10, 3 for remainer)
+    * Binary Clock with hours and minuts.
+    * hours in top rows (4 for multiplum of 10, 3 for remainer) \n 
     * minuts in bottom rows (1 for multiplum of 10, 0 for remainer)
     *
     * @param minuts of the day
@@ -120,9 +132,11 @@
     void vertClock(uint16_t minuts); 
     
     /**
-    * Binary Clock, hours in row 4 (top row)
-    * minuts in rows 3 and 2  (3 for multiplum of 10, 2 for remainer)
-    * seconds in rows 1 and 0 (1 for multiplum of 10, 0 for remainer) 
+    * Binary Clock with hours, minuts an seconds.
+    * hours in row 4 (top row)\n 
+    * minuts in rows 3 and 2  (3 for multiplum of 10, 2 for remainer)\n 
+    * seconds in rows 1 and 0 (1 for multiplum of 10, 0 for remainer)\n 
+    *
     * @param second of the day
     */
     void vertSecClock(uint32_t minuts); 
diff -r 77aaf68a180b -r b4d5e007640e OLED.cpp
--- a/OLED.cpp	Tue Feb 25 18:22:01 2020 +0000
+++ b/OLED.cpp	Tue Feb 25 20:59:35 2020 +0000
@@ -5,11 +5,6 @@
 #include "OLED.h"
 #include "cppNorm.h"
 
-/**
-  * ssd1306 compatible device of 128x64 pixels OLED display.
-  * Init() must be called after construction.
-  * Works for some untraced circumstances not in fibers
-  */
 OLED::OLED() : 
      i2c(I2C_SDA0,I2C_SCL0)
     ,charX(0)
@@ -27,10 +22,6 @@
     i2c.write(chipAdress,buf,2);
 }
 
-/**
-  * Initialisere display and clears it. A buffer representing charaters are 
-  * filled with space characters
-  */ 
 void OLED::init() {
     init(128, 64);
     }
@@ -93,16 +84,6 @@
     setTextArea(32,true);
 }
 
-/**
-  * Put a char on display. The font used displays characters in 6x8 pixels
-  * area (6 horizontal). The font does actual contain 5 colums - the six'd
-  * makes charcters seperation. Character values 0, 0x20, and 0xff are
-  * are bitpatterns with all null pixels (like space)
-  *
-  * @param x horizontal pixelwise position, range [0,displayWidth - 6]
-  * @param y vertical position, range [0,7]
-  * @param chr character to put on display
-  */
 void OLED::drawChar(uint8_t x, uint8_t y, uint8_t chr ) {
     command(SSD1306_SETCOLUMNADRESS);
     command(x);
@@ -130,23 +111,12 @@
                 textArea[xPos][line]=chr;
 }
 
-/**
-  * Scroll display one line up. An empty line will arise at bottom.
-  * test: only in cpp
-  */
 void OLED::scroll() {
     for (int8_t line = 1; line <= 8; line++)
         for (int8_t xPos = 0; xPos < 22; xPos++)
             drawChar(6*xPos,line-1,textArea[xPos][line]);
 }    
 
-/** 
-  * Makes a newline by incrementing charY and assigning xOffset to charX \n 
-  * If charY becomes 8 the display screen is scrolled one line and charY \n 
-  * is decremented to 7. pendingNewline=false is done at last. \n
-  * pendingNewline=false is done at last. 
-  *
-  */
 void OLED::newLine() {
     charY++;
     charX = xOffset;
@@ -157,13 +127,6 @@
     pendingNewline=false;
 }
             
-/** 
-  * Writes a string at charX, charY position. Afterwards are \n 
-  * charX, charY set to the next starting point for writting to display \n 
-  * \\n and \\r is processed - \\n includes \\r  functionality. \n 
-  *
-  * @param str to be displayed at (charX, charY).   
-  */
 void OLED::puts(string str) {
     for (uint16_t i = 0; i < str.length(); i++) {
         if (str.charAt(i) == '\r')
@@ -181,11 +144,6 @@
     }
 }
 
-/**
-  * printf - the old classic. \\n and \\r is processed. \n 
-  * \\n includes \\r  functionality. \n    
-  * This function is the main reason to that OLED not works in fibers. \n
-  */
 uint8_t OLED::printf(const char * fmt, ...) {
     va_list args;
     va_start(args, fmt);
diff -r 77aaf68a180b -r b4d5e007640e OLED.h
--- a/OLED.h	Tue Feb 25 18:22:01 2020 +0000
+++ b/OLED.h	Tue Feb 25 20:59:35 2020 +0000
@@ -31,9 +31,10 @@
 #define SSD1306_SETSTARTLINE 0x40
 
 /**
-  * Access to bit 0-7, named  by0 or x, and bit 8-15, named by1 or y 
-  * of 16 bit named that16. Can be consructed with either two uint8_t or
-  * a uint16_t
+  * Access to bitfields under different names.
+  * Access to bit 0-7, named  by0 or x, and bit 8-15, named by1 or y \n  
+  * of 16 bit named that16. Can be consructed with either two \n  
+  * uint8_t or a uint16_t
   */
 union uint16 {
     struct {
@@ -307,7 +308,7 @@
     {0x00,0x00,0x00,0x00,0x00}};
 
 /**
-  * Representation of a 128x64 pixels, SSD1306 compatibel OLED display
+  * Representation of a 128x64 pixels, SSD1306 compatibel OLED display.
   */ 
 class OLED {
     
@@ -339,19 +340,19 @@
 
     /**
       * ssd1306 compatible device of 128x64 pixels OLED display.
-      * Init() must be called after construction.
+      * Init() must be called after construction. \n 
       * Works for some untraced circumstances not in fibers
       */
     OLED();
 
     /**
-      * Initialisere display and clears it. A buffer representing charaters are 
-      * filled with space characters
+      * Initialisere display and clears it. 
+      * A buffer representing charaters are filled with space characters.
       */ 
     void init();
     
     /**
-      * Clears the display. only in h
+      * Clears the display.
       */
     void clear();
 
@@ -359,15 +360,15 @@
       * Makes a newline by incrementing charY and assigning xOffset to charX \n 
       * if charY becomes 8 the display screen is scrolled one line and charY \n 
       * is decremented to 7. pendingNewline=false is done at last.
-      * pendingNewline=false is done at last.
       */
     void newLine();
     
     /**
-      * Put a char on display. The font used displays characters in 6x8 pixels
-      * area (6 horizontal). The font does actual contain 5 colums - the six'd
-      * makes charcters seperation. Character values 0, 0x20, and 0xff are
-      * are bitpatterns with all null pixels (like space)
+      * Put a char on display. 
+      * The font represent display characters as 6x8 pixels areas (6 horizontal). \n 
+      * The font does actual contain 5 colums - the six'd makes characters \n 
+      * seperation. Character values 0, 0x20, and 0xff are bitpatterns with \n
+      * all null pixels (like space)
       *
       * @param x horizontal pixelwise position, range [0,displayWidth - 6]
       * @param y vertical position, range [0,7]
@@ -391,8 +392,10 @@
       */
     uint8_t printf(const char * frmt, ...);   
     
+    /**
+     *  Scroll the display one line
+     */
     void scroll();
     
 };
 #endif
-
diff -r 77aaf68a180b -r b4d5e007640e doc/microbitOLED.md
--- a/doc/microbitOLED.md	Tue Feb 25 18:22:01 2020 +0000
+++ b/doc/microbitOLED.md	Tue Feb 25 20:59:35 2020 +0000
@@ -1,4 +1,4 @@
-pesentation on Github
+Presentation on Github
 
     https://github.com/bvirk/myMicrobit/blob/master/mbed/microbitOLED.md