A little experimentation showed that MINIMAL flating point-only two primitives: convert integer to float, and multiply-coupled with a display routine from the user-projects section that used only one more floating-point construct was actually smaller and faster than my hand-built scaling routines. Pressure units vary all over the map in magnitude, and conversion of the internal reading to pressure display in varying units was complicated and error prone and not small. *outstring++ = ((unsigned char)work) | 0x30 // last character, even if 0.Īll that said, I had a tight app that had a pressure-monitor feature, with a limited-width LED display. Index = 0 // start at the left-most character zero = 0 // if not 0, a non-zero digit has been found Unsigned char index // which character are we working on. Unsigned char digit // this BCD digit to be output unsigned char zero // flag for zero supression The resulting string is null-terminated. Mungkin apabila yang sudah terbiasa menggunakan bahasa assembly atau AVR-GCC pada AVR Studio hal ini tidak akan menjadi masalah. Ē.30 amps could be displayed instead of 2 or 3. Akan tetapi ada sekikit permasalahan yang muncul nantinya, terlebih lagi apabila kita yang sudah terbiasa bermain-main mikrokontroler dengan menggunakan bahasa C yaitu pada Codevision AVR versi 2.05 atau dibawahnya. It can also be used to display tenths for numbers that are small-e.g., There are 5 characters output with this version. Only the significant characters are output. Transform a 16-bit unsigned value into unpacked ASCII. * U T O A Z 2 (UTOA with 2 decimal position) This is for cycle times accumulated in tenths of seconds. If used a lot then use the divide routine that returns quotient and remainder. Here is one method with divide and modulo.
I have my own flavours of itoa() that use the simple powers-of-10 subtraction method, right-justify to a fixed width, have optional leading-zero supression, and can be unsigned. Also, itoa() and friends make a left-justified string, variable length, not usually desired for display. My general rule of thumb is that I'll use (s)printf() if I have a number of display conversions to make, and I feel that the hundreds of words are a good tradeoff versus a lot of detailed character-by-character formatting. In almost all my apps, I process the info and end up with something like "tenths of degrees" or "hundreths of amps" or "tenths of seconds" or "hundreths of gallons". Not only does it add a thousand words to (s)printf(), the float has to be constructed somehow. I agree I have very few apps with floating point in them. Pro.2010.09 CodeVision AVR 2.05 CodeVisionAVR v2.04.4a CODEWARECOMPRESSBUILD6258 CodeWarrior for HC12 v4.6 CodeWarrior for Microcontrollers v6.3 Cogito.