Пример #1
0
void Com::printArrayFLN(FSTRINGPARAM(text),int32_t *arr,uint8_t n)
{
    printF(text);
    for(uint8_t i=0; i<n; i++)
        printF(Com::tSpace,arr[i]);
    println();
} // printArrayFLN
Пример #2
0
void Com::printArrayFLN(FSTRINGPARAM(text),float *arr,uint8_t n,uint8_t digits)
{
    printF(text);
    for(uint8_t i=0; i<n; i++)
        printF(Com::tSpace,arr[i],digits);
    println();
} // printArrayFLN
Пример #3
0
void lsmReadMotionData(void)
{
   int count;
   int tmp_a, tmp_g;
   double val_a, val_g;
   unsigned char rcv_g[7];
   unsigned char rcv_a[7];

   lsmCsaLow();
   lsmCsgLow();

   SPIGBUF = 0xE7;         // Read, Auto address increment
   SPIABUF = 0x00;         // dummy write

   for(count=0;count<7;count++)
   {
      SPIGBUF = 0x00;      // dummy write
      SPIABUF = 0x00;      // dummy write
   }

   // Wait for TX/RX to complete.. At this speed (~15us) it really isn't worth
   // going back to do something else and return when an interrupt occurs
   for(count=0;count<100;count++);

   lsmCsaHigh();
   lsmCsgHigh();

   count = SPIGBUF;        // dummy read (the initial address byte)
   count = SPIABUF;        // dummy read

   // Both SPIXBUF registers should now be filled with 7 data bytes
   for(count=0;count<7;count++)
   {
      rcv_g[count] = SPIGBUF;
      rcv_a[count] = SPIABUF;

      //printF("%02Xuc,%02Xuc,",rcv_g[count], rcv_a[count]);
   }
   //printF("\n\r");

   for(count=1;count<7;count+=2)
   {
      tmp_g = (int)((rcv_g[count+1] << 8) | rcv_g[count]);
      tmp_a = (int)((rcv_a[count+1] << 8) | rcv_a[count]);

      val_g = ((double)tmp_g)/131.072;
      val_a = ((double)tmp_a)/16384.0;

      printF("%0+2.2d,%0+2.2d,", val_g, val_a);
   }
   printF("\n\r");

}
Пример #4
0
void P1(int argc, char* argv[]) {
  printF("%d\n",argc);
  for(int i=0;i<argc;i++){
    printF("%s\n",argv[i]);
  }
  while( 1 ) {
    // compute the gcd between pairs of x and y for 2^4 < x, y < 2^8
    for( uint32_t x = ( 1 << 4 ); x < ( 1 << 8 ); x++ ) {
      for( uint32_t y = ( 1 << 4 ); y < ( 1 << 8 ); y++ ) {
        uint32_t r = gcd( x, y );  //printF( "gcd( %d, %d ) = %d\n", x, y, r );
      }
    }
  }

  return;
}
void follow(char *name1, char *name2, user *head)
{
	user *usr = getUserName(name2, head);
	user *usr2 = getUserName(name1, head);
	follows *root = usr->head;
	follows *cur;
	
	if(usr->head==NULL)
	{
		usr->head = (follows*)malloc(sizeof(follows));
		usr->head->usr = usr2;
		usr->head->next = usr->head->prev = usr->head;
		
		if(DEBUG)
			printf("Followers for %s initiated with %s\n", usr->name, usr2->name);
		return;
	}
	
	cur=usr->head->prev;
	cur->next = (follows*)malloc(sizeof(follows));
	cur->next->prev = cur;
	cur = cur->next;
	cur->next = root;
	cur->usr = usr2;
	root->prev = cur;
	
	if(DEBUG)
		printf("%s added to followers of %s\n", usr2->name, usr->name);
		
	if(DEBUG)
		printF(usr);
}
Пример #6
0
void Com::printFloat(float number, uint8_t digits)
{
	if (isnan(number))
	{
		printF(tNAN);
		return;
	}
	if (isinf(number))
	{
		printF(tINF);
		return;
	}

	// Handle negative numbers
	if (number < 0.0)
	{
		print('-');
		number = -number;
	}

	// Round correctly so that print(1.999, 2) prints as "2.00"
	float rounding = 0.5;
	for (uint8_t i=0; i<digits; ++i)
		rounding /= 10.0;

	number += rounding;

	// Extract the integer part of the number and print it
	unsigned long	int_part  = (unsigned long)number;
	float			remainder = number - (float)int_part;
  
	
	printNumber(int_part);

	// Print the decimal point, but only if there are digits beyond
	if (digits > 0)
		print('.');

	// Extract digits from the remainder one at a time
	while (digits-- > 0)
	{
		remainder *= 10.0;
		int toPrint = int(remainder);
		print(toPrint);
		remainder -= toPrint;
	}
} // printFloat
/**
  * @brief  Main program.
  * @param  None
  * @retval None
  */
void main(void)
{
	static u16 i=0;
	
	CLK_Config();

	UART_Config();

	TIM2_Config();
	enableInterrupts();

	printF("TIM2_Config finish !\n",FALSE,0);

    /* Infinite loop */
    while (1)
    {
    	_Delay(100);
		printF("LOG MSG (%4d) !\n",TRUE,i++);
    }
}
Пример #8
0
int main()
{
	char  str[100];
	intr i,length=0,c=0;
	printf("enter any string");
	scanf("%d",&str);
	length=strlen[str]\;
	for(i=0;i<length;i++)
	{
	if (str[i] >= 50 && str[i]<= 60)
	{
		printF("%d%d is a string",c,length);
		return 0;
	}
	}
}
Пример #9
0
void lsmInit(void)
{
   unsigned int i;

   SPIGCON1bits.MODE16 = 0;   // 8-bit mode
   SPIGCON1bits.SMP = 1;      // Sample data at end of data output time
   SPIGCON1bits.CKE = 0;      // SDO changes on idle to active
   SPIGCON1bits.CKP = 1;      // Clock idles high
   SPIGCON1bits.MSTEN = 1;    // Master mode
   SPIGCON1bits.SPRE = 5;     // Secondary prescale bits (based on 140 Mhz)
   SPIGCON1bits.PPRE = 2;     // Primary prescale bits
   SPIGCON2bits.SPIBEN = 1;   // enhanced buffer mode (8 deep fifo)

   SPIACON1bits.MODE16 = 0;   // 8-bit mode
   SPIACON1bits.SMP = 1;      // Sample data at end of data output time
   SPIACON1bits.CKE = 0;      // SDO changes on idle to active
   SPIACON1bits.CKP = 1;      // Clock idles high
   SPIACON1bits.MSTEN = 1;    // Master mode
   SPIACON1bits.SPRE = 5;     // Secondary prescale bits (based on 140 Mhz)
   SPIACON1bits.PPRE = 2;     // Primary prescale bits
   SPIACON2bits.SPIBEN = 1;   // enhanced buffer mode (8 deep fifo)
   SPIACON1bits.DISSCK = 1;   // Disable CLK output (provided by SPI1)
   SPIACON1bits.DISSDO = 1;   // Disable data (MOSI) output (provided by SPI1)

   SPIGSTATbits.SPIEN = 1;    // Enable the module
   SPIASTATbits.SPIEN = 1;    // Enable the module
   
   lsmCsaHigh();
   lsmCsgHigh();

   for(i=0;i<100;i++);        // a short delay

   printF("WHOAMI: %Xuc\n\r",lsmReadRegister(GYRO,WHO_AM_I_G));

   // ACCEL: 100Hz ODR, Normal power, Z, Y, X Enabled
   lsmWriteRegister(ACCEL, CTRL_REG1_A, 0b01010111);
   // ACCEL: Data LSb @ lower address, +/-2G range, high resolution
   lsmWriteRegister(ACCEL, CTRL_REG4_A, 0b00001000);

   // GYRO: ODR=380, Cut-off=100Hz, Normal power, Z, Y, X Enabled
   lsmWriteRegister(GYRO, CTRL_REG1_G, 0b10111111);

}
Пример #10
0
void Com::config(FSTRINGPARAM(text),uint32_t value){
    printF(tConfig);
    printFLN(text,value);
}
Пример #11
0
void Com::config(FSTRINGPARAM(text),float value,uint8_t digits){
    printF(tConfig);
    printFLN(text,value,digits);
}
Пример #12
0
void Com::printFLN(FSTRINGPARAM(text),int32_t value)
{
    printF(text);
    print(value);
    println();
} // printFLN
Пример #13
0
void Com::config(FSTRINGPARAM(text),const char *msg) {
    printF(tConfig);
    printF(text);
    print(msg);
    println();
}
void Com::printFLN(FSTRINGPARAM(text),unsigned long value) {
    printF(text);
    printNumber(value);
    println();
}
void Com::printF(FSTRINGPARAM(text),int value) {
    printF(text);
    print(value);
}
void Com::printFLN(FSTRINGPARAM(text)) {
    printF(text);
    println();
}
void Com::printInfoFLN(FSTRINGPARAM(text)) {
    printF(tInfo);
    printFLN(text);
}
Пример #18
0
void Com::printFLN(FSTRINGPARAM(text),uint32_t value) {
    printF(text);
    printNumber(value);
    println();
}
void Com::printWarningFLN(FSTRINGPARAM(text)) {
    printF(tWarning);
    printFLN(text);
}
Пример #20
0
void LCD_1602_RUS::printF(const wchar_t *_str) {
    printF(_str, cols_count);
}
void Com::printErrorFLN(FSTRINGPARAM(text)) {
    printF(tError);
    printFLN(text);
}
Пример #22
0
int main(int argc, char **argv){

int i,j,value;
char *cad1, *cad2;
int m,n;

PRINT_RESULT = 1;
DEBUG=1;

//  For debugging:
//char cadena1[] = "CGAGACGT";   //2,1,0,1,0,2,1,3,3,
//char cadena2[] = "AGACTAGTTAC";//0,1,0,2,3,0,1,3,3,0,2,2,0

  
  if (argc<3) {
	printf("\n Usage: ./cadenas-adn filey.adn filex.adn \n\n");
	exit(EXIT_FAILURE);
  }


  printf("\n ---------------- Begin of Needleman-Wunsch implementation -------------------------\n");

//  char *cad1=readFile(FILENAME1); 
//  char *cad2=readFile(FILENAME2);

  cad1=readFile(argv[1]);
  cad2=readFile(argv[2]);

  m = strlen(cad1)-1;  
  n = strlen(cad2)-1;

  a = malloc(sizeof(int) * m);
  b = malloc(sizeof(int) * n);

DEBUG=0;

  if (DEBUG) printf("\n a[]=");
  for(i=0;i<m;i++){
     a[i] = convNucleotido(cad1[i]);
     if (DEBUG) printf("%d,",a[i]);
  }
  if (DEBUG) printf("\n");


  if (DEBUG) printf("\n b[]=");
  for(j=0;j<n;j++){
     b[j] = convNucleotido(cad2[j]);
     if (DEBUG) printf("%d,",b[j]);
  }
  if (DEBUG) printf("\n");

  //DEBUG=1;

  int *f = computeF(m+1,n+1);
 
  if (DEBUG) printF(f,m,n);

  genAlignment(f,m+1,n+1);

  printf("\n ---------------- End of Needleman-Wunsch implementation -------------------------\n");
  exit(EXIT_SUCCESS);
}
void Com::printF(FSTRINGPARAM(text),const char *msg) {
    printF(text);
    print(msg);
}
void unfollow(char *name1, char *name2, user *head)
{
	user *usr1 = getUserName(name1, head);
	user *usr2 = getUserName(name2, head);
	message *curm, *fwdm, *bckm;
	follows *fwd, *bck;
	int toDel=0, del=0;
	
	follows *cur = usr2->head;
	while(cur->usr != usr1)
		cur = cur->next;
		
	if(DEBUG)
		printf("%s unfollowed %s\n", usr1->name, usr2->name);
	
	if(cur->next == cur)
	{
		free(usr2->head);
		usr2->head = NULL;
	}
	else
	{
		fwd = cur->next;
		bck = cur->prev;
		if(cur == usr2->head)
			usr2->head = fwd;
		unlink(cur, fwd, bck);
	}
	
	if(DEBUG)
		printF(usr2);
	
	curm = usr1->msgs;
	if(curm==NULL)
		return;
	do
	{
		toDel+=curm->auth==usr2;
		curm = curm->next;
	}
	while(curm!=usr1->msgs);
	
	do
	{
		if(curm->auth == usr2)
		{
			if(DEBUG)
				printf("Msg %lu deleted from %s\n", curm->id, usr1->name);
			if(curm==usr1->msgs)
			{
				if(curm->next==curm)
				{
					free(curm);
					usr1->msgs=NULL;
					break;
				}
				usr1->msgs = usr1->msgs->next;
			}
				
			fwdm = curm->next;
			bckm = curm->prev;
			unlink(curm, fwdm, bckm);
			del++;

			curm = fwdm;
			continue;
		}
		curm = curm->next;
	}
	while(del<toDel);
}
void Com::printFLN(FSTRINGPARAM(text),long value) {
    printF(text);
    print(value);
    println();
}
Пример #26
0
void Com::config(FSTRINGPARAM(text)) {
    printF(tConfig);
    printFLN(text);
}
void Com::printF(FSTRINGPARAM(text),float value,uint8_t digits) {
    printF(text);
    printFloat(value,digits);
}
void Com::cap(FSTRINGPARAM(text)) {
    printF(tCap);
    printFLN(text);
}