Debian Codegraph @

extras/graphic_lcd/src/sed1520.h

raw
1 /*
2 Copyright (C) 2005 T. Scott Dattalo
3
4 This file is part of gpsim.
5
6 gpsim is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2, or (at your option)
9 any later version.
10
11 gpsim is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with gpsim; see the file COPYING. If not, write to
18 the Free Software Foundation, 59 Temple Place - Suite 330,
19 Boston, MA 02111-1307, USA. */
20
21
22 #ifndef EXTRAS_GRAPHIC_LCD_SRC_GLCD_100X32_SED1520_H__SED1520_H_
23 #define EXTRAS_GRAPHIC_LCD_SRC_GLCD_100X32_SED1520_H__SED1520_H_
24
25 class SED1520 {
26 enum {
27 eNPAGES = 4,
28 eNCOLUMNS_PER_PAGE = 80
29 };
30
31 enum {
32 eA0 = 1,
33 eRW = 2,
34 eE = 4,
35
36 eDataRead = eA0 | eRW,
37 eDataWrite = eA0,
38 eStatusRead = eRW,
39 eCommandWrite = 0
40 };
41
42 public:
43 SED1520();
44
45 void setA0(bool);
46 void setE(bool);
47 void setRW(bool);
48 void setData(unsigned int);
49 void driveDataBus(unsigned int);
50 bool dataBusDirection();
51 unsigned int getDataBus();
52 void advanceColumnAddress();
53 void storeData();
54 void executeCommand();
55
56 void randomizeRAM();
57
58 unsigned int getData();
59 unsigned int getStatus();
60
61 inline unsigned int &operator[](unsigned int index)
62 {
63 return (index < eNCOLUMNS_PER_PAGE * eNPAGES) ? m_ram[index] : prBadRam(index);
64 }
65
66 private:
67 // called if an illegal access is made to the RAM
68 unsigned int &prBadRam(unsigned int);
69
70 /// I/O pin interface
71 bool m_bE;
72 unsigned int m_controlState;
73 unsigned int m_dataBus;
74
75 // Display ram
76 unsigned int m_ram[eNCOLUMNS_PER_PAGE * eNPAGES];
77
78 // State information
79 unsigned int m_page;
80 unsigned int m_columnAddress;
81
82 };
83
84 #endif