fix cm?
This commit is contained in:
@@ -131,10 +131,18 @@ void lcd_write_int(int number)
|
|||||||
lcd_write_string(str);
|
lcd_write_string(str);
|
||||||
}
|
}
|
||||||
|
|
||||||
void lcd_write_double(char prefix[], double number, char suffix[])
|
void lcd_write_double(char prefix[], float number, char suffix[])
|
||||||
{
|
{
|
||||||
int length = snprintf(NULL, 0, "%s: %.3f %s", prefix, number, suffix);
|
int length = snprintf(NULL, 0, "%s: %.3f %s", prefix, number, suffix);
|
||||||
char str[length + 1];
|
char str[length + 1];
|
||||||
snprintf(str, length + 1, "%s: %.3f %s", prefix, number, suffix);
|
snprintf(str, length + 1, "%s: %.3f %s", prefix, number, suffix);
|
||||||
lcd_write_string(str);
|
lcd_write_string(str);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void lcd_write_ultrasonic_value(float number)
|
||||||
|
{
|
||||||
|
int length = snprintf(NULL, 0, "%.3f CM", number);
|
||||||
|
char str[length + 1];
|
||||||
|
snprintf(str, length + 1, "%.3f CM", number);
|
||||||
|
lcd_write_string(str);
|
||||||
|
}
|
||||||
|
|||||||
@@ -41,6 +41,11 @@ void lcd_write_int(int number);
|
|||||||
/************************************************************************/
|
/************************************************************************/
|
||||||
void lcd_write_double(char prefix[], double number, char suffix[]);
|
void lcd_write_double(char prefix[], double number, char suffix[]);
|
||||||
|
|
||||||
|
/************************************************************************/
|
||||||
|
/* write ultrasonic reading on the lcd */
|
||||||
|
/************************************************************************/
|
||||||
|
void lcd_write_ultrasonic_value(float number);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#endif /* LCD_CONTROL_H_ */
|
#endif /* LCD_CONTROL_H_ */
|
||||||
@@ -69,7 +69,7 @@ int main(void)
|
|||||||
{
|
{
|
||||||
lcd_clear();
|
lcd_clear();
|
||||||
// set the ultrasonic value to the lcd.
|
// set the ultrasonic value to the lcd.
|
||||||
lcd_write_int(ultrasonic_get_timer_dist());
|
lcd_write_ultrasonic_value(ultrasonic_get_timer_dist());
|
||||||
|
|
||||||
wait_ms(LCD_SET_DELAY);
|
wait_ms(LCD_SET_DELAY);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user