2 * GraphLCD driver library
4 * gu126x64D-K610A4.c - 8-bit driver module for Noritake GU126x64D-K610A4 VFD
5 * displays. The VFD is operating in its 8 bit-mode
6 * connected to a single PC parallel port.
9 * gu256x64-372 driver module for graphlcd
10 * (c) 2004 Andreas 'randy' Weinberger (randy AT smue.org)
11 * gu256x64-3900 driver module for graphlcd
12 * (c) 2004 Ralf Mueller (ralf AT bj-ig.de)
13 * gu140x32f driver module for graphlcd
14 * (c) 2003 Andreas Brachold <vdr04 AT deltab.de>
15 * ks0108 driver module for graphlcd
16 * (c) 2004 Andreas 'randy' Weinberger (randy AT smue.org)
18 * This file is released under the GNU General Public License. Refer
19 * to the COPYING file distributed with this package.
21 * (c) 2007 Alexander Rieger (Alexander.Rieger AT inka.de)
31 #include "gu126x64D-K610A4.h"
36 //----- commands to the display -----------------------------------------------
37 static const unsigned char CMD_RUN_MACRO_01 = 0x01; // run macro 1
38 static const unsigned char CMD_RUN_MACRO_02 = 0x02; // run macro 2
39 static const unsigned char CMD_RUN_MACRO_03 = 0x03; // run macro 3
40 static const unsigned char CMD_RUN_MACRO_04 = 0x04; // run macro 4
41 static const unsigned char CMD_RUN_MACRO_05 = 0x05; // run macro 5
42 static const unsigned char CMD_RUN_MACRO_06 = 0x06; // run macro 6
43 static const unsigned char CMD_RUN_MACRO_07 = 0x07; // run macro 7
45 static const unsigned char CMD_CURSOR_POS = 0x10; // Set cursor position
46 static const unsigned char CMD_BOX_SET = 0x11; // Set area
47 static const unsigned char CMD_BOX_CLEAR = 0x12; // Clear area
48 static const unsigned char CMD_BOX_INVERT = 0x13; // Invert area
49 static const unsigned char CMD_RECT_SET = 0x14; // Set outline
50 static const unsigned char CMD_RECT_CLEAR = 0x15; // Clear outline
52 static const unsigned char CMD_PIXEL_SET = 0x16; // Set pixel at current pos
53 static const unsigned char CMD_PIXEL_CLEAR = 0x17; // Clear pixel at current pos
55 static const unsigned char CMD_GRAPHIC_WRITE = 0x18; // Write graphics data (args: len, data)
56 static const unsigned char CMD_RESET = 0x19; // Reset display
57 static const unsigned char CMD_WRITE_MODE = 0x1A; // Write mode
58 static const unsigned char CMD_INTRO = 0x1B; // Intro for other commands (see CMA_*)
59 static const unsigned char CMD_FONT_PROP_SML = 0x1C; // Select font: proportional mini
60 static const unsigned char CMD_FONT_FIX_MED = 0x1D; // Select font: fixed spaced 5x7
61 static const unsigned char CMD_FONT_FIX_BIG = 0x1E; // Select font: fixed spaced 10x14
63 static const unsigned char CMA_MACROS_ERASE = 0x4D; // Erase Macros (usage: CMD_INTRO + this)
64 static const unsigned char CMA_EPROM_LOCK = 0x4C; // Lock EEPROM (usage: CMD_INTRO + this)
65 static const unsigned char CMA_EPROM_UNLOCK = 0x55; // Unlock EEPROM (usage: CMD_INTRO + this)
67 static const unsigned char CMA_POWER_OFF = 0x46; // Power off (usage: CMD_INTRO + this)
68 static const unsigned char CMA_POWER_ON = 0x50; // Power on (usage: CMD_INTRO + this)
70 //----- signal lines ----------------------------------------------------------
71 static const unsigned char OUT_EN_HI = kAutoLow ;
72 static const unsigned char OUT_EN_LO = kAutoHigh;
73 static const unsigned char OUT_EN_MASK = OUT_EN_HI;
75 static const unsigned char IN_MB_HI = 0x40;
76 static const unsigned char IN_MB_LO = 0x00;
77 static const unsigned char IN_MB_MASK = IN_MB_HI;
79 //----- log flags -------------------------------------------------------------
80 static const unsigned int LL_REFRESH_START = 0x0001; // 1
81 static const unsigned int LL_REFRESH_END = 0x0002; // 2
82 static const unsigned int LL_REFRESH_MED = 0x0004; // 4
83 static const unsigned int LL_VFD_CMD = 0x0008; // 8
84 static const unsigned int LL_MAX_WAIT = 0x0010; // 16
86 //----- mixed consts ----------------------------------------------------------
87 static const long ADJUST_FACTOR = 100; // used to adjust timing
89 //-----------------------------------------------------------------------------
90 cDriverGU126X64D_K610A4::cDriverGU126X64D_K610A4(cDriverConfig * config)
97 , myUseSleepInit (false)
100 , myRefreshCounter (0)
102 , myDataPendingCounter(0)
105 oldConfig = new cDriverConfig(*config);
106 } // cDriverGU126X64D_K610A4::cDriverGU126X64D_K610A4()
108 //-----------------------------------------------------------------------------
109 cDriverGU126X64D_K610A4::~cDriverGU126X64D_K610A4()
112 } // cDriverGU126X64D_K610A4::cDriverGU126X64D_K610A4()
114 //-----------------------------------------------------------------------------
115 int cDriverGU126X64D_K610A4::Init()
117 width = config->width;
118 if (width <= 0 || width > 256) // don't allow unreasonable big sizes from config
123 height = config->height;
124 if (height <= 0 || height > 256) // don't allow unreasonable big sizes from config
129 //----- parse config -----
130 for (unsigned int i = 0; i < config->options.size(); i++)
132 if (config->options[i].name == "Debug")
134 myLogFlags = atoi(config->options[i].value.c_str());
138 myNumRows = ((height + 7) / 8);
139 port = new cParallelPort();
141 // setup drawing memory
142 myDrawMem = new unsigned char *[width];
143 for (int x = 0; x < width; x++)
145 myDrawMem[x] = new unsigned char[myNumRows];
146 memset(myDrawMem[x], 0, myNumRows);
150 myVFDMem = new unsigned char *[width];
151 for (int x = 0; x < width; x++)
153 myVFDMem[x] = new unsigned char[myNumRows];
154 memset(myVFDMem[x], 0, myNumRows);
157 if (initParallelPort() < 0)
164 *oldConfig = *config;
166 // Set Display SetBrightness
167 SetBrightness(config->brightness);
173 syslog( LOG_INFO, "%s: initialized (width: %d height: %d)"
174 , config->name.c_str(), width, height
178 } // cDriverGU126X64D_K610A4::Init()
180 //-----------------------------------------------------------------------------
181 int cDriverGU126X64D_K610A4::DeInit()
185 for (int x = 0; x < width; x++)
187 delete[] myVFDMem[x];
195 for(int x = 0; x < width; x++)
197 delete[] myDrawMem[x];
205 // claim port to avoid msg when closing the port
207 if (port->Close() != 0)
216 } // cDriverGU126X64D_K610A4::DeInit()
218 //-----------------------------------------------------------------------------
219 int cDriverGU126X64D_K610A4::checkSetup()
221 if ( config->device != oldConfig->device
222 || config->port != oldConfig->port
223 || config->width != oldConfig->width
224 || config->height != oldConfig->height
232 if (config->brightness != oldConfig->brightness)
234 oldConfig->brightness = config->brightness;
235 SetBrightness(config->brightness);
238 if ( config->upsideDown != oldConfig->upsideDown
239 || config->invert != oldConfig->invert
242 oldConfig->upsideDown = config->upsideDown;
243 oldConfig->invert = config->invert;
249 } // cDriverGU126X64D_K610A4::checkSetup()
251 //-----------------------------------------------------------------------------
252 int cDriverGU126X64D_K610A4::initParallelPort()
254 struct timeval tv1, tv2;
256 if (config->device == "")
259 if (port->Open(config->port) != 0)
261 syslog(LOG_ERR, "%s: unable to initialize gu256x64-3900!", config->name.c_str());
264 syslog(LOG_INFO, "%s: using direct IO!", config->name.c_str());
270 if (port->Open(config->device.c_str()) != 0)
272 syslog(LOG_ERR, "%s: unable to initialize gu256x64-3900!", config->name.c_str());
275 syslog(LOG_INFO, "%s: using ppdev!", config->name.c_str());
278 if (nSleepInit() != 0)
280 syslog(LOG_ERR, "%s: INFO: cannot change wait parameters Err: %s (cDriver::Init)", config->name.c_str(), strerror(errno));
281 myUseSleepInit = false;
285 myUseSleepInit = true;
288 //----- measure the time to write to the port -----
289 syslog(LOG_DEBUG, "%s: benchmark started.", config->name.c_str());
290 gettimeofday(&tv1, 0);
292 const int aBenchCount = 1000; // don't change this!
293 for (int x = 0; x < aBenchCount; x++)
295 port->WriteData(x % 0x100);
298 gettimeofday(&tv2, 0);
300 // release the port, which was implicitely claimed by open
303 if (myUseSleepInit) nSleepDeInit();
305 myPortDelayNS = (tv2.tv_sec - tv1.tv_sec) * 1000000 + (tv2.tv_usec - tv1.tv_usec);
307 myDelay125NS = std::max(125 + (ADJUST_FACTOR * config->adjustTiming) - myPortDelayNS, 0L);
309 syslog( LOG_DEBUG, "%s: benchmark stopped. Time for Port Command: %ldns, delay: %ldns"
310 , config->name.c_str(), myPortDelayNS, myDelay125NS
314 } // cDriverGU126X64D_K610A4::initParallelPort()
316 //-----------------------------------------------------------------------------
317 void cDriverGU126X64D_K610A4::initDisplay()
322 } // cDriverGU126X64D_K610A4::initDisplay()
324 //-----------------------------------------------------------------------------
325 void cDriverGU126X64D_K610A4::clearVFDMem()
327 for (int x = 0; x < width; x++)
329 memset(myVFDMem[x], 0, myNumRows);
331 } // cDriverGU126X64D_K610A4::clearVFDMem()
333 //-----------------------------------------------------------------------------
334 void cDriverGU126X64D_K610A4::Clear()
336 for (int x = 0; x < width; x++)
338 memset(myDrawMem[x], 0, myNumRows);
340 } // cDriverGU126X64D_K610A4::Clear()
342 //-----------------------------------------------------------------------------
343 void cDriverGU126X64D_K610A4::SetBrightness(unsigned int percent)
346 cmdSetBrightness(percent);
348 } // cDriverGU126X64D_K610A4::SetBrightness()
350 //-----------------------------------------------------------------------------
351 bool cDriverGU126X64D_K610A4::waitForStatus(unsigned char theMask, unsigned char theValue, int theMaxWait)
353 theValue = theValue & theMask;
355 int status = port->ReadStatus();
357 if ((status & theMask) != theValue)
359 // wait some time for MB go HI/LO but not forever
361 for(i = 0; ((status & theMask) != theValue) && i < theMaxWait; i++)
363 status = port->ReadStatus();
366 if (isLogEnabled(LL_MAX_WAIT) && i >= theMaxWait)
368 syslog( LOG_INFO, "%s: slept for %5d times while waiting for MB = %d"
369 , config->name.c_str(), i, ((theMask & theValue) == 0 ? 0 : 1)
374 return ((status & theMask) == theValue);
375 } // cDriverGU126X64D_K610A4::waitForStatus()
377 //-----------------------------------------------------------------------------
378 void cDriverGU126X64D_K610A4::writeParallel(unsigned char data)
380 if (myUseSleepInit) nSleepInit();
382 waitForStatus(IN_MB_MASK, IN_MB_LO, 500); // wait for MB == LO
384 port->WriteData(data); // write data
385 nSleep(myDelay125NS); // - sleep
387 port->WriteControl(OUT_EN_LO & OUT_EN_MASK); // set ENABLE to LO
388 nSleep(myDelay125NS); // - sleep
390 port->WriteControl(OUT_EN_HI & OUT_EN_MASK); // set ENABLE to HI
392 waitForStatus(IN_MB_MASK, IN_MB_HI, 50); // wait for MB == HI
394 // the other drivers don't do this neither
395 // if (myUseSleepInit) nSleepDeInit();
396 } // cDriverGU126X64D_K610A4::writeParallel()
398 //-----------------------------------------------------------------------------
399 int cDriverGU126X64D_K610A4::write(unsigned char data)
406 // if data == 0x60 -> send 0x60 twice
407 // (0x60 switches to hex-mode)
415 } // cDriverGU126X64D_K610A4::write()
417 //-----------------------------------------------------------------------------
418 void cDriverGU126X64D_K610A4::setPixel(int x, int y)
420 if (!myDrawMem ) return;
421 if (x >= width || x < 0) return;
422 if (y >= height || y < 0) return;
424 if (config->upsideDown)
430 unsigned char c = 0x80 >> (y % 8);
432 myDrawMem[x][y/8] = myDrawMem[x][y/8] | c;
433 } // cDriverGU126X64D_K610A4::setPixel()
435 //-----------------------------------------------------------------------------
436 void cDriverGU126X64D_K610A4::Set8Pixels(int x, int y, unsigned char data)
438 // x - pos isn't maybe align to 8
441 for (int n = 0; n < 8; ++n)
443 if ((data & (0x80 >> n)) != 0) // if bit is set
448 } // cDriverGU126X64D_K610A4::Set8Pixels()
450 //-----------------------------------------------------------------------------
451 void cDriverGU126X64D_K610A4::Refresh(bool refreshAll)
453 // no mem present -> return
454 if (!myVFDMem || !myDrawMem)
460 if (isLogEnabled(LL_REFRESH_START))
462 syslog( LOG_INFO, "%s: > Refresh() all = %d RefreshDisplay = %d RefreshCtr = %d Delay = %ld"
463 , config->name.c_str()
465 , config->refreshDisplay
471 // setup changed -> refresh all
472 if (checkSetup() > 0)
474 syslog(LOG_DEBUG, "%s: Refresh() checkSetup() returned != 0 -> refreshAll = true", config->name.c_str());
478 // refresh-counter exceeded -> refresh all
479 if (!refreshAll && config->refreshDisplay != 0)
481 myRefreshCounter = (myRefreshCounter + 1) % config->refreshDisplay;
482 refreshAll = myRefreshCounter == 0;
484 if (refreshAll && isLogEnabled(LL_REFRESH_START))
486 syslog(LOG_DEBUG, "%s: Refresh() refresh-count reached -> refreshAll = true", config->name.c_str());
490 if (isLogEnabled(LL_REFRESH_START))
492 syslog( LOG_INFO, "%s: Refresh() all = %d RefreshDisplay = %d RefreshCtr = %d Delay = %ld"
493 , config->name.c_str()
495 , config->refreshDisplay
502 struct timeval tv1, tv2;
503 gettimeofday(&tv1, 0);
507 int chunk = 128; // displays with more than 128 pixels width are written in chunks
508 // note: this driver isn't really prepared to handle displays
509 // with other dimensions than 126x64
514 for (yb = 0; yb < myNumRows; ++yb)
519 //----- if !refreshAll -> check modified bytes
522 for (xb = 0; xb < width; ++xb)
524 if (myVFDMem[xb][yb] != myDrawMem[xb][yb])
526 minX = std::min(minX, xb);
527 maxX = std::max(maxX, xb);
538 if (isLogEnabled(LL_REFRESH_MED))
542 syslog( LOG_INFO, "%s: Row[%d] %3d - %3d : %3d"
543 , config->name.c_str(), yb
550 syslog( LOG_INFO, "%s: Row[%d] --- - --- : ---"
551 , config->name.c_str(), yb
559 bc += cmdSetCursorPos(minX, yb * 8);
561 for (xb = minX; xb <= maxX; ++xb)
563 if ((xb - minX) % chunk == 0)
565 bc += cmdGraphicWrite(std::min((maxX - xb + 1), chunk));
568 bc += cmdGraphicData(myDrawMem[xb][yb]);
569 myVFDMem[xb][yb] = myDrawMem[xb][yb];
577 if (isLogEnabled(LL_REFRESH_END))
579 gettimeofday(&tv2, 0);
581 long duration_ms = ((tv2.tv_sec - tv1.tv_sec) * 1000000 + (tv2.tv_usec - tv1.tv_usec))
582 / 1000 /* us -> ms */
585 syslog( LOG_INFO, "%s: < Refresh() all = %d took %3ld ms %5ld bytes = %5ld bytes/sec = %5ld ns/byte"
586 , config->name.c_str()
590 , duration_ms == 0 ? -1 : bc * 1000 / duration_ms
591 , bc == 0 ? -1 : duration_ms * 1000000 / bc
594 } // cDriverGU126X64D_K610A4::Refresh()
596 //-----------------------------------------------------------------------------
597 int cDriverGU126X64D_K610A4::cmdReset()
599 ensureNotInGraphics();
602 if (isLogEnabled(LL_VFD_CMD))
604 syslog(LOG_INFO, "- 1B: CMD_RESET : 0x%02X ", int(CMD_RESET));
607 b += write(CMD_RESET);
609 unsigned char aMode = 1 << 7 // data orientation : 0: horizontal, 1: vertical , default: 0
610 | 0 << 6 // cursor movement : 0: horizontal, 1: vertical , default: 0
611 | 0 << 5 // cursor direction : 0: forwards , 1: backwards, default: 0
612 | 0 << 4 // underscore cursor: 0: off , 1: on , default: 0
613 | 0 << 3 // underscore cursor: 0: static , 1: flash , default: 0
614 | 0 << 2 // not in documentation
615 | 0 << 0 // pen type: 0: overwrite, 1: AND, 2: OR, 3: XOR , default: 0
618 if (isLogEnabled(LL_VFD_CMD))
620 syslog(LOG_INFO, "- 2B: CMD_WRITE_MODE : 0x%02X 0x%02X", int(CMD_RESET), int(aMode));
623 b += write(CMD_WRITE_MODE);
627 } // cDriverGU126X64D_K610A4::cmdReset()
629 //-----------------------------------------------------------------------------
630 int cDriverGU126X64D_K610A4::cmdPower(bool fOn)
632 ensureNotInGraphics();
635 if (isLogEnabled(LL_VFD_CMD))
637 syslog( LOG_INFO, "- 2B: CMD_POWER : 0x%02X 0x%02X"
638 , int(CMD_INTRO), int(fOn ? CMA_POWER_ON : CMA_POWER_OFF)
642 b += write(CMD_INTRO);
643 b += write(fOn ? CMA_POWER_ON : CMA_POWER_OFF);
646 } // cDriverGU126X64D_K610A4::cmdPower()
648 //-----------------------------------------------------------------------------
649 int cDriverGU126X64D_K610A4::cmdLock(bool fLock)
651 ensureNotInGraphics();
654 if (isLogEnabled(LL_VFD_CMD))
656 syslog( LOG_INFO, "- 2B: CMD_LOCK : 0x%02X 0x%02X"
657 , int(CMD_INTRO), int(fLock ? CMA_EPROM_LOCK : CMA_EPROM_UNLOCK)
661 b += write(CMD_INTRO);
662 b += write(fLock ? CMA_EPROM_LOCK : CMA_EPROM_UNLOCK);
665 } // cDriverGU126X64D_K610A4::cmdPower()
667 //-----------------------------------------------------------------------------
668 int cDriverGU126X64D_K610A4::cmdSetCursorPos(unsigned char x, unsigned char y)
670 ensureNotInGraphics();
673 if (isLogEnabled(LL_VFD_CMD))
675 syslog( LOG_INFO, "- 3B: CMD_CURSOR_POS : 0x%02X 0x%02X 0x%02X (x = %3d, y = %3d)"
676 , int(CMD_CURSOR_POS), int(x), int(y), int(x), int(y)
680 b += write(CMD_CURSOR_POS); // cmd
681 b += write(x ); // xpos
682 b += write(y ); // ypos
685 } // cDriverGU126X64D_K610A4::cmdSetCursorPos();
687 //-----------------------------------------------------------------------------
688 int cDriverGU126X64D_K610A4::cmdGraphicWrite(unsigned char count)
690 ensureNotInGraphics();
693 if (isLogEnabled(LL_VFD_CMD))
695 syslog( LOG_INFO, "- 2B: CMD_GRAPHIC_WRITE: 0x%02X 0x%02X (%d bytes)"
696 , int(CMD_GRAPHIC_WRITE), int(count), int(count)
700 b += write(CMD_GRAPHIC_WRITE); // cmd
701 b += write(count ); // len
703 myDataPendingCounter = count;
706 } // cDriverGU126X64D_K610A4::cmdGraphicWrite()
708 //-----------------------------------------------------------------------------
709 int cDriverGU126X64D_K610A4::cmdGraphicData(unsigned char data)
713 myDataPendingCounter--;
714 if (myDataPendingCounter < 0)
716 syslog( LOG_WARNING, "%s error: more graphic data written than announced -> ignored"
717 , config->name.c_str()
722 if (isLogEnabled(LL_VFD_CMD))
724 syslog( LOG_INFO, "- 1B: CMD_GRAPHIC_DATA : 0x%02X (expecting another %d bytes)"
725 , int(data), myDataPendingCounter
729 b += write(data ^ (config->invert ? 0xFF : 0x00));
733 } // cDriverGU126X64D_K610A4::cmdGraphicData()
735 //-----------------------------------------------------------------------------
736 int cDriverGU126X64D_K610A4::cmdSetBrightness(unsigned int percent)
738 ensureNotInGraphics();
741 unsigned char bright = 0;
742 if (percent >= 85) bright = 0xFF;
743 else if (percent >= 71) bright = 0xFE;
744 else if (percent >= 57) bright = 0xFD;
745 else if (percent >= 43) bright = 0xFC;
746 else if (percent >= 29) bright = 0xFB;
747 else if (percent >= 15) bright = 0xFA;
748 else if (percent >= 1) bright = 0xF9;
751 if (isLogEnabled(LL_VFD_CMD))
753 syslog( LOG_INFO, "- 2B: CMD_INTRO : 0x%02X 0x%02X = set brightness"
754 , int(CMD_INTRO), int(bright)
758 b += write(CMD_INTRO);
762 } // cDriverGU126X64D_K610A4::cmdSetBrightness()
764 //-----------------------------------------------------------------------------
765 int cDriverGU126X64D_K610A4::cmdSetFont(FontType theFont)
767 ensureNotInGraphics();
770 unsigned char aCmd = 0;
773 case FONT_PROP_SML: aCmd = CMD_FONT_PROP_SML; break;
774 case FONT_FIX_BIG : aCmd = CMD_FONT_FIX_BIG ; break;
776 default : aCmd = CMD_FONT_FIX_MED ; break;
779 if (isLogEnabled(LL_VFD_CMD))
781 syslog(LOG_INFO, "- 1B: CMD_SET_FONT : 0x%02X", int(aCmd));
787 } // cDriverGU126X64D_K610A4::cmdSetFont()
789 //-----------------------------------------------------------------------------
790 int cDriverGU126X64D_K610A4::cmdWriteText(const char *theText)
792 ensureNotInGraphics();
795 if (isLogEnabled(LL_VFD_CMD))
797 syslog(LOG_INFO, "-%2dB: WRITE_TEXT : '%s'", strlen(theText), theText);
800 for (const char *p = theText; *p != '\0'; ++p)
806 } // cDriverGU126X64D_K610A4::cmdWriteText()
808 //-----------------------------------------------------------------------------
809 int cDriverGU126X64D_K610A4::cmdDrawRect(unsigned char x1, unsigned char y1, unsigned char x2, unsigned char y2)
811 ensureNotInGraphics();
814 if (isLogEnabled(LL_VFD_CMD))
816 syslog( LOG_INFO, "- 5B: CMD_SET_OUTLINE : 0x%02X 0x%02X 0x%02X 0x%02X 0x%02X (x1 = %3d, y1 = %3d, x2 = %3d, y2 = %3d)"
817 , int(CMD_CURSOR_POS)
818 , int(x1), int(y1), int(x2), int(y2)
819 , int(x1), int(y1), int(x2), int(y2)
823 b += write(CMD_RECT_SET );
830 } // cDriverGU126X64D_K610A4::cmdDrawRect()
832 //-----------------------------------------------------------------------------
833 int cDriverGU126X64D_K610A4::cmdSetMacro(unsigned char theMacroNum, unsigned char theCountBytes)
840 ensureNotInGraphics();
843 if (isLogEnabled(LL_VFD_CMD))
845 syslog( LOG_INFO, "- 3B: CMD_INTRO : 0x%02X 0x%02X 0x%02X (define macro %d with length %d)"
847 , int(theMacroNum), int(theCountBytes)
848 , int(theMacroNum), int(theCountBytes)
852 b += write(CMD_INTRO );
853 b += write(theMacroNum );
854 b += write(theCountBytes );
857 } // cDriverGU126X64D_K610A4::cmdSetMacro()
859 //-----------------------------------------------------------------------------
860 int cDriverGU126X64D_K610A4::cmdSetPixel(bool fSet)
866 ensureNotInGraphics();
868 if (isLogEnabled(LL_VFD_CMD))
870 syslog(LOG_INFO, "- 1B: SET_PIXEL : 0x%02X", 0x16);
873 b += write(CMD_PIXEL_SET);
881 } // cDriverGU126X64D_K610A4::cmdSetPixel()
883 //-----------------------------------------------------------------------------
884 int cDriverGU126X64D_K610A4::cmdClrPixel()
886 ensureNotInGraphics();
889 if (isLogEnabled(LL_VFD_CMD))
891 syslog(LOG_INFO, "- 1B: CLR_PIXEL : 0x%02X", 0x17);
894 b += write(CMD_PIXEL_CLEAR);
897 } // cDriverGU126X64D_K610A4::cmdClrPixel()
899 //-----------------------------------------------------------------------------
900 void cDriverGU126X64D_K610A4::ensureNotInGraphics()
902 if (myClaimCounter <= 0)
904 syslog(LOG_ERR, "%s: ERROR: port not claimed (%d)", config->name.c_str(), myClaimCounter);
907 if (myDataPendingCounter > 0)
909 syslog( LOG_WARNING, "%s error: expected another %d bytes graphic data, filling with 0x00"
910 , config->name.c_str(), myDataPendingCounter
913 while (myDataPendingCounter > 0)
917 } // cDriverGU126X64D_K610A4::ensureNotInGraphics()
920 //-----------------------------------------------------------------------------
921 void cDriverGU126X64D_K610A4::claimPort()
923 if (myClaimCounter == 0)
930 if (myClaimCounter > 1)
932 syslog( LOG_WARNING, "%s: port claimed more than once (%d)"
933 , config->name.c_str(), myClaimCounter
937 } // cDriverGU126X64D_K610A4::claimPort()
939 //-----------------------------------------------------------------------------
940 void cDriverGU126X64D_K610A4::releasePort()
942 if (myClaimCounter == 1)
949 if (myClaimCounter < 0)
951 syslog( LOG_WARNING, "%s: port released more often than claimed"
952 , config->name.c_str()
957 } // cDriverGU126X64D_K610A4::releasePort()
959 //-----------------------------------------------------------------------------
960 bool cDriverGU126X64D_K610A4::isLogEnabled(int theLevel) const
962 return (theLevel & myLogFlags) != 0;
963 } // cDriverGU126X64D_K610A4::isLogEnabled()
965 //-----------------------------------------------------------------------------
966 } // end of namespace