// *** rprintfStrLen *** // prints a section of a string stored in RAM // begins printing at position indicated by <start> // prints number of characters indicated by <len> void rprintfStrLen(char str[], unsigned int start, unsigned int len) { register int i=0; // check to make sure we have a good pointer if (!str) return; // spin through characters up to requested start // keep going as long as there's no null while((i++<start) && (*str++)); // for(i=0; i<start; i++) // { // // keep steping through string as long as there's no null // if(*str) str++; // } // then print exactly len characters for(i=0; i<len; i++) { // print data out of the string as long as we haven't reached a null yet // at the null, start printing spaces if(*str) rprintfChar(*str++); else rprintfChar(' '); } }
void ataPrintSector( u08 *Buffer) { u08 i; u16 j; u08 *buf; u08 s; buf = Buffer; // print the low order address indicies rprintfProgStrM(" 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F 0123456789ABCDEF\r\n"); rprintfProgStrM(" ----------------------------------------------- ---- ASCII -----\r\n"); // print the data for(j=0; j<0x20; j++) { // print the high order address index for this line rprintfu16(j<<4); rprintfProgStrM(" "); // print the hex data for(i=0; i<0x10; i++) { rprintfu08(buf[(j<<4)+i]); rprintfProgStrM(" "); } // leave some space rprintfProgStrM(" "); // print the ascii data for(i=0; i<0x10; i++) { s = buf[(j<<4)+i]; // make sure character is printable if(s >= 0x20) { rprintfChar(s); } else { rprintfChar(0x20); } } rprintfCRLF(); } }
// floating-point print void rprintfFloat(char numDigits, double x) { unsigned char firstplace = FALSE; unsigned char negative; unsigned char i, digit; double place = 1.0; // save sign negative = (x<0); // convert to absolute value x = (x>0)?(x):(-x); // find starting digit place for(i=0; i<15; i++) { if((x/place) < 10.0) break; else place *= 10.0; } // print polarity character if(negative) rprintfChar('-'); else rprintfChar('+'); // print digits for(i=0; i<numDigits; i++) { digit = (x/place); if(digit | firstplace | (place == 1.0)) { firstplace = TRUE; rprintfChar(digit+0x30); } else rprintfChar(' '); if(place == 1.0) { rprintfChar('.'); } x -= (digit*place); place /= 10.0; } }
// *** rprintfCRLF *** // prints carriage return and line feed void rprintfCRLF(void) { // print CR/LF //rprintfChar('\r'); // LF -> CR/LF translation built-in to rprintfChar() rprintfChar('\n'); }
int main() { u08 i; i = 0; u08 adc_0, adc_1; setup(); while(1==1) { adc_0 = a2dConvert8bit(ADC_CH_ADC0); adc_1 = a2dConvert8bit(ADC_CH_ADC1); rprintfu08(adc_0); rprintfu08(adc_1); rprintfChar(0); // rprintfCRLF(); _delay_ms(32); /* i++; if(i<=128) { sbi(PORTB, PB3); } if(i>128) { cbi(PORTB, PB3); } */ //_delay_ms(32); //_delay_ms(32); //_delay_ms(32); } return 0; }
void SendData(char data1, char data2) { rprintfChar(SYNC_PACKET); rprintfChar(data1); rprintfChar(data2); rprintfChar(right_x); rprintfChar(right_y); rprintfChar(left_x); rprintfChar(left_y); rprintfChar(END_PACKET); }
void ProcessErrors(void) { if (GetMessage(MSG_B_KEY_PRESSED)) { bufferAddToEnd(&speakerBuffer, CLICK); SendMessage(MSG_BEEP); rprintfChar(keyPressedCode); } }
// *** rprintfStr *** // prints a null-terminated string stored in RAM void rprintfStr(char str[]) { // send a string stored in RAM // check to make sure we have a good pointer if (!str) return; // print the string until a null-terminator while (*str) rprintfChar(*str++); }
// *** rprintfu04 *** // prints an unsigned 4-bit number in hex (1 digit) void rprintfu04(unsigned char data) { // print 4-bit hex value // char Character = data&0x0f; // if (Character>9) // Character+='A'-10; // else // Character+='0'; rprintfChar(hexchar(data)); }
// functions u08 inputString(u08 termChar, u08 termLen, u08* data) { u08 s=0; u08 length=0; while(length < termLen) { // get input #ifdef __AVR_ATmega128__ while(!uartReceiveByte(INPUT_UART,&s)); #else while(!uartReceiveByte(&s)); #endif // handle special characters if(s == 0x08) // backspace { if(length > 0) { // echo backspace-space-backspace rprintfChar(0x08); rprintfChar(' '); rprintfChar(0x08); length--; } } else if(s == termChar) // termination character { // save null-termination data[length] = 0; break; } else { // echo character rprintfChar(s); // save character data[length++] = s; } } return length; }
void dallasPrintROM(dallas_rom_id_T* rom_id) { s08 i; // print out the rom in the format: xx xx xx xx xx xx xx xx for(i=7; i>=0; i--) { rprintfu08(rom_id->byte[i]); rprintfChar(' '); } }
// *** rprintfProgStr *** // prints a null-terminated string stored in program ROM void rprintfProgStr(const char * str) { // print a string stored in program memory register char c; // check to make sure we have a good pointer if (!str) return; // print the string until the null-terminator while((c = pgm_read_byte(str++))) rprintfChar(c); }
int main(void) { u08 i; setup(); while(1==1) { if(bit_is_clear(PIND, PIND5)) { sbi(PORTB, PB3); rprintfChar('1'); rprintfCRLF(); rprintfChar(0); } else if(bit_is_clear(PIND, PIND6)) { sbi(PORTB, PB3); rprintfChar('2'); rprintfCRLF(); rprintfChar(0); } else if(bit_is_clear(PIND, PIND7)) { sbi(PORTB, PB3); rprintfChar('3'); rprintfCRLF(); rprintfChar(0); } else { cbi(PORTB, PB3); } } return 0; }
void ds18b20Print(u16 result, u08 resolution) { // print raw value rprintfProgStrM(" 0x"); rprintfu16(result); rprintfChar(' '); // print real temp rprintfNum(10, 4, TRUE , ' ', result>>4); rprintf("."); rprintfNum(10, 4, FALSE, '0', (10000*((u32)(result&0x000F)))/16 ); rprintfProgStrM(" C"); }
void serviceLocal(void) { int c; unsigned char buffer[100]; if ( (c = uartGetByte()) != -1) { // echo command to terminal rprintfChar(c); // process command switch (c) { case 'i': rprintfProgStrM("\r\nInitializing Ethernet Controller\r\n"); nicInit(); break; case 'd': rprintfProgStrM("\r\nEthernet Controller State\r\n"); nicRegDump(); break; case 't': rprintfProgStrM("\r\nCurrent Uptime: "); rprintfNum(10, 9, FALSE, ' ', UptimeMs); rprintfProgStrM("ms\r\n"); break; case 'c': rprintfProgStrM("\r\nCrashing System....\r\n"); while(1); break; case 'u': rprintfProgStrM("\r\nSending UDP packet\r\n"); strcpy((char*)&buffer[ETH_HEADER_LEN+IP_HEADER_LEN+UDP_HEADER_LEN], "hello"); udpSend((ipGetConfig()->ip|~ipGetConfig()->netmask), CONTROL_PORT, 6, &buffer[ETH_HEADER_LEN+IP_HEADER_LEN+UDP_HEADER_LEN]); break; case '?': rprintfProgStrM("\r\nCommands:\r\n"); rprintfProgStrM("(i) Initialize Ethernet Controller\r\n"); rprintfProgStrM("(d) Dump Ethernet Controller State\r\n"); rprintfProgStrM("(u) Send Broadcast UDP frame\r\n"); rprintfProgStrM("(t) Print current uptime\r\n"); rprintfProgStrM("(?) Help\r\n"); break; case '\n': default: break; } // print new prompt rprintfProgStrM("\r\ncmd>"); } }
static void copyToken(char token){ const char* vocabEntry = s_vocab; int y=0; while(getVocab(vocabEntry,y)){ if(getVocab(vocabEntry,y) == token && getVocab(vocabEntry,y+1) & 0x80){ while(getVocab(vocabEntry,++y)){ rprintfChar((char)(getVocab(vocabEntry,y) & 0x7f)); } break; } while(getVocab(vocabEntry,y++)); // Move to end of phoneme } }
void sayText(const char * src){ Writer old; #ifdef _LOG_ loggerCRLF(); loggerP(PSTR("Say:'")); // Say: ' logger(src); // ... the text .... loggerc('\''); // ' loggerCRLF(); #endif old = rprintfInit(&phonemeWriter); // Push the current writer text2Phonemes(src); // Write the current phonemes rprintfChar(0); // Flush out the current text rprintfInit(old); // Restore the previous writer }
void dallasPrintROM(dallas_rom_id_T* rom_id) { s08 i; // print out the rom in the format: xx xx xx xx xx xx xx xx for(i=7;i>=0;i--) { rprintfu08(rom_id->byte[i]); rprintfChar(' '); } // print out the rom in the format: 0xXXXXXXXXXXXXXXXX rprintfProgStrM(" (0x"); for(i=7;i>=0;i--) { rprintfu08(rom_id->byte[i]); } rprintfProgStrM("ULL)"); }
// prints a section of a string stored in RAM // begins printing at position indicated by <start> // prints number of characters indicated by <len> void rprintfStrLen(char str[], size_t start, size_t len) { if(str){ register size_t i=0; // spin through characters up to requested start // keep going as long as there's no null while( (i++<start) && (*str) ){ str++; } // then print exactly len characters while(len--) { // print data out of the string as long as we haven't reached a null yet // at the null, start printing spaces rprintfChar( (*str) ? *str++ : ' '); } } }
void ax88796RegDump(void) { unsigned char result; result = ax88796Read(TR); rprintf("Media State: "); if(!(result & AUTOD)) rprintf("Autonegotiation\r\n"); else if(result & RST_B) rprintf("PHY in Reset \r\n"); else if(!(result & RST_10B)) rprintf("10BASE-T \r\n"); else if(!(result & RST_TXB)) rprintf("100BASE-T \r\n"); //rprintf("TR regsiter : %x\r\n",result); //result = read_mii(0x10,0); //rprintf("MII regsiter 0x10: %x\r\n",result); rprintfProgStrM("Page0: CR BNRY PSR PST ISR TSR RSR MMR TR GPI\r\n"); rprintfProgStrM(" "); rprintfu08(ax88796Read(CR)); rprintfProgStrM(" "); rprintfu08(ax88796Read(BNRY)); rprintfProgStrM(" "); rprintfu08(ax88796Read(PSTART)); rprintfProgStrM(" "); rprintfu08(ax88796Read(PSTOP)); rprintfProgStrM(" "); rprintfu08(ax88796Read(ISR)); rprintfProgStrM(" "); rprintfu08(ax88796Read(TSR)); rprintfProgStrM(" "); rprintfu08(ax88796Read(RSR)); rprintfProgStrM(" "); rprintfu08(ax88796Read(MEMR)); rprintfProgStrM(" "); rprintfu08(ax88796Read(TR)); rprintfProgStrM(" "); rprintfu08(ax88796Read(GPI)); rprintfCRLF(); ax88796Write(CR,ax88796Read(CR)|PS0); rprintf("Page1: CR PAR CPR\r\n"); rprintfProgStrM(" "); rprintfu08(ax88796Read(CR)); rprintfProgStrM(" "); rprintfChar(ax88796Read(PAR0)); rprintfChar(ax88796Read(PAR1)); rprintfChar(ax88796Read(PAR2)); rprintfChar(ax88796Read(PAR3)); rprintfChar(ax88796Read(PAR4)); rprintfChar(ax88796Read(PAR5)); rprintfProgStrM(" "); rprintfu08(ax88796Read(CPR)); ax88796Write(CR,ax88796Read(CR)&~PS0); delay_ms(25); }
// This routine is called repeatedly - its your main loop TICK_COUNT appControl(LOOP_COUNT loopCount, TICK_COUNT loopStart){ if(sonyPS2_read(&controller1)) { xButton_pressure = sonyPS2_buttonPressure(&controller1, PS2_BTN_X); SqButton_pressure = sonyPS2_buttonPressure(&controller1, PS2_BTN_SQUARE); DL_Button_pressure = sonyPS2_buttonPressure(&controller1, PS2_DPAD_LEFT); DR_Button_pressure = sonyPS2_buttonPressure(&controller1, PS2_DPAD_RIGHT); if(sonyPS2_setAnalogMode(&controller1)) { left_x = sonyPS2_joystick(&controller1, PS2_STICK_LEFT_X); left_y = sonyPS2_joystick(&controller1, PS2_STICK_LEFT_Y); right_x = sonyPS2_joystick(&controller1, PS2_STICK_RIGHT_X); right_y = sonyPS2_joystick(&controller1, PS2_STICK_RIGHT_Y); if((left_x+left_y+right_x+right_y) != 0) { SendData(PS2_B_BTN_NONE, PS2_B_BTN_NONE); } } if(sonyPS2_buttonHeld(&controller1, PS2_BTN_R1)) { LED_on(&RightRed); SendData(PS2_B_BTN_R1, PS2_B_BTN_R1); } else if(sonyPS2_buttonHeld(&controller1, PS2_DPAD_RIGHT)) { LED_on(&RightRed); SendData(PS2_B_DPAD_RIGHT, DR_Button_pressure); } else { LED_off(&RightRed); } if(sonyPS2_buttonHeld(&controller1, PS2_BTN_L1)) { LED_on(&LeftRed); rprintfChar(SYNC_PACKET); rprintfChar(PS2_B_BTN_L1); rprintfChar(right_x); rprintfChar(right_y); rprintfChar(left_x); rprintfChar(left_y); rprintfChar(END_PACKET); } else if(sonyPS2_buttonHeld(&controller1, PS2_DPAD_LEFT)) { LED_on(&LeftRed); SendData(PS2_B_DPAD_LEFT, DL_Button_pressure); } else { LED_off(&LeftRed); } if(sonyPS2_buttonHeld(&controller1, PS2_BTN_R2)) { SendData(PS2_B_BTN_R2, PS2_B_BTN_R2); } else { } if(sonyPS2_buttonHeld(&controller1, PS2_BTN_L2)) { SendData(PS2_B_BTN_L2, PS2_B_BTN_L2); } else { } if(sonyPS2_buttonHeld(&controller1, PS2_BTN_TRIANGLE)) { SpotLightState++; if(SpotLightState % 2 == 0) { LED_off(&SpotLightWhite); } else { LED_on(&SpotLightWhite); } SendData(PS2_B_BTN_TRIANGLE, PS2_B_BTN_TRIANGLE); } else { } if(sonyPS2_buttonHeld(&controller1, PS2_BTN_CIRCLE)) { SendData(PS2_B_BTN_CIRCLE, PS2_B_BTN_CIRCLE); } else { } if(sonyPS2_buttonHeld(&controller1, PS2_BTN_SQUARE)) { SendData(PS2_B_BTN_SQUARE, SqButton_pressure); if(SqButton_pressure == 255) { sonyPS_setRumble(&controller1, SqButton_pressure/2, false); } else { sonyPS_setRumble(&controller1, SqButton_pressure/2, false); } } else if(sonyPS2_buttonHeld(&controller1, PS2_BTN_X)) { SendData(PS2_B_BTN_X, xButton_pressure); if(xButton_pressure == 255) { sonyPS_setRumble(&controller1, xButton_pressure/2, false); } else { sonyPS_setRumble(&controller1, xButton_pressure/2, false); } } else { sonyPS_setRumble(&controller1, 0, false); } if(sonyPS2_buttonHeld(&controller1, PS2_DPAD_UP)) { SendData(PS2_B_DPAD_UP, PS2_B_DPAD_UP); } else { } if(sonyPS2_buttonHeld(&controller1, PS2_DPAD_DOWN)) { SendData(PS2_B_DPAD_DOWN, PS2_B_DPAD_DOWN); } else { } if(sonyPS2_buttonHeld(&controller1, PS2_BTN_SELECT)) { SendData(PS2_B_BTN_SELECT, PS2_B_BTN_SELECT); } else { } if(sonyPS2_buttonHeld(&controller1, PS2_BTN_START)) { SendData(PS2_B_BTN_START, PS2_B_BTN_START); } else { } if(sonyPS2_buttonHeld(&controller1, PS2_BTN_L3)) { SendData(PS2_B_BTN_L3, PS2_B_BTN_L3); } else { } if(sonyPS2_buttonHeld(&controller1, PS2_BTN_R3)) { SendData(PS2_B_BTN_R3, PS2_B_BTN_R3); } else { } } else { } //act_setSpeed(&engine, FrontSpeed); //act_setSpeed(&rudder, RudderPos); return 200000; // wait for 1 second before calling me again. 1000000us = 1 //second }
/******************************************************************* * rprintf_test *******************************************************************/ void rprintf_test(void) { u16 val; u08 mydata; u08 mystring[10]; double b; u08 small; u16 medium; u32 big; // initialize the UART (serial port) uartInit(); // set the baud rate of the UART for our debug/reporting output uartSetBaudRate(38400); // initialize rprintf system // - use uartSendByte as the output for all rprintf statements // this will cause all rprintf library functions to direct their // output to the uart // - rprintf can be made to output to any device which takes characters. // You must write a function which takes an unsigned char as an argument // and then pass this to rprintfInit like this: rprintfInit(YOUR_FUNCTION); rprintfInit(uartSendByte); // initialize vt100 library vt100Init(); // clear the terminal screen vt100ClearScreen(); while (!(getkey() == 1)) //do the folling block until enter is pressed { // print a little intro message so we know things are working rprintf("\r\nWelcome to rprintf Test!\r\n"); // print single characters rprintfChar('H'); rprintfChar('e'); rprintfChar('l'); rprintfChar('l'); rprintfChar('o'); // print a constant string stored in FLASH rprintfProgStrM(" World!"); // print a carriage return, line feed combination rprintfCRLF(); // note that using rprintfCRLF() is more memory-efficient than // using rprintf("\r\n"), especially if you do it repeatedly mystring[0] = 'A'; mystring[1] = ' '; mystring[2] = 'S'; mystring[3] = 't'; mystring[4] = 'r'; mystring[5] = 'i'; mystring[6] = 'n'; mystring[7] = 'g'; mystring[8] = '!'; mystring[9] = 0; // null termination // print a null-terminated string from RAM rprintfStr(mystring); rprintfCRLF(); // print a section of a string from RAM // - start at index 2 // - print 6 characters rprintfStrLen(mystring, 2, 6); rprintfCRLF(); val = 24060; mydata = 'L'; // print a decimal number rprintf("This is a decimal number: %d\r\n", val); // print a hex number rprintf("This is a hex number: %x\r\n", mydata); // print a character rprintf("This is a character: %c\r\n", mydata); // print hex numbers small = 0x12; // a char medium = 0x1234; // a short big = 0x12345678; // a long rprintf("This is a 2-digit hex number (char) : "); rprintfu08(small); rprintfCRLF(); rprintf("This is a 4-digit hex number (short): "); rprintfu16(medium); rprintfCRLF(); rprintf("This is a 8-digit hex number (long) : "); rprintfu32(big); rprintfCRLF(); // print a formatted decimal number // - use base 10 // - use 8 characters // - the number is signed [TRUE] // - pad with '.' periods rprintf("This is a formatted decimal number: "); rprintfNum(10, 8, TRUE, '.', val); rprintfCRLF(); b = 1.23456; // print a floating point number // use 10-digit precision // NOTE: TO USE rprintfFloat() YOU MUST ENABLE SUPPORT IN global.h // use the following in your global.h: #define RPRINTF_FLOAT rprintf("This is a floating point number: "); rprintfFloat(8, b); rprintfCRLF(); } }
// Print a part of memory as a formatted hex table with ascii translation void debugPrintHexTable(u16 length, u08 *buffer) { u08 i; u16 j; u08 *buf; u08 s; buf = buffer; // print the low order address indicies and ASCII header rprintfProgStrM(" 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F 0123456789ABCDEF\r\n"); rprintfProgStrM(" ----------------------------------------------- ---- ASCII -----\r\n"); // print the data for(j=0; j<((length+15)>>4); j++) { // print the high order address index for this line rprintfu16(j<<4); rprintfChar(' '); // print the hex data for(i=0; i<0x10; i++) { // be nice and print only up to the exact end of the data if( ((j<<4)+i) < length) { // print hex byte rprintfu08(buf[(j<<4)+i]); rprintfChar(' '); } else { // we're past the end of the data's length // print spaces rprintfProgStrM(" "); } } // leave some space rprintfChar(' '); // print the ascii data for(i=0; i<0x10; i++) { // be nice and print only up to the exact end of the data if( ((j<<4)+i) < length) { // get the character s = buf[(j<<4)+i]; // make sure character is printable if(s >= 0x20) rprintfChar(s); else rprintfChar('.'); } else { // we're past the end of the data's length // print a space rprintfChar(' '); } } rprintfCRLF(); } }
static int rprintfOut(char c, FILE* f){ return rprintfChar(c); }
/** * Enter: * src => English text * return null if errors, else phoneme string */ static void text2Phonemes(const char * src){ // int outIndex = 0;// Current offset into phonemes int inIndex = -1; // Starts at -1 so that a leading space is assumed while(inIndex==-1 || src[inIndex]){ // until end of text int maxMatch=0; // Max chars matched on input text // int numOut=0; // Number of characters copied to output stream for the best match int maxWildcardPos = 0; // Start with first vocab entry const char* vocabEntry = s_vocab; // Keep track of best match so far const char* bestEntry = null; int bestWildCardInPos=0; char bestWildCard=0; boolean bestHasWhiteSpace=FALSE; int wildcardInPos; // Get next phoneme, P2 while(getVocab(vocabEntry,0)){ int y; char wildcard=0; // The wildcard character boolean hasWhiteSpace=FALSE; wildcardInPos=0; // The index in the vocab where it occurs for(y=0;;y++){ char nextCharIn,nextVocabChar; // Get next char from user input // Make next char upper case and remove control characters nextCharIn = (y + inIndex == -1) ? ' ' : src[y + inIndex]; if(nextCharIn>='a' && nextCharIn<='z'){ nextCharIn = nextCharIn - 'a' + 'A'; }else if(nextCharIn<' '){ nextCharIn = ' '; } // Get next text char from vocab nextVocabChar = getVocab(vocabEntry,y); if( (nextVocabChar & 0x80)){ nextVocabChar = 0; } // If its a wildcard then save its value and position if(nextVocabChar=='#' && nextCharIn >= 'A' && nextCharIn <= 'Z'){ wildcard = nextCharIn; // The character equivalent to the '#' wildcardInPos=y; continue; } // Check if vocab is looking for end of word if(nextVocabChar=='_'){ // try to match against a white space hasWhiteSpace=TRUE; if(whitespace(nextCharIn)){ continue; } y--; break; } // check for end of either string if(nextVocabChar==0 || nextCharIn==0){ break; } if(nextVocabChar != nextCharIn){ break; } } // See if its the longest complete match so far if(y > maxMatch && ( getVocab(vocabEntry,y) & 0x80) == 0x80){ // This is the longest complete match maxMatch = y; maxWildcardPos = 0; // Point to the start of the phoneme bestEntry = vocabEntry + y; bestWildCardInPos = wildcardInPos; bestWildCard = wildcard; bestHasWhiteSpace = hasWhiteSpace; } // Move to start of next entry while(getVocab(vocabEntry,y++)); // Move to end of phoneme asciiz vocabEntry += y; }// check next phoneme // 15 - end of vocab table //16 if(bestHasWhiteSpace==TRUE){ maxMatch--; } //17 if(maxMatch==0){ loggerP(PSTR("No token for ")); logger(&src[inIndex]); loggerCRLF(); return; } // Copy data for best match { int y; // Copy the matching phrase changing any '#' to the phoneme for the wildcard for(y=0;;y++){ char c = getVocab(bestEntry,y) & 0x7f; // Get the next phoneme character if(c==0){ y++; // move to start of next vocab entry break; } if(c=='#'){ if(getVocab(bestEntry,y+1)==0){ // replacement ends in wild card maxWildcardPos = bestWildCardInPos; }else{ // Copy the phonemes for the wild card character copyToken(bestWildCard); } }else{ rprintfChar(c); // output the phoneme character } } } inIndex += (maxWildcardPos>0) ? maxWildcardPos : maxMatch; } }
/* vb Returns multiple lines one for each blob ix = vblob((unsigned char *)FRAME_BUF, (unsigned char*)FRAME_BUF3, ch1); printf("##vb%c %d\r\n", ch2, ix); for (iy=0; iy<ix; iy++) { printf(" %d - %d %d %d %d \r\n", blobcnt[iy], blobx1[iy], blobx2[iy], bloby1[iy],bloby2[iy]); } */ uint8_t blackfinDetectBlobs (BLACKFIN_CAMERA* camera, uint8_t bin){ int32_t values[5]; BLACKFIN_BLOB* dest; uint8_t actual = 0; // allocate space for blob storage if(camera->blob==null){ camera->blob = malloc(MAX_BLOBS * sizeof(BLACKFIN_BLOB)) ; } dest = camera->blob; // Make rprintf go to _blackfin_command Writer old = rprintfInit(&_blackfin_putcmd); _blackfin_index=0; rprintf("vb%d",bin);//start command, send bin # // process the command int args = __blackfinCommand(camera,PSTR("##vb"),PSTR(" vblob #"),values,2); #ifdef BLACKFIN_DEBUG _blackfin_set_active(camera->debug); //Send rprintf to the debugger #endif if(args==2 && values[0]==bin){ int8_t numBlobs = values[1]; // The number of blobs if(numBlobs > MAX_BLOBS){ numBlobs = MAX_BLOBS; } #ifdef BLACKFIN_DEBUG rprintf(" %d blobs\n",(int)numBlobs); #endif // Get each blob for(int8_t num = 0; num < numBlobs; num++){ args = __blackfin_get_args(camera, values, 5, TRUE); #ifdef BLACKFIN_DEBUG rprintf(" #%d=",(int)num); #endif if(args==5){ dest->pixels = values[0]; dest->left = values[1]; dest->right = values[2]; dest->top = values[3]; dest->bottom = values[4]; dest->xCenter = dest->left + ((dest->right - dest->left)>>1); dest->yCenter = dest->top + ((dest->bottom - dest->top)>>1); #ifdef BLACKFIN_DEBUG rprintf("Left,Top="); rprintfNum(10,4,FALSE,'0',dest->left); rprintfChar(','); rprintfNum(10,4,FALSE,'0',dest->top); rprintf(" Right,Bottom="); rprintfNum(10,4,FALSE,'0',dest->right); rprintfChar(','); rprintfNum(10,4,FALSE,'0',dest->bottom); rprintf(" Pixels=");rprintfNum(10,10,FALSE,' ',dest->pixels); rprintfCRLF(); #endif dest++; actual++; }else{
void rprintfTest(void) { u16 val; u08 mydata; u08 mystring[10]; float b; u08 small; u16 medium; u32 big; // print a little intro message so we know things are working rprintf("\r\nThis is my cool program!\r\n"); rprintf("\r\nWelcome to rprintf Test!\r\n"); // print single characters rprintfChar('H'); rprintfChar('e'); rprintfChar('l'); rprintfChar('l'); rprintfChar('o'); // print a constant string stored in FLASH rprintfProgStrM(" World!"); // print a carriage return, line feed combination rprintfCRLF(); // note that using rprintfCRLF() is more memory-efficient than // using rprintf("\r\n"), especially if you do it repeatedly mystring[0] = 'A'; mystring[1] = ' '; mystring[2] = 'S'; mystring[3] = 't'; mystring[4] = 'r'; mystring[5] = 'i'; mystring[6] = 'n'; mystring[7] = 'g'; mystring[8] = '!'; mystring[9] = 0; // null termination // print a null-terminated string from RAM rprintfStr(mystring); rprintfCRLF(); // print a section of a string from RAM // - start at index 2 // - print 6 characters rprintfStrLen(mystring, 2, 6); rprintfCRLF(); val = 24060; mydata = 'L'; // print a decimal number rprintf("This is a decimal number: %d\r\n", val); // print a hex number rprintf("This is a hex number: %x\r\n", mydata); // print a character rprintf("This is a character: %c\r\n", mydata); // print hex numbers small = 0x12; // a char medium = 0x1234; // a short big = 0x12345678; // a long rprintf("This is a 2-digit hex number (char) : "); rprintfu08(small); rprintfCRLF(); rprintf("This is a 4-digit hex number (short): "); rprintfu16(medium); rprintfCRLF(); rprintf("This is a 8-digit hex number (long) : "); rprintfu32(big); rprintfCRLF(); // print a formatted decimal number // - use base 10 // - use 8 characters // - the number is signed [TRUE] // - pad with '.' periods rprintf("This is a formatted decimal number: "); rprintfNum(10, 8, TRUE, '.', val); rprintfCRLF(); b = 1.23456; // print a floating point number // use 10-digit precision // NOTE: TO USE rprintfFloat() YOU MUST ENABLE SUPPORT IN global.h // use the following in your global.h: #define RPRINTF_FLOAT //rprintf("This is a floating point number: "); //rprintfFloat(8, b); //rprintfCRLF(); }
void systickHandler(void) { uint16_t tms; uint8_t ts,tm,th; uint8_t pb; // set timer for 10ms interval TCNT2 = (unsigned char)-TIMER_INTERVAL; // count up on uptime UptimeMs += 10; // if we at a 100ths millisecond interval, update the display if(!(UptimeMs % 100)) { // redirect rprintf() output to spyglass LCD rprintfInit(spyglassLcdWriteChar); // print banner message spyglassLcdGotoXY(0,0); rprintfProgStrM("**** SpyglassUI ****"); // read pushbuttons and take appropriate action pb = spyglassGetPushbuttons(); spyglassLcdGotoXY(0,1); rprintf("Buttons: "); rprintfNum(2,8,FALSE,'0',pb); if((pb & 0x01) && (Contrast < 255)) Contrast++; if((pb & 0x02) && (Contrast > 0)) Contrast--; if(pb & 0x08) spyglassSetLeds(0x01); if(pb & 0x10) spyglassSetLeds(0x02); // show display contrast spyglassLcdGotoXY(0,2); rprintf("LCD Contrast: "); rprintfNum(10,3,FALSE,' ',Contrast); spyglassSetLcdContrast(Contrast); // show time tms = (UptimeMs)%1000; ts = (UptimeMs/1000)%60; tm = (UptimeMs/60000l)%60; th = (UptimeMs/3600000l); spyglassLcdGotoXY(0,3); rprintf("Time:"); rprintfNum(10,3,FALSE,' ',th); rprintfChar(':'); rprintfNum(10,2,FALSE,'0',tm); rprintfChar(':'); rprintfNum(10,2,FALSE,'0',ts); rprintfChar('.'); rprintfNum(10,3,FALSE,'0',tms); rprintf("ms"); // return rprintf() output to serial port rprintfInit(uartSendByte); } }
//------------------------------------------------------------------------------------ void sp5K_helpFunction(void) { if (xSemaphoreTake( sem_CmdUart, MSTOTAKECMDUARTSEMPH ) == pdTRUE ) { rprintfProgStrM(CMD_UART, "Spymovil \0"); rprintfProgStrM(CMD_UART, SP5K_MODELO); rprintfChar(CMD_UART, ' '); rprintfProgStrM(CMD_UART, SP5K_VERSION); rprintfChar(CMD_UART, ' '); rprintfProgStrM(CMD_UART, EE_TYPE); rprintfChar(CMD_UART, '-'); rprintfProgStrM(CMD_UART, FTYPE); rprintfChar(CMD_UART, ' '); rprintfProgStrM(CMD_UART, SP5K_REV); rprintfChar(CMD_UART, ' '); rprintfProgStrM(CMD_UART, SP5K_DATE); rprintfCRLF(CMD_UART); rprintfProgStrM(CMD_UART, "Available commands are:\r\n"); rprintfProgStrM(CMD_UART, "-cls\r\n\0"); rprintfProgStrM(CMD_UART, "-help\r\n\0"); rprintfProgStrM(CMD_UART, "-reset {default ,memory}\r\n\0"); rprintfProgStrM(CMD_UART, "-status\r\n\0"); rprintfProgStrM(CMD_UART, "-write rtc YYMMDDhhmm \r\n"); rprintfProgStrM(CMD_UART, " param { wrkmode [service | monitor {sqe|frame}], pwrmode [continuo|discreto] } \r\n"); rprintfProgStrM(CMD_UART, " timerpoll, timerdial, dlgid \r\n"); rprintfProgStrM(CMD_UART, " debuglevel +/-{none,i2c,bd,data,gprs,digital,all} \r\n"); rprintfProgStrM(CMD_UART, " loglevel (none, info, all)\r\n"); rprintfProgStrM(CMD_UART, " imin|imax|mmin|mmax|magp|offmmin|offmmax X val\r\n"); rprintfProgStrM(CMD_UART, " aname, dname\r\n"); rprintfProgStrM(CMD_UART, " apn, port, ip, script, passwd\r\n"); #ifdef CHANNELS_3 rprintfProgStrM(CMD_UART, " consigna [none|doble], [dia|noche] {hh:mm} \r\n"); #endif rprintfProgStrM(CMD_UART, " save\r\n"); if ( systemVars.wrkMode == WK_SERVICE) { rprintfProgStrM(CMD_UART, " mcp devId regAddr {xxxxxxxx}\r\n"); rprintfProgStrM(CMD_UART, " ee addr string\r\n"); rprintfProgStrM(CMD_UART, " led {0|1},gprspwr {0|1},gprssw {0|1},termpwr {0|1},sensorpwr {0|1},analogpwr {0|1}\r\n"); rprintfProgStrM(CMD_UART, " sms {nro,msg}, atcmd {atcmd,timeout}\r\n"); #ifdef CHANNELS_3 rprintfProgStrM(CMD_UART, " ph [A/B][1/2] {0|1}, en [A/B][1/2] {0|1}, vreset {0|1} vsleep {0|1}\r\n"); rprintfProgStrM(CMD_UART, " vpulse [A/B][1/2] {+|-} {ms}\r\n"); rprintfProgStrM(CMD_UART, " open [A/B][1/2], close [A/B][1/2], consigna [dia|noche] \r\n"); #endif } rprintfProgStrM(CMD_UART, "-read rtc\r\n"); rprintfProgStrM(CMD_UART, " mcp devId regAddr\r\n"); rprintfProgStrM(CMD_UART, " dcd,ri,termsw,din0,din1\r\n"); if ( systemVars.wrkMode == WK_SERVICE) { rprintfProgStrM(CMD_UART, " adc{channel}, frame\r\n"); rprintfProgStrM(CMD_UART, " ee addr lenght\r\n"); rprintfProgStrM(CMD_UART, " memory \r\n"); rprintfCRLF(CMD_UART); } xSemaphoreGive( sem_CmdUart ); } }
u08 tsipProcess(cBuffer* rxBuffer) { u08 foundpacket = FALSE; u08 startFlag = FALSE; u08 data; u08 i,j,k; u08 TsipPacketIdx; // process the receive buffer // go through buffer looking for packets while(rxBuffer->datalength > 1) { // look for a potential start of TSIP packet if(bufferGetAtIndex(rxBuffer,0) == DLE) { // make sure the next byte is not DLE or ETX data = bufferGetAtIndex(rxBuffer,1); if((data != DLE) && (data != ETX)) { // found potential start startFlag = TRUE; // done looking for start break; } } else // not DLE, dump character from buffer bufferGetFromFront(rxBuffer); } // if we detected a start, look for end of packet if(startFlag) { for(i=1; i<(rxBuffer->datalength)-1; i++) { // check for potential end of TSIP packet if((bufferGetAtIndex(rxBuffer,i) == DLE) && (bufferGetAtIndex(rxBuffer,i+1) == ETX)) { // have a packet end // dump initial DLE bufferGetFromFront(rxBuffer); // copy data to TsipPacket TsipPacketIdx = 0; for(j=0; j<(i-1); j++) { data = bufferGetFromFront(rxBuffer); if(data == DLE) { if(bufferGetAtIndex(rxBuffer,0) == DLE) { // found double-DLE escape sequence, skip one of them bufferGetFromFront(rxBuffer); j++; } } TsipPacket[TsipPacketIdx++] = data; } // dump ending DLE+ETX bufferGetFromFront(rxBuffer); bufferGetFromFront(rxBuffer); // found a packet if(debug) { rprintf("Rx TSIP packet type: 0x%x len: %d rawlen: %d\r\n", TsipPacket[0], TsipPacketIdx, i); for(k=0; k<TsipPacketIdx; k++) { rprintfu08(TsipPacket[k]); rprintfChar(' '); } //rprintfu08(bufferGetFromFront(rxBuffer)); rprintfChar(' '); //rprintfu08(bufferGetFromFront(rxBuffer)); rprintfChar(' '); rprintfCRLF(); } // done with this processing session foundpacket = TRUE; break; } } } if(foundpacket) { // switch on the packet type switch(TsipPacket[0]) { case TSIPTYPE_GPSTIME: tsipProcessGPSTIME(TsipPacket); break; case TSIPTYPE_POSFIX_XYZ_SP: tsipProcessPOSFIX_XYZ_SP(TsipPacket); break; case TSIPTYPE_VELFIX_XYZ: tsipProcessVELFIX_XYZ(TsipPacket); break; case TSIPTYPE_POSFIX_LLA_SP: tsipProcessPOSFIX_LLA_SP(TsipPacket); break; case TSIPTYPE_VELFIX_ENU: tsipProcessVELFIX_ENU(TsipPacket); break; case TSIPTYPE_RAWDATA: break; default: //if(debug) rprintf("Unhandled TSIP packet type: 0x%x\r\n",TsipPacket[0]); break; } } return foundpacket; }