Debian Codegraph @

extras/graphic_lcd/src/glcd.h

raw
1 /*
2 Copyright (C) 2007 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_H_
23 #define EXTRAS_GRAPHIC_LCD_SRC_GLCD_H_
24
25 #include <gtk/gtk.h>
26 #include <src/modules.h>
27 #include <src/gpsim_interface.h>
28 #include <src/ioports.h>
29
30 #define IN_BREADBOARD 0
31
32 class LCDColor {
33 public:
34 LCDColor() : r(0.0), g(0.0), b(0.0) {}
35 double r, g, b;
36 };
37
38 //========================================================================
39 // gLCD - graphic LCD
40 //
41 // gLCD implements the graphical component of the gpsim graphical LCD
42 // modules. The I/O pins and various LCD controllers chips are implemented
43 // elsehere.
44
45 class gLCD {
46 public:
47 gLCD(unsigned int cols,
48 unsigned int rows,
49 unsigned int pixel_size_x,
50 unsigned int pixel_size_y,
51 unsigned int pixel_gap,
52 unsigned int nColors = 2
53 );
54 ~gLCD();
55
56 void clear(cairo_t *cr);
57 void setPixel(cairo_t *cr, unsigned int col, unsigned int row);
58 void setPixel(cairo_t *cr, unsigned int col, unsigned int row, unsigned int colorIdx);
59 void setColor(unsigned int colorIdx, double r, double g, double b);
60
61 protected:
62 unsigned int m_nColumns;
63 unsigned int m_nRows;
64 unsigned int m_border;
65
66 // pixel size Mapping between graphical pixmap and LCD.
67 unsigned int m_xPixel;
68 unsigned int m_yPixel;
69 unsigned int m_pixelGap;
70
71 // Colors
72 LCDColor *m_Colors;
73 unsigned int m_nColors;
74
75 void setPixel(cairo_t *cr, unsigned int col, unsigned int row, double r, double g, double b);
76 };
77
78
79 //========================================================================
80 class gLCD_Module;
81
82 class gLCD_Interface : public Interface {
83 private:
84 gLCD_Module *plcd;
85
86 public:
87 explicit gLCD_Interface(gLCD_Module *_gp);
88
89 //virtual void UpdateObject (gpointer xref,int new_value);
90 //virtual void RemoveObject (gpointer xref);
91 virtual void SimulationHasStopped(gpointer object);
92 //virtual void NewProcessor (unsigned int processor_id);
93 //virtual void NewModule (Module *module);
94 //virtual void NodeConfigurationChanged (Stimulus_Node *node);
95 //virtual void NewProgram (unsigned int processor_id);
96 virtual void Update(gpointer object);
97 };
98
99
100 //========================================================================
101 // gLCD_Module - base class of graphic's LCD modules
102 //
103 class gLCD_Module : public Module {
104 public:
105 gLCD_Module(const char *new_name, const char *desc,
106 unsigned int nCols, unsigned int nRows);
107 virtual ~gLCD_Module();
108 virtual void Update(GtkWidget *pw = nullptr);
109
110 protected:
111 GtkWidget *window;
112 GtkWidget *darea; // Drawable containing the graphics
113
114 gLCD *m_plcd;
115 unsigned int m_nColumns;
116 unsigned int m_nRows;
117 unsigned int interface_seq_no;
118 };
119
120
121 //------------------------------------------------------------------------
122 class ModuleTraceType;
123 class LcdPortRegister : public PortRegister {
124 public:
125 LcdPortRegister(gLCD_Module *plcd, const char * _name, const char *_desc);
126 virtual ~LcdPortRegister();
127
128 private:
129 gLCD_Module *m_pLCD;
130 ModuleTraceType *mMTT;
131 };
132
133 #endif