wordfrequency

Dependencies:   LCD_DISCO_F429ZI mbed TS_DISCO_F429ZI BSP_DISCO_F429ZI

Revision:
0:349c994479c8
Child:
1:586013f67abf
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Sat Dec 05 21:12:01 2020 +0000
@@ -0,0 +1,70 @@
+#include "mbed.h"
+#include "TS_DISCO_F429ZI.h"
+#include "LCD_DISCO_F429ZI.h"
+
+LCD_DISCO_F429ZI lcd;
+TS_DISCO_F429ZI ts;
+
+
+extern "C" int32_t CountItems();
+extern "C" int32_t SumAllFrequencies();
+extern "C" uint8_t * GetWordAt(int32_t i);   // NOTE: returns a pointer to a string
+extern "C" int16_t GetFreqAt(int32_t i);      // NOTE: return the value of the frequency count
+
+int16_t words;
+
+int main()
+{
+    TS_StateTypeDef TS_State;
+    uint16_t x, y;
+    uint8_t text[30];
+    uint8_t status;
+  
+    BSP_LCD_SetFont(&Font20);
+  
+    lcd.DisplayStringAt(0, LINE(5), (uint8_t *)"TOUCHSCREEN", CENTER_MODE);
+    lcd.DisplayStringAt(0, LINE(6), (uint8_t *)"DEMO", CENTER_MODE);
+    wait(1);
+  
+    status = ts.Init(lcd.GetXSize(), lcd.GetYSize());
+  
+    if (status != TS_OK)
+    {
+      lcd.Clear(LCD_COLOR_RED);
+      lcd.SetBackColor(LCD_COLOR_RED);
+      lcd.SetTextColor(LCD_COLOR_WHITE);
+      lcd.DisplayStringAt(0, LINE(5), (uint8_t *)"TOUCHSCREEN", CENTER_MODE);
+      lcd.DisplayStringAt(0, LINE(6), (uint8_t *)"INIT FAIL", CENTER_MODE);
+    }
+    else
+    {
+      lcd.Clear(LCD_COLOR_GREEN);
+      lcd.SetBackColor(LCD_COLOR_GREEN);
+      lcd.SetTextColor(LCD_COLOR_WHITE);
+      lcd.DisplayStringAt(0, LINE(5), (uint8_t *)"TOUCHSCREEN", CENTER_MODE);
+      lcd.DisplayStringAt(0, LINE(6), (uint8_t *)"INIT OK", CENTER_MODE);
+    }
+    
+    wait(1);
+    lcd.Clear(LCD_COLOR_BLUE);
+    lcd.SetBackColor(LCD_COLOR_BLUE);
+    lcd.SetTextColor(LCD_COLOR_WHITE);
+    
+    words = CountItems();
+    
+    while(1)
+    {
+      
+      ts.GetState(&TS_State);      
+      if (TS_State.TouchDetected)
+      {
+        x = TS_State.X;
+        y = TS_State.Y;
+        sprintf((char*)text, "x=%d y=%d    ", x, y);
+        lcd.DisplayStringAt(0, LINE(0), (uint8_t *)&text, LEFT_MODE);
+      }
+       sprintf((char*)text, "words=%d", words);
+       lcd.DisplayStringAt(0, LINE(0), (uint8_t *)&text, CENTER);
+      
+    }
+}