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

view.h

Committer:
Rhamao
Date:
2020-06-17
Revision:
5:c4038609e806
Parent:
3:86ea18a6bfff
Child:
6:03acf74857cc

File content as of revision 5:c4038609e806:

#ifndef VIEW_H
#define VIEW_H
#include "mbed.h"
#include "button.h"
#include "stm32746g_discovery_lcd.h"
#include "stm32746g_discovery_ts.h"
#include <list>
#include <stdlib.h>
#define SCREENWIDTH 480
#define SCREENHEIGHT 272
#define LED_BUTTON_SIZE 40
#define RGB_TEXT_VIEW_WIDTH 30
#define RGB_TEXT_VIEW_HEIGHT 15
#define PLUS_MINUS_BUTTON_SIZE 30
#define ANIMATION_BUTTON_WIDTH 80
#define ANIMATION_BUTTON_HEIGHT 15
#define LIGHT_GRAY (uint32_t)0xFFe0e0d1
#include <ESP8266.h>

extern RawSerial pc;
extern RawSerial wifi;


class View
{
public:
    View(int width = SCREENWIDTH, int height = SCREENHEIGHT);
    void contain(int x, int y);
    void draw();
    void updateLCD();
    bool updatePlusMinus(Button* button);
    bool updateLEDS(Button* button);
    bool updateSetNewColorAndCancel(Button* button);
    ~View();
    

private :
    void initLCD();
    void drawText();
    int16_t m_width = SCREENWIDTH;
    int16_t m_height = SCREENHEIGHT;
    uint32_t m_bgColor = LCD_COLOR_WHITE;
    list<Button *> m_buttonList;
    ESP8266 * m_esp;
    TS_StateTypeDef TS_State;
    uint16_t x, y;
    uint8_t idx;
    bool screenReleased=false;
    bool cleared = false;
    uint8_t RGB[3];
    char str[10];
    bool ledSelected[12]={false, false, false, false,
                          false, false, false, false,
                          false, false, false, false};
    //LEDS buttons
    Button *led0 = new Button(300, 5, LED_BUTTON_SIZE, LED_BUTTON_SIZE, LCD_COLOR_BLACK, LCD_COLOR_WHITE);
    Button *led1 = new Button(353, 20, LED_BUTTON_SIZE, LED_BUTTON_SIZE, LCD_COLOR_BLACK, LCD_COLOR_WHITE);
    Button *led2 = new Button(397, 65, LED_BUTTON_SIZE, LED_BUTTON_SIZE, LCD_COLOR_BLACK, LCD_COLOR_WHITE);
    Button *led3 = new Button(410, 118, LED_BUTTON_SIZE, LED_BUTTON_SIZE, LCD_COLOR_BLACK, LCD_COLOR_WHITE);
    Button *led4 = new Button(396, 170, LED_BUTTON_SIZE, LED_BUTTON_SIZE, LCD_COLOR_BLACK, LCD_COLOR_WHITE);
    Button *led5 = new Button(354, 212, LED_BUTTON_SIZE, LED_BUTTON_SIZE, LCD_COLOR_BLACK, LCD_COLOR_WHITE);
    Button *led6 = new Button(300, 227, LED_BUTTON_SIZE, LED_BUTTON_SIZE, LCD_COLOR_BLACK, LCD_COLOR_WHITE);
    Button *led7 = new Button(245, 212, LED_BUTTON_SIZE, LED_BUTTON_SIZE, LCD_COLOR_BLACK, LCD_COLOR_WHITE);
    Button *led8 = new Button(204, 170, LED_BUTTON_SIZE, LED_BUTTON_SIZE, LCD_COLOR_BLACK, LCD_COLOR_WHITE);
    Button *led9 = new Button(190, 118, LED_BUTTON_SIZE, LED_BUTTON_SIZE, LCD_COLOR_BLACK, LCD_COLOR_WHITE);
    Button *led10 = new Button(203, 62, LED_BUTTON_SIZE, LED_BUTTON_SIZE, LCD_COLOR_BLACK, LCD_COLOR_WHITE);
    Button *led11 = new Button(245, 20, LED_BUTTON_SIZE, LED_BUTTON_SIZE, LCD_COLOR_BLACK, LCD_COLOR_WHITE);
    //RGB TextView
    Button *redTextview = new Button(90, 38, RGB_TEXT_VIEW_WIDTH, RGB_TEXT_VIEW_HEIGHT, LCD_COLOR_RED);
    Button *greenTextview  = new Button(90, 128, RGB_TEXT_VIEW_WIDTH, RGB_TEXT_VIEW_HEIGHT, LCD_COLOR_GREEN);
    Button *blueTextview  = new Button(90, 218, RGB_TEXT_VIEW_WIDTH, RGB_TEXT_VIEW_HEIGHT, LCD_COLOR_BLUE);
    //RGB + and -
    Button *plusRED = new Button(185-130, 8, PLUS_MINUS_BUTTON_SIZE, PLUS_MINUS_BUTTON_SIZE, LIGHT_GRAY);
    Button *minusRED  = new Button(185-130, 53, PLUS_MINUS_BUTTON_SIZE, PLUS_MINUS_BUTTON_SIZE, LIGHT_GRAY);
    Button *plusGREEN  = new Button(185-130, 98, PLUS_MINUS_BUTTON_SIZE, PLUS_MINUS_BUTTON_SIZE, LIGHT_GRAY);
    Button *minusGREEN = new Button(185-130, 143, PLUS_MINUS_BUTTON_SIZE, PLUS_MINUS_BUTTON_SIZE, LIGHT_GRAY);
    Button *plusBLUE  = new Button(185-130, 188, PLUS_MINUS_BUTTON_SIZE, PLUS_MINUS_BUTTON_SIZE, LIGHT_GRAY);
    Button *minusBLUE  = new Button(185-130, 233, PLUS_MINUS_BUTTON_SIZE, PLUS_MINUS_BUTTON_SIZE, LIGHT_GRAY);
    Button *plus10RED = new Button(185-35-130, 8, PLUS_MINUS_BUTTON_SIZE, PLUS_MINUS_BUTTON_SIZE, LIGHT_GRAY);
    Button *minus10RED  = new Button(185-35-130, 53, PLUS_MINUS_BUTTON_SIZE, PLUS_MINUS_BUTTON_SIZE, LIGHT_GRAY);
    Button *plus10GREEN  = new Button(185-35-130, 98, PLUS_MINUS_BUTTON_SIZE, PLUS_MINUS_BUTTON_SIZE, LIGHT_GRAY);
    Button *minus10GREEN = new Button(185-35-130, 143, PLUS_MINUS_BUTTON_SIZE, PLUS_MINUS_BUTTON_SIZE, LIGHT_GRAY);
    Button *plus10BLUE  = new Button(185-35-130, 188, PLUS_MINUS_BUTTON_SIZE, PLUS_MINUS_BUTTON_SIZE, LIGHT_GRAY);
    Button *minus10BLUE  = new Button(185-35-130, 233, PLUS_MINUS_BUTTON_SIZE, PLUS_MINUS_BUTTON_SIZE, LIGHT_GRAY);
    //SET NEW COLOR
    Button *setNewColor  = new Button(270, 100, 100, 25, LIGHT_GRAY);
    Button *cancel  = new Button(270, 150, 100, 25, LIGHT_GRAY);
    //Animations
    /*Button *anim1  = new Button(20, 38, ANIMATION_BUTTON_WIDTH, ANIMATION_BUTTON_HEIGHT, LIGHT_GRAY);
    Button *anim2  = new Button(20, 68, ANIMATION_BUTTON_WIDTH, ANIMATION_BUTTON_HEIGHT, LIGHT_GRAY);
    Button *anim3 = new Button(20, 98, ANIMATION_BUTTON_WIDTH, ANIMATION_BUTTON_HEIGHT, LIGHT_GRAY);
    Button *start  = new Button(20, 128, 120, ANIMATION_BUTTON_HEIGHT+5, LIGHT_GRAY);
    Button *stop  = new Button(20, 163, 120, ANIMATION_BUTTON_HEIGHT+5, LIGHT_GRAY);*/

};

#endif