test

Dependencies:   ad5422_arduino mbed LT1446 ADS1248-1 LM35-1 Flash FT813 PGA280_ADS1259

TFT/display.myWidgets.cpp

Committer:
nikmaos
Date:
2020-09-01
Revision:
7:c364201bc3ed
Parent:
5:21240fa1ee4c

File content as of revision 7:c364201bc3ed:

#include "display.h"

void Display::myWdget_Edit(uint16_t x,uint16_t y,uint16_t w,uint16_t h,uint8_t selected,const char * text)
{
    
    (*_TFT).DL(BEGIN(RECTS));
    //рамка
    (*_TFT).DL(COLOR_RGB(0, 0, 0));    
    if(selected)
    (*_TFT).DL(COLOR_RGB(255, 0, 0));//если выбрана для редактирования
    (*_TFT).DL(VERTEX2II(x, y, 0, 0));
    (*_TFT).DL(VERTEX2II(x+w, y+h, 0, 0));
    //поле
    (*_TFT).DL(COLOR_RGB(255, 255, 255));
    (*_TFT).DL(VERTEX2II(x+2, y+2, 0, 0));
    (*_TFT).DL(VERTEX2II(x+w-2, y+h-2, 0, 0));
    (*_TFT).DL(END());
    (*_TFT).DL(COLOR_RGB(0, 0, 0));    
    (*_TFT).Text(x+4, y+7, 28, 0, text);
}

void Display::myWdget_NumPad(uint16_t x,uint16_t y)
{
    //шарина одной кнопки = 240/3
    //высота 60
    //расстояние между 2
    char key;
    uint16_t y1=y; //для отрисовки
    if(TouchX>x&&TouchY>y&&TouchX<(x+80)&&TouchY<(y+60))
    key='1';
    pressedButton=key;
    if(TouchX>x+80&&TouchY>y&&TouchX<(x+160)&&TouchY<(y+60))
    key='2';
    pressedButton=key;
    if(TouchX>x+160&&TouchY>y&&TouchX<(x+240)&&TouchY<(y+60))
    key='3';
    pressedButton=key;
    
    y+=63;
    if(TouchX>x&&TouchY>y&&TouchX<(x+80)&&TouchY<(y+60))
    key='4';
    pressedButton=key;
    if(TouchX>x+80&&TouchY>y&&TouchX<(x+160)&&TouchY<(y+60))
    key='5';
    pressedButton=key;
    if(TouchX>x+160&&TouchY>y&&TouchX<(x+240)&&TouchY<(y+60))
    key='6';
    pressedButton=key;
    
    y+=63;
    if(TouchX>x&&TouchY>y&&TouchX<(x+80)&&TouchY<(y+60))
    key='7';
    pressedButton=key;
    if(TouchX>x+80&&TouchY>y&&TouchX<(x+160)&&TouchY<(y+60))
    key='8';
    pressedButton=key;
    if(TouchX>x+160&&TouchY>y&&TouchX<(x+240)&&TouchY<(y+60))
    key='9';
    pressedButton=key;
    
    y+=63;
    if(TouchX>x&&TouchY>y&&TouchX<(x+80)&&TouchY<(y+60))
    key='.';
    pressedButton=key;
    if(TouchX>x+80&&TouchY>y&&TouchX<(x+160)&&TouchY<(y+60))
    key='0';
    pressedButton=key;
    if(TouchX>x+160&&TouchY>y&&TouchX<(x+240)&&TouchY<(y+60))
    key='<';
    pressedButton=key;
    
    (*_TFT).Keys(x, y1, 240, 60, 29, key, "123");
    (*_TFT).Keys(x, y1+63, 240, 60, 29, key, "456");
    (*_TFT).Keys(x, y1+63+63, 240, 60, 29, key, "789");
    (*_TFT).Keys(x, y1+63+63+63, 240, 60, 29, key, ".0<");
}

void Display::myWdget_Edit_change(char * text)
{
/*cursor=strlen(text);
char i;
while(text[i])
{
str_edit[i]=text[i];    
i++;
}
str_edit[i]='_';*/
    
if(pressedButton>='0'&&pressedButton<='9'||pressedButton=='.'||pressedButton=='<')
        {
            if(cursor<10){
            if(pressedButton=='<'){                
                cursor--;
                str_edit[cursor]='_';
                str_edit[cursor+1]=0;                
                if(cursor==255) cursor=0;
                }
                else{
            str_edit[cursor]=pressedButton;
            str_edit[cursor+1]='_';
            str_edit[cursor+2]=0;
            cursor++;}
            
            }//cersor<10
            else cursor=9;            
        }    
}