{"id":485,"date":"2017-11-24T23:55:07","date_gmt":"2017-11-24T22:55:07","guid":{"rendered":"http:\/\/mikrocontroller.bplaced.net\/wordpress\/?page_id=485"},"modified":"2017-12-30T19:39:25","modified_gmt":"2017-12-30T18:39:25","slug":"75-string-library-stm32f4","status":"publish","type":"page","link":"https:\/\/mikrocontroller.bplaced.net\/wordpress\/?page_id=485","title":{"rendered":"75-String-Library (STM32F4)"},"content":{"rendered":"<p><div id=\"nav-below\" class=\"navigation\"><div class=\"nav-previous\"><a href=\"https:\/\/mikrocontroller.bplaced.net\/wordpress\/?page_id=483\" title=\"74-SPI_Slave-Library (STM32F4)\"><span class=\"meta-nav\">\u2190<\/span> 74-SPI_Slave-Library (STM32F4)<\/a><\/div><\/div><!-- #nav-below --><div id=\"nav-below\" class=\"navigation\"><div class=\"nav-next\"><a href=\"https:\/\/mikrocontroller.bplaced.net\/wordpress\/?page_id=487\" title=\"76-LCD_N95_8GB-Library (STM32F4)\">76-LCD_N95_8GB-Library (STM32F4) <span class=\"meta-nav\">&rarr;<\/span><\/a><\/div><\/div><!-- #nav-below --><\/p>\n<p>Das hier ist weniger eine Library als eine Hilfe in C-Programmierung.<\/p>\n<p>Aber weil viele Fragen dazu gestellt wurden, hab ich das jetzt in ein File gepackt.<\/p>\n<p>Es geht um das konvertieren von Zahlen in Strings und umgekehrt.<\/p>\n<p>Im Beispiel sind so ziemlich alle Arten von Umwandlungen zu sehen<br \/>\n(in der CoIDE wird \u201cretarget printf\u201d ben\u00f6tigt)<\/p>\n<p>Zus\u00e4tzlich sind noch 3 Funktionen dabei um Teilstrings zu kopieren<br \/>\n(die k\u00f6nnen im H-File auch abgeschaltet werden, falls nicht ben\u00f6tigt)<\/p>\n<p><strong>Funktionen :<\/strong><\/p>\n<pre lang=\"c\" line=\"1\">void UB_String_FloatToDezStr(float wert);                       \/\/ wandelt eine FLOAT-Zahl in einen String\r\nfloat UB_String_DezStringToFloat(char *ptr);                    \/\/ wandelt einen String in eine FLOAT-Zahl\r\nint16_t UB_String_DezStringToInt(char *ptr);                    \/\/ wandelt einen String in eine INT-Zahl\r\nvoid UB_String_Mid(char *ptr, uint16_t start, uint16_t length); \/\/ kopiert einen Teilstring von der Mitte\r\nvoid UB_String_Left(char *ptr, uint16_t length);                \/\/ kopiert den linken Teil eines Strings\r\nvoid UB_String_Right(char *ptr, uint16_t length);               \/\/ kopiert den rechten Teil eines String<\/pre>\n<p><strong>Beispiel :<\/strong><\/p>\n<pre lang=\"c\" line=\"1\">\/\/--------------------------------------------------------------\r\n\/\/ File     : main.c\r\n\/\/ Datum    : 09.02.2014\r\n\/\/ Version  : 1.0\r\n\/\/ Autor    : UB\r\n\/\/ EMail    : mc-4u(@)t-online.de\r\n\/\/ Web      : www.mikrocontroller-4u.de\r\n\/\/ CPU      : STM32F4\r\n\/\/ IDE      : CooCox CoIDE 1.7.4\r\n\/\/ GCC      : 4.7 2012q4\r\n\/\/ Module   : CMSIS_BOOT, M4_CMSIS_CORE\r\n\/\/ Funktion : Demo der String-Library\r\n\/\/ Hinweis  : Diese zwei Files muessen auf 8MHz stehen\r\n\/\/              \"cmsis_boot\/stm32f4xx.h\"\r\n\/\/              \"cmsis_boot\/system_stm32f4xx.c\"\r\n\/\/--------------------------------------------------------------\r\n\r\n#include \"main.h\"\r\n#include \"stm32_ub_uart.h\"\r\n#include \"stm32_ub_string.h\"\r\n\r\nint main(void)\r\n{\r\n  uint16_t uint_wert;\r\n  int16_t int_wert;\r\n  int16_t int_wert2;\r\n  float float_wert;\r\n  float float_wert2;\r\n\r\n  SystemInit(); \/\/ Quarz Einstellungen aktivieren\r\n\r\n  UB_Uart_Init();\r\n\r\n  UB_Uart_SendString(COM3, \"Demo der String-Lib\", LFCR);\r\n\r\n  \/\/ unsigned integer Zahl in String wandeln\r\n  UB_Uart_SendString(COM3, \"unsigned INT Zahl:\", LFCR);\r\n  uint_wert=1234;\r\n  sprintf(STRING_BUF,\"%d\",uint_wert);\r\n  UB_Uart_SendString(COM3, STRING_BUF, LFCR);\r\n\r\n  \/\/ signed integer Zahl in String wandeln\r\n  UB_Uart_SendString(COM3, \"signed INT Zahl:\", LFCR);\r\n  int_wert=-1234;\r\n  sprintf(STRING_BUF,\"%d\",int_wert);\r\n  UB_Uart_SendString(COM3, STRING_BUF, LFCR);\r\n\r\n  \/\/ unsigned integer Zahl in 4stellig HEX wandeln (mit f\u00fchrenden Nullen)\r\n  UB_Uart_SendString(COM3, \"HEX Ausgabe:\", LFCR);\r\n  uint_wert=1234;\r\n  sprintf(STRING_BUF,\"%04X\",uint_wert);\r\n  UB_Uart_SendString(COM3, STRING_BUF, LFCR);\r\n\r\n  \/\/ float Zahl in String wandeln\r\n  UB_Uart_SendString(COM3, \"float Zahl:\", LFCR);\r\n  float_wert=123.4567;\r\n  UB_String_FloatToDezStr(float_wert);\r\n  UB_Uart_SendString(COM3, STRING_BUF, LFCR);\r\n\r\n  \/\/ String in float Zahl wandeln\r\n  UB_Uart_SendString(COM3, \"String in float:\", LFCR);\r\n  float_wert2=UB_String_DezStringToFloat(\"-345.6789\");\r\n  UB_String_FloatToDezStr(float_wert2);\r\n  UB_Uart_SendString(COM3, STRING_BUF, LFCR);\r\n\r\n  \/\/ String in signed integer Zahl wandeln\r\n  UB_Uart_SendString(COM3, \"String in integer:\", LFCR);\r\n  int_wert2=UB_String_DezStringToInt(\"-3456\");\r\n  sprintf(STRING_BUF,\"%d\",int_wert2);\r\n  UB_Uart_SendString(COM3, STRING_BUF, LFCR);\r\n\r\n  while(1)\r\n  {\r\n\r\n  }\r\n}\r\n<\/pre>\n<p>Hier die Library zum\u00a0<strong>Download :<\/strong><\/p>\n<p><a href=\"http:\/\/mikrocontroller.bplaced.net\/wordpress\/wp-content\/uploads\/2014\/03\/ub_stm32f4_string_v101.zip\">ub_stm32f4_string_v101<\/a><\/p>\n<p>Hier der komplette CooCox-Projektordner zum\u00a0<strong>Download :<\/strong><\/p>\n<p><a href=\"http:\/\/mikrocontroller.bplaced.net\/wordpress\/wp-content\/uploads\/2014\/03\/Demo_75_String.zip\">Demo_75_String<\/a><\/p>\n<hr \/>\n<h3 id=\"comments-title\">12 Antworten auf <em>75-String-Library (STM32F4)<\/em><\/h3>\n<ol class=\"commentlist\">\n<li id=\"li-comment-1370\" class=\"comment even thread-even depth-1\">\n<div id=\"comment-1370\">\n<div class=\"comment-author vcard\"><img loading=\"lazy\" decoding=\"async\" class=\"avatar avatar-40 photo\" src=\"http:\/\/0.gravatar.com\/avatar\/af5be9fa3f95b3ec9c424ed130b7f2d3?s=40&amp;d=http%3A%2F%2F0.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D40&amp;r=G\" alt=\"\" width=\"40\" height=\"40\" \/><cite class=\"fn\">Cortex-Einsteiger<\/cite> <span class=\"says\">sagt:<\/span><\/div>\n<p><!-- .comment-author .vcard --><\/p>\n<div class=\"comment-meta commentmetadata\">9. Februar 2014 um 15:12<\/div>\n<p><!-- .comment-meta .commentmetadata --><\/p>\n<div class=\"comment-body\">\n<p>ein kleiner Helferlein, danke.<br \/>\nIrgendwo hatte ich mal gelesen, dass die normale sprintf Umwandlung von float2string einen Bug hat.<\/p>\n<\/div>\n<\/div>\n<p><!-- #comment-## --><\/li>\n<li id=\"li-comment-1378\" class=\"comment odd alt thread-odd thread-alt depth-1\">\n<div id=\"comment-1378\">\n<div class=\"comment-author vcard\"><img loading=\"lazy\" decoding=\"async\" class=\"avatar avatar-40 photo\" src=\"http:\/\/1.gravatar.com\/avatar\/9fd3d5bde6304cf9f30120d717721ef9?s=40&amp;d=http%3A%2F%2F1.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D40&amp;r=G\" alt=\"\" width=\"40\" height=\"40\" \/><cite class=\"fn\"><a class=\"url\" href=\"https:\/\/sites.google.com\/site\/suprabotics\/\" rel=\"external nofollow\">Fabrice<\/a><\/cite> <span class=\"says\">sagt:<\/span><\/div>\n<p><!-- .comment-author .vcard --><\/p>\n<div class=\"comment-meta commentmetadata\">12. Februar 2014 um 20:02<\/div>\n<p><!-- .comment-meta .commentmetadata --><\/p>\n<div class=\"comment-body\">\n<p>Letztes jahre habe ich andere string routine geschriben.<br \/>\nDu kannst die an deine als upgrade addieren , sind auch oft benutzt.<br \/>\nDatei : StrFnc.h<br \/>\n<code><br \/>\n#ifndef __STRFNC_H<br \/>\n#define __STRFNC_H<\/code><\/p>\n<p>#include &#8222;stm32f4xx.h&#8220;<br \/>\n#include<br \/>\n#include<\/p>\n<p>char *Mid(char *text, uint16_t start, uint16_t length);<br \/>\nchar *Left(char *text, uint16_t nbchar);<br \/>\nchar *Right(char *text, uint16_t length);<br \/>\nuint8_t Asc(char *str);<br \/>\nchar Chr(uint8_t value);<br \/>\nuint16_t Instr(uint16_t start, char *string1, char *string2);<br \/>\nchar *TrimStr(char *str);<\/p>\n<p>\/\/&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br \/>\n#endif \/\/ __STRFNC_H<\/p>\n<p>Datei : StrFnc.c<br \/>\n#include &#8222;StrFnc.h&#8220;<br \/>\n#include<br \/>\n#include<\/p>\n<p>\/\/ ********************************************************************<br \/>\n\/\/ returns a string containing a specified number of characters<br \/>\n\/\/ text: the input string<br \/>\n\/\/ start: First char to get<br \/>\n\/\/ length: How much char we extract<br \/>\n\/\/ example: Mid(&#8222;input string&#8220;,2,6) will return &#8218;put st&#8216;<br \/>\n\/\/ ********************************************************************<br \/>\nchar *Mid(char *text, uint16_t start, uint16_t length)<br \/>\n{<br \/>\nuint16_t i;<br \/>\nuint16_t cnt = 0;<br \/>\nstatic char result[80]={&#8222;&#8220;};<\/p>\n<p>for (i=start;i strlen(text)) return result;<br \/>\nresult[cnt] = text[i];<br \/>\ncnt++;<br \/>\n}<br \/>\nreturn result;<br \/>\n}<\/p>\n<p>\/\/ ********************************************************************<br \/>\n\/\/ extracts a substring from a string starting from the left-most character<br \/>\n\/\/ text: the input string<br \/>\n\/\/ nbchar: How much char we extract<br \/>\n\/\/ example: Left(&#8222;input string&#8220;,7) will return &#8218;input s&#8216;<br \/>\n\/\/ ********************************************************************<\/p>\n<p>char *Left(char *text, uint16_t nbchar)<br \/>\n{<br \/>\nstatic char result[80];<\/p>\n<p>if (nbchar &gt; 0 &amp;&amp; nbchar 0 &amp;&amp; length &lt; strlen(text) )<br \/>\n{<br \/>\nstrncpy(result,text + (strlen(text) &#8211; length), length);<br \/>\nresult[length] = &#8220;;<br \/>\n}<br \/>\nreturn result;<br \/>\n}<\/p>\n<p>\/\/ ********************************************************************<br \/>\n\/\/ returns the ASCII value of a character<br \/>\n\/\/ str: the input string<br \/>\n\/\/ example: Asc(&#8222;A&#8220;) will return 65<br \/>\n\/\/ ********************************************************************<br \/>\nuint8_t Asc(char *str)<br \/>\n{<br \/>\nchar a;<\/p>\n<p>a = str[0];<br \/>\nreturn a;<br \/>\n}<\/p>\n<p>\/\/ ********************************************************************<br \/>\n\/\/ Converts the specified ANSI character code to a character<br \/>\n\/\/ value: the character code<br \/>\n\/\/ example: Chr(65) will return &#8218;A&#8216;<br \/>\n\/\/ ********************************************************************<br \/>\nchar Chr(uint8_t value)<br \/>\n{<br \/>\nchar a;<\/p>\n<p>a = value;<br \/>\nreturn a;<br \/>\n}<\/p>\n<p>\/\/ ********************************************************************<br \/>\n\/\/ Return the place where String2 start into String1<br \/>\n\/\/ start: where we start to search<br \/>\n\/\/ string1: the input string<br \/>\n\/\/ string2: the string to find into string1<br \/>\n\/\/ example: Instr(&#8222;input string&#8220;,0,&#8220;s&#8220;) will return 6<br \/>\n\/\/ ********************************************************************<br \/>\nuint16_t Instr(uint16_t start, char *string1, char *string2)<br \/>\n{<br \/>\nuint16_t i;<\/p>\n<p>for(i=start;i&lt;strlen(string1);i++)<br \/>\nif(string1[i] == string2[0]) return i;<br \/>\nreturn 0;<br \/>\n}<\/p>\n<p>\/\/ ********************************************************************<br \/>\n\/\/ Return the string without any space<br \/>\n\/\/ str:the input string<br \/>\n\/\/ example: TrimStr(&#8222;&#8220;. bla bla bla bla bla .&#8220;) will return &#8218;.blablablablabla.&#8216;<br \/>\n\/\/ ********************************************************************<br \/>\nchar *TrimStr(char *str)<br \/>\n{<br \/>\nuint16_t i = 0;<br \/>\nuint16_t cnt = 0;<br \/>\nstatic char result[80];<\/p>\n<p>for (i=0; i &lt;= strlen(str) &#8211; 1 ; i++)<br \/>\nif(str[i]!=&#8216; &#8218;)<br \/>\n{<br \/>\nresult[cnt] = str[i];<br \/>\ncnt++;<br \/>\n}<br \/>\nresult[cnt]=0;<br \/>\nreturn result;<br \/>\n}<\/p>\n<p>Gruss.<\/p>\n<p>Fabrice.<\/p>\n<\/div>\n<\/div>\n<p><!-- #comment-## --><\/p>\n<ul class=\"children\">\n<li id=\"li-comment-1429\" class=\"comment byuser comment-author-admin_ub bypostauthor even depth-2\">\n<div id=\"comment-1429\">\n<div class=\"comment-author vcard\"><img loading=\"lazy\" decoding=\"async\" class=\"avatar avatar-40 photo\" src=\"http:\/\/0.gravatar.com\/avatar\/67426419ead44d5afa132e92685bb460?s=40&amp;d=http%3A%2F%2F0.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D40&amp;r=G\" alt=\"\" width=\"40\" height=\"40\" \/><cite class=\"fn\">admin_ub<\/cite> <span class=\"says\">sagt:<\/span><\/div>\n<p><!-- .comment-author .vcard --><\/p>\n<div class=\"comment-meta commentmetadata\">2. M\u00e4rz 2014 um 10:16<\/div>\n<p><!-- .comment-meta .commentmetadata --><\/p>\n<div class=\"comment-body\">\n<p>danke, habe 3 St\u00fcck hinzugef\u00fcgt.<\/p>\n<\/div>\n<\/div>\n<p><!-- #comment-## --><\/li>\n<\/ul>\n<\/li>\n<li id=\"li-comment-1379\" class=\"comment odd alt thread-even depth-1\">\n<div id=\"comment-1379\">\n<div class=\"comment-author vcard\"><img loading=\"lazy\" decoding=\"async\" class=\"avatar avatar-40 photo\" src=\"http:\/\/1.gravatar.com\/avatar\/9fd3d5bde6304cf9f30120d717721ef9?s=40&amp;d=http%3A%2F%2F1.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D40&amp;r=G\" alt=\"\" width=\"40\" height=\"40\" \/><cite class=\"fn\"><a class=\"url\" href=\"https:\/\/sites.google.com\/site\/suprabotics\/\" rel=\"external nofollow\">Fabrice<\/a><\/cite> <span class=\"says\">sagt:<\/span><\/div>\n<p><!-- .comment-author .vcard --><\/p>\n<div class=\"comment-meta commentmetadata\">12. Februar 2014 um 20:04<\/div>\n<p><!-- .comment-meta .commentmetadata --><\/p>\n<div class=\"comment-body\">\n<p>Urgenswie sind 2 includes nicht sichtbar <img decoding=\"async\" class=\"wp-smiley\" src=\"wp-includes\/images\/smilies\/icon_smile.gif\" alt=\":)\" \/><br \/>\n#include \u201cStrFnc.h\u201d<br \/>\n#include<br \/>\n#include<br \/>\nHoffen das dieses mal gut ist <img decoding=\"async\" class=\"wp-smiley\" src=\"wp-includes\/images\/smilies\/icon_smile.gif\" alt=\":)\" \/><\/p>\n<\/div>\n<\/div>\n<p><!-- #comment-## --><\/li>\n<li id=\"li-comment-1380\" class=\"comment even thread-odd thread-alt depth-1\">\n<div id=\"comment-1380\">\n<div class=\"comment-author vcard\"><img loading=\"lazy\" decoding=\"async\" class=\"avatar avatar-40 photo\" src=\"http:\/\/1.gravatar.com\/avatar\/9fd3d5bde6304cf9f30120d717721ef9?s=40&amp;d=http%3A%2F%2F1.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D40&amp;r=G\" alt=\"\" width=\"40\" height=\"40\" \/><cite class=\"fn\"><a class=\"url\" href=\"https:\/\/sites.google.com\/site\/suprabotics\/\" rel=\"external nofollow\">Fabrice<\/a><\/cite> <span class=\"says\">sagt:<\/span><\/div>\n<p><!-- .comment-author .vcard --><\/p>\n<div class=\"comment-meta commentmetadata\">12. Februar 2014 um 20:06<\/div>\n<p><!-- .comment-meta .commentmetadata --><\/p>\n<div class=\"comment-body\">\n<p>Nah ! , dan ist ein bug ins der blog message oder etwas ich nicht weis .<br \/>\nDie 2 nicht sichtbar include sind :<br \/>\nstdlib.h und cstring.h<\/p>\n<\/div>\n<\/div>\n<p><!-- #comment-## --><\/li>\n<li id=\"li-comment-1425\" class=\"comment odd alt thread-even depth-1\">\n<div id=\"comment-1425\">\n<div class=\"comment-author vcard\"><img loading=\"lazy\" decoding=\"async\" class=\"avatar avatar-40 photo\" src=\"http:\/\/0.gravatar.com\/avatar\/c309f58e046d09ef114e7c1e72af3896?s=40&amp;d=http%3A%2F%2F0.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D40&amp;r=G\" alt=\"\" width=\"40\" height=\"40\" \/><cite class=\"fn\">AmirMohammad<\/cite> <span class=\"says\">sagt:<\/span><\/div>\n<p><!-- .comment-author .vcard --><\/p>\n<div class=\"comment-meta commentmetadata\">28. Februar 2014 um 07:44<\/div>\n<p><!-- .comment-meta .commentmetadata --><\/p>\n<div class=\"comment-body\">\n<p>Hi<br \/>\nby using the following step , you can use \u201csprintf\u201d for float variables.<\/p>\n<p>*** just select \u201cC Library\u201d from \u201cRepository\u201d ***<\/p>\n<p>See photos below:<br \/>\n<a href=\"..\/..\/www.up2www.com\/uploads\/1393565617431.png\" rel=\"nofollow\">http:\/\/www.up2www.com\/uploads\/1393565617431.png<\/a><br \/>\n<a href=\"..\/..\/www.up2www.com\/uploads\/139356561752.png\" rel=\"nofollow\">http:\/\/www.up2www.com\/uploads\/139356561752.png<\/a><br \/>\n<a href=\"..\/..\/www.up2www.com\/uploads\/1393565617573.png\" rel=\"nofollow\">http:\/\/www.up2www.com\/uploads\/1393565617573.png<\/a><br \/>\n<a href=\"..\/..\/www.up2www.com\/uploads\/1393565617644.png\" rel=\"nofollow\">http:\/\/www.up2www.com\/uploads\/1393565617644.png<\/a><\/p>\n<p>Source Code + Pictures in OneDrive:<br \/>\n<a href=\"https:\/\/onedrive.live.com\/redir?resid=EBE5A8A1DBF2F082!165&amp;authkey=!ALTSaXOwAP3VavM&amp;ithint\" rel=\"nofollow\">https:\/\/onedrive.live.com\/redir?resid=EBE5A8A1DBF2F082!165&amp;authkey=!ALTSaXOwAP3VavM&amp;ithint<\/a><\/p>\n<\/div>\n<\/div>\n<p><!-- #comment-## --><\/p>\n<ul class=\"children\">\n<li id=\"li-comment-1426\" class=\"comment byuser comment-author-admin_ub bypostauthor even depth-2\">\n<div id=\"comment-1426\">\n<div class=\"comment-author vcard\"><img loading=\"lazy\" decoding=\"async\" class=\"avatar avatar-40 photo\" src=\"http:\/\/0.gravatar.com\/avatar\/67426419ead44d5afa132e92685bb460?s=40&amp;d=http%3A%2F%2F0.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D40&amp;r=G\" alt=\"\" width=\"40\" height=\"40\" \/><cite class=\"fn\">admin_ub<\/cite> <span class=\"says\">sagt:<\/span><\/div>\n<p><!-- .comment-author .vcard --><\/p>\n<div class=\"comment-meta commentmetadata\">1. M\u00e4rz 2014 um 10:56<\/div>\n<p><!-- .comment-meta .commentmetadata --><\/p>\n<div class=\"comment-body\">\n<p>ok, thanks<br \/>\nin combination with the \u201cretarget printf\u201d Library from CooCox the \u201c%f\u201d didn\u2019t work. The naked \u201cC Library\u201d reserverd a lot of flash, but you are right.<\/p>\n<\/div>\n<\/div>\n<p><!-- #comment-## --><\/li>\n<\/ul>\n<\/li>\n<li id=\"li-comment-2650\" class=\"comment odd alt thread-odd thread-alt depth-1\">\n<div id=\"comment-2650\">\n<div class=\"comment-author vcard\"><img loading=\"lazy\" decoding=\"async\" class=\"avatar avatar-40 photo\" src=\"http:\/\/0.gravatar.com\/avatar\/4b14cef9e5c5fafc2ec87e19388a66e3?s=40&amp;d=http%3A%2F%2F0.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D40&amp;r=G\" alt=\"\" width=\"40\" height=\"40\" \/><cite class=\"fn\">Mustafa<\/cite> <span class=\"says\">sagt:<\/span><\/div>\n<p><!-- .comment-author .vcard --><\/p>\n<div class=\"comment-meta commentmetadata\">7. Dezember 2014 um 16:02<\/div>\n<p><!-- .comment-meta .commentmetadata --><\/p>\n<div class=\"comment-body\">\n<p>I\u2019ve discovered this library and been using it in my SDIO code for data logging. Thank you for making this.<\/p>\n<\/div>\n<\/div>\n<p><!-- #comment-## --><\/li>\n<li id=\"li-comment-3360\" class=\"comment even thread-even depth-1\">\n<div id=\"comment-3360\">\n<div class=\"comment-author vcard\"><img loading=\"lazy\" decoding=\"async\" class=\"avatar avatar-40 photo\" src=\"http:\/\/0.gravatar.com\/avatar\/e0d6fe76b57df72af3fc300acf637642?s=40&amp;d=http%3A%2F%2F0.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D40&amp;r=G\" alt=\"\" width=\"40\" height=\"40\" \/><cite class=\"fn\">Joe<\/cite> <span class=\"says\">sagt:<\/span><\/div>\n<p><!-- .comment-author .vcard --><\/p>\n<div class=\"comment-meta commentmetadata\">25. Juni 2015 um 23:54<\/div>\n<p><!-- .comment-meta .commentmetadata --><\/p>\n<div class=\"comment-body\">\n<p>Ich habe bemerkt dass die Funktion UB_String_FloatToDezStr am Randbereich nicht mehr richtig funktioniert.<br \/>\nAlso wird z.B. bei der Einstellung von zwei Nachkommastellen aus 24.999 dann anstatt 25.00.<\/p>\n<\/div>\n<\/div>\n<p><!-- #comment-## --><\/p>\n<ul class=\"children\">\n<li id=\"li-comment-3361\" class=\"comment odd alt depth-2\">\n<div id=\"comment-3361\">\n<div class=\"comment-author vcard\"><img loading=\"lazy\" decoding=\"async\" class=\"avatar avatar-40 photo\" src=\"http:\/\/0.gravatar.com\/avatar\/a1409b1fe6254bc7fbdcfa48b73a1ee9?s=40&amp;d=http%3A%2F%2F0.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D40&amp;r=G\" alt=\"\" width=\"40\" height=\"40\" \/><cite class=\"fn\">Joerg B.<\/cite> <span class=\"says\">sagt:<\/span><\/div>\n<p><!-- .comment-author .vcard --><\/p>\n<div class=\"comment-meta commentmetadata\">26. Juni 2015 um 07:58<\/div>\n<p><!-- .comment-meta .commentmetadata --><\/p>\n<div class=\"comment-body\">\n<p>Schon mal Zahlen gerundet? ab 6 wird aufgerundet\u2026. was wird dann wohl aus 24,999 ???<\/p>\n<\/div>\n<\/div>\n<p><!-- #comment-## --><\/li>\n<\/ul>\n<\/li>\n<li id=\"li-comment-3363\" class=\"comment even thread-odd thread-alt depth-1\">\n<div id=\"comment-3363\">\n<div class=\"comment-author vcard\"><img loading=\"lazy\" decoding=\"async\" class=\"avatar avatar-40 photo\" src=\"http:\/\/0.gravatar.com\/avatar\/e0d6fe76b57df72af3fc300acf637642?s=40&amp;d=http%3A%2F%2F0.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D40&amp;r=G\" alt=\"\" width=\"40\" height=\"40\" \/><cite class=\"fn\">Joe<\/cite> <span class=\"says\">sagt:<\/span><\/div>\n<p><!-- .comment-author .vcard --><\/p>\n<div class=\"comment-meta commentmetadata\">26. Juni 2015 um 21:58<\/div>\n<p><!-- .comment-meta .commentmetadata --><\/p>\n<div class=\"comment-body\">\n<p>Das aufgerundet wird ist mir schon klar! Ich wollte hier nur zum Ausdruck bringen dass sich die Lib am Randbereich eben nicht wie z.B. sprintf verh\u00e4lt, was manche m\u00f6glicherweise erwarten.<\/p>\n<p>Oben fehlt leider ein Teil meines Satzes.<br \/>\nGemeint war dass z.B. bei sprintf bei der Einstellung von zwei Nachkommastellen aus 24.999 dann 25.00 macht. Diese Lib hier macht aus 24.999 dann 24.10.<\/p>\n<\/div>\n<\/div>\n<p><!-- #comment-## --><\/p>\n<ul class=\"children\">\n<li id=\"li-comment-4520\" class=\"comment odd alt depth-2\">\n<div id=\"comment-4520\">\n<div class=\"comment-author vcard\"><img loading=\"lazy\" decoding=\"async\" class=\"avatar avatar-40 photo\" src=\"http:\/\/1.gravatar.com\/avatar\/5db14fc61285f3acbcdf427f1950cda2?s=40&amp;d=http%3A%2F%2F1.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D40&amp;r=G\" alt=\"\" width=\"40\" height=\"40\" \/><cite class=\"fn\">Thomas<\/cite> <span class=\"says\">sagt:<\/span><\/div>\n<p><!-- .comment-author .vcard --><\/p>\n<div class=\"comment-meta commentmetadata\">15. Januar 2016 um 10:45<\/div>\n<p><!-- .comment-meta .commentmetadata --><\/p>\n<div class=\"comment-body\">\n<p>Zwei kleine \u00c4nderungen in der Funktion UB_String_FloatToDezStr beheben das Problem.<br \/>\nDas Runden einfach direkt am Anfang machen und es unten entfernen.<\/p>\n<p>void UB_String_FloatToDezStr(float wert, char* buffer)<br \/>\n{<br \/>\nwert += 0.5 \/ STRING_FLOAT_FAKTOR;<br \/>\n\u2026..<br \/>\nnachkomma = (uint16_t)(rest*(float)(STRING_FLOAT_FAKTOR));<br \/>\n\u2026..<br \/>\n}<\/p>\n<\/div>\n<\/div>\n<p><!-- #comment-## --><\/li>\n<\/ul>\n<\/li>\n<\/ol>\n","protected":false},"excerpt":{"rendered":"<p>Das hier ist weniger eine Library als eine Hilfe in C-Programmierung. Aber weil viele Fragen dazu gestellt wurden, hab ich das jetzt in ein File gepackt. Es geht um das konvertieren von Zahlen in Strings und umgekehrt. Im Beispiel sind &hellip; <a href=\"https:\/\/mikrocontroller.bplaced.net\/wordpress\/?page_id=485\">Weiterlesen <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"parent":144,"menu_order":75,"comment_status":"open","ping_status":"closed","template":"","meta":{"footnotes":""},"categories":[128],"tags":[9,7,231],"class_list":["post-485","page","type-page","status-publish","hentry","category-stm32f4","tag-library","tag-stm32f4","tag-string"],"_links":{"self":[{"href":"https:\/\/mikrocontroller.bplaced.net\/wordpress\/index.php?rest_route=\/wp\/v2\/pages\/485","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/mikrocontroller.bplaced.net\/wordpress\/index.php?rest_route=\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/mikrocontroller.bplaced.net\/wordpress\/index.php?rest_route=\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/mikrocontroller.bplaced.net\/wordpress\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/mikrocontroller.bplaced.net\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=485"}],"version-history":[{"count":3,"href":"https:\/\/mikrocontroller.bplaced.net\/wordpress\/index.php?rest_route=\/wp\/v2\/pages\/485\/revisions"}],"predecessor-version":[{"id":1614,"href":"https:\/\/mikrocontroller.bplaced.net\/wordpress\/index.php?rest_route=\/wp\/v2\/pages\/485\/revisions\/1614"}],"up":[{"embeddable":true,"href":"https:\/\/mikrocontroller.bplaced.net\/wordpress\/index.php?rest_route=\/wp\/v2\/pages\/144"}],"wp:attachment":[{"href":"https:\/\/mikrocontroller.bplaced.net\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=485"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mikrocontroller.bplaced.net\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=485"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mikrocontroller.bplaced.net\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=485"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}