updated math functions

This commit is contained in:
hugogogo
2025-03-15 18:15:30 +01:00
parent 16a5bcd313
commit ec928d14b1
12 changed files with 200 additions and 66 deletions

View File

@@ -25,7 +25,7 @@ void adc_print_dec(uint16_t value) {
// value = calibrate_temperature(value, 5);
// }
char buffer[17] = {0};
uint16_to_string(value, buffer);
int_to_string((uint16_t)value, buffer);
uart_printstr(buffer);
}

View File

@@ -25,7 +25,7 @@ extern volatile uint8_t adc_channel;
void timer_1B_init();
// math.c
void int_to_hex_string(uint64_t value, char *out, uint8_t num_digits);
void uint16_to_string(uint16_t value, char *out);
void int_to_string(uint64_t value, char *out);
// adc.c
void adc_init(uint8_t prescaler_value);
uint16_t calibrate_temperature(uint16_t value, uint8_t speed);

View File

@@ -8,7 +8,7 @@ void int_to_hex_string(uint64_t value, char *out, uint8_t num_digits) { // nu
out[num_digits] = '\0';
}
void uint16_to_string(uint16_t value, char buffer[17]) {
void int_to_string(uint64_t value, char *buffer) {
// handle zero case
if (value == 0) {
buffer[0] = '0';
@@ -16,7 +16,7 @@ void uint16_to_string(uint16_t value, char buffer[17]) {
}
uint8_t size = -1;
uint16_t copy = value;
uint64_t copy = value;
while (copy) {
copy /= 10;
@@ -29,4 +29,4 @@ void uint16_to_string(uint16_t value, char buffer[17]) {
value /= 10;
size--;
}
}
}