boolean _blackfinGetPixel(CAMERA* cam,uint16_t x, uint16_t y, COLOR * color){ BLACKFIN_CAMERA* camera = (BLACKFIN_CAMERA*)cam; boolean rtn = FALSE; int32_t values[3]; // Make rprintf go to _blackfin_command Writer old = rprintfInit(&_blackfin_putcmd); _blackfin_index=0; // send 'vp' command rprintf("vp"); rprintfNum(10,4,FALSE,'0',x); rprintfNum(10,4,FALSE,'0',y); // process the command int args = __blackfinCommand(camera,PSTR("##vp "),null,values,3); if(args==3){ rtn = TRUE; colorSetYUV(color,(uint8_t)(values[0]), (uint8_t)(values[1]),(uint8_t)(values[2])); #ifdef BLACKFIN_DEBUG _blackfin_set_active(camera->debug); //Send rprintf to the debugger rprintf(" Color = "); colorDump(color); rprintfCRLF(); #endif } // Restore rprintf to original position rprintfInit(old); return rtn; }
void encoderTest(void) { // initialize the encoders encoderInit(); // print a little intro message so we know things are working rprintf("\r\nWelcome to the encoder test!\r\n"); // report encoder position continuously while(1) { rprintfProgStrM("Encoder0: "); // print encoder0 position // use base-10, 10 chars, signed, pad with spaces rprintfNum(10, 10, TRUE, ' ', encoderGetPosition(0)); rprintfProgStrM(" Encoder1: "); // print encoder1 position // use base-10, 10 chars, signed, pad with spaces rprintfNum(10, 10, TRUE, ' ', encoderGetPosition(1)); // print carriage return and line feed rprintfCRLF(); } }
void dumpArgsHex(void) { rprintfCRLF(); rprintf("Dump arguments as hex integers\r\n"); rprintf("Arg1 as hex: "); rprintfNum(16, 8, FALSE, ' ', cmdlineGetArgHex(1)); rprintfCRLF(); rprintf("Arg2 as hex: "); rprintfNum(16, 8, FALSE, ' ', cmdlineGetArgHex(2)); rprintfCRLF(); rprintf("Arg3 as hex: "); rprintfNum(16, 8, FALSE, ' ', cmdlineGetArgHex(3)); rprintfCRLF(); rprintfCRLF(); }
void dumpArgsInt(void) { rprintfCRLF(); rprintf("Dump arguments as integers\r\n"); // printf %d will work but only if your numbers are less than 16-bit values //rprintf("Arg1 as int: %d\r\n", cmdlineGetArgInt(1)); //rprintf("Arg2 as int: %d\r\n", cmdlineGetArgInt(2)); //rprintf("Arg3 as int: %d\r\n", cmdlineGetArgInt(3)); // printfNum is good for longs too rprintf("Arg1 as int: "); rprintfNum(10, 10, TRUE, ' ', cmdlineGetArgInt(1)); rprintfCRLF(); rprintf("Arg2 as int: "); rprintfNum(10, 10, TRUE, ' ', cmdlineGetArgInt(2)); rprintfCRLF(); rprintf("Arg3 as int: "); rprintfNum(10, 10, TRUE, ' ', cmdlineGetArgInt(3)); rprintfCRLF(); rprintfCRLF(); }
void gpsInfoPrint(void) { rprintfProgStrM("TOW: "); rprintfFloat(8, GpsInfo.TimeOfWeek.f); rprintfCRLF(); rprintfProgStrM("WkNum: "); rprintfNum(10,4,0,' ',GpsInfo.WeekNum); rprintfCRLF(); rprintfProgStrM("UTCoffset:"); rprintfFloat(8, GpsInfo.UtcOffset.f); rprintfCRLF(); rprintfProgStrM("Num SVs: "); rprintfNum(10,4,0,' ',GpsInfo.numSVs); rprintfCRLF(); rprintfProgStrM("X_ECEF: "); rprintfFloat(8, GpsInfo.PosECEF.x.f); rprintfCRLF(); rprintfProgStrM("Y_ECEF: "); rprintfFloat(8, GpsInfo.PosECEF.y.f); rprintfCRLF(); rprintfProgStrM("Z_ECEF: "); rprintfFloat(8, GpsInfo.PosECEF.z.f); rprintfCRLF(); rprintfProgStrM("TOF: "); rprintfFloat(8, GpsInfo.PosECEF.TimeOfFix.f); rprintfCRLF(); rprintfProgStrM("Updates: "); rprintfNum(10,6,0,' ',GpsInfo.PosECEF.updates); rprintfCRLF(); //u08 str[20]; //rprintfProgStrM(" PosLat: "); rprintfStr(dtostrf(GpsInfo.PosLat.f, 10, 5, str)); rprintfProgStrM("PosLat: "); rprintfFloat(8, 180*(GpsInfo.PosLLA.lat.f/PI)); rprintfCRLF(); rprintfProgStrM("PosLon: "); rprintfFloat(8, 180*(GpsInfo.PosLLA.lon.f/PI)); rprintfCRLF(); rprintfProgStrM("PosAlt: "); rprintfFloat(8, GpsInfo.PosLLA.alt.f); rprintfCRLF(); rprintfProgStrM("TOF: "); rprintfFloat(8, GpsInfo.PosLLA.TimeOfFix.f); rprintfCRLF(); rprintfProgStrM("Updates: "); rprintfNum(10,6,0,' ',GpsInfo.PosLLA.updates); rprintfCRLF(); rprintfProgStrM("Vel East: "); rprintfFloat(8, GpsInfo.VelENU.east.f); rprintfCRLF(); rprintfProgStrM("Vel North:"); rprintfFloat(8, GpsInfo.VelENU.north.f); rprintfCRLF(); rprintfProgStrM("Vel Up: "); rprintfFloat(8, GpsInfo.VelENU.up.f); rprintfCRLF(); // rprintfProgStrM("TOF: "); rprintfFloat(8, GpsInfo.VelENU.TimeOfFix.f); rprintfCRLF(); rprintfProgStrM("Updates: "); rprintfNum(10,6,0,' ',GpsInfo.VelENU.updates); rprintfCRLF(); rprintfProgStrM("Vel Head: "); rprintfFloat(8, GpsInfo.VelHS.heading.f); rprintfCRLF(); rprintfProgStrM("Vel Speed:"); rprintfFloat(8, GpsInfo.VelHS.speed.f); rprintfCRLF(); // rprintfProgStrM("TOF: "); rprintfFloat(8, GpsInfo.VelHS.TimeOfFix.f); rprintfCRLF(); rprintfProgStrM("Updates: "); rprintfNum(10,6,0,' ',GpsInfo.VelHS.updates); rprintfCRLF(); }
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>"); } }
//----- Begin Code ------------------------------------------------------------ int main(void) { // init a few string variables: char *welcome_msg1 = " LC Meter III "; char *welcome_msg2 = "dansworkshop.com"; char *cal_message1 = "Switch to Cal/C "; char *cal_message2 = "for calibration."; char *cal_message3 = "calibrating... "; char *blank_lcd_line = " "; // initialize LCD lcdInit(); // init timers and I/O: init(); sei(); // enable global interrupts // direct printf output to LCD rprintfInit(lcdDataWrite); // print vanity message on LCD for a second: rprintfStr(welcome_msg1); lcdGotoXY(0,1); rprintfStr(welcome_msg2); _delay_ms(1000); // initialize the UART (serial port) uartInit(); // make all rprintf statements use uart for output rprintfInit(uartSendByte); // print a little intro message so we know things are working rprintfStr(welcome_msg1); rprintf("\r\nhttp://www."); rprintfStr(welcome_msg2); rprintf("\r\n"); // instruct about setting mode switch to C for calibration if(bit_is_clear(PIND, 4)) { rprintfInit(lcdDataWrite); lcdGotoXY(0,0); rprintfStr(cal_message1); lcdGotoXY(0,1); rprintfStr(cal_message2); rprintfInit(uartSendByte); rprintfStr(cal_message1); rprintfStr(cal_message2); rprintf("\r\n"); } while(bit_is_clear(PIND, 4)) { // wait for user to switch mode to C } // send out the calibration message: rprintfStr(cal_message3); rprintf("\r\n"); rprintfInit(lcdDataWrite); lcdGotoXY(0,0); rprintfStr(cal_message3); lcdGotoXY(0,1); rprintfStr(blank_lcd_line); rprintfInit(uartSendByte); _delay_ms(1600); F1 = running; // get open frequency rprintfNum(10, 10, 0, ' ', F1 * 5); rprintf("\r\n"); sbi(PORTD, PD3); // energize relay _delay_ms(1000); // stabilize F2 = running; // get test frequency rprintfNum(10, 10, 0, ' ', F2 * 5); rprintf("\r\n"); cbi(PORTD, PD3); // turn off relay // do some floating point: Cs = square(F2 * 5) * (.00000000092 / (square(F1 * 5) - square(F2 * 5))); // this should fit in a 64-bit value Ls = 1 / (4 * square(M_PI) * square(F1 * 5) * Cs); // everything out of the lcd for now: rprintfInit(lcdDataWrite); // enable PC5 as output sbi(DDRC, PC5); while (1) { _delay_ms(200); lcdGotoXY(0,0); if(bit_is_clear(PIND, 4)) { // inductance measurement mode if(running < 3) { rprintf("Not an inductor \r"); } else { Lt = (square(F1 * 5) / (square(running * 5)) - 1) * Ls; rprintf("Lx: "); if(Lt > .0001) { rprintfFloat(4, Lt * 1000); rprintf("mH"); } else if(Lt > .0000001) { rprintfFloat(4, Lt * 1000000); rprintf("uH"); } else { rprintfFloat(4, Lt * 1000000000); rprintf("nH"); } rprintf(" \r"); } } else { // capacitance measurement mode if(running < 300) { rprintf("Not a capacitor \r"); } else { Ct = (square(F1 * 5) / (square(running * 5)) - 1) * Cs; rprintf("Cx: "); if(Ct > .0001) { rprintfFloat(4, Ct * 1000); rprintf("mF"); } else if(Ct > .0000001) { rprintfFloat(4, Ct * 1000000); rprintf("uF"); } else if(Ct > .0000000001){ rprintfFloat(4, Ct * 1000000000); rprintf("nF"); } else { rprintfFloat(4, Ct * 1000000000000); rprintf("pF"); } rprintf(" \r"); } } if(bit_is_clear(PIND, 7)) { lcdGotoXY(0,0); rprintf("zeroed \r"); lcdGotoXY(0,1); rprintfStr(blank_lcd_line); lcdGotoXY(0,0); F1 = running; } while(bit_is_clear(PIND, 7)) { // do nothing till the user lets go of the zero button } // display the lcdGotoXY(0,1); rprintfNum(10, 6, 0, ' ', running * 5); rprintf("Hz "); } return 0; }
void dhcpIn(unsigned int len, struct netDhcpHeader* packet) { uint8_t msgtype; uint32_t sid; uint8_t* optptr; uint32_t val; uint32_t netmask; uint32_t gateway; #if NET_DEBUG >= 3 dhcpPrintHeader(packet); #endif // check that this is a reply, and for me if ((packet->bootp.op != BOOTP_OP_BOOTREPLY) || (packet->bootp.xid != DhcpTransactID)) return; // process incoming packet // check reply type dhcpGetOption(packet->options, DHCP_OPT_DHCPMSGTYPE, 1, &msgtype); #if NET_DEBUG >= 2 rprintf("DHCP: Received msgtype = %d\r\n", msgtype); #endif if (msgtype == DHCP_MSG_DHCPOFFER) { // get DHCP server ID dhcpGetOption(packet->options, DHCP_OPT_SERVERID, 4, &sid); #ifdef DHCP_DEBUG rprintfProgStrM("DHCP: Got offer from server "); netPrintIPAddr(htonl(sid)); rprintfCRLF(); #endif // build DHCP request (on top of this reply) packet->bootp.op = BOOTP_OP_BOOTREQUEST; // request type // set operation val = DHCP_MSG_DHCPREQUEST; optptr = dhcpSetOption(packet->options, DHCP_OPT_DHCPMSGTYPE, 1, &val); // set the server ID optptr = dhcpSetOption(optptr, DHCP_OPT_SERVERID, 4, &sid); // request the IP previously offered optptr = dhcpSetOption(optptr, DHCP_OPT_REQUESTEDIP, 4, &packet->bootp.yiaddr); // request additional information ((uint8_t*)&val)[0] = DHCP_OPT_NETMASK; ((uint8_t*)&val)[1] = DHCP_OPT_ROUTERS; ((uint8_t*)&val)[2] = DHCP_OPT_DNSSERVERS; ((uint8_t*)&val)[3] = DHCP_OPT_DOMAINNAME; optptr = dhcpSetOption(optptr, DHCP_OPT_PARAMREQLIST, 4, &val); #ifdef DHCP_DEBUG rprintfProgStrM("DHCP: Sending request in response to offer\r\n"); #endif // send DHCP request DhcpServerIP = htonl(sid); udpSend(DhcpServerIP, DHCP_UDP_SERVER_PORT, DHCP_HEADER_LEN+3+6+6+6+1, (uint8_t*)packet); } else if (msgtype == DHCP_MSG_DHCPACK) { // get netmask dhcpGetOption(packet->options, DHCP_OPT_NETMASK, 4, &val); netmask = htonl(val); // get gateway dhcpGetOption(packet->options, DHCP_OPT_ROUTERS, 4, &val); gateway = htonl(val); // get lease time dhcpGetOption(packet->options, DHCP_OPT_LEASETIME, 4, &val); DhcpLeaseTime = htonl(val); // assign new network info ipSetConfig(htonl(packet->bootp.yiaddr), netmask, gateway); #ifdef DHCP_DBUG rprintf("DHCP: Got request ACK, bind complete\r\n"); //debugPrintHexTable(len-DHCP_HEADER_LEN, (packet->options)); // print info ipPrintConfig(ipGetConfig()) rprintfProgStrM("LeaseTm : "); rprintfNum(10, 8, FALSE, ' ', DhcpLeaseTime); rprintfCRLF(); #endif } }
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); } }
/* 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(); }
/******************************************************************* * 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(); } }
int main(void) { avr_init(); u08 even; // u16 i; //u08 temp; command = 45; // actualTemp = 85; // u16 temp; for(;;) { // Tasks here. // Command line reception of commands... // pass characters received on the uart (serial port) // into the cmdline processor // while(uartReceiveByte(&c)){ // vt100SetCursorPos(1, 0); // uartSendByte(c); // cmdlineInputFunc(c); // // } // bounce the character, keep to the top 3 rows... // run the cmdline execution functions vt100SetCursorPos(3, 0); cmdlineMainLoop(); // Command line reception ends here if (APP_STATUS_REG & BV(DO_SAMPLE)) { readMAX6675(&tempData); // get data to tempData variable CLEAR_SAMPLE_FLAG; //debug, invert pin PIND ^= BV(PD5); //update PID // output = pid_Controller(command, tempData, &PID_data); //invert PID // output = PHASE_ANGLE_LIMIT_HIGH - output; } if(APP_STATUS_REG & BV(DO_PID)) { #ifdef REG_PID //update PID output = pid_Controller(command, tempData, &PID_data); #ifndef CMDLINE #ifndef RX_DBG rprintf("PID raw: "); rprintfNum(10, 6, TRUE, ' ', output); rprintfCRLF(); #endif //invert & limit PID if(output > 29700) output = 700; //output = PHASE_ANGLE_LIMIT_HIGH - output; #ifndef RX_DBG rprintf("PID scaled: "); rprintfNum(10, 6, TRUE, ' ', output); rprintfCRLF(); #endif #endif #endif #ifdef REG_PD #endif // actualTemp +=10; // OCR0A = output; CLEAR_PID_FLAG; // } /* if((temp = 0xFFFF-output) > 30000) { temp = 30000;} else if (temp < 1000) { temp = 1000;} */ // Limit to within 1 half-phase: if((output > PHASE_ANGLE_LIMIT_HIGH) || (output < 0)){ #ifndef CMDLINE #ifndef RX_DBG rprintf("Max out");rprintfCRLF(); #endif #endif output = PHASE_ANGLE_LIMIT_HIGH; // don't fire the triac at all! SET_HOLD_FIRE; // set flag to not fire triac } else { CLEAR_HOLD_FIRE; // set flag to fire triac } if ((output < PHASE_ANGLE_LIMIT_LOW)){ // || (output < 0)) #ifndef CMDLINE #ifndef RX_DBG rprintf("Min out");rprintfCRLF(); #endif #endif output = PHASE_ANGLE_LIMIT_LOW; // fire the triac at zerocrozz to get complete halfwave } #ifndef WALK_PHASEANGLE OCR1A = output; #endif //OCR1A = PHASE_ANGLE_LIMIT_LOW; //OCR1A = PHASE_ANGLE_LIMIT_HIGH; } #ifdef DEBUG_SER // uartPrintfNum(10, 6, TRUE, ' ', 1234); --> " +1234" // uartPrintfNum(16, 6, FALSE, '.', 0x5AA5); --> "..5AA5" // rprintfNum(10, 4, FALSE, ' ', tempData);// rprintfCRLF(); #ifndef CMDLINE #ifndef RX_DBG if(sensorDisconnected) { rprintfProgStrM("Disconnected Probe!\r\n"); } else { rprintf("Process Value: "); rprintfNum(10, 4, FALSE, ' ', tempData); rprintfCRLF(); rprintf("Target Value: "); rprintfNum(10, 4, FALSE, ' ', command); rprintfCRLF(); // rprintf("PID Phaselimit: "); // rprintfNum(10, 6, TRUE, ' ', output); rprintfCRLF(); rprintf("OCR1A: "); rprintfNum(10, 6, FALSE, ' ', OCR1A); rprintfCRLF(); //----------- // rprintf("dummy: "); // rprintfNum(10, 6, TRUE, ' ', _DUMMY); rprintfCRLF(); rprintf("E "); rprintfNum(10, 4, TRUE, ' ', _ERROR); rprintfCRLF(); rprintf("P "); rprintfNum(10, 8, TRUE, ' ', _PTERM); rprintfCRLF(); rprintf("I "); rprintfNum(10, 8, TRUE, ' ', _ITERM); rprintfCRLF(); rprintf("D "); rprintfNum(10, 8, TRUE, ' ', _DTERM); rprintfCRLF(); //----------- } vt100SetCursorPos(3, 0); if(even++ == 10){ vt100ClearScreen(); vt100SetCursorPos(3,0); even = 0; } #endif //#ifndef RX_DBG #endif //#ifndef CMDLINE #endif //#ifdef DEBUG_SER } return(0); }