int cmd_relay(int argc, char *argv[]) { unsigned char pin,value; unsigned short module; module = MODULE1; if(!(module_exists(module) && (module_profile_id(module) == PROFILE_RELAY))) { cmd_print("No relay available."); return(0); } if (argc == 2) { pin = ustrtoul(argv[1],NULL,0); cmd_print("\r\nrelay module: %d pin: %d value: %d",module,pin, relay_read(module,pin)); } else if (argc == 3) { pin = ustrtoul(argv[1],NULL,0); value = ustrtoul(argv[2],NULL,16); relay_write(module,pin,value); } return(0); }
Host::Host(QWidget *ParentMainWin, USB_VCP *usbObj) : QWidget(ParentMainWin) { // Rename obj pointers for convenience mainWin = (MainWindow*)ParentMainWin; ui = (Ui::MainWindow*)mainWin->ui; usb_vcp = (USB_VCP*)usbObj; // Comms connect(ui->pushButton_comms_open, SIGNAL(clicked()), this, SLOT(comms_open())); connect(ui->pushButton_comms_test, SIGNAL(clicked()), this, SLOT(comms_test())); //ui->listWidget_comms_list->hide(); connect(ui->listWidget_comms_list, SIGNAL(itemPressed(QListWidgetItem*)), this, SLOT(comms_open_selected(QListWidgetItem*))); // PDP connect(ui->pushButton_read_DMA, SIGNAL(clicked()), this, SLOT(read_DMA())); ui->pushButton_read_DMA->setVisible(false); connect(ui->pushButton_read_AC, SIGNAL(clicked()), this, SLOT(read_channelDMA())); ui->pushButton_read_AC->setVisible(false); connect(ui->pushButton_read_AC_filtered, SIGNAL(clicked()), this, SLOT(read_channelDMA_filtered())); connect(ui->pushButton_write_command, SIGNAL(clicked()), this, SLOT(write_command())); connect(ui->pushButton_read_status, SIGNAL(clicked()), this, SLOT(read_status())); connect(ui->pushButton_read_relay, SIGNAL(clicked()), this, SLOT(relay_read())); connect(ui->radioButton_relayOn, SIGNAL(clicked()), this, SLOT(relay_on())); connect(ui->radioButton_relayOff, SIGNAL(clicked()), this, SLOT(relay_off())); QGridLayout *gbox = new QGridLayout(ui->groupBox_relaySelect); int i = 0; for(int x = 0;x < 4; x++) { for(int y = 0;y < 4; y++) { relaySelectButton[i] = new QRadioButton(IntToStr(i)); gbox->addWidget(relaySelectButton[i], y, x); connect(relaySelectButton[i], SIGNAL(clicked()), this, SLOT(relay_selected())); i++; } } ui->groupBox_relaySelect->setLayout(gbox); relayNumberSelected = 0; relaySelectButton[relayNumberSelected]->setChecked(true); // PDP graph init graph_init(); }