{"id":313,"date":"2017-11-23T20:58:46","date_gmt":"2017-11-23T19:58:46","guid":{"rendered":"http:\/\/mikrocontroller.bplaced.net\/wordpress\/?page_id=313"},"modified":"2017-12-30T19:30:15","modified_gmt":"2017-12-30T18:30:15","slug":"15-touch_stmpe811-library-stm32f429","status":"publish","type":"page","link":"https:\/\/mikrocontroller.bplaced.net\/wordpress\/?page_id=313","title":{"rendered":"15-Touch_STMPE811-Library (STM32F429)"},"content":{"rendered":"<p><div id=\"nav-below\" class=\"navigation\"><div class=\"nav-previous\"><a href=\"https:\/\/mikrocontroller.bplaced.net\/wordpress\/?page_id=311\" title=\"14-I2C_LoLevel-Library (STM32F429)\"><span class=\"meta-nav\">\u2190<\/span> 14-I2C_LoLevel-Library (STM32F429)<\/a><\/div><\/div><!-- #nav-below --><div id=\"nav-below\" class=\"navigation\"><div class=\"nav-next\"><a href=\"https:\/\/mikrocontroller.bplaced.net\/wordpress\/?page_id=315\" title=\"16-SPI_LoLevel_HalfDuplex-Library (STM32F429)\">16-SPI_LoLevel_HalfDuplex-Library (STM32F429) <span class=\"meta-nav\">&rarr;<\/span><\/a><\/div><\/div><!-- #nav-below --><\/p>\n<p>diese Library dient zum auswerten eines 4Wire-Touch mit einem STMPE811-Chip<br \/>\n(das ist der Chip, der auf dem STM32F429 Discovery-Board eingebaut ist)<\/p>\n<p>der Controller h\u00e4ngt am I2C-Bus (I2C3) also wird diese <a href=\"http:\/\/mikrocontroller.bplaced.net\/wordpress\/?page_id=311\">I2C-Library<\/a> zus\u00e4tzlich ben\u00f6tigt.<\/p>\n<p>der Touch scheint mir besser zu funktionieren wie der auf meinem STM32F407-Board (aber probiert es selbst mal aus)<\/p>\n<p><strong>Beispielbild :<\/strong><\/p>\n<p><a href=\"wp-content\/uploads\/2013\/11\/touch_f429.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-2895\" src=\"wp-content\/uploads\/2013\/11\/touch_f429-179x300.jpg\" alt=\"touch_f429\" width=\"179\" height=\"300\" \/><\/a><\/p>\n<p><strong>Benutzte Pins :<\/strong><\/p>\n<pre lang=\"c\" line=\"1\">SCL = PA8\r\nSDA = PC9<\/pre>\n<p><strong>Globale Struktur :<\/strong><\/p>\n<pre lang=\"c\" line=\"1\">typedef struct {\r\n  Touch_Status_t status; \/\/ [TOUCH_PRESSED, TOUCH_RELEASED]\r\n  uint16_t xp;           \/\/ [0...239]\r\n  uint16_t yp;           \/\/ [0...319]\r\n}Touch_Data_t;\r\nTouch_Data_t Touch_Data;<\/pre>\n<p><strong>Funktionen :<\/strong><\/p>\n<pre lang=\"c\" line=\"1\">ErrorStatus UB_Touch_Init(void); \/\/ zum init und check vom Touch\r\nErrorStatus UB_Touch_Read(void); \/\/ um die Touch Daten auszulesen<\/pre>\n<p><strong>Beispiel :<\/strong><\/p>\n<pre lang=\"c\" line=\"1\">\/\/--------------------------------------------------------------\r\n\/\/ File     : main.c\r\n\/\/ Datum    : 03.11.2013\r\n\/\/ Version  : 1.1\r\n\/\/ Autor    : UB\r\n\/\/ EMail    : mc-4u(@)t-online.de\r\n\/\/ Web      : www.mikrocontroller-4u.de\r\n\/\/ CPU      : STM32F429\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 Touch-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\/\/ In Configuration diese Define hinzuf\u00fcgen :\r\n\/\/ \"STM32F429_439xx\" , \"__ASSEMBLY__\" , \"USE_STDPERIPH_DRIVER\"\r\n\/\/--------------------------------------------------------------\r\n\r\n#include \"main.h\"\r\n#include \"stm32_ub_lcd_ili9341.h\"\r\n#include \"stm32_ub_font.h\"\r\n#include \"stm32_ub_touch_stmpe811.h\"\r\n#include &lt;stdio.h&gt;\r\n\r\nint main(void)\r\n{\r\n  uint16_t xp,yp;\r\n  char buf[30];\r\n\r\n  SystemInit(); \/\/ Quarz Einstellungen aktivieren\r\n\r\n  \/\/ Init vom LCD\r\n  UB_LCD_Init();\r\n  \/\/ Init der Layer\r\n  UB_LCD_LayerInit_Fullscreen();\r\n  \/\/ auf Hintergrund schalten\r\n  UB_LCD_SetLayer_1();\r\n  \/\/ Hintergrund komplett mit einer Farbe f\u00fcllen\r\n  UB_LCD_FillLayer(RGB_COL_WHITE);\r\n  \/\/ auf Vordergrund schalten\r\n  UB_LCD_SetLayer_2();\r\n  \/\/ Vordergrund komplett mit einer Farbe f\u00fcllen\r\n  UB_LCD_FillLayer(RGB_COL_GREEN);\r\n\r\n  \/\/ Ueberschrift\r\n  UB_Font_DrawString(10,10,\"Demo_15 :     \",&amp;Arial_11x18,RGB_COL_WHITE,RGB_COL_RED);\r\n  UB_Font_DrawString(10,30,\"Touch STMPE811\",&amp;Arial_11x18,RGB_COL_WHITE,RGB_COL_RED);\r\n\r\n  \/\/ init und Check vom Touch\r\n  if(UB_Touch_Init()!=SUCCESS) {\r\n    UB_Font_DrawString(10,70,\"Error\",&amp;Arial_11x18,RGB_COL_WHITE,RGB_COL_RED);\r\n    while(1);\r\n  }\r\n\r\n  while(1)\r\n  {\r\n    \/\/ Touch auslesen\r\n    UB_Touch_Read();\r\n    if(Touch_Data.status==TOUCH_PRESSED) {\r\n      UB_Font_DrawString(10,70,\"Pressed \",&amp;Arial_11x18,RGB_COL_BLACK,RGB_COL_GREEN);\r\n      xp=Touch_Data.xp;\r\n      yp=Touch_Data.yp;\r\n      \/\/ XY-Koordinaten anzeigen\r\n      sprintf(buf,\"X=%4d\",xp);\r\n      UB_Font_DrawString(10,90,buf,&amp;Arial_11x18,RGB_COL_BLACK,RGB_COL_GREEN);\r\n      sprintf(buf,\"Y=%4d\",yp);\r\n      UB_Font_DrawString(10,110,buf,&amp;Arial_11x18,RGB_COL_BLACK,RGB_COL_GREEN);\r\n      \/\/ einen Punkt an XY-Koordinate zeichnen\r\n      UB_LCD_SetCursor2Draw(xp,yp);\r\n      UB_LCD_DrawPixel(RGB_COL_BLACK);\r\n    }\r\n    else {\r\n      UB_Font_DrawString(10,70,\"Released\",&amp;Arial_11x18,RGB_COL_BLACK,RGB_COL_GREEN);\r\n      UB_Font_DrawString(10,90,\"       \",&amp;Arial_11x18,RGB_COL_BLACK,RGB_COL_GREEN);\r\n      UB_Font_DrawString(10,110,\"       \",&amp;Arial_11x18,RGB_COL_BLACK,RGB_COL_GREEN);\r\n    }\r\n  }\r\n}\r\n<\/pre>\n<p>Hier die Library zum\u00a0<strong>Download :<\/strong><\/p>\n<p><a href=\"wp-content\/uploads\/2013\/11\/touch_stmpe811_f429_v100.zip\">touch_stmpe811_f429_v100<\/a><\/p>\n<p>Hier der komplette CooCox-Projektordner zum\u00a0<strong>Download :<\/strong><\/p>\n<p><a href=\"wp-content\/uploads\/2013\/11\/Demo_F429_15.zip\">Demo_F429_15<\/a><\/p>\n<hr \/>\n<h3 id=\"comments-title\">8 Antworten auf <em>15-Touch_STMPE811-Library (STM32F429)<\/em><\/h3>\n<ol class=\"commentlist\">\n<li id=\"li-comment-1485\" class=\"comment even thread-even depth-1\">\n<div id=\"comment-1485\">\n<div class=\"comment-author vcard\"><img loading=\"lazy\" decoding=\"async\" class=\"avatar avatar-40 photo\" src=\"http:\/\/1.gravatar.com\/avatar\/7a04d60e57c7da266ee9a499e5bca673?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\">Burkhard<\/cite> <span class=\"says\">sagt:<\/span><\/div>\n<p><!-- .comment-author .vcard --><\/p>\n<div class=\"comment-meta commentmetadata\">21. M\u00e4rz 2014 um 22:56<\/div>\n<p><!-- .comment-meta .commentmetadata --><\/p>\n<div class=\"comment-body\">\n<p>Bekomme ganz oft die Werte X=239 Y=0 obwohl ich nicht mal in der N\u00e4he bin. Hast du eine Erkl\u00e4rung daf\u00fcr? Kann den Fehler nicht finden.<\/p>\n<\/div>\n<\/div>\n<p><!-- #comment-## --><\/p>\n<ul class=\"children\">\n<li id=\"li-comment-1487\" class=\"comment byuser comment-author-admin_ub bypostauthor odd alt depth-2\">\n<div id=\"comment-1487\">\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\">22. M\u00e4rz 2014 um 21:29<\/div>\n<p><!-- .comment-meta .commentmetadata --><\/p>\n<div class=\"comment-body\">\n<p>Ja, das Problem kenne ich. Scheint ein BUG vom Touch zu sein (oder von der Kalibrierung). Ich hab als \u201cWorkaround\u201d meist eine Valid-Abfrage.<\/p>\n<pre lang=\"c\" line=\"1\">if((x&gt;0 &amp;&amp; x&lt;239) &amp;&amp; (y&gt;0 &amp;&amp; y&lt;319)) {\r\n  \/\/ touch-data valid\r\n}\r\n<\/pre>\n<\/div>\n<\/div>\n<p><!-- #comment-## --><\/p>\n<ul class=\"children\">\n<li id=\"li-comment-1569\" class=\"comment even depth-3\">\n<div id=\"comment-1569\">\n<div class=\"comment-author vcard\"><img loading=\"lazy\" decoding=\"async\" class=\"avatar avatar-40 photo\" src=\"http:\/\/1.gravatar.com\/avatar\/7a04d60e57c7da266ee9a499e5bca673?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\">Burkhard<\/cite> <span class=\"says\">sagt:<\/span><\/div>\n<p><!-- .comment-author .vcard --><\/p>\n<div class=\"comment-meta commentmetadata\">18. April 2014 um 16:42<\/div>\n<p><!-- .comment-meta .commentmetadata --><\/p>\n<div class=\"comment-body\">\n<p>Bei der UB_Touch_Init() bleibt er sehr oft mit \u201cError\u201d h\u00e4ngen(ca. 20%), dann muss ich das Board komplett vom Strom trennen damit es wieder l\u00e4uft. Der Resetbutton reicht nicht. Ist das bei dir auch so? VG Burkhard<\/p>\n<\/div>\n<\/div>\n<p><!-- #comment-## --><\/p>\n<ul class=\"children\">\n<li id=\"li-comment-1571\" class=\"comment byuser comment-author-admin_ub bypostauthor odd alt depth-4\">\n<div id=\"comment-1571\">\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\">19. April 2014 um 09:31<\/div>\n<p><!-- .comment-meta .commentmetadata --><\/p>\n<div class=\"comment-body\">\n<p>nein, er bleib zwar ab und zu h\u00e4ngen, aber nicht so oft. Vlt einmal bei 100 mal PowerOn. Versuch mal nach dem PowerOn eine Pause einzubauen (100ms) vor dem init vom Touch.<\/p>\n<\/div>\n<\/div>\n<p><!-- #comment-## --><\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<\/li>\n<li id=\"li-comment-2023\" class=\"comment even depth-2\">\n<div id=\"comment-2023\">\n<div class=\"comment-author vcard\"><img loading=\"lazy\" decoding=\"async\" class=\"avatar avatar-40 photo\" src=\"http:\/\/1.gravatar.com\/avatar\/5c98d9eb9878155d61ced27149322c1d?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\">Flo<\/cite> <span class=\"says\">sagt:<\/span><\/div>\n<p><!-- .comment-author .vcard --><\/p>\n<div class=\"comment-meta commentmetadata\">7. August 2014 um 23:07<\/div>\n<p><!-- .comment-meta .commentmetadata --><\/p>\n<div class=\"comment-body\">\n<p>Ich habe mir das Modul umgeschrieben, um nur bei Interrupts vom TSC die Koordinaten auszulesen. Da hatte ich auch oft { 239, 0 }. Das passiert scheinbar dann, wenn ein Touch erkannt wird, die Register TSC_DATA_X\/Y aber noch nicht beschrieben sind. Bei mir hat es geholfen, nach dem Touch-Interrupt 3 ms zu warten, bevor ich die Koordinaten auslese. Zu lange darf man allerdings nicht warten, sonst sind die Werte { 0, 0 }.<\/p>\n<p>Ein Tippfehler ist mir in der Library noch aufgefallen:<\/p>\n<p>#define TOUCH_IO_ALL (uint32_t)(IO_Pin_1 | IO_Pin_2 | IO_Pin_3 | IO_Pin_4)<\/p>\n<p>sollte wohl hei\u00dfen:<\/p>\n<p>#define TOUCH_IO_ALL (uint32_t)(IO_Pin_0 | IO_Pin_1 | IO_Pin_2 | IO_Pin_3)<\/p>\n<\/div>\n<\/div>\n<p><!-- #comment-## --><\/p>\n<ul class=\"children\">\n<li id=\"li-comment-2040\" class=\"comment byuser comment-author-admin_ub bypostauthor odd alt depth-3\">\n<div id=\"comment-2040\">\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\">17. August 2014 um 11:36<\/div>\n<p><!-- .comment-meta .commentmetadata --><\/p>\n<div class=\"comment-body\">\n<p>ja, da scheint noch mehr nicht zu stimmen. TOUCH_XD liegt z.B. nicht auf IO_Pin_2. Diese defines werden aber im Programm nicht benutzt.<\/p>\n<\/div>\n<\/div>\n<p><!-- #comment-## --><\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<\/li>\n<li id=\"li-comment-2884\" class=\"comment even thread-odd thread-alt depth-1\">\n<div id=\"comment-2884\">\n<div class=\"comment-author vcard\"><img loading=\"lazy\" decoding=\"async\" class=\"avatar avatar-40 photo\" src=\"http:\/\/1.gravatar.com\/avatar\/bf30e169224e064a88f9720cdf86d608?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\">Ryan<\/cite> <span class=\"says\">sagt:<\/span><\/div>\n<p><!-- .comment-author .vcard --><\/p>\n<div class=\"comment-meta commentmetadata\">11. Februar 2015 um 15:19<\/div>\n<p><!-- .comment-meta .commentmetadata --><\/p>\n<div class=\"comment-body\">\n<p>How can I change the resolution of touch screen?<\/p>\n<\/div>\n<\/div>\n<p><!-- #comment-## --><\/p>\n<ul class=\"children\">\n<li id=\"li-comment-2889\" class=\"comment byuser comment-author-admin_ub bypostauthor odd alt depth-2\">\n<div id=\"comment-2889\">\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\">13. Februar 2015 um 19:05<\/div>\n<p><!-- .comment-meta .commentmetadata --><\/p>\n<div class=\"comment-body\">\n<p>You must change the \u201cP_Touch_Read_X\u201d and \u201cP_Touch_Read_Y\u201d functions.<br \/>\nCheck in Debug-Mode the Raw-Data from the Sensor and adjust the calculation for the pixel-position.<\/p>\n<\/div>\n<\/div>\n<p><!-- #comment-## --><\/li>\n<\/ul>\n<\/li>\n<\/ol>\n","protected":false},"excerpt":{"rendered":"<p>diese Library dient zum auswerten eines 4Wire-Touch mit einem STMPE811-Chip (das ist der Chip, der auf dem STM32F429 Discovery-Board eingebaut ist) der Controller h\u00e4ngt am I2C-Bus (I2C3) also wird diese I2C-Library zus\u00e4tzlich ben\u00f6tigt. der Touch scheint mir besser zu funktionieren &hellip; <a href=\"https:\/\/mikrocontroller.bplaced.net\/wordpress\/?page_id=313\">Weiterlesen <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":3,"featured_media":0,"parent":160,"menu_order":15,"comment_status":"open","ping_status":"closed","template":"","meta":{"footnotes":""},"categories":[129],"tags":[98,9,102,256,143],"class_list":["post-313","page","type-page","status-publish","hentry","category-stm32f429","tag-i2c","tag-library","tag-stm32f429","tag-stmpe811","tag-touch"],"_links":{"self":[{"href":"https:\/\/mikrocontroller.bplaced.net\/wordpress\/index.php?rest_route=\/wp\/v2\/pages\/313","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\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/mikrocontroller.bplaced.net\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=313"}],"version-history":[{"count":4,"href":"https:\/\/mikrocontroller.bplaced.net\/wordpress\/index.php?rest_route=\/wp\/v2\/pages\/313\/revisions"}],"predecessor-version":[{"id":1677,"href":"https:\/\/mikrocontroller.bplaced.net\/wordpress\/index.php?rest_route=\/wp\/v2\/pages\/313\/revisions\/1677"}],"up":[{"embeddable":true,"href":"https:\/\/mikrocontroller.bplaced.net\/wordpress\/index.php?rest_route=\/wp\/v2\/pages\/160"}],"wp:attachment":[{"href":"https:\/\/mikrocontroller.bplaced.net\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=313"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mikrocontroller.bplaced.net\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=313"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mikrocontroller.bplaced.net\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=313"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}