J L / Mbed 2 deprecated Neptune_170620

Dependencies:   mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers NextionLCD.h Source File

NextionLCD.h

00001 /* NextionLCD Library v1.0
00002  * Copyright (c) 2018 Grant Phillips
00003  * grant.phillips@mandela.ac.za
00004  *
00005  *
00006  * Permission is hereby granted, free of charge, to any person obtaining a copy
00007  * of this software and associated documentation files (the "Software"), to deal
00008  * in the Software without restriction, including without limitation the rights
00009  * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
00010  * copies of the Software, and to permit persons to whom the Software is
00011  * furnished to do so, subject to the following conditions:
00012  *
00013  * The above copyright notice and this permission notice shall be included in
00014  * all copies or substantial portions of the Software.
00015  *
00016  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
00017  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
00018  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
00019  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
00020  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
00021  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
00022  * THE SOFTWARE.
00023  */
00024  
00025 #ifndef NEXTIONLCD_H
00026 #define NEXTIONLCD_H
00027  
00028 #include "mbed.h"
00029 
00030 #define BLACK   0
00031 #define BLUE    31
00032 #define BROWN   48192
00033 #define GREEN   1024
00034 #define YELLOW  65504
00035 #define RED     63488
00036 #define GRAY    33840
00037 #define WHITE   65535
00038  
00039 //extern NextionLCD lcd;//Tx, Rx, Nextion Port
00040 
00041 extern bool push;
00042 extern bool pop;
00043 extern volatile bool keyScanFlag;
00044 extern bool scrnUpdate;//Update the Nexion screen
00045 
00046 extern uint8_t nexDataLSB;
00047 extern uint8_t nexDataMSB;
00048 extern volatile uint8_t page;
00049 extern volatile uint8_t id;
00050 extern volatile bool pushPop;
00051 
00052 class NextionLCD 
00053 {
00054   public:
00055 
00056     NextionLCD(PinName Tx, PinName Rx);
00057     void nexRst(void);
00058     void nexSendVal(string id,uint16_t val);
00059     void nexSetBckLite(uint8_t val);//ok        
00060     void nexCls(string colour);
00061     void nexSetBaud(uint32_t baud);//ok                  
00062     void nexChgPage(uint8_t page);//ok             
00063     void nexSetDSBtn(string id, uint8_t on_off);    
00064     void nexRotArrow(bool on_off);
00065     void nexSetCrop(string id, uint16_t picc);//ok    
00066     void nexSetTimer(string id,uint16_t tim, uint16_t on_off);//ok        
00067     void nexSetSlider(string id, uint16_t sliderVal);//ok        
00068     void nexSetPrgBar(string id, uint16_t progBarVal);//ok    
00069     void nexSendTxt(string id,string txt);//ok
00070     void ClrScr(uint16_t color);//ok
00071     void nexSendGetVal(string id);    
00072     void nexSetFont(string id, uint8_t val);
00073     void nexSendFloat(string id,float val,uint8_t p);
00074     void nexLoadSD(void);
00075     void nexDrawLine(uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, uint16_t color);
00076     void nexSetFontCol(string id, uint16_t colour);
00077     void nexDispSymbol(string id, bool on_off);
00078         
00079     
00080   private:
00081     RawSerial lcd;             //Serial object for connecting to Nextion LCD
00082     //Serial pc;
00083     bool mTouch;
00084     int mTouchX, mTouchY;
00085     char mRxMsg[40];
00086     int mRxIdx;
00087     void RxInterrupt(void); //Rx Interrupt
00088 };
00089  
00090 #endif