]> rtime.felk.cvut.cz Git - mf6xx.git/blob - src/qemu/mf624_interface/untitled/mainwindow.cpp
0daea2cfe7a1d709098882f75a90e81be0c4b761
[mf6xx.git] / src / qemu / mf624_interface / untitled / mainwindow.cpp
1 #include <stdio.h>
2 #include "mainwindow.h"
3 #include "ui_mainwindow.h"
4 #include "socket_thread.h"
5 #include "mf624_io_status.h"
6 extern mf624_io_status_t mf624_io_status;
7
8
9 MainWindow::MainWindow(QWidget *parent) :
10     QMainWindow(parent),
11     ui(new Ui::MainWindow)
12 {
13         ui->setupUi(this);
14         // Set fixed size for window
15         this->setFixedSize(this->width(), this->height());
16
17         // create new thread (on heap) and start it
18         s_thread = new socket_thread(this);
19         s_thread->start(); // after this, thread's run() method starts
20 }
21
22 MainWindow::~MainWindow()
23 {
24     delete ui;
25 }
26
27
28 void MainWindow::din_set(int bit, int val)
29 {
30         if(val == 0) {
31                 mf624_io_status.DIN &= ~(1 << bit);
32         }
33         else if (val == 2) {
34                 mf624_io_status.DIN |= (1 << bit);
35         }
36
37         s_thread->socket_send("DIN=%f\n", (double)(mf624_io_status.DIN));
38 }
39
40 void MainWindow::on_checkBox_stateChanged(int arg1)
41 {
42         din_set(0, arg1);
43 }
44
45 void MainWindow::on_checkBox_2_stateChanged(int arg1)
46 {
47         din_set(1, arg1);
48 }
49
50 void MainWindow::on_checkBox_3_stateChanged(int arg1)
51 {
52         din_set(2, arg1);
53 }
54
55 void MainWindow::on_checkBox_4_stateChanged(int arg1)
56 {
57         din_set(3, arg1);
58 }
59
60 void MainWindow::on_checkBox_5_stateChanged(int arg1)
61 {
62         din_set(4, arg1);
63 }
64
65 void MainWindow::on_checkBox_6_stateChanged(int arg1)
66 {
67         din_set(5, arg1);
68 }
69
70 void MainWindow::on_checkBox_7_stateChanged(int arg1)
71 {
72         din_set(6, arg1);
73 }
74
75 void MainWindow::on_checkBox_8_stateChanged(int arg1)
76 {
77         din_set(7, arg1);
78 }
79
80 void MainWindow::on_adc0_valueChanged(double arg1)
81 {
82         s_thread->socket_send("ADC0=%f\n", arg1);
83 }
84
85 void MainWindow::on_adc1_valueChanged(double arg1)
86 {
87         s_thread->socket_send("ADC1=%f\n", arg1);
88 }
89
90 void MainWindow::on_adc2_valueChanged(double arg1)
91 {
92         s_thread->socket_send("ADC2=%f\n", arg1);
93 }
94
95 void MainWindow::on_adc3_valueChanged(double arg1)
96 {
97         s_thread->socket_send("ADC3=%f\n", arg1);
98 }
99
100 void MainWindow::on_adc4_valueChanged(double arg1)
101 {
102         s_thread->socket_send("ADC4=%f\n", arg1);
103 }
104
105 void MainWindow::on_adc5_valueChanged(double arg1)
106 {
107         s_thread->socket_send("ADC5=%f\n", arg1);
108 }
109
110 void MainWindow::on_adc6_valueChanged(double arg1)
111 {
112         s_thread->socket_send("ADC6=%f\n", arg1);
113 }
114
115 void MainWindow::on_adc7_valueChanged(double arg1)
116 {
117         s_thread->socket_send("ADC7=%f\n", arg1);
118 }