• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

ストロベリー・リナックスUSB温度計USBRHを使った温度計 by Qt


Commit MetaInfo

Revision5b1379c54f22dca4e8adfc6066350b5b6a6b05cd (tree)
Time2013-03-24 12:35:06
Authoralucky4416 <alucky4416@user...>
Commiterarakaki

Log Message

feature: add set heater on/off.

Change Summary

Incremental Difference

--- a/mainwindow.cpp
+++ b/mainwindow.cpp
@@ -88,3 +88,10 @@ void MainWindow::on_checkBox_LED_1_stateChanged(int arg1)
8888 rc = rhdev->set_led_status(1, (unsigned char)arg1);
8989
9090 }
91+
92+void MainWindow::on_checkBox_HEATER_stateChanged(int arg1)
93+{
94+ int rc;
95+ rc = rhdev->set_heater_status((unsigned char)arg1);
96+
97+}
--- a/mainwindow.h
+++ b/mainwindow.h
@@ -25,6 +25,8 @@ private slots:
2525
2626 void on_checkBox_LED_1_stateChanged(int arg1);
2727
28+ void on_checkBox_HEATER_stateChanged(int arg1);
29+
2830 private:
2931 Ui::MainWindow *ui;
3032
--- a/mainwindow.ui
+++ b/mainwindow.ui
@@ -174,7 +174,7 @@
174174 <widget class="QCheckBox" name="checkBox_LED_1">
175175 <property name="geometry">
176176 <rect>
177- <x>210</x>
177+ <x>140</x>
178178 <y>120</y>
179179 <width>80</width>
180180 <height>20</height>
@@ -184,6 +184,19 @@
184184 <string>LED 1</string>
185185 </property>
186186 </widget>
187+ <widget class="QCheckBox" name="checkBox_HEATER">
188+ <property name="geometry">
189+ <rect>
190+ <x>270</x>
191+ <y>120</y>
192+ <width>80</width>
193+ <height>20</height>
194+ </rect>
195+ </property>
196+ <property name="text">
197+ <string>Heater</string>
198+ </property>
199+ </widget>
187200 </widget>
188201 <widget class="QMenuBar" name="menuBar">
189202 <property name="geometry">
--- a/usbrh.cpp
+++ b/usbrh.cpp
@@ -253,6 +253,25 @@ int usbrh::set_led_status(unsigned char led_index, unsigned char led_onoff)
253253 return rc;
254254 }
255255
256+int usbrh::set_heater_status(unsigned char heater_onoff)
257+{
258+ int rc = 0;
259+ char buff[USBRH_BUFFER_SIZE];
260+
261+ if (gDevHandle == (usb_dev_handle *)NULL) return 1;
262+
263+ memset(buff, 0, sizeof(buff));
264+ buff[0] = 1;
265+ buff[1] = heater_onoff << 2; // heater_onoff = 1 is led on
266+ rc = usb_control_msg(gDevHandle, USB_ENDPOINT_OUT + USB_TYPE_CLASS + USB_RECIP_INTERFACE,
267+ 0x09, 0x03<<8, 0, buff, USBRH_BUFFER_SIZE, 5000);
268+ if (rc < 0) {
269+ qDebug() << QString("usb_control_msg error : ") << QString(usb_strerror());
270+ }
271+
272+ return rc;
273+}
274+
256275 void usbrh::close()
257276 {
258277 int rc = 0;
--- a/usbrh.h
+++ b/usbrh.h
@@ -28,6 +28,7 @@ public:
2828 int config();
2929 int get_tempr_humid(double *tempr, double *humid);
3030 int set_led_status(unsigned char led_index, unsigned char led_onoff);
31+ int set_heater_status(unsigned char heater_onoff);
3132 void close();
3233
3334 };