예제 #1
0
 private void button1_Click_1(object sender, EventArgs e)
 {
     if (button1.Text == "开始")
     {
         tbLog.Clear();
         if (GY7502_USBSPI.GY7502_USBSPI_Open() == 0)
         {
             tbLog.AppendText("USB2SPI打开失败\r\n");
             return;
         }
         tbLog.AppendText("USB2SPI打开成功\r\n");
         GY7502_CONFIG_INFO ConfigInfo = new GY7502_CONFIG_INFO();
         ConfigInfo.kFreq   = 1;
         ConfigInfo.SpiMode = 2;
         int x = GY7502_USBSPI.GY7502_USBSPI_SetConfig(ref ConfigInfo);
         if (x == 0)
         {
             tbLog.AppendText("USB2SPI工作参数设置失败\r\n");
             return;
         }
         if (x == -1)
         {
             tbLog.AppendText("USB2SPI工作参数设置失败,尚未打开\r\n");
             return;
         }
         button1.Text = "停止";
         for (int i = 0; i < 24; i++)
         {
             FileStream fs = new FileStream(Files[i], FileMode.Create);
             fs.Close();
         }
         tbHH.ReadOnly  = true;
         tbMM.Text      = "00";
         tbSS.Text      = "00";
         timer1.Enabled = true;
         PickTimes      = 0;
         SaveTimes      = 0;
     }
     else
     {
         button1.Text   = "开始";
         tbHH.ReadOnly  = false;
         timer1.Enabled = false;
         GY7502_USBSPI.GY7502_USBSPI_Close();
     }
 }
예제 #2
0
        private void button1_Click(object sender, EventArgs e)
        {
            GY7502_CONFIG_INFO ConfigInfo = new GY7502_CONFIG_INFO();

            ConfigInfo.kFreq   = 3;
            ConfigInfo.SpiMode = 2;
            int x = GY7502_USBSPI.GY7502_USBSPI_SetConfig(ref ConfigInfo);

            if (x == 0)
            {
                return;
            }
            if (GY7502_USBSPI.GY7502_USBSPI_Open() == 0)
            {
                return;
            }
        }