Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: TS_DISCO_F746NG LCD_DISCO_F746NG BSP_DISCO_F746NG BUTTON_GROUP Arduino
Diff: Functions.h
- Revision:
- 3:e7e663758e6d
- Parent:
- 2:65480fe798bf
- Child:
- 4:0ce191d3f0ce
--- a/Functions.h Sun Dec 20 01:41:00 2020 +0000
+++ b/Functions.h Sun Dec 20 14:23:23 2020 +0000
@@ -1,5 +1,6 @@
#ifndef FUNCTIONS_H
#define FUNCTIONS_H
+using namespace ButGrp;
void PressButton()
{
@@ -10,4 +11,100 @@
BSP_LCD_DisplayStringAt(0, LINE(6), (uint8_t *) str, CENTER_MODE);
}
+void GestioneButton()
+{
+ int num;
+ bool touched = bGroup.GetTouchedNumber(num, LCD_COLOR_DARKBLUE);
+
+ if (touched) {
+ char str[20];
+ BSP_LCD_.SetFont(&Font16);
+ BSP_LCD_.SetTextColor(LCD_COLOR_WHITE);
+ sprintf(str, "Button%d pressed", num+1);
+ BSP_LCD_.DisplayStringAt(X1, Y1, (uint8_t *)str, LEFT_MODE);
+
+ reset.Redraw();
+ }
+
+ if (sw.Touched(0, LCD_COLOR_DARKGREEN))
+ BSP_LCD_.DisplayStringAt(X1, 210, (uint8_t *)"ON ", LEFT_MODE);
+ if (sw.Touched(1, LCD_COLOR_DARKGREEN))
+ BSP_LCD_.DisplayStringAt(X1, 210, (uint8_t *)"OFF", LEFT_MODE);
+
+ if (reset.Touched()) {
+ bGroup.Redraw(num);
+ reset.Draw(INACTIVE, LCD_COLOR_GRAY);
+ BSP_LCD_.SetFont(&Font16);
+ BSP_LCD_.DisplayStringAt(X1, Y1, (uint8_t *)" ", LEFT_MODE);
+ }
+
+ int mNum;
+ if (multiTouch.GetTouchedNumber(mNum, LCD_COLOR_DARKBLUE)) {
+ Button::SetMultiTouch(mNum == 0); // Set or reset multi-touch
+ if (mNum == 0)
+ BSP_LCD_.DisplayStringAt(320, Y0+150, (uint8_t *)"ON ", LEFT_MODE);
+ else
+ BSP_LCD_.DisplayStringAt(320, Y0+150, (uint8_t *)"OFF", LEFT_MODE);
+ }
+ wait(0.01f);
+
+}
+
+void GestioneTouch()
+{
+ static uint16_t x=0, y=0;
+ uint8_t text[30];
+ uint8_t idx;
+ uint8_t cleared = 0;
+ uint8_t prev_nb_touches = 0;
+ BSP_TS_GetState(&TS_State);
+ if (TS_State.touchDetected) {
+ // Clear lines corresponding to old touches coordinates
+ if (TS_State.touchDetected < prev_nb_touches) {
+ for (idx = (TS_State.touchDetected + 1); idx <= 5; idx++) {
+ BSP_LCD_ClearStringLine(idx);
+ }
+ }
+ prev_nb_touches = TS_State.touchDetected;
+
+ cleared = 0;
+
+ sprintf((char*)text, "Touches: %d", TS_State.touchDetected);
+ BSP_LCD_DisplayStringAt(0, LINE(0), (uint8_t *)&text, LEFT_MODE);
+
+ BSP_LCD_DrawPixel(x, y, LCD_COLOR_BLACK);
+ for (idx = 0; idx < TS_State.touchDetected; idx++) {
+ x = TS_State.touchX[idx];
+ y = TS_State.touchY[idx];
+ sprintf((char*)text, "Touch %d: x=%d y=%d ", idx+1, x, y);
+ BSP_LCD_DisplayStringAt(0, LINE(idx+1), (uint8_t *)&text, LEFT_MODE);
+ }
+
+ BSP_LCD_DrawPixel(TS_State.touchX[0], TS_State.touchY[0], LCD_COLOR_WHITE);
+ } else {
+ if (!cleared) {
+ sprintf((char*)text, "Touches: 0");
+ BSP_LCD_DisplayStringAt(0, LINE(0), (uint8_t *)&text, LEFT_MODE);
+ cleared = 1;
+ }
+ }
+}
+
+void SetLayer(int numlayer)
+{
+ // vedere come passare BSPLCD_
+ for (int idx = 0; idx < NUMLAYER; idx++) {
+ sprintf(str, "Touches: %d",idx);
+ BSP_LCD_DisplayStringAt(0, LINE(12+idx), (uint8_t *)&str, LEFT_MODE);
+ if (idx==numlayer) {
+ BSP_LCD_SelectLayer(idx);
+ BSP_LCD_SetLayerVisible(idx, ENABLE);
+ BSP_LCD_DisplayStringAt(50, LINE(12+idx), (uint8_t *)"ON", RIGHT_MODE);
+ } else {
+ BSP_LCD_SetLayerVisible(idx, DISABLE);
+ BSP_LCD_DisplayStringAt(50, LINE(12+idx), (uint8_t *)"OFF", RIGHT_MODE);
+ }
+ }
+}
+
#endif
\ No newline at end of file