OpenCores
URL https://opencores.org/ocsvn/openarty/openarty/trunk

Subversion Repositories openarty

[/] [openarty/] [trunk/] [sim/] [verilated/] [oledsim.h] - Blame information for rev 58

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 58 dgisselq
////////////////////////////////////////////////////////////////////////////////
2
//
3
// Filename:    oledsim.h
4
//
5
// Project:     OpenArty, an entirely open SoC based upon the Arty platform
6
//
7
// Purpose:     To simulate the interaction between the OLED board and my
8
//              logic.  This simulator tries to read from the SPI generated
9
//      by the logic, verify that the SPI interaction is valid, and then
10
//      draws the OLED memory to the screen so you can see how the OLED
11
//      would work ... even without having an OLED connected.
12
//
13
// Creator:     Dan Gisselquist, Ph.D.
14
//              Gisselquist Technology, LLC
15
//
16
////////////////////////////////////////////////////////////////////////////////
17
//
18
// Copyright (C) 2015-2016, Gisselquist Technology, LLC
19
//
20
// This program is free software (firmware): you can redistribute it and/or
21
// modify it under the terms of  the GNU General Public License as published
22
// by the Free Software Foundation, either version 3 of the License, or (at
23
// your option) any later version.
24
//
25
// This program is distributed in the hope that it will be useful, but WITHOUT
26
// ANY WARRANTY; without even the implied warranty of MERCHANTIBILITY or
27
// FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
28
// for more details.
29
//
30
// You should have received a copy of the GNU General Public License along
31
// with this program.  (It's in the $(ROOT)/doc directory, run make with no
32
// target there if the PDF file isn't present.)  If not, see
33
// <http://www.gnu.org/licenses/> for a copy.
34
//
35
// License:     GPL, v3, as defined and found on www.gnu.org,
36
//              http://www.gnu.org/licenses/gpl.html
37
//
38
//
39
////////////////////////////////////////////////////////////////////////////////
40
//
41
//
42
#ifndef OLEDSIM_H
43
#define OLEDSIM_H
44
 
45
#include <gtkmm.h>
46
#include <assert.h>
47
 
48
#define OLED_OFF        1
49
#define OLED_RESET      2
50
#define OLED_VIO        3
51
#define OLED_POWERED    4
52
#define OLED_65kCLR     0
53
#define OLED_256CLR     1
54
 
55
class   OLEDSIM : public Gtk::DrawingArea {
56
public:
57
        typedef         Cairo::RefPtr<Cairo::Context>   CAIROGC;
58
        typedef const   Cairo::RefPtr<Cairo::Context>   CONTEXT;
59
        typedef         Cairo::RefPtr<Cairo::ImageSurface>      CAIROIMG;
60
 
61
private:
62
        CAIROIMG        m_pix;
63
        CAIROGC         m_gc;
64
 
65
        int     m_state, m_reset_clocks; // , m_address_counts;
66
 
67
        int     m_last_csn, m_last_sck, m_last_dcn;
68
 
69
        int     m_idx, m_bitpos;
70
        char    m_data[16];
71
 
72
        bool    m_vaddr_inc, m_locked;
73
        int     m_format;
74
        int     m_col_start, m_col_end, m_col;
75
        int     m_row_start, m_row_end, m_row, m_display_start_row;
76
 
77
 
78
        void    do_command(const int dcn, const int len, char *data);
79
        void    handle_io(const int, const int, const int, const int);
80
        void    clear_to(const double v);
81
        void    set_gddram(const int, const int, const double, const double, const double);
82
public:
83
        static const int        OLED_HEIGHT, OLED_WIDTH;
84
 
85
        OLEDSIM(void) : Gtk::DrawingArea() {
86
 
87
                set_has_window(true);
88
                Widget::set_can_focus(false);
89
                set_size_request(OLED_WIDTH, OLED_HEIGHT);
90
 
91
                m_state = OLED_OFF;
92
                m_locked = true;
93
                m_last_csn = 1;
94
                m_last_sck = 1;
95
                m_last_dcn = 1;
96
                m_format = OLED_65kCLR;
97
                m_display_start_row = 0;
98
                m_vaddr_inc = false;
99
                m_col = 0; m_row = 0;
100
                m_col_start = 0; m_row_start = 0;
101
                m_col_end = 95; m_row_end = 63;
102
        }
103
 
104
        void    get_preferred_width_vfunc(int &min, int &nw) const;
105
        void    get_preferred_height_vfunc(int &min, int &nw) const;
106
        void    get_preferred_height_for_width_vfunc(int w, int &min, int &nw) const;
107
        void    get_preferred_width_for_height_vfunc(int h, int &min, int &nw) const;
108
 
109
        virtual void    on_realize();
110
        virtual bool    on_draw(CONTEXT &gc);
111
        void    operator()(const int iopwr, const int rstn, const int dpwr,
112
                        const int csn, const int sck, const int dcn, const int mosi);
113
};
114
 
115
class   OLEDWIN : public Gtk::Window {
116
private:
117
        OLEDSIM *m_sim;
118
 
119
public:
120
        OLEDWIN(void);
121
        ~OLEDWIN(void) { delete m_sim; }
122
        void    operator()(int iopwr, int rstn, int dpwr,
123
                        int sck, int csn, int dcn, int mosi) {
124
                (*m_sim)(iopwr, rstn, dpwr, sck, csn, dcn, mosi);
125
        }
126
};
127
 
128
#endif

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.