Rev 647 | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | SVN | RSS feed
| Rev 647 | Rev 653 | ||
|---|---|---|---|
| Line 68... | Line 68... | ||
| 68 | void rotenc_action(uint8_t type); |
68 | void rotenc_action(uint8_t type); |
| 69 | 69 | ||
| 70 | 70 | ||
| 71 | void updateDisplay(uint8_t screen, uint8_t transition); |
71 | void updateDisplay(uint8_t screen, uint8_t transition); |
| 72 | 72 | ||
| 73 | #define |
73 | #define SCR_BOOST 0x00 |
| 74 | #define |
74 | #define SCR_MAXBOOST 0x01 |
| 75 | #define |
75 | #define SCR_LAMBDA 0x02 |
| 76 | #define SCR_RPM 0x03 |
76 | #define SCR_RPM 0x03 |
| 77 | #define SCR_VOLTAGE 0x04 |
77 | #define SCR_VOLTAGE 0x04 |
| - | 78 | #define SCR_VELOCITY 0x05 |
|
| - | 79 | #define SCR_FUELCONS 0x06 |
|
| - | 80 | //#define SCR_OILPRESS 0x07 |
|
| - | 81 | //#define SCR_OILTEMP 0x08 |
|
| 78 | #define LAST_SCREEN |
82 | #define LAST_SCREEN 0x06 |
| 79 | void standardScreen(char* text, uint16_t value, uint16_t maxvalue); |
- | |
| 80 | 83 | ||
| 81 | void numtoascii( int16_t num, char **str ); |
84 | void numtoascii( int16_t num, char **str ); |
| 82 | void |
85 | void signedtoascii(int16_t num, uint8_t decimalplace, char *string, uint8_t numberofdecimals); |
| - | 86 | void unsignedtoascii(uint16_t num, uint8_t decimalplace, char *string, uint8_t numberofdecimals); |
|
| 83 | 87 | ||
| 84 | uint8_t *parsetemperature(int16_t value, uint8_t *str,uint8_t decimal,uint8_t options); |
- | |
| 85 | uint8_t *io_s16toStr(int16_t value, uint8_t *str,uint8_t decimal,uint8_t options); |
- | |
| 86 | uint8_t *io_u16toStr(uint16_t value, uint8_t *str,uint8_t decimal,uint8_t options); |
- | |
| 87 | 88 | ||
| 88 | 89 | ||
| 89 | - | ||
| 90 | /******************************************************************************* |
90 | /******************************************************************************* |
| 91 | * Sensor Values, Scale factors etc. * |
91 | * Sensor Values, Scale factors etc. * |
| 92 | *******************************************************************************/ |
92 | *******************************************************************************/ |
| 93 | int16_t |
93 | int16_t sensor_Boost = 0.001*64; |
| 94 | int16_t sensor_Boost_Max |
94 | int16_t sensor_Boost_Max = 0.92*64; //highest boost so far |
| - | 95 | uint16_t sensor_Lambda = 32000; |
|
| - | 96 | uint16_t sensor_RPM = 3973*(2<<(SNS_DECPOINT_ROTSPEED-1)); |
|
| - | 97 | uint16_t sensor_Voltage = 12.7*(2<<(SNS_DECPOINT_VOLTAGE-1)); |
|
| - | 98 | uint16_t sensor_Velocity = 120*(2<<(SNS_DECPOINT_VELOCITY-1)); |
|
| - | 99 | uint16_t sensor_Fuelcons = 0.78*(2<<(SNS_DECPOINT_FUELCONS-1)); |
|
| 95 | 100 | ||
| - | 101 | #define SCALE_BOOSTMAX 1.2*64 //depending on memory usage later, maybe put these in eeprom? |
|
| 96 |
|
102 | #define SCALE_LAMBDAMAX 65535 |
| 97 |
|
103 | #define SCALE_RPMMAX 8000*(2<<(SNS_DECPOINT_ROTSPEED-1)) |
| 98 |
|
104 | #define SCALE_VOLTAGEMAX 15*(2<<(SNS_DECPOINT_VOLTAGE-1)) |
| - | 105 | #define SCALE_VELOCITYMAX 150*(2<<(SNS_DECPOINT_VELOCITY-1)) |
|
| - | 106 | #define SCALE_FUELCONSMAX 2*(2<<(SNS_DECPOINT_FUELCONS-1)) |
|
| - | 107 | ||
| 99 | 108 | ||
| 100 | #define scale_Boost 200 //see "Representation av storheter" |
- | |
| 101 | #define scale_BoostMAX 200 |
- | |
| 102 | #define scale_RPMMAX 8000 //Can be set as in eeprom later perhaps? |
- | |
| 103 | #define scale_Voltage 1024 |
- | |
| 104 | #define scale_VoltageMAX 150 |
- | |
| 105 | 109 | ||
| - | 110 | /******************************************************************************* |
|
| - | 111 | * Something else.. * |
|
| - | 112 | *******************************************************************************/ |
|
| 106 | 113 | ||
| 107 | uint8_t currentScreen; |
114 | uint8_t currentScreen; //current screen |
| 108 | 115 | ||
| 109 | // CAN message reception callback |
116 | // CAN message reception callback |
| 110 | // This function runs with interrupts disabled, keep it as short as possible |
117 | // This function runs with interrupts disabled, keep it as short as possible |
| 111 | void can_receive(Can_Message_t *msg){ |
118 | void can_receive(Can_Message_t *msg){ |
| 112 | if(!rxMsgFull){ |
119 | if(!rxMsgFull){ |
| Line 162... | Line 169... | ||
| 162 | TCCR1A |= (1<<COM1A1)|(1<<WGM11); |
169 | TCCR1A |= (1<<COM1A1)|(1<<WGM11); |
| 163 | TCCR1B |= (1<<WGM13)|(1<<WGM12)|(1<<CS10); |
170 | TCCR1B |= (1<<WGM13)|(1<<WGM12)|(1<<CS10); |
| 164 | ICR1 = 0xFF; // Make it 8 bits |
171 | ICR1 = 0xFF; // Make it 8 bits |
| 165 | OCR1A = 0xFF; |
172 | OCR1A = 0xFF; |
| 166 | DDRB |= (1<<DDB1); |
173 | DDRB |= (1<<DDB1); |
| 167 | 174 | ||
| 168 | 175 | ||
| 169 | Can_Message_t txMsg; |
176 | Can_Message_t txMsg; |
| 170 | txMsg.ExtendedFlag=1; |
177 | txMsg.ExtendedFlag=1; |
| 171 | txMsg.RemoteFlag=0; |
178 | txMsg.RemoteFlag=0; |
| 172 | // FIXME skicka app startad |
179 | // FIXME skicka app startad |
| 173 | BIOS_CanCallback = &can_receive; |
180 | BIOS_CanCallback = &can_receive; |
| 174 | 181 | ||
| 175 | lcd_init( LCD_DISP_ON ); |
182 | lcd_init( LCD_DISP_ON ); |
| Line 189... | Line 196... | ||
| 189 | if ( ((rxMsg.Id & CAN_MASK_CLASS)>>CAN_SHIFT_CLASS) == CAN_SNS){// FIXME ett jkla herk, stda upp |
196 | if ( ((rxMsg.Id & CAN_MASK_CLASS)>>CAN_SHIFT_CLASS) == CAN_SNS){// FIXME ett jkla herk, stda upp |
| 190 | 197 | ||
| 191 | sns_type = (uint16_t)((rxMsg.Id & CAN_MASK_SNS_TYPE) >> CAN_SHIFT_SNS_TYPE); |
198 | sns_type = (uint16_t)((rxMsg.Id & CAN_MASK_SNS_TYPE) >> CAN_SHIFT_SNS_TYPE); |
| 192 | snsid = (uint8_t)((rxMsg.Id & CAN_MASK_SNS_ID) >> CAN_SHIFT_SNS_ID); |
199 | snsid = (uint8_t)((rxMsg.Id & CAN_MASK_SNS_ID) >> CAN_SHIFT_SNS_ID); |
| 193 | 200 | ||
| 194 | 201 | switch(sns_type){ |
|
| 195 |
|
202 | case SNS_TYPE_PRESSURE: |
| 196 | sensor_Boost = rxMsg.Data.bytes[0]*256 + rxMsg.Data.bytes[1]; |
203 | sensor_Boost = rxMsg.Data.bytes[0]*256 + rxMsg.Data.bytes[1]; |
| - | 204 | sensor_Boost_Max = max(sensor_Boost,sensor_Boost_Max); |
|
| 197 | if (currentScreen == SCR_BOOST) updateDisplay(SCR_BOOST,0); |
205 | if (currentScreen == SCR_BOOST) updateDisplay(SCR_BOOST,0); |
| - | 206 | break; |
|
| - | 207 | case SNS_TYPE_ROTSPEED: |
|
| - | 208 | sensor_RPM = rxMsg.Data.bytes[0]*256 + rxMsg.Data.bytes[1]; |
|
| - | 209 | if (currentScreen == SCR_RPM) updateDisplay(SCR_RPM,0); |
|
| - | 210 | break; |
|
| - | 211 | case SNS_TYPE_VOLTAGE: |
|
| - | 212 | sensor_Voltage = rxMsg.Data.bytes[0]*256 + rxMsg.Data.bytes[1]; |
|
| - | 213 | if (currentScreen == SCR_VOLTAGE) updateDisplay(SCR_VOLTAGE,0); |
|
| 198 | } |
214 | } |
| 199 | 215 | ||
| 200 | } |
216 | } |
| 201 | rxMsgFull = 0; |
217 | rxMsgFull = 0; |
| 202 | } |
218 | } |
| 203 | } |
219 | } |
| 204 | } |
220 | } |
| 205 | 221 | ||
| 206 | void send_dimensions(){ |
222 | void send_dimensions(){ |
| 207 | Can_Message_t txMsg; |
223 | Can_Message_t txMsg; |
| 208 | 224 | ||
| 209 | txMsg.ExtendedFlag=1; |
225 | txMsg.ExtendedFlag=1; |
| 210 | txMsg.RemoteFlag=0; |
226 | txMsg.RemoteFlag=0; |
| 211 | txMsg.Id=0xA000001; |
227 | txMsg.Id=0xA000001; |
| 212 | txMsg.Data.bytes[0] = SIZE_X; |
228 | txMsg.Data.bytes[0] = SIZE_X; |
| Line 216... | Line 232... | ||
| 216 | BIOS_CanSend(&txMsg); |
232 | BIOS_CanSend(&txMsg); |
| 217 | } |
233 | } |
| 218 | 234 | ||
| 219 | void rotenc_action(uint8_t type){ |
235 | void rotenc_action(uint8_t type){ |
| 220 | //Let's do something with something! |
236 | //Let's do something with something! |
| 221 |
|
237 | |
| 222 | if (type == LEFT){ |
238 | if (type == LEFT){ |
| 223 | if (currentScreen == 0) currentScreen = LAST_SCREEN+1; |
239 | if (currentScreen == 0) currentScreen = LAST_SCREEN+1; |
| 224 | currentScreen--; |
240 | currentScreen--; |
| 225 | updateDisplay(currentScreen,1); |
241 | updateDisplay(currentScreen,1); |
| 226 | } |
242 | } |
| Line 240... | Line 256... | ||
| 240 | void updateDisplay(uint8_t screen, uint8_t transition){ |
256 | void updateDisplay(uint8_t screen, uint8_t transition){ |
| 241 | char buffer[20]; |
257 | char buffer[20]; |
| 242 | 258 | ||
| 243 | if (transition){ |
259 | if (transition){ |
| 244 | lcd_clrscr(); |
260 | lcd_clrscr(); |
| 245 | lcd_setanimation( |
261 | lcd_setanimation(1); |
| 246 | } else { |
262 | } else { |
| 247 | lcd_setanimation(0); |
263 | lcd_setanimation(0); |
| 248 | } |
264 | } |
| 249 | switch (screen){ |
265 | switch (screen){ |
| 250 | case SCR_LAMBDA: |
266 | case SCR_LAMBDA: |
| 251 | lcd_gotoxy(0,0); |
267 | lcd_gotoxy(0,0); |
| 252 | lcd_puts("LEAN Lambda RICH"); |
268 | lcd_puts("LEAN Lambda RICH"); |
| 253 | lcd_gotoxy(0,1); |
269 | lcd_gotoxy(0,1); |
| 254 | lcdProgressBar(sensor_Lambda, |
270 | lcdProgressBar(sensor_Lambda, SCALE_LAMBDAMAX, SIZE_X); //TODO: vacker bargraph med bara en plupp i mitten |
| 255 | break; |
271 | break; |
| 256 | case SCR_RPM: |
272 | case SCR_RPM: |
| 257 | lcd_gotoxy(0,0); |
273 | lcd_gotoxy(0,0); |
| 258 | itoa(sensor_RPM,buffer,10); |
- | |
| 259 | lcd_puts("RPM: "); |
274 | lcd_puts("RPM: "); |
| - | 275 | unsignedtoascii(sensor_RPM,SNS_DECPOINT_ROTSPEED,buffer,0); |
|
| 260 | lcd_puts(buffer); |
276 | lcd_puts(buffer); |
| 261 | lcd_gotoxy(0,1); |
277 | lcd_gotoxy(0,1); |
| 262 | lcdProgressBar(sensor_RPM, |
278 | lcdProgressBar(sensor_RPM, SCALE_RPMMAX, SIZE_X); |
| 263 | break; |
279 | break; |
| 264 | case SCR_BOOST: |
280 | case SCR_BOOST: |
| 265 | - | ||
| 266 | lcd_gotoxy(0,0); |
281 | lcd_gotoxy(0,0); |
| 267 | lcd_puts("Boost:"); |
282 | lcd_puts("Boost: "); |
| 268 | - | ||
| 269 | lcd_gotoxy(7,0); |
- | |
| 270 | //lcd_puts(io_s16toStr(((int32_t)sensor_Boost*scale_Boost)>>10,buffer,2,1)); |
- | |
| 271 |
|
283 | signedtoascii(sensor_Boost,SNS_DECPOINT_PRESSURE,buffer,2); |
| 272 | lcd_puts(buffer); |
284 | lcd_puts(buffer); |
| - | 285 | lcd_puts(" bar "); |
|
| 273 | 286 | ||
| 274 | //lcd_gotoxy(13,0); |
- | |
| 275 | lcd_puts(" bar"); |
- | |
| 276 | - | ||
| 277 | lcd_gotoxy(0,1); |
287 | lcd_gotoxy(0,1); |
| 278 | lcdProgressBar(max(0,sensor_Boost), |
288 | lcdProgressBar(max(0,sensor_Boost), SCALE_BOOSTMAX, SIZE_X); |
| 279 | break; |
289 | break; |
| 280 | case SCR_MAXBOOST: //currently just a testscreen ffs omg |
290 | case SCR_MAXBOOST: //currently just a testscreen ffs omg |
| 281 | lcd_gotoxy(0,0); |
291 | lcd_gotoxy(0,0); |
| 282 | lcd_puts("Max Boost: "); |
292 | lcd_puts("Max Boost: "); |
| 283 | lcd_gotoxy(11,0); |
- | |
| 284 | lcd_gotoxy(0,1); |
- | |
| 285 |
|
293 | signedtoascii(sensor_Boost_Max ,SNS_DECPOINT_PRESSURE,buffer,2); |
| 286 | lcd_puts(buffer); |
294 | lcd_puts(buffer); |
| - | 295 | lcd_puts(" bar"); |
|
| 287 | break; |
296 | break; |
| 288 | case SCR_VOLTAGE: |
297 | case SCR_VOLTAGE: |
| 289 | - | ||
| 290 | lcd_gotoxy(0,0); |
298 | lcd_gotoxy(0,0); |
| 291 | lcd_puts("Voltage:"); |
299 | lcd_puts("Voltage: "); |
| 292 | - | ||
| 293 | lcd_gotoxy(9,0); |
- | |
| 294 |
|
300 | unsignedtoascii(sensor_Voltage,SNS_DECPOINT_VOLTAGE,buffer,2); |
| 295 | - | ||
| 296 |
|
301 | lcd_puts(buffer); |
| 297 | lcd_puts("V"); |
302 | lcd_puts(" V"); |
| 298 | lcd_puts("spanning!"); |
- | |
| 299 | - | ||
| 300 | lcd_gotoxy(0,1); |
303 | lcd_gotoxy(0,1); |
| 301 | lcdProgressBar(sensor_Voltage, |
304 | lcdProgressBar(max(0,sensor_Voltage), SCALE_VOLTAGEMAX, SIZE_X); |
| 302 | break; |
305 | break; |
| 303 | } |
- | |
| 304 | } |
- | |
| 305 | - | ||
| 306 |
|
306 | case SCR_FUELCONS: |
| 307 | lcd_gotoxy(0,0); |
307 | lcd_gotoxy(0,0); |
| - | 308 | lcd_puts("Fuel: "); |
|
| - | 309 | unsignedtoascii(sensor_Fuelcons,SNS_DECPOINT_FUELCONS,buffer,2); |
|
| 308 |
|
310 | lcd_puts(buffer); |
| - | 311 | lcd_puts(" L/10km"); |
|
| 309 |
|
312 | lcd_gotoxy(0,1); |
| - | 313 | lcdProgressBar(max(0,sensor_Fuelcons), SCALE_FUELCONSMAX, SIZE_X); |
|
| - | 314 | break; |
|
| - | 315 | case SCR_VELOCITY: |
|
| 310 |
|
316 | lcd_gotoxy(0,0); |
| 311 | lcd_puts |
317 | lcd_puts("Speed: "); |
| - | 318 | unsignedtoascii(sensor_Velocity,SNS_DECPOINT_VELOCITY,buffer,0); |
|
| 312 | lcd_puts(buffer); |
319 | lcd_puts(buffer); |
| - | 320 | lcd_puts(" km/h"); |
|
| 313 | lcd_gotoxy(0,1); |
321 | lcd_gotoxy(0,1); |
| 314 | lcdProgressBar |
322 | lcdProgressBar(max(0,sensor_Velocity), SCALE_VELOCITYMAX, SIZE_X); |
| - | 323 | break; |
|
| - | 324 | } |
|
| 315 | } |
325 | } |
| 316 | - | ||
| 317 | - | ||
| 318 | 326 | ||
| 319 | 327 | ||
| 320 | 328 | ||
| 321 | 329 | ||
| 322 | 330 | ||
| Line 381... | Line 389... | ||
| 381 | } |
389 | } |
| 382 | } |
390 | } |
| 383 | 391 | ||
| 384 | 392 | ||
| 385 | 393 | ||
| 386 | - | ||
| 387 | - | ||
| 388 | - | ||
| 389 | - | ||
| 390 | - | ||
| 391 | - | ||
| 392 | // la pengi |
394 | // la pengi. Skall libbifieras. |
| 393 | void numtoascii( int16_t num, char **str ) { |
395 | void numtoascii( int16_t num, char **str ) { |
| 394 | if( num==0 ) return; |
396 | if( num==0 ) return; |
| 395 | numtoascii( num/10, str ); |
397 | numtoascii( num/10, str ); |
| 396 | **str = '0' + (num%10); |
398 | **str = '0' + (num%10); |
| 397 | (*str)++; |
399 | (*str)++; |
| 398 | } |
400 | } |
| 399 | 401 | ||
| 400 | void |
402 | void signedtoascii(int16_t num, uint8_t decimalplace, char *string, uint8_t numberofdecimals){ //decimalplace is number of decimals |
| 401 | uint8_t i; |
403 | uint8_t i; |
| 402 | #define ANTAL_NUFFROR 3 |
- | |
| - | 404 | ||
| 403 | if( num<0 ) { |
405 | if( num<0 ) { |
| 404 | *(string++) = '-'; |
406 | *(string++) = '-'; |
| 405 | num = -num; |
407 | num = -num; |
| 406 | } |
408 | } |
| 407 | numtoascii(num>>decimalplace, &string ); |
409 | numtoascii(num>>decimalplace, &string ); |
| - | 410 | if(numberofdecimals!=0) *(string++) = '.'; |
|
| - | 411 | for(i=0;i<numberofdecimals;i++) { |
|
| - | 412 | num %= 1<<decimalplace; |
|
| - | 413 | num *= 10; |
|
| - | 414 | *(string++) = '0' + (num>>decimalplace); |
|
| - | 415 | } |
|
| 408 | *(string++) = |
416 | *(string++) = 0; |
| - | 417 | } |
|
| - | 418 | ||
| - | 419 | void unsignedtoascii(uint16_t num, uint8_t decimalplace, char *string, uint8_t numberofdecimals){ //decimalplace is number of decimals |
|
| - | 420 | uint8_t i; |
|
| - | 421 | numtoascii(num>>decimalplace, &string ); |
|
| - | 422 | if(numberofdecimals!=0) *(string++) = '.'; |
|
| 409 | for(i=0;i< |
423 | for(i=0;i<numberofdecimals;i++) { |
| 410 | num %= 1<<decimalplace; |
424 | num %= 1<<decimalplace; |
| 411 | num *= 10; |
425 | num *= 10; |
| 412 | *(string++) = '0' + (num>>decimalplace); |
426 | *(string++) = '0' + (num>>decimalplace); |
| 413 | } |
427 | } |
| 414 | *(string++) = 0; |
428 | *(string++) = 0; |
| 415 | } |
429 | } |
| 416 | 430 | ||
| 417 | 431 | ||
| 418 | //Supersnodd: |
- | |
| 419 | - | ||
| 420 | - | ||
| 421 | - | ||
| 422 | uint8_t _io_buf[10]; |
- | |
| 423 | - | ||
| 424 | - | ||
| 425 | /* |
- | |
| 426 | uint8_t *parsetemperature(int16_t value,uint8_t *str,uint8_t decimal,uint8_t options){ |
- | |
| 427 | uint16_t tmp; |
- | |
| 428 | uint8_t i=0; |
- | |
| 429 | |
- | |
| 430 | //value = 0xfcf4; |
- | |
| 431 | //decimal = 6; |
- | |
| 432 | |
- | |
| 433 | if(value<0) { |
- | |
| 434 | str[i++]='-'; //add negative sign |
- | |
| 435 | tmp=-value>>decimal; |
- | |
| 436 | } else { |
- | |
| 437 | if(options&0x01) str[i++]=' '; //Can the number be negative? Leave space for minussign |
- | |
| 438 | tmp=value>>decimal; |
- | |
| 439 | } |
- | |
| 440 | |
- | |
| 441 | //Let's start axing up the value to print it beautifully. We have tmp, the integer part of the value |
- | |
| 442 | while(tmp>0) { |
- | |
| 443 | str[i++]='0' + (tmp%10); |
- | |
| 444 | tmp=tmp/10; |
- | |
| 445 | } |
- | |
| 446 | |
- | |
| 447 | //now we hafve printed all of zat |
- | |
| 448 | str[i++] = '.'; |
- | |
| 449 | |
- | |
| 450 | //let's go on to the fractional part... (cwap!) |
- | |
| 451 | |
- | |
| 452 | |
- | |
| 453 | str[i++]=0; |
- | |
| 454 | return(str); |
- | |
| 455 | } |
- | |
| 456 | */ |
- | |
| 457 | - | ||
| 458 | // nn annans rutin som jag inte riktigt frstr mig p. |
- | |
| 459 | uint8_t *io_s16toStr(int16_t value,uint8_t *str,uint8_t decimal,uint8_t options) { |
- | |
| 460 | uint8_t i=0,j=0,w=0; |
- | |
| 461 | uint16_t tmp; |
- | |
| 462 | - | ||
| 463 | if(value<0) { |
- | |
| 464 | str[i++]='-'; |
- | |
| 465 | tmp=-value; |
- | |
| 466 | } else { |
- | |
| 467 | if(options&0x01) str[i++]=' '; |
- | |
| 468 | tmp=value; |
- | |
| 469 | } |
- | |
| 470 | while(tmp>0) { |
- | |
| 471 | _io_buf[j++]='0'+(tmp%10); |
- | |
| 472 | tmp=tmp/10; |
- | |
| 473 | } |
- | |
| 474 | if(j<=decimal) { |
- | |
| 475 | str[i++]='0'; |
- | |
| 476 | if(decimal>0) str[i++]='.'; |
- | |
| 477 | w=i; |
- | |
| 478 | while((i-w)<(decimal-j)) str[i++]='0'; |
- | |
| 479 | while(j!=0) str[i++]=_io_buf[--j]; |
- | |
| 480 | } else { |
- | |
| 481 | while(j!=0) { |
- | |
| 482 | str[i++]=_io_buf[--j]; |
- | |
| 483 | if(j==decimal) str[i++]='.'; |
- | |
| 484 | } |
- | |
| 485 | } |
- | |
| 486 | str[i++]=0; |
- | |
| 487 | return(str); |
- | |
| 488 | } |
- | |
| 489 | - | ||
| 490 | uint8_t *io_u16toStr(uint16_t value,uint8_t *str,uint8_t decimal,uint8_t options) { |
- | |
| 491 | uint8_t i=0; |
- | |
| 492 | uint8_t j=0; |
- | |
| 493 | uint8_t w=0; |
- | |
| 494 | - | ||
| 495 | while(value>0) { |
- | |
| 496 | _io_buf[j++]='0'+(value%10); |
- | |
| 497 | value=value/10; |
- | |
| 498 | } |
- | |
| 499 | - | ||
| 500 | if(j<=decimal) { |
- | |
| 501 | str[i++]='0'; |
- | |
| 502 | if(decimal>0) str[i++]='.'; |
- | |
| 503 | w=i; |
- | |
| 504 | while((i-w)<(decimal-j)) str[i++]='0'; |
- | |
| 505 | while(j!=0) str[i++]=_io_buf[--j]; |
- | |
| 506 | } else { |
- | |
| 507 | while(j>0) { |
- | |
| 508 | str[i++]=_io_buf[--j]; |
- | |
| 509 | if((decimal>0)&&(j==decimal)) str[i++]='.'; |
- | |
| 510 | } |
- | |
| 511 | } |
- | |
| 512 | str[i++]=0; |
- | |
| 513 | return(str); |
- | |
| 514 | } |
- | |