예제 #1
0
파일: file.c 프로젝트: bgamari/geda-pcb
/* ---------------------------------------------------------------------------
 * writes via data
 */
static void
WriteViaData (FILE * FP, DataType *Data)
{
  GList *iter;
  /* write information about vias */
  for (iter = Data->Via; iter != NULL; iter = g_list_next (iter))
    {
      PinType *via = iter->data;
      pcb_fprintf (FP, "Via[%mr %mr %mr %mr %mr %mr ", via->X, via->Y,
                   via->Thickness, via->Clearance, via->Mask, via->DrillingHole);
      PrintQuotedString (FP, (char *)EMPTY (via->Name));
      fprintf (FP, " %s]\n", F2S (via, VIA_TYPE));
    }
}
예제 #2
0
파일: file.c 프로젝트: bgamari/geda-pcb
/* ---------------------------------------------------------------------------
 * writes rat-line data
 */
static void
WritePCBRatData (FILE * FP)
{
  GList *iter;
  /* write information about rats */
  for (iter = PCB->Data->Rat; iter != NULL; iter = g_list_next (iter))
    {
      RatType *line = iter->data;
      pcb_fprintf (FP, "Rat[%mr %mr %d %mr %mr %d ",
                   line->Point1.X, line->Point1.Y, line->group1,
                   line->Point2.X, line->Point2.Y, line->group2);
      fprintf (FP, " %s]\n", F2S (line, RATLINE_TYPE));
    }
}
예제 #3
0
파일: file.c 프로젝트: thequux/pcb
/* ---------------------------------------------------------------------------
 * writes rat-line data
 */
static void
WritePCBRatData (FILE * FP)
{
  int n;
  /* write information about rats */
  for (n = 0; n < PCB->Data->RatN; n++)
    {
      RatTypePtr line = &PCB->Data->Rat[n];
      fprintf (FP, "Rat[%i %i %i %i %i %i ",
	       (int) line->Point1.X, (int) line->Point1.Y,
	       (int) line->group1, (int) line->Point2.X,
	       (int) line->Point2.Y, (int) line->group2);
      fprintf (FP, " %s]\n", F2S (line, RATLINE_TYPE));
    }
}
예제 #4
0
파일: file.c 프로젝트: thequux/pcb
/* ---------------------------------------------------------------------------
 * writes via data
 */
static void
WriteViaData (FILE * FP, DataTypePtr Data)
{
  int n;
  /* write information about vias */
  for (n = 0; n < Data->ViaN; n++)
    {
      PinTypePtr via = &Data->Via[n];
      fprintf (FP, "Via[%i %i %i %i %i %i ",
	       via->X, via->Y,
	       via->Thickness, via->Clearance, via->Mask, via->DrillingHole);
      PrintQuotedString (FP, (char *)EMPTY (via->Name));
      fprintf (FP, " %s]\n", F2S (via, VIA_TYPE));
    }
}
예제 #5
0
파일: file.c 프로젝트: bgamari/geda-pcb
/* ---------------------------------------------------------------------------
 * writes layer data
 */
static void
WriteLayerData (FILE * FP, Cardinal Number, LayerType *layer)
{
  GList *n;
  /* write information about non empty layers */
  if (layer->LineN || layer->ArcN || layer->TextN || layer->PolygonN ||
      (layer->Name && *layer->Name))
    {
      fprintf (FP, "Layer(%i ", (int) Number + 1);
      PrintQuotedString (FP, (char *)EMPTY (layer->Name));
      fputs (")\n(\n", FP);
      WriteAttributeList (FP, &layer->Attributes, "\t");

      for (n = layer->Line; n != NULL; n = g_list_next (n))
	{
	  LineType *line = n->data;
          pcb_fprintf (FP, "\tLine[%mr %mr %mr %mr %mr %mr %s]\n",
                       line->Point1.X, line->Point1.Y,
                       line->Point2.X, line->Point2.Y,
                       line->Thickness, line->Clearance,
                       F2S (line, LINE_TYPE));
	}
      for (n = layer->Arc; n != NULL; n = g_list_next (n))
	{
	  ArcType *arc = n->data;
          pcb_fprintf (FP, "\tArc[%mr %mr %mr %mr %mr %mr %ma %ma %s]\n",
                       arc->X, arc->Y, arc->Width,
                       arc->Height, arc->Thickness,
                       arc->Clearance, arc->StartAngle,
                       arc->Delta, F2S (arc, ARC_TYPE));
	}
      for (n = layer->Text; n != NULL; n = g_list_next (n))
	{
	  TextType *text = n->data;
          pcb_fprintf (FP, "\tText[%mr %mr %d %d ",
                       text->X, text->Y,
                       text->Direction, text->Scale);
	  PrintQuotedString (FP, (char *)EMPTY (text->TextString));
	  fprintf (FP, " %s]\n", F2S (text, TEXT_TYPE));
	}
      for (n = layer->Polygon; n != NULL; n = g_list_next (n))
	{
	  PolygonType *polygon = n->data;
	  int p, i = 0;
	  Cardinal hole = 0;
	  fprintf (FP, "\tPolygon(%s)\n\t(", F2S (polygon, POLYGON_TYPE));
	  for (p = 0; p < polygon->PointN; p++)
	    {
	      PointType *point = &polygon->Points[p];

	      if (hole < polygon->HoleIndexN &&
		  p == polygon->HoleIndex[hole])
		{
		  if (hole > 0)
		    fputs ("\n\t\t)", FP);
		  fputs ("\n\t\tHole (", FP);
		  hole++;
		  i = 0;
		}

	      if (i++ % 5 == 0)
		{
		  fputs ("\n\t\t", FP);
		  if (hole)
		    fputs ("\t", FP);
		}
              pcb_fprintf (FP, "[%mr %mr] ", point->X, point->Y);
	    }
	  if (hole > 0)
	    fputs ("\n\t\t)", FP);
	  fputs ("\n\t)\n", FP);
	}
      fputs (")\n", FP);
    }
}
예제 #6
0
파일: file.c 프로젝트: bgamari/geda-pcb
/* ---------------------------------------------------------------------------
 * writes element data
 */
static void
WriteElementData (FILE * FP, DataType *Data)
{
  GList *n, *p;
  for (n = Data->Element; n != NULL; n = g_list_next (n))
    {
      ElementType *element = n->data;

      /* only non empty elements */
      if (!element->LineN && !element->PinN && !element->ArcN
	  && !element->PadN)
	continue;
      /* the coordinates and text-flags are the same for
       * both names of an element
       */
      fprintf (FP, "\nElement[%s ", F2S (element, ELEMENT_TYPE));
      PrintQuotedString (FP, (char *)EMPTY (DESCRIPTION_NAME (element)));
      fputc (' ', FP);
      PrintQuotedString (FP, (char *)EMPTY (NAMEONPCB_NAME (element)));
      fputc (' ', FP);
      PrintQuotedString (FP, (char *)EMPTY (VALUE_NAME (element)));
      pcb_fprintf (FP, " %mr %mr %mr %mr %d %d %s]\n(\n",
                   element->MarkX, element->MarkY,
                   DESCRIPTION_TEXT (element).X - element->MarkX,
                   DESCRIPTION_TEXT (element).Y - element->MarkY,
                   DESCRIPTION_TEXT (element).Direction,
                   DESCRIPTION_TEXT (element).Scale,
                   F2S (&(DESCRIPTION_TEXT (element)), ELEMENTNAME_TYPE));
      WriteAttributeList (FP, &element->Attributes, "\t");
      for (p = element->Pin; p != NULL; p = g_list_next (p))
	{
	  PinType *pin = p->data;
          pcb_fprintf (FP, "\tPin[%mr %mr %mr %mr %mr %mr ",
                       pin->X - element->MarkX,
                       pin->Y - element->MarkY,
                       pin->Thickness, pin->Clearance,
                       pin->Mask, pin->DrillingHole);
	  PrintQuotedString (FP, (char *)EMPTY (pin->Name));
	  fprintf (FP, " ");
	  PrintQuotedString (FP, (char *)EMPTY (pin->Number));
	  fprintf (FP, " %s]\n", F2S (pin, PIN_TYPE));
	}
      for (p = element->Pad; p != NULL; p = g_list_next (p))
	{
	  PadType *pad = p->data;
          pcb_fprintf (FP, "\tPad[%mr %mr %mr %mr %mr %mr %mr ",
                       pad->Point1.X - element->MarkX,
                       pad->Point1.Y - element->MarkY,
                       pad->Point2.X - element->MarkX,
                       pad->Point2.Y - element->MarkY,
                       pad->Thickness, pad->Clearance, pad->Mask);
	  PrintQuotedString (FP, (char *)EMPTY (pad->Name));
	  fprintf (FP, " ");
	  PrintQuotedString (FP, (char *)EMPTY (pad->Number));
	  fprintf (FP, " %s]\n", F2S (pad, PAD_TYPE));
	}
      for (p = element->Line; p != NULL; p = g_list_next (p))
	{
	  LineType *line = p->data;
          pcb_fprintf (FP, "\tElementLine [%mr %mr %mr %mr %mr]\n",
                       line->Point1.X - element->MarkX,
                       line->Point1.Y - element->MarkY,
                       line->Point2.X - element->MarkX,
                       line->Point2.Y - element->MarkY,
                       line->Thickness);
	}
      for (p = element->Arc; p != NULL; p = g_list_next (p))
	{
	  ArcType *arc = p->data;
          pcb_fprintf (FP, "\tElementArc [%mr %mr %mr %mr %ma %ma %mr]\n",
                       arc->X - element->MarkX,
                       arc->Y - element->MarkY,
                       arc->Width, arc->Height,
                       arc->StartAngle, arc->Delta,
                       arc->Thickness);
	}
      fputs ("\n\t)\n", FP);
    }
}
예제 #7
0
파일: file.c 프로젝트: thequux/pcb
/* ---------------------------------------------------------------------------
 * writes layer data
 */
static void
WriteLayerData (FILE * FP, Cardinal Number, LayerTypePtr layer)
{
  int n;
  /* write information about non empty layers */
  if (layer->LineN || layer->ArcN || layer->TextN || layer->PolygonN ||
      (layer->Name && *layer->Name))
    {
      fprintf (FP, "Layer(%i ", (int) Number + 1);
      PrintQuotedString (FP, (char *)EMPTY (layer->Name));
      fputs (")\n(\n", FP);
      WriteAttributeList (FP, &layer->Attributes, "\t");

      for (n = 0; n < layer->LineN; n++)
	{
	  LineTypePtr line = &layer->Line[n];
	  fprintf (FP, "\tLine[%i %i %i %i %i %i %s]\n",
		   (int) line->Point1.X, (int) line->Point1.Y,
		   (int) line->Point2.X, (int) line->Point2.Y,
		   (int) line->Thickness, (int) line->Clearance,
		   F2S (line, LINE_TYPE));
	}
      for (n = 0; n < layer->ArcN; n++)
	{
	  ArcTypePtr arc = &layer->Arc[n];
	  fprintf (FP, "\tArc[%i %i %i %i %i %i %i %i %s]\n",
		   (int) arc->X, (int) arc->Y, (int) arc->Width,
		   (int) arc->Height, (int) arc->Thickness,
		   (int) arc->Clearance, (int) arc->StartAngle,
		   (int) arc->Delta, F2S (arc, ARC_TYPE));
	}
      for (n = 0; n < layer->TextN; n++)
	{
	  TextTypePtr text = &layer->Text[n];
	  fprintf (FP, "\tText[%i %i %i %i ",
		   (int) text->X, (int) text->Y,
		   (int) text->Direction, (int) text->Scale);
	  PrintQuotedString (FP, (char *)EMPTY (text->TextString));
	  fprintf (FP, " %s]\n", F2S (text, TEXT_TYPE));
	}
      for (n = 0; n < layer->PolygonN; n++)
	{
	  PolygonTypePtr polygon = &layer->Polygon[n];
	  int p, i = 0;
	  Cardinal hole = 0;
	  fprintf (FP, "\tPolygon(%s)\n\t(", F2S (polygon, POLYGON_TYPE));
	  for (p = 0; p < polygon->PointN; p++)
	    {
	      PointTypePtr point = &polygon->Points[p];

	      if (hole < polygon->HoleIndexN &&
		  p == polygon->HoleIndex[hole])
		{
		  if (hole > 0)
		    fputs ("\n\t\t)", FP);
		  fputs ("\n\t\tHole (", FP);
		  hole++;
		  i = 0;
		}

	      if (i++ % 5 == 0)
		{
		  fputs ("\n\t\t", FP);
		  if (hole)
		    fputs ("\t", FP);
		}
	      fprintf (FP, "[%i %i] ", (int) point->X, (int) point->Y);
	    }
	  if (hole > 0)
	    fputs ("\n\t\t)", FP);
	  fputs ("\n\t)\n", FP);
	}
      fputs (")\n", FP);
    }
}
예제 #8
0
파일: file.c 프로젝트: thequux/pcb
/* ---------------------------------------------------------------------------
 * writes element data
 */
static void
WriteElementData (FILE * FP, DataTypePtr Data)
{
  int n, p;
  for (n = 0; n < Data->ElementN; n++)
    {
      ElementTypePtr element = &Data->Element[n];
      /* only non empty elements */
      if (!element->LineN && !element->PinN && !element->ArcN
	  && !element->PadN)
	continue;
      /* the coordinates and text-flags are the same for
       * both names of an element
       */
      fprintf (FP, "\nElement[%s ", F2S (element, ELEMENT_TYPE));
      PrintQuotedString (FP, (char *)EMPTY (DESCRIPTION_NAME (element)));
      fputc (' ', FP);
      PrintQuotedString (FP, (char *)EMPTY (NAMEONPCB_NAME (element)));
      fputc (' ', FP);
      PrintQuotedString (FP, (char *)EMPTY (VALUE_NAME (element)));
      fprintf (FP, " %i %i %i %i %i %i %s]\n(\n",
	       (int) element->MarkX, (int) element->MarkY,
	       (int) (DESCRIPTION_TEXT (element).X -
		      element->MarkX),
	       (int) (DESCRIPTION_TEXT (element).Y -
		      element->MarkY),
	       (int) DESCRIPTION_TEXT (element).Direction,
	       (int) DESCRIPTION_TEXT (element).Scale,
	       F2S (&(DESCRIPTION_TEXT (element)), ELEMENTNAME_TYPE));
      WriteAttributeList (FP, &element->Attributes, "\t");
      for (p = 0; p < element->PinN; p++)
	{
	  PinTypePtr pin = &element->Pin[p];
	  fprintf (FP, "\tPin[%i %i %i %i %i %i ",
		   (int) (pin->X - element->MarkX),
		   (int) (pin->Y - element->MarkY),
		   (int) pin->Thickness, (int) pin->Clearance,
		   (int) pin->Mask, (int) pin->DrillingHole);
	  PrintQuotedString (FP, (char *)EMPTY (pin->Name));
	  fprintf (FP, " ");
	  PrintQuotedString (FP, (char *)EMPTY (pin->Number));
	  fprintf (FP, " %s]\n", F2S (pin, PIN_TYPE));
	}
      for (p = 0; p < element->PadN; p++)
	{
	  PadTypePtr pad = &element->Pad[p];
	  fprintf (FP, "\tPad[%i %i %i %i %i %i %i ",
		   (int) (pad->Point1.X - element->MarkX),
		   (int) (pad->Point1.Y - element->MarkY),
		   (int) (pad->Point2.X - element->MarkX),
		   (int) (pad->Point2.Y - element->MarkY),
		   (int) pad->Thickness, (int) pad->Clearance,
		   (int) pad->Mask);
	  PrintQuotedString (FP, (char *)EMPTY (pad->Name));
	  fprintf (FP, " ");
	  PrintQuotedString (FP, (char *)EMPTY (pad->Number));
	  fprintf (FP, " %s]\n", F2S (pad, PAD_TYPE));
	}
      for (p = 0; p < element->LineN; p++)
	{
	  LineTypePtr line = &element->Line[p];
	  fprintf (FP,
		   "\tElementLine [%i %i %i %i %i]\n",
		   (int) (line->Point1.X -
			  element->MarkX),
		   (int) (line->Point1.Y -
			  element->MarkY),
		   (int) (line->Point2.X -
			  element->MarkX),
		   (int) (line->Point2.Y -
			  element->MarkY), (int) line->Thickness);
	}
      for (p = 0; p < element->ArcN; p++)
	{
	  ArcTypePtr arc = &element->Arc[p];
	  fprintf (FP,
		   "\tElementArc [%i %i %i %i %i %i %i]\n",
		   (int) (arc->X - element->MarkX),
		   (int) (arc->Y - element->MarkY),
		   (int) arc->Width, (int) arc->Height,
		   (int) arc->StartAngle, (int) arc->Delta,
		   (int) arc->Thickness);
	}
      fputs ("\n\t)\n", FP);
    }
}
예제 #9
0
파일: code.c 프로젝트: ilovin/CurrentSource
int main(void)
{
//    double Datav=123.4;

    str = a;
    int i;

//    char *str_1 = "abc" ;


  WDTCTL = WDTPW + WDTHOLD;                 // Stop WDT


  //Timer0
  TA0CCTL0 = CCIE;                          // CCR0 interrupt enabled
  TA0CCR0 = 5000;
  TA0CTL = TASSEL_2 + MC_1 + TACLR;         // SMCLK, upmode, clear TAR

  //GPIO
  P4DIR |= BIT7;                            // Set P4.7 to output direction
  P1DIR |= BIT0;                            // Set P1.0 to output direction
  P1DIR |= 0x3C;
  P3DIR |= BIT5+BIT6;
  P1OUT |= BIT5+BIT4;

  //buttom
  P2REN |= BIT1;
  P2OUT |= BIT1;
  P2IES |= BIT1;
  P2IFG &= ~BIT1;
  P2IE |= BIT1;

  P1REN |= BIT1;
  P1OUT |= BIT1;
  P1IES |= BIT1;
  P1IFG &= ~BIT1;
  P1IE |= BIT1;

  //IIC
  OLED_Init();
  OLED_ShowStr(0,2,"Please Set:",99,2);
//  Delay_ms(100);
//  OLED_Clear(0x00);
//end of IIC

  DMAInit();
  ADCInit();   //启动需要在增加 enable

  //UART
  UART_Init(UARTA0); //bluetooth
  UART_Init(UARTB0); //SPI

  UCA0IE |= UCRXIE;                         // Enable USCI_A0 RX interrupt
  //  UCB0IE |= UCRXIE;                         // Enable USCI_B0 RX interrupt

  //SPI
    P2OUT |= BIT5;                            // reset slave
    P2OUT &= ~BIT5;                           // Now with SPI signals initialized,
    for(i=50;i>0;i--);                        // Wait for slave to initialize

    MST_Data = 0x8FFF;                          // Initialize data values
    SLV_Data = 0x00;                          //
    while (!(UCB0IFG&UCTXIFG));               // USCI_B0 TX buffer ready?
  //end of SPI


  __bis_SR_register(LPM3_bits + GIE);       // Enter LPM0, enable interrupts
  while(1)
  {
//    OLED_ShowStr(12,2,(unsigned char *)F2S(Datav,tstr),6,1); //6*8
//    UartTX_Send("Done!\r\n",7);

      if(buttom_fct_flag != 0)
      {
    	  buttom_fct_stc_opt();
    	  buttom_fct_flag = 0;
      }

      if(buttom_fct_flags != 0)
      {
    	  buttom_fct_stcs_opt();
    	  buttom_fct_flags = 0;
      }


//    OLED_ShowStr(0,0,(unsigned char *)F2S(DMA_A1,tstr),8,1); //6*8
      if(fct_stc_flag != 0)
      {
          fct_stc_flag = 0;
          fct_stc_opt();
      }

      if(function!=0) // not off
      {
          ADC12CTL0 |= ADC12SC;   // Start sampling/conversion
      }

      switch(function)
      {
          case 0:
          {
//            OLED_OFF();
              __bis_SR_register(LPM3_bits + GIE);       // Enter LPM3, interrupts enabled;
          }
          break;

          case 1:
          {
              if(mode == 0)
              {
                    if(set_ack_flag == 1)
                    {
//                      OLED_ON();
//                      OLED_Clear(0x00);
                        set_ack_flag = 0;
                        MST_Data = (u16)(Datavin);
                        MST_Data |= 0x8000;
                        SPISend(MST_Data);
                        OLED_ShowStr(0,1,"I:",2,1); //6*8
                        OLED_ShowStr(16,1,(unsigned char *)F2S(Datai,tstr),8,1); //6*8
                        OLED_ShowStr(0,2,"stalls:",7,1); //6*8
                        OLED_ShowStr(42,2,(unsigned char *)I2S(stalls,tstr),6,1); //6*8
                    }
              }
              else   // current_pot
              {
                  Datavin = (double)DMA_A1*4/3.3;
                  MST_Data = (u16)(Datavin*4095/4);
                  MST_Data |= 0x8000;
                  SPISend(MST_Data);
                  I_out = (double)DMA_A2*3.3/4095*10;
                  OLED_ShowStr(0,2,"stalls:",7,1); //6*8
				  OLED_ShowStr(42,2,(unsigned char *)I2S(stalls,tstr),6,1); //6*8
//                OLED_ShowStr(0,2,"I_out:",6,1); //6*8
//                OLED_ShowStr(36,2,(unsigned char *)F2S(I_out,tstr),6,1); //6*8
                  if(!((Pre_A3 - ADC12MEM3)<40 | (ADC12MEM3 - Pre_A3)<40))
                  {
                      OLED_ShowStr(24,6,(unsigned char *)F2S(ADC12MEM3,tstr),4,1); //6*8
                  }
                  Pre_A3 = ADC12MEM3;

              }

          }
          break;

          case 2:
          {
            if(set_ack_flag == 1)
            {
                OLED_ON();
                set_ack_flag = 0;
            }
          }
          break;

          case 3:   //off
          {
//            OLED_OFF();
              //shutdown the circuit
              __bis_SR_register(LPM3_bits + GIE);       // Enter LPM3, interrupts enabled;
          }
          break;

      }//end of function switch;
      OLED_ShowStr(0,4,(unsigned char *)F2S(DMA_A0,tstr),4,1); //6*8
      OLED_ShowStr(0,5,(unsigned char *)F2S(DMA_A1,tstr),4,1); //6*8
      OLED_ShowStr(0,6,(unsigned char *)F2S(DMA_A2,tstr),4,1); //6*8
      OLED_ShowStr(0,7,(unsigned char *)F2S(ADC12MEM3,tstr),4,1); //6*8

//      Delay_ms(200);
      // if(strcmp(str_1,str)==0)
      // {
      //     P1OUT |= BIT0;
      //     UartTX_Send("Great!\r\n",8);
      //     Delay_ms(200);
      // }
      // else P1OUT &= ~BIT0;
  } //end of while

}