forked from ccsens_hardware/qt_qcp_show
Browse Source
程序启动切换到可执行文件所在目录 推送消息中没有倒计时不显示 添加轮播患者 2个api测试完成 添加按键检测 修改qtdebug->qtcore11 修改qtdebug->qtcore pro文件中去除无用文件,以缩减目标平台编译时间 test device 1 test device Co-authored-by: zhangsan <zezhao_wei@163.com> Reviewed-on: https://dd.tall.wiki/gitea/ccsens_hardware/qt_qcp_show/pulls/4master
16 changed files with 338 additions and 74 deletions
@ -0,0 +1,47 @@ |
|||
GET https://example.com/comments/1 HTTP/1.1 |
|||
|
|||
### |
|||
|
|||
GET https://example.com/topics/1 HTTP/1.1 |
|||
|
|||
### |
|||
# @name signin |
|||
POST http://test.tall.wiki/gateway/tall3/v3.0/users/signin HTTP/1.1 |
|||
content-type: application/json |
|||
|
|||
{ |
|||
"client": 1, |
|||
"data": { |
|||
"credential": "123456", |
|||
"identifier": "shoufeichu" |
|||
}, |
|||
"scene": 0, |
|||
"type": 3 |
|||
} |
|||
|
|||
### |
|||
|
|||
POST https://test.tall.wiki/gateway/qcp/v3.0/button/idCardDiscern HTTP/1.1 |
|||
content-type: application/json |
|||
Authorization: Bearer {{signin.response.body.$.data.token}} |
|||
|
|||
{ |
|||
"param":{ |
|||
"idcard":"142733198703123919", |
|||
"name":"彭于晏", |
|||
"sex":"1", |
|||
"nation":"汉族" |
|||
} |
|||
} |
|||
|
|||
### |
|||
|
|||
POST https://test.tall.wiki/gateway/qcp/v3.0/button/buttonStart HTTP/1.1 |
|||
content-type: application/json |
|||
Authorization: Bearer {{signin.response.body.$.data.token}} |
|||
|
|||
{ |
|||
"param":{ |
|||
"idcard":"142733198703123919" |
|||
} |
|||
} |
@ -0,0 +1,93 @@ |
|||
#include "deviceservice.h" |
|||
#include <QtCore> |
|||
#ifdef Q_OS_LINUX |
|||
#include <wiringPi.h> |
|||
#else |
|||
#endif |
|||
|
|||
#define WIRING_PIN_LED 4 //GPIO.4
|
|||
#define WIRING_PIN_KEY 3 //GPIO.3
|
|||
#define Click_Overtime 50 |
|||
|
|||
DeviceService::DeviceService(QObject *parent) : QObject(parent) |
|||
{ |
|||
key.flag = None; |
|||
key.lastState = KEY_Up; |
|||
m_ledStatus = 0; |
|||
m_keyStatus = 0; |
|||
|
|||
#ifdef Q_OS_LINUX |
|||
wiringPiSetup(); |
|||
pinMode(WIRING_PIN_LED,OUTPUT);//LED输出模式 可选值:INPUT、OUTPUT、PWM_OUTPUT,GPIO_CLOCK
|
|||
pinMode(WIRING_PIN_KEY,INPUT); //KEY输入模式
|
|||
pullUpDnControl(WIRING_PIN_KEY,PUD_UP); //KEY设置上拉
|
|||
#else |
|||
qDebug() << "wiringPiSetup()"; |
|||
qDebug() << "pinMode(WIRING_PIN_LED,OUTPUT)"; |
|||
qDebug() << "pinMode(WIRING_PIN_BTN,INPUT)"; |
|||
#endif |
|||
|
|||
timer1.setInterval(1000); |
|||
timer1.start(); |
|||
connect(&timer1,&QTimer::timeout,[=](){ |
|||
m_ledStatus ^= 1; |
|||
ledSet(m_ledStatus); |
|||
}); |
|||
|
|||
timer2.setInterval(50); |
|||
timer2.start(); |
|||
connect(&timer2,&QTimer::timeout,[=](){ |
|||
// quint8 keyStatus = keyReadOnce();
|
|||
// if(keyStatus != m_keyStatus){
|
|||
// m_keyStatus = keyStatus;
|
|||
// qDebug() << "m_keyStatus " << m_keyStatus;
|
|||
// }
|
|||
key.flag = (KeyFlag)keyDetection(); |
|||
if(key.flag != None){ |
|||
if(key.flag == Click){ |
|||
emit keyClicked(); |
|||
} |
|||
} |
|||
}); |
|||
} |
|||
|
|||
void DeviceService::ledSet(int status) |
|||
{ |
|||
#ifdef Q_OS_LINUX |
|||
digitalWrite(WIRING_PIN_LED,status == 1 ? LOW : HIGH);//'HIGH'代表高电平,’LOW‘则为低电平
|
|||
#else |
|||
qDebug() << "LED set: " << status; |
|||
#endif |
|||
} |
|||
|
|||
/**
|
|||
* @brief DeviceService::keyReadOnce |
|||
* 按键按下返回0,按键弹起返回1 |
|||
* @return |
|||
*/ |
|||
quint8 DeviceService::keyReadOnce() |
|||
{ |
|||
#ifdef Q_OS_LINUX |
|||
return digitalRead(WIRING_PIN_KEY); |
|||
#else |
|||
//qDebug() << "keyReadOnce()";
|
|||
return KEY_Up; |
|||
#endif |
|||
} |
|||
|
|||
quint8 DeviceService::keyDetection() |
|||
{ |
|||
key.flag = None; //清空按键标志
|
|||
quint8 status = keyReadOnce(); |
|||
if ((status == KEY_Down) && (key.lastState == KEY_Up)) |
|||
{ |
|||
uint16_t i = Click_Overtime; |
|||
while(i--); |
|||
status = keyReadOnce(); |
|||
if(status == KEY_Down){ |
|||
key.flag = Click; //先确定按键标志为单击
|
|||
} |
|||
} |
|||
key.lastState = status; |
|||
return key.flag; |
|||
} |
@ -0,0 +1,46 @@ |
|||
#ifndef DEVICESERVICE_H |
|||
#define DEVICESERVICE_H |
|||
|
|||
#include <QObject> |
|||
#include <QTimer> |
|||
|
|||
typedef enum{ |
|||
GPIO_PIN_RESET = 0u, |
|||
GPIO_PIN_SET |
|||
} GPIO_PinState; |
|||
|
|||
typedef enum{ |
|||
None = (uint8_t)0, |
|||
Click = (uint8_t)1, |
|||
Dbl_Click = (uint8_t)2, |
|||
Tri_Click = (uint8_t)3, |
|||
Press = (uint8_t)4, |
|||
}KeyFlag; |
|||
|
|||
#define KEY_Up 1 |
|||
#define KEY_Down 0 |
|||
|
|||
typedef struct{ |
|||
KeyFlag flag; |
|||
quint8 lastState; |
|||
}KeyType; |
|||
|
|||
class DeviceService : public QObject |
|||
{ |
|||
Q_OBJECT |
|||
public: |
|||
explicit DeviceService(QObject *parent = 0); |
|||
private: |
|||
KeyType key; |
|||
int m_ledStatus,m_keyStatus; |
|||
QTimer timer1,timer2; |
|||
signals: |
|||
void keyClicked(); |
|||
|
|||
public slots: |
|||
void ledSet(int status); |
|||
quint8 keyReadOnce(); |
|||
quint8 keyDetection(); |
|||
}; |
|||
|
|||
#endif // DEVICESERVICE_H
|
@ -1,9 +0,0 @@ |
|||
https://example.com/comments/1 |
|||
|
|||
POST https://example.com/comments HTTP/1.1 |
|||
content-type: application/json |
|||
|
|||
{ |
|||
"name": "sample", |
|||
"time": "Wed, 21 Oct 2015 18:27:50 GMT" |
|||
} |
@ -0,0 +1,27 @@ |
|||
[MAIN] |
|||
;最大患者数量 |
|||
maxPatientNum = 5 |
|||
;切换病人时间(s) |
|||
switchPatientInterval = 5 |
|||
|
|||
[USER] |
|||
;登录用户名 |
|||
username = shoufeichu |
|||
;登录密码 |
|||
password = 123456 |
|||
|
|||
[HTTP] |
|||
;登录请求URL |
|||
loginUrl = http://test.tall.wiki/gateway/tall3/v3.0/users/signin |
|||
;发送身份证信息URL |
|||
sendUserInfoUrl = https://test.tall.wiki/gateway/qcp/v3.0/button/idCardDiscern |
|||
;一键启动URL |
|||
oneKeyStartUrl = https://test.tall.wiki/gateway/qcp/v3.0/button/buttonStart |
|||
;服务状态改变URL(rgb) |
|||
serviceStatusChangedUrl = https://test.tall.wiki/gateway/qcp/v3.0/button/updateStatus |
|||
|
|||
[WEBSOCKET] |
|||
;Websocket URL |
|||
wsUrl = wss://test.tall.wiki/websocket/message/v4.0/ws |
|||
;Websocket心跳间隔(s) |
|||
wsHeartInterval = 10 |
Loading…
Reference in new issue