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

Subversion Repositories riscv_vhdl

[/] [riscv_vhdl/] [trunk/] [debugger/] [src/] [gui_plugin/] [PeriphWidgets/] [GpioWidget.cpp] - Blame information for rev 2

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 sergeykhbr
#include "LedArea.h"
2
#include "DipArea.h"
3
#include "GpioWidget.h"
4
#include "moc_GpioWidget.h"
5
 
6
#include <QtCore/QDate>
7
#include <QtGui/QPainter>
8
#include <QtWidgets/QScrollBar>
9
#include <QtWidgets/QGridLayout>
10
#include <QtWidgets/QLabel>
11
#include <memory>
12
 
13
namespace debugger {
14
 
15
GpioWidget::GpioWidget(IGui *igui, QWidget *parent)
16
    : QWidget(parent) {
17
    igui_ = igui;
18
    newValue_.u.val[0] = 0;
19
 
20
    //setMinimumWidth(150);
21
    //setMinimumHeight(100); 
22
 
23
 
24
    QGridLayout *layout = new QGridLayout(this);
25
 
26
    // Row 0:
27
    QLabel *lbl1 = new QLabel(this);
28
    lbl1->setText(tr("User defined LEDs"));
29
    layout->addWidget(lbl1, 0, 0, 1, 2, Qt::AlignCenter);
30
 
31
    // Row 1
32
    LedArea *ledArea = new LedArea(this);
33
    layout->addWidget(ledArea, 1, 0, Qt::AlignCenter);
34
    connect(this, SIGNAL(signalLedValue(uint32_t)),
35
            ledArea, SLOT(slotUpdate(uint32_t)));
36
 
37
    QLabel *lbl2 = new QLabel(this);
38
    lbl2->setText(tr("xx"));
39
    layout->addWidget(lbl2, 1, 1, Qt::AlignLeft);
40
 
41
    // Row 2:
42
    QLabel *lbl3 = new QLabel(this);
43
    lbl3->setText(tr("User defined DIPs"));
44
    layout->addWidget(lbl3, 2, 0, 1, 2, Qt::AlignCenter);
45
 
46
    // Row 3:
47
    DipArea *dipArea = new DipArea(this);
48
    layout->addWidget(dipArea, 3, 0, Qt::AlignCenter);
49
    connect(this, SIGNAL(signalDipValue(uint32_t)),
50
            dipArea, SLOT(slotUpdate(uint32_t)));
51
 
52
    QLabel *lbl4 = new QLabel(this);
53
    lbl4->setText(tr("xx"));
54
    layout->addWidget(lbl4, 3, 1, Qt::AlignLeft);
55
 
56
    setLayout(layout);
57
 
58
    char tstr[64];
59
    ISocInfo *info = static_cast<ISocInfo *>(igui_->getSocInfo());
60
    uint32_t addr_gpio = static_cast<int>(info->addressGpio());
61
    RISCV_sprintf(tstr, sizeof(tstr), "read 0x%08x 8", addr_gpio);
62
    cmdRd_.make_string(tstr);
63
}
64
 
65
GpioWidget::~GpioWidget() {
66
    igui_->removeFromQueue(static_cast<IGuiCmdHandler *>(this));
67
}
68
 
69
void GpioWidget::handleResponse(AttributeType *req, AttributeType *resp) {
70
    newValue_.u.val[0] = resp->to_uint64();
71
}
72
 
73
void GpioWidget::slotUpdateByTimer() {
74
    if (!isVisible()) {
75
        return;
76
    }
77
    value_ = newValue_;
78
    emit signalLedValue(value_.u.map.led);
79
    emit signalDipValue(value_.u.map.dip);
80
 
81
    igui_->registerCommand(static_cast<IGuiCmdHandler *>(this), &cmdRd_, true);
82
}
83
 
84
}  // namespace debugger

powered by: WebSVN 2.1.0

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