graphlcd-base/glcddrivers/driver.c
changeset 4 df6a40031aa5
child 30 7fd00015f62f
equal deleted inserted replaced
3:d0e62fc47285 4:df6a40031aa5
       
     1 /*
       
     2  * GraphLCD driver library
       
     3  *
       
     4  * driver.c  -  driver base class
       
     5  *
       
     6  * parts were taken from graphlcd plugin for the Video Disc Recorder
       
     7  * (c) 2001-2004 Carsten Siebholz <c.siebholz AT t-online.de>
       
     8  *
       
     9  * This file is released under the GNU General Public License. Refer
       
    10  * to the COPYING file distributed with this package.
       
    11  *
       
    12  * (c) 2004 Andreas Regel <andreas.regel AT powarman.de>
       
    13  */
       
    14 
       
    15 #include "common.h"
       
    16 #include "driver.h"
       
    17 
       
    18 
       
    19 namespace GLCD
       
    20 {
       
    21 
       
    22 cDriver::cDriver()
       
    23 :   width(0),
       
    24     height(0)
       
    25 {
       
    26 }
       
    27 
       
    28 void cDriver::SetScreen(const unsigned char * data, int wid, int hgt, int lineSize)
       
    29 {
       
    30     int x, y;
       
    31 
       
    32     if (wid > width)
       
    33         wid = width;
       
    34     if (hgt > height)
       
    35         hgt = height;
       
    36 
       
    37     Clear();
       
    38     if (data)
       
    39     {
       
    40         for (y = 0; y < hgt; y++)
       
    41         {
       
    42             for (x = 0; x < (wid / 8); x++)
       
    43             {
       
    44                 Set8Pixels(x * 8, y, data[y * lineSize + x]);
       
    45             }
       
    46             if (width % 8)
       
    47             {
       
    48                 Set8Pixels((wid / 8) * 8, y, data[y * lineSize + wid / 8] & bitmaskl[wid % 8 - 1]);
       
    49             }
       
    50         }
       
    51     }
       
    52 }
       
    53 
       
    54 } // end of namespace