Rev 519 | Rev 728 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
| Rev 519 | Rev 523 | ||
|---|---|---|---|
| Line 245... | Line 245... | ||
| 245 | * <pad> = 1 will cause blank spaced to be filled up with zeros e.g. 007 instead of 7 |
245 | * <pad> = 1 will cause blank spaced to be filled up with zeros e.g. 007 instead of 7 |
| 246 | */ |
246 | */ |
| 247 | void write_ndigit_number_u_10th(uint8_t x, uint8_t y, uint16_t number, int16_t length, uint8_t pad) { |
247 | void write_ndigit_number_u_10th(uint8_t x, uint8_t y, uint16_t number, int16_t length, uint8_t pad) { |
| 248 | char s[7]; |
248 | char s[7]; |
| 249 | itoa(number, s, 10 ); |
249 | itoa(number, s, 10 ); |
| - | 250 | uint8_t len = strlen(s); |
|
| 250 | for (uint8_t i = 0; i < length - strlen(s); i++) { |
251 | for (uint8_t i = 0; i < length - len; i++) { |
| 251 | if (pad) write_char((x++)+(y * 30), 10); |
252 | if (pad) write_char((x++)+(y * 30), 10); // zero |
| 252 | else write_ascii_char((x++)+(y * 30), 0); |
253 | else write_char((x++)+(y * 30), 0); // blank |
| 253 | } |
254 | } |
| 254 | char rest = s[strlen(s)-1]; |
255 | char rest = s[len - 1]; |
| 255 | s[strlen(s)-1] = 0; |
256 | s[len - 1] = 0; |
| - | 257 | if (len == 1) { |
|
| 256 | if (number < 10) write_char((x-1)+(y * 30), 10); // zero |
258 | write_char((x-1)+(y * 30), 10); // zero |
| - | 259 | } else if (len == 2 && s[0] == '-') { |
|
| - | 260 | write_char((x-1)+(y * 30), 0x49); // minus |
|
| - | 261 | write_char((x)+(y * 30), 10); // zero |
|
| - | 262 | } else { |
|
| 257 | else write_ascii_string(x, y, s); |
263 | write_ascii_string(x, y, s); |
| - | 264 | } |
|
| 258 | x += strlen(s); |
265 | x += len - 1; |
| 259 | write_char((x++)+(y * 30), 65); // decimal point |
266 | write_char((x++)+(y * 30), 65); // decimal point |
| 260 | write_ascii_char((x++)+(y * 30), rest); // after dot |
267 | write_ascii_char((x++)+(y * 30), rest); // after dot |
| 261 | } |
268 | } |
| Line 262... | Line 269... | ||
| 262 | 269 | ||
| Line 266... | Line 273... | ||
| 266 | * <pad> = 1 will cause blank spaced to be filled up with zeros e.g. 007 instead of 7 |
273 | * <pad> = 1 will cause blank spaced to be filled up with zeros e.g. 007 instead of 7 |
| 267 | */ |
274 | */ |
| 268 | void write_ndigit_number_s_10th(uint8_t x, uint8_t y, int16_t number, int16_t length, uint8_t pad) { |
275 | void write_ndigit_number_s_10th(uint8_t x, uint8_t y, int16_t number, int16_t length, uint8_t pad) { |
| 269 | char s[7]; |
276 | char s[7]; |
| 270 | itoa(number, s, 10 ); |
277 | itoa(number, s, 10 ); |
| - | 278 | uint8_t len = strlen(s); |
|
| 271 | for (uint8_t i = 0; i < length - strlen(s); i++) { |
279 | for (uint8_t i = 0; i < length - len; i++) { |
| 272 | if (pad) write_char((x++)+(y * 30), 10); |
280 | if (pad) write_char((x++)+(y * 30), 10); // zero |
| 273 | else write_char((x++)+(y * 30), 0); |
281 | else write_char((x++)+(y * 30), 0); // blank |
| 274 | } |
282 | } |
| 275 | char rest = s[strlen(s)-1]; |
283 | char rest = s[len - 1]; |
| 276 | s[strlen(s)-1] = 0; |
284 | s[len - 1] = 0; |
| - | 285 | if (len == 1) { |
|
| - | 286 | write_char((x-1)+(y * 30), 10); // zero |
|
| - | 287 | } else if (len == 2 && s[0] == '-') { |
|
| - | 288 | write_char((x-1)+(y * 30), 0x49); // minus |
|
| 277 | if (number < 10) write_char((x)+(y * 30), 10); // zero |
289 | write_char((x)+(y * 30), 10); // zero |
| 278 | else { |
290 | } else { |
| 279 | write_ascii_string(x, y, s); |
291 | write_ascii_string(x, y, s); |
| 280 | } |
292 | } |
| 281 | x += strlen(s); |
293 | x += len - 1; |
| 282 | write_char((x++)+(y * 30), 65); // decimal point |
294 | write_char((x++)+(y * 30), 65); // decimal point |
| 283 | write_ascii_char((x++)+(y * 30), rest); // after dot |
295 | write_ascii_char((x++)+(y * 30), rest); // after dot |
| 284 | - | ||
| 285 | } |
296 | } |
| Line 286... | Line 297... | ||
| 286 | 297 | ||
| 287 | /** |
298 | /** |
| 288 | * write <seconds> as human readable time at <x>/<y> to MAX7456 display mem |
299 | * write <seconds> as human readable time at <x>/<y> to MAX7456 display mem |