
Code sensor IR
Dependencies: BSP_DISCO_F746NG
Diff: view.cpp
- Revision:
- 0:8c1b74ecac29
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/view.cpp Thu Jun 25 16:51:20 2020 +0000 @@ -0,0 +1,73 @@ +#include "view.h" +#include "stm32746g_discovery_lcd.h" +#include "mbed.h" +#include "button.h" +#include <list> +#include "entrer-limiter.h" + +View::View(int width, int height, uint32_t bgColor) + : m_width(width), m_height(height), m_bgColor(bgColor) +{ + Button *butDefault = new Button(100, 200, 150, 40, LCD_COLOR_GREEN,2); + Button *but = new Button(250,200, 150, 40, LCD_COLOR_BLUE,2); + but->setText("-1" ); + butDefault->setText("reset"); + m_buttonList.push_front(butDefault); + m_buttonList.push_front(but); + m_bgColor = LCD_COLOR_RED; + draw(); + +} + +View::~View() +{ + for (Button * it : m_buttonList) { + delete it; + } + m_buttonList.clear(); +} + +void View::drawImage(int offsetX, int offsetY) +{ + int x = 0; + int y = 0; + uint32_t* dataPtr = (uint32_t*)entrerlimiter.data; + while(y < entrerlimiter.height) { + while(x < entrerlimiter.width) { + BSP_LCD_DrawPixel(x + offsetX, y + offsetY, *dataPtr); + dataPtr++; + x++; + } + x = 0; + y++; + } +} + +void View::contain(int x, int y) +{ + int idBut = 0; + for (Button *it : m_buttonList) { + bool memoetat = it->etat(); + if (it->contain(x,y)) { + if (idBut == 0) { + if (!memoetat) { + *i=*i-1; + } + } else { + if (!memoetat) { + *i=0; + } + } + } + idBut++; + } +} + +void View::draw() +{ + BSP_LCD_Clear(m_bgColor); + for (Button *it : m_buttonList) { + it->draw(); + } + +} \ No newline at end of file