Interfaçage NeoPixel Ring 12, LPRO MECSE, Arnaud A.

Revision:
0:c95a8c8c3c9b
Child:
1:2a58d8fcf7f9
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/view2.cpp	Wed Jun 17 16:34:16 2020 +0000
@@ -0,0 +1,71 @@
+#include "view2.h"
+
+View2::View2(int width, int height) : m_width(width), m_height(height){}
+
+View2::~View2()                                                                                //Destructeur de bouton
+{
+    for (Button * button : m_buttonList) {
+        delete button;
+    }
+    m_buttonList.clear();
+}
+
+
+void View2::contain(int x, int y)
+{
+    if(!screenReleased){
+        screenReleased=true;
+        for (Button * button : m_buttonList) {
+            if (button->contain(x,y)) {
+                
+            }
+        }
+    }
+}
+
+
+void View2::draw()
+{
+    BSP_LCD_Clear(m_bgColor);                                 //Enlève l'affichage du début
+    for (Button * button : m_buttonList) {
+        button->draw();
+    }
+}
+
+
+void View2::initView(){
+    m_bgColor = LCD_COLOR_BLACK;
+    //Animations
+    anim1->setText("Animations1");
+    anim2->setText("Animations2");
+    anim3->setText("Animations3");
+    start->setText("Start animation");
+    stop->setText("Stop animation");
+    //Animations
+    m_buttonList.push_front(anim1);
+    m_buttonList.push_front(anim2);
+    m_buttonList.push_front(anim3);
+    m_buttonList.push_front(start);
+    m_buttonList.push_front(stop);
+}
+
+void View2::updateLCD(){
+    BSP_TS_GetState(&TS_State);
+    if (TS_State.touchDetected) {                                                        //Detecte si l'écran tactile est touché
+        cleared = false;
+        for (idx = 0; idx < TS_State.touchDetected; idx++) {
+            x = TS_State.touchX[idx];
+            y = TS_State.touchY[idx];
+            contain(x, y);
+
+        }
+    } else {
+        screenReleased=false;
+        if (!cleared) {
+            draw();
+            cleared = true;
+
+        }
+    }
+
+}
\ No newline at end of file