18,17 → 18,24 |
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * |
****************************************************************************/ |
|
#include "main.h" |
#include <avr/io.h> |
#include <util/delay.h> |
#include <avr/pgmspace.h> |
#include <string.h> |
#include <stdlib.h> |
#include "main.h" |
#include "max7456_software_spi.h" |
|
|
char conv_array[7]; // general array for number -> char conversation |
|
int pow(int a, int b) { |
if (b <= 0) return 1; |
int res = 1; |
while (b-- > 0) res *= a; |
return res; |
} |
|
/* ########################################################################## |
* MAX7456 SPI & Display stuff |
* ##########################################################################*/ |
228,6 → 235,9 |
* <pad> = 1 will cause blank spaced to be filled up with zeros e.g. 007 instead of 7 |
*/ |
void write_ndigit_number_u(uint8_t x, uint8_t y, uint16_t number, int16_t length, uint8_t pad) { |
if (number >= pow(10, length)) { |
number = pow(10, length) - 1; |
} |
itoa(number, conv_array, 10); |
for (uint8_t i = 0; i < length - strlen(conv_array); i++) { |
if (pad) write_char((x++)+(y * 30), 10); |
242,10 → 252,18 |
* <pad> = 1 will cause blank spaced to be filled up with zeros e.g. 007 instead of 7 |
*/ |
void write_ndigit_number_s(uint8_t x, uint8_t y, int16_t number, int16_t length, uint8_t pad) { |
if (number <= -pow(10, length)) { |
number = -pow(10, length) + 1; |
} else if (number >= pow(10, length)) { |
number = pow(10, length) - 1; |
} |
|
itoa(number, conv_array, 10); |
for (uint8_t i = 0; i < length - strlen(conv_array); i++) { |
if (pad) write_char((x++)+(y * 30), 10); |
else write_ascii_char((x++)+(y * 30), 0); |
if (strlen(conv_array) < length) { |
for (uint8_t i = 0; i < length - strlen(conv_array); i++) { |
if (pad) write_char((x++)+(y * 30), 10); |
else write_ascii_char((x++)+(y * 30), 0); |
} |
} |
write_ascii_string(x, y, conv_array); |
} |
256,6 → 274,9 |
* <pad> = 1 will cause blank spaced to be filled up with zeros e.g. 007 instead of 7 |
*/ |
void write_ndigit_number_u_10th(uint8_t x, uint8_t y, uint16_t number, int16_t length, uint8_t pad) { |
if (number >= pow(10, length)) { |
number = pow(10, length) - 1; |
} |
itoa(number, conv_array, 10); |
uint8_t len = strlen(conv_array); |
for (uint8_t i = 0; i < length - len; i++) { |
283,6 → 304,9 |
* <pad> = 1 will cause blank spaced to be filled up with zeros e.g. 007 instead of 7 |
*/ |
void write_ndigit_number_s_10th(uint8_t x, uint8_t y, int16_t number, int16_t length, uint8_t pad) { |
if (number >= pow(10, length)) { |
number = pow(10, length) - 1; |
} |
itoa(number, conv_array, 10); |
uint8_t len = strlen(conv_array); |
for (uint8_t i = 0; i < length - len; i++) { |