Hallo,
analog zur Funktion PrintInt habe ich die Funktion PrintFloat geschrieben.
Über Verbesserungsvorschläge bin ich wie immer dankbar.Code:void PrintFloat (float wert, char vorkomma, char nachkomma) // vorkomma + nachkomma max 7 { char text [10]; dtostrf(wert, vorkomma, nachkomma, text); SerPrint (text); }
Beispielprogramm:
GrussCode:#include <stdlib.h> #include "asuro.h" void PrintFloat (float wert, char vorkomma, char nachkomma) // vorkomma + nachkomma max 7 { char text [10]; dtostrf(wert, vorkomma, nachkomma, text); SerPrint (text); } int main(void) { Init (); SerWrite ("\r\n", 2); PrintFloat (123.4567, 3, 4); SerWrite ("\r\n", 2); SerWrite ("\r\n", 2); PrintFloat (-123.4567, 5, 2); SerWrite ("\r\n", 2); SerWrite ("\r\n", 2); PrintFloat (-1.234567, 1, 6); SerWrite ("\r\n", 2); SerWrite ("\r\n", 2); PrintFloat (1.234567, 1, 3); SerWrite ("\r\n", 2); while (1); return 0; }
M.







 
			
			 
					
					
					
						 Zitieren
Zitieren

Lesezeichen