UniGraphic-Fork for ST7920-LCD-controller and SH1106. Tested with 128x64 LCD with SPI and 128x64-OLED with IIC

Dependents:   UniGraphic-St7920-Test AfficheurUTILECO

Fork of UniGraphic by GraphicsDisplay

Fork of the UniGraphic-Library for monochrome LCDs with ST7920 controller and 128x64-IIC-OLED-Display with SH1106-Controller

/media/uploads/charly/20170522_210344.jpg

/media/uploads/charly/20180425_230623.jpg

Had to adapt LCD for following reasons:

  • Give access to screenbuffer buffer[] to parent class
  • pixel() and pixel_read() as they are hardware-dependent
  • added reset-pin to IIC-Interface

GraphicDisplay:: sends buffer to LCD when auto_update is set to true.

Testprogram for ST7920 can be found here:

https://developer.mbed.org/users/charly/code/UniGraphic-St7920-Test/

Files at this revision

API Documentation at this revision

Comitter:
Geremia
Date:
Thu Jun 11 22:39:09 2015 +0000
Parent:
21:ae0a4eedfc90
Child:
23:d0eb35bbd2f3
Commit message:
Add set_font_zoom(x_mul, y_mul)

Changed in this revision

Graphics/GraphicsDisplay.cpp Show annotated file Show diff for this revision Revisions of this file
Graphics/GraphicsDisplay.h Show annotated file Show diff for this revision Revisions of this file
--- a/Graphics/GraphicsDisplay.cpp	Tue Mar 31 21:14:48 2015 +0000
+++ b/Graphics/GraphicsDisplay.cpp	Thu Jun 11 22:39:09 2015 +0000
@@ -32,6 +32,8 @@
     char_y = 0;
     oriented_width=0;
     oriented_height=0;
+    fontzoomver=1;
+    fontzoomhor=1;
     auto_up = true;
 }
     
@@ -244,13 +246,19 @@
     firstch = firstascii;   // first ascii code present in font array (usually 32)
     lastch = lastascii;     // last ascii code present in font array (usually 127)
     fontprop=proportional;
+    set_font_zoom(1,1);
+}
+void GraphicsDisplay::set_font_zoom(unsigned char x_mul, unsigned char y_mul)
+{
+    fontzoomhor=((x_mul==0) ? 1:x_mul);
+    fontzoomver=((y_mul==0) ? 1:y_mul);
 }
 int GraphicsDisplay::_putc(int value)
 {
     if (value == '\n') {    // new line
         char_x = 0;
-        char_y = char_y + fontvert;
-        if (char_y >= oriented_height - fontvert) {
+        char_y = char_y + fontvert*fontzoomver;
+        if (char_y >= oriented_height - fontvert*fontzoomver) {
             char_y = 0;
         }
     } else {
@@ -265,7 +273,7 @@
     char_y=y;
     int j,i,b;
     unsigned char* zeichen;
-    unsigned char z,w;
+    unsigned char z,w,v;
 
     if ((c < firstch) || (c > lastch)) return;   // test char range
 
@@ -275,36 +283,38 @@
     vert = font[2];                      // get vert size of font
     bpl = font[3];                       // bytes per line
 */
-    if (char_x + fonthor > oriented_width) {
+    if (char_x + fonthor*fontzoomhor > oriented_width) {
         char_x = 0;
-        char_y = char_y + fontvert;
-        if (char_y > oriented_height - fontvert) {
+        char_y = char_y + fontvert*fontzoomver;
+        if (char_y > oriented_height - fontvert*fontzoomver) {
             char_y = 0;
         }
     }
-    window(char_x, char_y,fonthor,fontvert); // char box
+    window(char_x, char_y,fonthor*fontzoomhor,fontvert*fontzoomver); // char box
     zeichen = &font[((c-firstch) * fontoffset) + 4]; // start of char bitmap
     w = zeichen[0];                          // width of actual char
     // construct the char into the buffer
     for (j=0; j<fontvert; j++) {  //  vert line
+        for (v=0; v<fontzoomver; v++) { // repeat horiz line for vertical zooming
         for (i=0; i<fonthor; i++) {   //  horz line
             z =  zeichen[(fontbpl * i) + ((j & 0xF8) >> 3)+1];
             b = 1 << (j & 0x07);
             if (( z & b ) == 0x00) {
              //   pixel(char_x+i,char_y+j,0);
-                window_pushpixel(_background);
+                window_pushpixel(_background, fontzoomhor); //(color, howmany)
             } else {
             //    pixel(char_x+i,char_y+j,1);
-                window_pushpixel(_foreground);
+                window_pushpixel(_foreground, fontzoomhor);
             }
         }
+        } //for each zoomed vert
     }
     if(fontprop)
     {
-        if((w+1)<fonthor) char_x += w+1; // put at least 1 blank after variable-width characters, except characters that occupy whole fonthor space like "_"
-        else char_x += fonthor;
+        if((w+1)<fonthor) char_x += (w*fontzoomhor)+1; // put at least 1 blank after variable-width characters, except characters that occupy whole fonthor space like "_"
+        else char_x += fonthor*fontzoomhor;
     }
-    else char_x += fonthor; // fixed width
+    else char_x += fonthor*fontzoomhor; // fixed width
 }
 void GraphicsDisplay::Bitmap_BW(Bitmap_s bm, int x, int y)
 {
--- a/Graphics/GraphicsDisplay.h	Tue Mar 31 21:14:48 2015 +0000
+++ b/Graphics/GraphicsDisplay.h	Thu Jun 11 22:39:09 2015 +0000
@@ -277,6 +277,13 @@
    *
    */  
   void set_font(unsigned char* f, unsigned char firstascii=32, unsigned char lastascii=127, bool proportional = true);
+  
+  /** Zoom fount
+   *
+   * @param x_mul horizontal size multiplier
+   * @param y_mul vertical size multiplier
+   */  
+  void set_font_zoom(unsigned char x_mul, unsigned char y_mul);
 
     /** Get the number of columns based on the currently active font.
     * @returns number of columns.
@@ -341,6 +348,8 @@
     int  fonthor;   // hor size of font (char)
     int  fontvert;  // ver size of font (char)
     int fontbpl;   // bytes per line (char)
+    int fontzoomver; // size multiplier
+    int fontzoomhor; // size multiplier
     unsigned char firstch;  // first ascii code present in font array (usually 32)
     unsigned char lastch;   // last ascii code present in font array (usually 127)
     bool auto_up;  // autoupdate flag for LCD