summaryrefslogtreecommitdiff
path: root/glcddrivers/gu126x64D-K610A4.h
blob: 3d989e4fd7e00e4bc1e64ab78a968fc00d5552af (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
/*
 * GraphLCD driver library
 *
 * gu126x64D-K610A4.h -  8-bit driver module for Noritake GU126x64D-K610A4 VFD
 *                       displays. The VFD is operating in its 8 bit-mode
 *                       connected to a single PC parallel port.
 *
 * based on:
 *   gu256x64-372 driver module for graphlcd
 *     (c) 2004 Andreas 'randy' Weinberger (randy AT smue.org)
 *   gu256x64-3900 driver module for graphlcd
 *     (c) 2004 Ralf Mueller (ralf AT bj-ig.de)
 *   gu140x32f driver module for graphlcd
 *     (c) 2003 Andreas Brachold <vdr04 AT deltab.de>
 *   ks0108 driver module for graphlcd
 *     (c) 2004 Andreas 'randy' Weinberger (randy AT smue.org)
 *
 * This file is released under the GNU General Public License. Refer
 * to the COPYING file distributed with this package.
 *
 * (c) 2007      Alexander Rieger (Alexander.Rieger AT inka.de)
 * (c) 2011      Wolfgang Astleitner <mrwastl AT users.sourceforge.net>
 */

#ifndef _GLCDDRIVERS_GU126X64D_K610A4_H_
#define _GLCDDRIVERS_GU126X64D_K610A4_H_

#include "driver.h"

//===============================================================================
//     namespace GLCD
//===============================================================================
namespace GLCD
{

class cDriverConfig;
class cParallelPort;

//===============================================================================
//     class cDriverGU126X64D_K610A4
//===============================================================================
class cDriverGU126X64D_K610A4 : public cDriver
{
public:
    //---------------------------------------------------------------------------
    //     constructor/destructor
    //---------------------------------------------------------------------------
    cDriverGU126X64D_K610A4(cDriverConfig * config);
    virtual ~cDriverGU126X64D_K610A4();

    //---------------------------------------------------------------------------
    //     from cDriver
    //---------------------------------------------------------------------------
    virtual int Init();
    virtual int DeInit();

    virtual void Clear();
    virtual void SetPixel (int x, int y, uint32_t data);
    //virtual void Set8Pixels(int x, int y, unsigned char data);
    virtual void Refresh(bool refreshAll = false);
    virtual void SetBrightness(unsigned int percent);

    //---------------------------------------------------------------------------
    //     display-specific enums/methods/etc.
    //---------------------------------------------------------------------------
    enum FontType
    {
        FONT_PROP_SML
    ,   FONT_FIX_MED
    ,   FONT_FIX_BIG
    };


    int  cmdReset        ();
    int  cmdPower        (bool fOn);
    int  cmdLock         (bool fLock);
    int  cmdSetCursorPos (unsigned char x, unsigned char y);
    int  cmdGraphicWrite (unsigned char count);
    int  cmdGraphicData  (unsigned char data);
    int  cmdSetBrightness(unsigned int  percent);
    int  cmdSetFont      (FontType);
    int  cmdWriteText    (const char *theText);
    int  cmdDrawRect     (unsigned char x1, unsigned char y1, unsigned char x2, unsigned char y2);
    int  cmdSetMacro     (unsigned char theMacroNum, unsigned char theCountBytes);
    int  cmdSetPixel     (bool fSet = true);
    int  cmdClrPixel     ();

    void claimPort();
    void releasePort();

private:
    //---------------------------------------------------------------------------
    //     helper methods
    //---------------------------------------------------------------------------
    void clearVFDMem();
    int  checkSetup();
    int  initParallelPort();
    void initDisplay();

    bool waitForStatus(unsigned char theMask, unsigned char theValue, int theMaxWait);
    void writeParallel(unsigned char data);
    int  write(unsigned char data);

    void ensureNotInGraphics();
    bool isLogEnabled(int theLevel) const;

    //---------------------------------------------------------------------------
    //     attributes
    //---------------------------------------------------------------------------
    cParallelPort  *port;

    cDriverConfig  *config;
    cDriverConfig  *oldConfig;

    int             myNumRows;
    unsigned char **myDrawMem;
    unsigned char **myVFDMem;

    bool            myUseSleepInit;
    long            myPortDelayNS;
    long            myDelay125NS;
    int             myRefreshCounter;
    int             myClaimCounter;
    int             myDataPendingCounter;
    unsigned int    myLogFlags;

}; // class cDriverGU126X64D_K610A4

} // namespace GLCD

#endif