This is program 4
Dependencies: LCD_DISCO_F429ZI mbed TS_DISCO_F429ZI BSP_DISCO_F429ZI
Diff: main.cpp
- Revision:
- 2:a38c09fad0fe
- Parent:
- 1:2308340de21d
- Child:
- 3:2ec663c724ea
--- a/main.cpp Sun Dec 06 05:36:32 2020 +0000 +++ b/main.cpp Mon Dec 07 04:03:14 2020 +0000 @@ -10,6 +10,21 @@ LCD_DISCO_F429ZI lcd; TS_DISCO_F429ZI ts; +InterruptIn user_button(USER_BUTTON); + +void button_pressed(){ + lcd.Clear(LCD_COLOR_BLACK); +} + +void button_released(){ + lcd.Clear(LCD_COLOR_RED); +} + +void button_callback(){ + user_button.rise(&button_pressed); + user_button.fall(&button_released); +} + int main() { TS_StateTypeDef TS_State; @@ -29,7 +44,7 @@ { lcd.Clear(LCD_COLOR_RED); lcd.SetBackColor(LCD_COLOR_RED); - lcd.SetTextColor(LCD_COLOR_WHITE); + lcd.SetTextColor(LCD_COLOR_WHIT); lcd.DisplayStringAt(0, LINE(5), (uint8_t *)"TOUCHSCREEN", CENTER_MODE); lcd.DisplayStringAt(0, LINE(6), (uint8_t *)"INIT FAIL", CENTER_MODE); } @@ -47,15 +62,29 @@ lcd.SetBackColor(LCD_COLOR_BLUE); lcd.SetTextColor(LCD_COLOR_WHITE); + + uint8_t *word; + int16_t wordfrequency; + float percentage; + + int32_t MAX = CountItems(); sprintf((char*)text, "MAX=%d", MAX); - lcd.DisplayStringAt(0, LINE(5), (uint8_t *)&text, LEFT_MODE); + lcd.DisplayStringAt(0, LINE(3), (uint8_t *)&text, LEFT_MODE); int32_t totalfrequency = SumAllFrequencies(); sprintf((char*)text, "totalfrequency=%d", totalfrequency); - ;WHEN I CHANGE the next LINE to 6 it messes up - lcd.DisplayStringAt(0, LINE(5), (uint8_t *)&text, LEFT_MODE); + lcd.DisplayStringAt(0, LINE(4), (uint8_t *)&text, LEFT_MODE); while(1) { + button_callback(); + for(int32_t i = 1; i < (MAX + 1); i++){ + word = GetWordAt(i); + wordfrequency = GetFreqAt(i); + percentage = wordfrequency/totalfrequency; + sprintf((char*)text, "word=%d", word); + lcd.DisplayStringAt(0, LINE(5), (uint8_t *)&text, LEFT_MODE); + } + wait(1); } }