2023-12-07 18:29:49 +08:00
|
|
|
|
|
|
|
|
|
#include "base/base.h"
|
|
|
|
|
#include "base/check_cfg.h"
|
|
|
|
|
#include "base/mycfg.h"
|
|
|
|
|
#include "prot/prot_m4.h"
|
|
|
|
|
#include "prot/prot_pc.h"
|
2024-01-29 18:05:23 +08:00
|
|
|
|
#include "base/beep.h"
|
|
|
|
|
#include "prot_cmd/cmd_coder.h"
|
|
|
|
|
#include "elec/coder_lib.h"
|
|
|
|
|
#include "elec/elec_judge.h"
|
2023-12-07 18:29:49 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
typedef struct{
|
|
|
|
|
int key_pressed;
|
|
|
|
|
int ke1_pressed;
|
|
|
|
|
}self_def;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static self_def g_self;
|
|
|
|
|
|
|
|
|
|
|
2024-01-29 18:05:23 +08:00
|
|
|
|
static int docmd_ke1();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2023-12-07 18:29:49 +08:00
|
|
|
|
void cmd_m4_init()
|
|
|
|
|
{
|
|
|
|
|
prot_m4 *m4=protM4();
|
2024-01-29 18:05:23 +08:00
|
|
|
|
beep *beep_=Beep();
|
|
|
|
|
mycfg *cfg_=syscfg();
|
2023-12-07 18:29:49 +08:00
|
|
|
|
m4->set_irq_fun([=](myarray data){
|
|
|
|
|
ProtPc *pc=protPc();
|
|
|
|
|
g_self.key_pressed=1;
|
|
|
|
|
qDebug("key press");
|
|
|
|
|
pc->send_data_slot(0x37,myarray(1,char(0)));
|
|
|
|
|
},"key press");
|
|
|
|
|
m4->set_irq_fun([=](myarray data){
|
|
|
|
|
g_self.key_pressed=0;
|
|
|
|
|
qDebug("key up");
|
|
|
|
|
},"key up");
|
|
|
|
|
m4->set_irq_fun([=](myarray data){
|
|
|
|
|
g_self.ke1_pressed=1;
|
2024-01-29 18:05:23 +08:00
|
|
|
|
beep_->set_state(true);
|
2023-12-07 18:29:49 +08:00
|
|
|
|
qDebug("ke1 press");
|
|
|
|
|
},"ke1 press");
|
|
|
|
|
m4->set_irq_fun([=](myarray data){
|
|
|
|
|
g_self.ke1_pressed=0;
|
2024-01-29 18:05:23 +08:00
|
|
|
|
beep_->set_state(false);
|
2023-12-07 18:29:49 +08:00
|
|
|
|
qDebug("ke1 up");
|
2024-01-29 18:05:23 +08:00
|
|
|
|
docmd_ke1();
|
2023-12-07 18:29:49 +08:00
|
|
|
|
},"ke1 up");
|
|
|
|
|
// m4->set_irq_fun([=](myarray data){
|
|
|
|
|
// ProtPc *pc=protPc();
|
|
|
|
|
// qDebug("send 0x37 to pc");
|
|
|
|
|
// pc->send_data_slot(0x37,myarray(1,char(0)));
|
|
|
|
|
// },"key press");
|
|
|
|
|
}
|
|
|
|
|
|
2023-12-29 18:09:10 +08:00
|
|
|
|
// 返回1则按键已按下
|
|
|
|
|
int cmd_m4_key_pressed()
|
|
|
|
|
{
|
|
|
|
|
if(g_self.key_pressed){
|
|
|
|
|
return 1;
|
|
|
|
|
}else{
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
}
|
2023-12-07 18:29:49 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2024-01-29 18:05:23 +08:00
|
|
|
|
static int docmd_ke1(){
|
|
|
|
|
/*
|
|
|
|
|
赋码仪按键按下时,如果是赋码仪一体机,则发送请求赋码命令0x8b
|
|
|
|
|
按键加上300ms屏蔽
|
|
|
|
|
赋码仪按键按下,直接开始检测
|
|
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
ProtPc *pc=protPc();
|
|
|
|
|
mycfg *cfg_=syscfg();
|
|
|
|
|
check_cfg *ccfg_=check_plan();
|
|
|
|
|
if(cfg_->device_type=="inte_coder"){
|
|
|
|
|
int chip=elec_extract_chip(ccfg_->get_plan_id());
|
|
|
|
|
QByteArray r;
|
|
|
|
|
r.append(char(chip));
|
|
|
|
|
qInfo("key1 press:send cmd 0x8b.");
|
|
|
|
|
pc->send_data_slot(0x8b,r);
|
|
|
|
|
}else{
|
|
|
|
|
char data[]={10,0};
|
|
|
|
|
qInfo("key1 press:start check.");
|
|
|
|
|
pc->docmd(0xe0,myarray(data,2));
|
|
|
|
|
}
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|