graphlcd-base/glcddrivers/serdisp.c
changeset 4 df6a40031aa5
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/graphlcd-base/glcddrivers/serdisp.c	Wed Feb 06 17:32:55 2008 +0000
     1.3 @@ -0,0 +1,467 @@
     1.4 +/*
     1.5 + * GraphLCD driver library
     1.6 + *
     1.7 + * serdisp.h  -  include support for displays supported by serdisplib (if library is installed)
     1.8 + *               http://serdisplib.sourceforge.net
     1.9 + *
    1.10 + * This file is released under the GNU General Public License. Refer
    1.11 + * to the COPYING file distributed with this package.
    1.12 + *
    1.13 + * (c) 2003-2005 Wolfgang Astleitner <mrwastl AT users.sourceforge.net>
    1.14 + */
    1.15 +
    1.16 +#include <stdio.h>
    1.17 +#include <stdlib.h>
    1.18 +#include <syslog.h>
    1.19 +#include <dlfcn.h>
    1.20 +
    1.21 +#include "common.h"
    1.22 +#include "config.h"
    1.23 +#include "serdisp.h"
    1.24 +
    1.25 +#define SERDISP_VERSION(a,b) ((long)(((a) << 8) + (b)))
    1.26 +#define SERDISP_VERSION_GET_MAJOR(_c)  ((int)( (_c) >> 8 ))
    1.27 +#define SERDISP_VERSION_GET_MINOR(_c)  ((int)( (_c) & 0xFF ))
    1.28 +
    1.29 +// taken from serdisp_control.h
    1.30 +#define FEATURE_CONTRAST  0x01
    1.31 +#define FEATURE_REVERSE   0x02
    1.32 +#define FEATURE_BACKLIGHT 0x03
    1.33 +#define FEATURE_ROTATE    0x04
    1.34 +
    1.35 +#define SD_COL_BLACK      0xFF000000
    1.36 +
    1.37 +namespace GLCD
    1.38 +{
    1.39 +
    1.40 +cDriverSerDisp::cDriverSerDisp(cDriverConfig * config)
    1.41 +:   config(config)
    1.42 +{
    1.43 +    oldConfig = new cDriverConfig(*config);
    1.44 +
    1.45 +    dd = (void *) NULL;
    1.46 +}
    1.47 +
    1.48 +cDriverSerDisp::~cDriverSerDisp(void)
    1.49 +{
    1.50 +    delete oldConfig;
    1.51 +}
    1.52 +
    1.53 +int cDriverSerDisp::Init(void)
    1.54 +{
    1.55 +    char* errmsg; // error message returned by dlerror()
    1.56 +
    1.57 +    std::string controller;
    1.58 +    std::string optionstring = "";
    1.59 +    std::string wiringstring;
    1.60 +
    1.61 +
    1.62 +    // dynamically load serdisplib using dlopen() & co.
    1.63 +
    1.64 +    sdhnd = dlopen("libserdisp.so", RTLD_LAZY);
    1.65 +    if (!sdhnd) { // try /usr/local/lib
    1.66 +        sdhnd = dlopen("/usr/local/lib/libserdisp.so", RTLD_LAZY);
    1.67 +    }
    1.68 +
    1.69 +    if (!sdhnd) { // serdisplib seems not to be installed
    1.70 +        syslog(LOG_ERR, "%s: error: unable to dynamically load library '%s'. Err: %s (cDriver::Init)\n",
    1.71 +        config->name.c_str(), "libserdisp.so", "not found");
    1.72 +        return -1;
    1.73 +    }
    1.74 +
    1.75 +    dlerror(); // clear error code
    1.76 +
    1.77 +    /* pre-init some flags, function pointers, ... */
    1.78 +    supports_options = 0;
    1.79 +    fg_colour = 1;
    1.80 +    bg_colour = -1;
    1.81 +
    1.82 +    // get serdisp version
    1.83 +    fp_serdisp_getversioncode = (long int (*)()) dlsym(sdhnd, "serdisp_getversioncode");
    1.84 +
    1.85 +    if (dlerror()) { // no serdisp_getversioncode() -> version of serdisplib is < 1.95
    1.86 +        syslog(LOG_DEBUG, "%s: INFO: symbol serdisp_getversioncode unknown: autodetecting pre 1.95 serdisplib version (cDriver::Init)\n",
    1.87 +        config->name.c_str());
    1.88 +
    1.89 +        fp_SDCONN_open = (void*(*)(const char*)) dlsym(sdhnd, "SDCONN_open");
    1.90 +        if (dlerror()) { // no SDCONN_open() -> version of serdisplib is < 1.93
    1.91 +            serdisp_version = SERDISP_VERSION(1,92);
    1.92 +            syslog(LOG_DEBUG, "%s: INFO: detected serdisplib version <= 1.92 (cDriver::Init)\n", config->name.c_str());
    1.93 +
    1.94 +            fp_PP_open = (void*(*)(const char*))dlsym(sdhnd, "PP_open");
    1.95 +            if ( (errmsg = dlerror()) != NULL  ) { // should not happen
    1.96 +                syslog(LOG_ERR, "%s: error: cannot load symbol %s. Err:%s (cDriver::Init)\n",
    1.97 +                    config->name.c_str(), "PP_open", errmsg);
    1.98 +                return -1;
    1.99 +            }
   1.100 +            fp_PP_close = (void*(*)(void*))dlsym(sdhnd, "PP_close");
   1.101 +            if ( (errmsg = dlerror()) != NULL  ) { // should not happen
   1.102 +                syslog(LOG_ERR, "%s: error: cannot load symbol %s. Err:%s (cDriver::Init)\n",
   1.103 +                    config->name.c_str(), "PP_close", errmsg);
   1.104 +                return -1;
   1.105 +            }
   1.106 +        } else {
   1.107 +            serdisp_version = SERDISP_VERSION(1,94);  // no serdisp_getversioncode, but SDCONN_open: 1.93 or 1.94
   1.108 +            syslog(LOG_DEBUG, "%s: INFO: detected serdisplib version 1.93 or 1.94 (cDriver::Init)\n", config->name.c_str());
   1.109 +
   1.110 +            fp_serdisp_quit = (void (*)(void*)) dlsym(sdhnd, "serdisp_quit");
   1.111 +            if ( (errmsg = dlerror()) != NULL  ) { // should not happen
   1.112 +                syslog(LOG_ERR, "%s: error: cannot load symbol %s. Err:%s (cDriver::Init)\n",
   1.113 +                    config->name.c_str(), "serdisp_quit", errmsg);
   1.114 +                return -1;
   1.115 +            }
   1.116 +        }
   1.117 +
   1.118 +        fp_serdisp_setpixcol = (void (*)(void*, int, int, long int)) dlsym(sdhnd, "serdisp_setpixel");
   1.119 +        if ( (errmsg = dlerror()) != NULL  ) { // should not happen
   1.120 +            syslog(LOG_ERR, "%s: error: cannot load symbol %s. Err:%s (cDriver::Init)\n",
   1.121 +                config->name.c_str(), "serdisp_setpixel", errmsg);
   1.122 +            return -1;
   1.123 +        }
   1.124 +        fg_colour = 1; /* set foreground to 'pixel on' */
   1.125 +
   1.126 +    } else {  // serdisp version >= 1.95
   1.127 +        serdisp_version = fp_serdisp_getversioncode();
   1.128 +        syslog(LOG_DEBUG, "%s: INFO: detected serdisplib version %d.%d (cDriver::Init)\n",
   1.129 +            config->name.c_str(), SERDISP_VERSION_GET_MAJOR(serdisp_version), SERDISP_VERSION_GET_MINOR(serdisp_version));
   1.130 +
   1.131 +
   1.132 +        fp_SDCONN_open = (void*(*)(const char*)) dlsym(sdhnd, "SDCONN_open");
   1.133 +        if ( (errmsg = dlerror()) != NULL  ) { // should not happen
   1.134 +            syslog(LOG_ERR, "%s: error: cannot load symbol %s. Err:%s (cDriver::Init)\n",
   1.135 +                config->name.c_str(), "SDCONN_open", errmsg);
   1.136 +            return -1;
   1.137 +        }
   1.138 +        fp_serdisp_quit = (void (*)(void*)) dlsym(sdhnd, "serdisp_quit");
   1.139 +        if ( (errmsg = dlerror()) != NULL  ) { // should not happen
   1.140 +            syslog(LOG_ERR, "%s: error: cannot load symbol %s. Err:%s (cDriver::Init)\n",
   1.141 +                config->name.c_str(), "serdisp_quit", errmsg);
   1.142 +            return -1;
   1.143 +        }
   1.144 +        fp_serdisp_setpixcol = (void (*)(void*, int, int, long int)) dlsym(sdhnd, "serdisp_setcolour");
   1.145 +        if ( (errmsg = dlerror()) != NULL  ) { // should not happen
   1.146 +            syslog(LOG_ERR, "%s: error: cannot load symbol %s. Err:%s (cDriver::Init)\n",
   1.147 +                config->name.c_str(), "serdisp_setcolour", errmsg);
   1.148 +            return -1;
   1.149 +        }
   1.150 +        fg_colour = SD_COL_BLACK; /* set foreground colour to black */
   1.151 +
   1.152 +        if (serdisp_version >= SERDISP_VERSION(1,96) ) {
   1.153 +            supports_options = 1;
   1.154 +
   1.155 +            fp_serdisp_isoption = (int (*)(void*, const char*)) dlsym(sdhnd, "serdisp_isoption");
   1.156 +            if ( (errmsg = dlerror()) != NULL  ) { // should not happen
   1.157 +                syslog(LOG_ERR, "%s: error: cannot load symbol %s. Err:%s (cDriver::Init)\n",
   1.158 +                    config->name.c_str(), "serdisp_isoption", errmsg);
   1.159 +                return -1;
   1.160 +            }
   1.161 +            fp_serdisp_setoption = (void (*)(void*, const char*, long int)) dlsym(sdhnd, "serdisp_setoption");
   1.162 +            if ( (errmsg = dlerror()) != NULL  ) { // should not happen
   1.163 +                syslog(LOG_ERR, "%s: error: cannot load symbol %s. Err:%s (cDriver::Init)\n",
   1.164 +                    config->name.c_str(), "serdisp_setoption", errmsg);
   1.165 +                return -1;
   1.166 +            }
   1.167 +        } /* >= 1.96 */
   1.168 +    }
   1.169 +
   1.170 +    // load other symbols that will be required
   1.171 +    fp_serdisp_init = (void*(*)(void*, const char*, const char*)) dlsym(sdhnd, "serdisp_init");
   1.172 +    if ( (errmsg = dlerror()) != NULL  ) { // should not happen
   1.173 +        syslog(LOG_ERR, "%s: error: cannot load symbol %s. Err:%s (cDriver::Init)\n",
   1.174 +            config->name.c_str(), "serdisp_init", errmsg);
   1.175 +        return -1;
   1.176 +    }
   1.177 +
   1.178 +    fp_serdisp_rewrite = (void (*)(void*)) dlsym(sdhnd, "serdisp_rewrite");
   1.179 +    if ( (errmsg = dlerror()) != NULL  ) { // should not happen
   1.180 +        syslog(LOG_ERR, "%s: error: cannot load symbol %s. Err:%s (cDriver::Init)\n",
   1.181 +            config->name.c_str(), "serdisp_rewrite", errmsg);
   1.182 +        return -1;
   1.183 +    }
   1.184 +
   1.185 +    fp_serdisp_update = (void (*)(void*)) dlsym(sdhnd, "serdisp_update");
   1.186 +    if ( (errmsg = dlerror()) != NULL  ) { // should not happen
   1.187 +        syslog(LOG_ERR, "%s: error: cannot load symbol %s. Err:%s (cDriver::Init)\n",
   1.188 +            config->name.c_str(), "serdisp_update", errmsg);
   1.189 +        return -1;
   1.190 +    }
   1.191 +
   1.192 +    fp_serdisp_clearbuffer = (void (*)(void*)) dlsym(sdhnd, "serdisp_clearbuffer");
   1.193 +    if ( (errmsg = dlerror()) != NULL  ) { // should not happen
   1.194 +        syslog(LOG_ERR, "%s: error: cannot load symbol %s. Err:%s (cDriver::Init)\n",
   1.195 +            config->name.c_str(), "serdisp_clearbuffer", errmsg);
   1.196 +        return -1;
   1.197 +    }
   1.198 +
   1.199 +    fp_serdisp_feature = (int (*)(void*, int, int)) dlsym(sdhnd, "serdisp_feature");
   1.200 +    if ( (errmsg = dlerror()) != NULL  ) { // should not happen
   1.201 +        syslog(LOG_ERR, "%s: error: cannot load symbol %s. Err:%s (cDriver::Init)\n",
   1.202 +            config->name.c_str(), "serdisp_feature", errmsg);
   1.203 +        return -1;
   1.204 +    }
   1.205 +
   1.206 +    fp_serdisp_close = (void (*)(void*))dlsym(sdhnd, "serdisp_close");
   1.207 +    if ( (errmsg = dlerror()) != NULL  ) { // should not happen
   1.208 +        syslog(LOG_ERR, "%s: error: cannot load symbol %s. Err:%s (cDriver::Init)\n",
   1.209 +            config->name.c_str(), "serdisp_close", errmsg);
   1.210 +        return -1;
   1.211 +    }
   1.212 +
   1.213 +    fp_serdisp_getwidth = (int (*)(void*)) dlsym(sdhnd, "serdisp_getwidth");
   1.214 +    if ( (errmsg = dlerror()) != NULL  ) { // should not happen
   1.215 +        syslog(LOG_ERR, "%s: error: cannot load symbol %s. Err:%s (cDriver::Init)\n",
   1.216 +            config->name.c_str(), "serdisp_getwidth", errmsg);
   1.217 +        return -1;
   1.218 +    }
   1.219 +
   1.220 +    fp_serdisp_getheight = (int (*)(void*)) dlsym(sdhnd, "serdisp_getheight");
   1.221 +    if ( (errmsg = dlerror()) != NULL  ) { // should not happen
   1.222 +        syslog(LOG_ERR, "%s: error: cannot load symbol %s. Err:%s (cDriver::Init)\n",
   1.223 +            config->name.c_str(), "serdisp_getheight", errmsg);
   1.224 +        return -1;
   1.225 +    }
   1.226 +
   1.227 +    // done loading all required symbols
   1.228 +
   1.229 +
   1.230 +    // setting up the display
   1.231 +    width = 0;
   1.232 +    height = 0;
   1.233 +
   1.234 +    for (unsigned int i = 0; i < config->options.size(); i++)
   1.235 +    {
   1.236 +        if (config->options[i].name == "Controller") {
   1.237 +            controller = config->options[i].value;
   1.238 +        } else if (config->options[i].name == "Options") {
   1.239 +            optionstring = config->options[i].value;
   1.240 +        } else if (config->options[i].name == "Wiring") {
   1.241 +            wiringstring = config->options[i].value;
   1.242 +        } else if (config->options[i].name == "FGColour") {
   1.243 +            fg_colour = strtoul(config->options[i].value.c_str(), (char **)NULL, 0);
   1.244 +            fg_colour |= 0xFF000000L;  /* force alpha to 0xFF */
   1.245 +        } else if (config->options[i].name == "BGColour") {
   1.246 +            bg_colour = strtoul(config->options[i].value.c_str(), (char **)NULL, 0);
   1.247 +            bg_colour |= 0xFF000000L;  /* force alpha to 0xFF */
   1.248 +        }
   1.249 +    }
   1.250 +
   1.251 +    if (wiringstring.length()) {
   1.252 +        optionstring = "WIRING=" + wiringstring + ((optionstring != "") ? ";" + optionstring : "");
   1.253 +    }
   1.254 +
   1.255 +    if (controller == "")
   1.256 +    {
   1.257 +        syslog(LOG_ERR, "%s error: no controller given!\n", config->name.c_str());
   1.258 +        return -1;
   1.259 +    }
   1.260 +
   1.261 +
   1.262 +    if (config->device == "")
   1.263 +    {
   1.264 +        // use DirectIO
   1.265 +
   1.266 +        // neither device nor port is set
   1.267 +        if (config->port == 0)
   1.268 +            return -1;
   1.269 +
   1.270 +        char temp[10];
   1.271 +        snprintf(temp, 8, "0x%x", config->port);
   1.272 +
   1.273 +        if (serdisp_version < SERDISP_VERSION(1,93) ) {
   1.274 +            sdcd = fp_PP_open(temp);
   1.275 +        } else {
   1.276 +            sdcd = fp_SDCONN_open(temp);
   1.277 +        }
   1.278 +
   1.279 +        if (sdcd == 0) {
   1.280 +            syslog(LOG_ERR, "%s: error: unable to open port 0x%x for display %s. (cDriver::Init)\n",
   1.281 +                config->name.c_str(), config->port, controller.c_str());
   1.282 +            return -1;
   1.283 +        }
   1.284 +
   1.285 +        uSleep(10);
   1.286 +    }
   1.287 +    else
   1.288 +    {
   1.289 +        // use ppdev
   1.290 +        if (serdisp_version < SERDISP_VERSION(1,93) ) {
   1.291 +            sdcd = fp_PP_open(config->device.c_str());
   1.292 +        } else {
   1.293 +            sdcd = fp_SDCONN_open(config->device.c_str());
   1.294 +        }
   1.295 +
   1.296 +        if (sdcd == 0) {
   1.297 +            syslog(LOG_ERR, "%s: error: unable to open device %s for display %s. (cDriver::Init)\n",
   1.298 +                config->name.c_str(), config->device.c_str(), controller.c_str());
   1.299 +            return -1;
   1.300 +        }
   1.301 +    }
   1.302 +
   1.303 +    if (serdisp_version < SERDISP_VERSION(1,95) )
   1.304 +        dd = fp_serdisp_init(sdcd, controller.c_str(), "");
   1.305 +    else
   1.306 +        dd = fp_serdisp_init(sdcd, controller.c_str(), optionstring.c_str());
   1.307 +
   1.308 +    if (!dd)
   1.309 +    {
   1.310 +        syslog(LOG_ERR, "%s: error: cannot open display %s. Err:%s (cDriver::Init)\n",
   1.311 +            config->name.c_str(), controller.c_str(), "no handle");
   1.312 +        return -1;
   1.313 +    }
   1.314 +
   1.315 +    width = config->width;
   1.316 +    if (width <= 0)
   1.317 +        width = fp_serdisp_getwidth(dd);
   1.318 +    height = config->height;
   1.319 +    if (height <= 0)
   1.320 +        height = fp_serdisp_getheight(dd);
   1.321 +
   1.322 +    if (serdisp_version < SERDISP_VERSION(1,96) ) {
   1.323 +        fp_serdisp_feature(dd, FEATURE_ROTATE, config->upsideDown);
   1.324 +        fp_serdisp_feature(dd, FEATURE_CONTRAST, config->contrast);
   1.325 +        fp_serdisp_feature(dd, FEATURE_BACKLIGHT, config->backlight);
   1.326 +        fp_serdisp_feature(dd, FEATURE_REVERSE, config->invert);
   1.327 +    } else {
   1.328 +        /* standard options */
   1.329 +        fp_serdisp_setoption(dd, "ROTATE", config->upsideDown);
   1.330 +        fp_serdisp_setoption(dd, "CONTRAST", config->contrast);
   1.331 +        fp_serdisp_setoption(dd, "BACKLIGHT", config->backlight);
   1.332 +        fp_serdisp_setoption(dd, "INVERT", config->invert);
   1.333 +
   1.334 +        /* driver dependend options */
   1.335 +        for (unsigned int i = 0; i < config->options.size(); i++) {
   1.336 +            std::string optionname = config->options[i].name;
   1.337 +            if (optionname != "UpsideDown" && optionname != "Contrast" &&
   1.338 +                optionname != "Backlight" && optionname != "Invert") {
   1.339 +
   1.340 +                if ( fp_serdisp_isoption(dd, optionname.c_str()) == 1 )  /* if == 1: option is existing AND r/w */
   1.341 +                    fp_serdisp_setoption(dd, optionname.c_str(), strtol(config->options[i].value.c_str(), NULL, 0));
   1.342 +            }
   1.343 +        }
   1.344 +
   1.345 +    }
   1.346 +
   1.347 +    *oldConfig = *config;
   1.348 +
   1.349 +    // clear display
   1.350 +    Clear();
   1.351 +
   1.352 +    syslog(LOG_INFO, "%s: SerDisp with %s initialized.\n", config->name.c_str(), controller.c_str());
   1.353 +    return 0;
   1.354 +}
   1.355 +
   1.356 +int cDriverSerDisp::DeInit(void)
   1.357 +{
   1.358 +    if (serdisp_version < SERDISP_VERSION(1,93) ) {
   1.359 +        fp_serdisp_close(dd);
   1.360 +        fp_PP_close(sdcd);
   1.361 +        sdcd = NULL;
   1.362 +    } else {
   1.363 +        //fp_serdisp_quit(dd);
   1.364 +        /* use serdisp_close instead of serdisp_quit so that showpic and showtext are usable together with serdisplib */
   1.365 +        fp_serdisp_close(dd);
   1.366 +    }
   1.367 +    (int) dlclose(sdhnd);
   1.368 +    sdhnd = NULL;
   1.369 +
   1.370 +    return 0;
   1.371 +}
   1.372 +
   1.373 +int cDriverSerDisp::CheckSetup()
   1.374 +{
   1.375 +    bool update = false;
   1.376 +
   1.377 +    if (config->device != oldConfig->device ||
   1.378 +        config->port != oldConfig->port ||
   1.379 +        config->width != oldConfig->width ||
   1.380 +        config->height != oldConfig->height)
   1.381 +    {
   1.382 +        DeInit();
   1.383 +        Init();
   1.384 +        return 0;
   1.385 +    }
   1.386 +
   1.387 +    if (config->contrast != oldConfig->contrast)
   1.388 +    {
   1.389 +        fp_serdisp_feature(dd, FEATURE_CONTRAST, config->contrast);
   1.390 +        oldConfig->contrast = config->contrast;
   1.391 +        update = true;
   1.392 +    }
   1.393 +    if (config->backlight != oldConfig->backlight)
   1.394 +    {
   1.395 +        fp_serdisp_feature(dd, FEATURE_BACKLIGHT, config->backlight);
   1.396 +        oldConfig->backlight = config->backlight;
   1.397 +        update = true;
   1.398 +    }
   1.399 +    if (config->upsideDown != oldConfig->upsideDown)
   1.400 +    {
   1.401 +        fp_serdisp_feature(dd, FEATURE_ROTATE, config->upsideDown);
   1.402 +        oldConfig->upsideDown = config->upsideDown;
   1.403 +        update = true;
   1.404 +    }
   1.405 +    if (config->invert != oldConfig->invert)
   1.406 +    {
   1.407 +        fp_serdisp_feature(dd, FEATURE_REVERSE, config->invert);
   1.408 +        oldConfig->invert = config->invert;
   1.409 +        update = true;
   1.410 +    }
   1.411 +
   1.412 +    /* driver dependend options */
   1.413 +    for (unsigned int i = 0; i < config->options.size(); i++) {
   1.414 +        std::string optionname = config->options[i].name;
   1.415 +        if (optionname != "UpsideDown" && optionname != "Contrast" &&
   1.416 +            optionname != "Backlight" && optionname != "Invert") {
   1.417 +
   1.418 +            if ( fp_serdisp_isoption(dd, optionname.c_str()) == 1 )  /* if == 1: option is existing AND r/w */
   1.419 +                fp_serdisp_setoption(dd, optionname.c_str(), strtol(config->options[i].value.c_str(), NULL, 0));
   1.420 +            oldConfig->options[i] = config->options[i];
   1.421 +            update = true;
   1.422 +        }
   1.423 +    }
   1.424 +
   1.425 +
   1.426 +    if (update)
   1.427 +        return 1;
   1.428 +    return 0;
   1.429 +}
   1.430 +
   1.431 +void cDriverSerDisp::Clear(void)
   1.432 +{
   1.433 +    if (bg_colour == -1)
   1.434 +        fp_serdisp_clearbuffer(dd);
   1.435 +    else {  /* if bg_colour is set, draw background 'by hand' */
   1.436 +        int x,y;
   1.437 +        for (y = 0; y < fp_serdisp_getheight(dd); y++)
   1.438 +            for (x = 0; x < fp_serdisp_getwidth(dd); x++)
   1.439 +                fp_serdisp_setpixcol(dd, x, y, bg_colour);   /* >= 1.95: serdisp_setcolour(), < 1.95: serdisp_setpixel() */
   1.440 +    }
   1.441 +}
   1.442 +
   1.443 +void cDriverSerDisp::Set8Pixels(int x, int y, unsigned char data) {
   1.444 +    int i, start, pixel;
   1.445 +
   1.446 +    data = ReverseBits(data);
   1.447 +
   1.448 +    start = (x >> 3) << 3;
   1.449 +
   1.450 +    for (i = 0; i < 8; i++) {
   1.451 +        pixel = data & (1 << i);
   1.452 +        if (pixel)
   1.453 +            fp_serdisp_setpixcol(dd, start + i, y, fg_colour);   /* >= 1.95: serdisp_setcolour(), < 1.95: serdisp_setpixel() */
   1.454 +        else if (!pixel && bg_colour != -1)  /* if bg_colour is set: use it if pixel is not set */
   1.455 +            fp_serdisp_setpixcol(dd, start + i, y, bg_colour);   /* >= 1.95: serdisp_setcolour(), < 1.95: serdisp_setpixel() */
   1.456 +    }
   1.457 +}
   1.458 +
   1.459 +void cDriverSerDisp::Refresh(bool refreshAll)
   1.460 +{
   1.461 +    if (CheckSetup() == 1)
   1.462 +        refreshAll = true;
   1.463 +
   1.464 +    if (refreshAll)
   1.465 +        fp_serdisp_rewrite(dd);
   1.466 +    else
   1.467 +        fp_serdisp_update(dd);
   1.468 +}
   1.469 +
   1.470 +} // end of namespace