Initial commit

This is just the 2018 code configured for PlatformIO
This commit is contained in:
jvblanck
2021-06-09 12:10:12 +02:00
commit 4faddf9248
77 changed files with 10334 additions and 0 deletions

1
lib/arduino-ediptft-master/.gitignore vendored Normal file
View File

@ -0,0 +1 @@
doc/

View File

@ -0,0 +1,38 @@
------------------------------------------------------------------------------
Library for controlling Electronic Assembly eDIPTFT displays
Copyright (c) 2013 Stefan Gofferje. All rights reserved.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later
version.
This library is distributed in the hope that it will be
useful, but WITHOUT ANY WARRANTY; without even the implied
warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the GNU Lesser General Public License for more
details.
You should have received a copy of the GNU Lesser General
Public License along with this library; if not, write to the
Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
Boston, MA 02110-1301 USA
------------------------------------------------------------------------------
---- 10feb2015 Stefan Lehmann
- Added support for displays with only 1 Byte display coordinates (<255 pixels):
eDIP128, eDIP160 and eDIP240
---- 24feb2013 Stefan Gofferje
- Added functions for touch switches and radio groups
---- 03feb2013 Stefan Gofferje
- Smallprotocol works!!! Yay!
- More functions added.
---- 29jan2013 Stefan Gofferje
- Basic functionality is there
---- 26jan2013 Stefan Gofferje
- Project started

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,697 @@
//
// Library for controlling Electronic Assembly eDIPTFT displays
//
// Copyright (c) 2013 Stefan Gofferje. All rights reserved.
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later
// version.
//
// This library is distributed in the hope that it will be
// useful, but WITHOUT ANY WARRANTY; without even the implied
// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
// PURPOSE. See the GNU Lesser General Public License for more
// details.
//
// You should have received a copy of the GNU Lesser General
// Public License along with this library; if not, write to the
// Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
// Boston, MA 02110-1301 USA
//
#include "EDIPTFT.h"
#include "Arduino.h"
#define DEBUG false
EDIPTFT::EDIPTFT(boolean smallprotocol, boolean displaybool) {
_smallprotocol = smallprotocol;
_displaybool = displaybool;
}
void EDIPTFT::begin(long baud) {
SERIAL_DEV.begin(baud);
}
void EDIPTFT::sendByte(char data) {
SERIAL_DEV.write(data);
}
char EDIPTFT::readByte() {
return SERIAL_DEV.read();
}
void EDIPTFT::waitBytesAvailable() {
const uint32_t t_start = millis();
char loop = 0;
while (loop == 0)
{
if (bytesAvailable() != 0){
loop = 1;
}
if(t_start + 100 < millis())
{
//Serial.println("Error: waited to long!");
loop =1;
}
}
}
char EDIPTFT::waitandreadByte() {
waitBytesAvailable();
char result = readByte();
return(result);
}
unsigned char EDIPTFT::bytesAvailable() {
return SERIAL_DEV.available();
//ÄNDERN
}
void EDIPTFT::sendData(char* data, char len) {
/*for(int i=0; i < len; i++) {
Serial.print(data[i]);
}
Serial.print('\n');
Serial.println(len);*/
if (DEBUG) {
unsigned char i;
for (i = 0; i < len; i++) {
//Serial.print(byte(data[i]), HEX);
SERIAL_DEV.print(byte(data[i]), HEX);
SERIAL_DEV.print(" ");
}
SERIAL_DEV.println();
}
if (_smallprotocol) {
sendSmall(data, len);
}
else {
unsigned char i;
for(i=0; i < len; i++) {
sendByte(data[i]);
}
}
}
void EDIPTFT::sendSmall(char* data, char len) {
unsigned char i, bcc;
char ok = 0;
const uint32_t t_start = millis();
while (ok == 0) {
sendByte(0x11);
bcc = 0x11;
sendByte(len);
bcc = bcc + len;
for(i=0; i < len; i++) {
sendByte(data[i]);
bcc = bcc + data[i];
}
sendByte(bcc);
waitBytesAvailable();
if (bytesAvailable() > 0) {
char x = readByte();
//Serial.print(uint16_t(x));
if (x == ACK) ok = 1;
else {
ok = 0;
}
}
else {
delay(200);
ok = 0;
}
if(t_start + 1000 < millis())
{
//Serial.println("Error: waited to long!");
ok =1;
_displaybool = true;
}
}
}
void EDIPTFT::sendSmallDC2(char* data, char len) {
unsigned char i, bcc;
char ok = 0;
while (ok == 0) {
sendByte(0x12);
bcc = 0x12;
for(i=0; i < len; i++) {
sendByte(data[i]);
bcc = bcc + data[i];
}
sendByte(bcc);
waitBytesAvailable(); //delay(6); im 17er
if (bytesAvailable() > 0) {
if (readByte() == ACK) ok = 1;
else ok = 0;
}
else {
delay(200);
ok = 0;
}
}
}
void EDIPTFT::smallProtoSelect(char address) {
char command [] = {
0x03, 'A', 'S', address
};
sendSmallDC2(command, sizeof(command));
}
void EDIPTFT::smallProtoDeselect(char address) {
char command [] = {
0x03, 'A', 'D', address
};
sendSmallDC2(command, sizeof(command));
}
unsigned char EDIPTFT::datainBuffer() {
unsigned char result;
char command [] = {
0x01, 'I'
};
sendSmallDC2(command, sizeof(command));
waitandreadByte();
waitandreadByte();
result=waitandreadByte();
waitandreadByte();
waitandreadByte();
return result;
}
int EDIPTFT::readBuffer(char* data) { //return void
unsigned char len, i; // char in 17er
char command [] = {
0x01, 'S'
};
sendSmallDC2(command, sizeof(command));
waitandreadByte();
len=waitandreadByte();
char result[len];
for (i = 0; i < len; i++) {
result[i] = waitandreadByte();
}
memcpy(data, result, len);
waitandreadByte();
return len; //zeile nicht vorhanden
}
void EDIPTFT::clear() { //vgl 17er
this->deleteDisplay();
this->removeTouchArea(0, 1);
}
void EDIPTFT::deleteDisplay() {
char command [] = {
27, 'D', 'L'
};
sendData(command, sizeof(command));
}
void EDIPTFT::invert() {
char command [] = {
27, 'D', 'I'
};
sendData(command, sizeof(command));
}
void EDIPTFT::setDisplayColor(char fg, char bg) {
char command [] = {
27, 'F', 'D', fg, bg
};
sendData(command, sizeof(command));
}
void EDIPTFT::fillDisplayColor(char bg) {
char command [] = {
27, 'D', 'F', bg
};
sendData(command, sizeof(command));
}
void EDIPTFT::terminalOn(boolean on) {
if (on) {
char command [] = {27, 'T', 'E'};
sendData(command, sizeof(command));
}
else {
char command [] = {27, 'T', 'A'};
sendData(command, sizeof(command));
}
}
void EDIPTFT::loadImage(int x1, int y1, int nr) {
char command [] = {27, 'U', 'I',
#if COORD_SIZE == 1
(char)x1, (char)y1,
#else
lowByte(x1), highByte(x1), lowByte(y1), highByte(y1),
#endif
nr};
sendData(command, sizeof(command));
}
void EDIPTFT::cursorOn(boolean on) {
if (on) {
char command [] = {27, 'T', 'C', 1};
sendData(command, sizeof(command));
}
else {
char command [] = {27, 'T', 'C', 0};
sendData(command, sizeof(command));
}
}
void EDIPTFT::setCursor(char col, char row) {
char command [] = {27, 'T', 'P', col, row};
sendData(command, sizeof(command));
}
void EDIPTFT::displayLight(char no) {
char command [] = {
27, 'Y', 'H', no
};
sendData(command, sizeof(command));
}
void EDIPTFT::defineBargraph(char dir, char no, int x1, int y1, int x2, int y2, byte sv, byte ev, char type, char mst) {
char command [] = {
27, 'B', dir, no,
#if COORD_SIZE == 1
x1, y1, x2, y2,
#else
lowByte(x1), highByte(x1), lowByte(y1), highByte(y1),
lowByte(x2), highByte(x2), lowByte(y2), highByte(y2),
#endif
char(sv),
char(ev),
type,
mst
};
sendData(command, sizeof(command));
//mst fehlt 17
}
void EDIPTFT::updateBargraph(char no, char val) {
char command [] = {
27, 'B', 'A', no, val
};
sendData(command, sizeof(command));
}
void EDIPTFT::setBargraphColor(char no, char fg, char bg, char fr) {
char command [] = {
27, 'F', 'B', no, fg, bg, fr
};
sendData(command, sizeof(command));
}
void EDIPTFT::linkBargraphLight(char no) {
char command [] = {
27, 'Y', 'B', no
};
sendData(command, sizeof(command));
}
void EDIPTFT::makeBargraphTouch(char no) {
char command [] = {
27, 'A', 'B', no
};
sendData(command, sizeof(command));
}
void EDIPTFT::deleteBargraph(char no,char n1) {
char command [] = {
27, 'B', 'D', no, n1
};
sendData(command, sizeof(command));
}
void EDIPTFT::defineInstrument(char no, int x1, int y1, char image, char angle, char sv, char ev) {
char command [] = {
27, 'I', 'P', no,
#if COORD_SIZE == 1
x1, y1,
#else
lowByte(x1), highByte(x1), lowByte(y1), highByte(y1),
#endif
image, angle, sv, ev
};
sendData(command, sizeof(command));
}
void EDIPTFT::updateInstrument(char no, char val) {
char command [] = {
27, 'I', 'A', no, val
};
sendData(command, sizeof(command));
}
void EDIPTFT::redrawInstrument(char no) {
char command [] = {
27, 'I', 'N', no
};
sendData(command, sizeof(command));
}
void EDIPTFT::deleteInstrument(char no, char n1, char n2) {
char command [] = {
27, 'B', 'D', no, n1, n2
};
sendData(command, sizeof(command));
}
void EDIPTFT::setLineColor(char fg, char bg) {
char command [] = {
27, 'F', 'G', fg, bg
};
sendData(command, sizeof(command));
}
void EDIPTFT::setLineThick(char x, char y) {
char command [] = {
27, 'G', 'Z', x, y
};
sendData(command, sizeof(command));
}
void EDIPTFT::setTextColor(char fg, char bg) {
char command [] = {
27, 'F', 'Z', fg, bg
};
sendData(command, sizeof(command));
}
void EDIPTFT::setTextFont(char font) {
char command [] = {
27, 'Z', 'F', font
};
sendData(command, sizeof(command));
}
void EDIPTFT::setTextSize(int xsize, int ysize){
char command[] = {27, 'Z', 'Z', xsize, ysize};
sendData(command,sizeof(command));
}
void EDIPTFT::setTextAngle(char angle) {
// 0 = 0°, 1 = 90°, 2 = 180°, 3 = 270°
char command [] = {
27, 'Z', 'W', angle
};
sendData(command, sizeof(command));
}
void EDIPTFT::drawText(uint16_t x1, uint16_t y1, char justification, const char* text) {
//nicht const 17//
byte len = strlen(text);
byte i;
char helper [3 + 4 + len + 1];
helper[0] = 27; //esc
helper[1] = 'Z';
helper[2] = justification;
helper[3] = x1 & 0xFF;
helper[4] = (x1 >> 8) & 0xFF;
helper[5] = y1 & 0xFF;
helper[6] = (y1 >> 8) & 0xFF;
for (i = 0; i <= len; i++) {
helper[i + 7] = text[i];
}
sendData(helper, sizeof(helper));
}
void EDIPTFT::drawLine(int x1, int y1, int x2, int y2) {
char command [] = {
27,'G','D',
#if COORD_SIZE == 1
x1, y1, x2, y2
#else
lowByte(x1),highByte(x1),lowByte(y1),highByte(y1),
lowByte(x2),highByte(x2),lowByte(y2),highByte(y2)
#endif
};
sendData(command, sizeof(command));
}
void EDIPTFT::drawRect(int x1, int y1, int x2, int y2) {
char command [] = {
27,'G','R',
#if COORD_SIZE == 1
x1, y1, x2, y2
#else
lowByte(x1),highByte(x1),lowByte(y1),highByte(y1),
lowByte(x2),highByte(x2),lowByte(y2),highByte(y2)
#endif
};
sendData(command, sizeof(command));
}
void EDIPTFT::drawRectf(int x1, int y1, int x2, int y2, char color) {
char command [] = {
27,'R','F',
#if COORD_SIZE == 1
x1, y1, x2, y2,
#else
lowByte(x1),highByte(x1),lowByte(y1),highByte(y1),
lowByte(x2),highByte(x2),lowByte(y2),highByte(y2),
#endif
color
};
sendData(command, sizeof(command));
}
void EDIPTFT::defineTouchKey(int x1, int y1, int x2, int y2, char down, char up,
const char* text) { //text nicht const 17
byte len = strlen(text);
byte i;
char helper [len + 6 + 4 * COORD_SIZE];//len+13 17
char command [] = {
27, 'A', 'T',
#if COORD_SIZE == 1
x1, y1, x2, y2,
#else
lowByte(x1), highByte(x1), lowByte(y1), highByte(y1),
lowByte(x2), highByte(x2), lowByte(y2), highByte(y2),
#endif
down, up
};
for (i = 0; i < (5 + 4 * COORD_SIZE); i++) helper[i] = command[i];//i<=12 17
for (i = 0; i <= len+1; i++) helper[i + 5 + 4 * COORD_SIZE] = text[i];//i<=len 17
sendData(helper, sizeof(helper));//size len+14 17
}
void EDIPTFT::defineTouchSwitch(int x1, int y1, int x2, int y2,
char down, char up, const char* text) {//const nicht 17
byte len = strlen(text);
byte i;
char helper [len + 6 + 4 * COORD_SIZE];//len+13 17
char command [] = {
27, 'A', 'K',
#if COORD_SIZE == 1
x1, y1, x2, y2,
#else
lowByte(x1),highByte(x1),lowByte(y1),highByte(y1),
lowByte(x2),highByte(x2),lowByte(y2),highByte(y2),
#endif
down, up
};
for (i = 0; i < 5 + 4 * COORD_SIZE; i++) helper[i] = command[i];
for (i = 0; i <= len; i++) helper[i + 5 + 4 * COORD_SIZE] = text[i];
sendData(helper, sizeof(helper));//size len+14
}
void EDIPTFT::defineTouchSwitch(int x, int y, int img, char downcode,
char upcode, const char* text) {
byte len = strlen(text);
byte i;
byte n = 6 + 2 * COORD_SIZE;
char helper [len + n + 1];
char command [] = {
27, 'A', 'J',
#if COORD_SIZE == 1
x, y,
#else
lowByte(x), highByte(x), lowByte(y), highByte(y),
#endif
img, downcode, upcode
};
for (i = 0; i < n; i++) helper[i] = command[i];
for (i = 0; i <= len; i++) helper[i + n] = text[i];
sendData(helper, sizeof(helper));
}
void EDIPTFT::setTouchSwitch(char code,char value) {
char command [] = {
27, 'A', 'P', code, value
};
sendData(command, sizeof(command));
}
void EDIPTFT::setTouchkeyColors(
char n1, char n2, char n3, char s1, char s2, char s3) {
char command [] = {
27, 'F', 'E', n1, n2, n3, s1, s2, s3
};
sendData(command, sizeof(command));
}
void EDIPTFT::setTouchkeyFont(char font) {
char command [] = {
27, 'A', 'F', font
};
sendData(command, sizeof(command));
}
void EDIPTFT::setTouchkeyLabelColors(char nf, char sf) {
char command [] = {
27, 'F', 'A', nf, sf
};
sendData(command, sizeof(command));
}
void EDIPTFT::setTouchGroup(char group) {
char command [] = {
27, 'A', 'R', group
};
sendData(command, sizeof(command));
}
void EDIPTFT::removeTouchArea(char code, char n1) {
char command [] = {
27, 'A', 'L', code, n1
};
sendData(command, sizeof(command));
}
void EDIPTFT::callMacro(uint nr) {
char command[] = {
27, 'M', 'N', nr
};
sendData(command, sizeof(command));
}
void EDIPTFT::callTouchMacro(uint nr) {
char command[] = {
27, 'M', 'T', nr
};
sendData(command, sizeof(command));
}
void EDIPTFT::callMenuMacro(uint nr) {
char command[] = {
27, 'M', 'M', nr
};
sendData(command, sizeof(command));
}
void EDIPTFT::defineTouchMenu(int x1, int y1, int x2, int y2,
char downcode, char upcode, char mnucode, const char *text) {
byte len = strlen(text);
byte n = 6 + 4 * COORD_SIZE;
char helper [len + n + 1];
char command [] = {
27, 'A', 'M',
#if COORD_SIZE == 1
x1, y1, x2, y2,
#else
lowByte(x1),highByte(x1),lowByte(y1),highByte(y1),
lowByte(x2),highByte(x2),lowByte(y2),highByte(y2),
#endif
downcode, upcode, mnucode
};
for (int i = 0; i < n; i++) helper[i] = command[i];
for (int i = 0; i <= len; i++) helper[i + n] = text[i];
sendData(helper, sizeof(helper));
}
void EDIPTFT::openTouchMenu() {
char command [] = {
27, 'N', 'T', 2
};
sendData(command, sizeof(command));
}
void EDIPTFT::setMenuFont(char font) {
char command [] = {
27, 'N', 'F', font
};
sendData(command, sizeof(command));
}
void EDIPTFT::setTouchMenuAutomation(bool val) {
char n1 = val ? 1 : 0;
char command [] = {
27, 'N', 'T', n1
};
sendData(command, sizeof(command));
}

View File

@ -0,0 +1,434 @@
//
// Library for controlling Electronic Assembly eDIPTFT displays
//
// Copyright (c) 2013 Stefan Gofferje. All rights reserved.
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later
// version.
//
// This library is distributed in the hope that it will be
// useful, but WITHOUT ANY WARRANTY; without even the implied
// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
// PURPOSE. See the GNU Lesser General Public License for more
// details.
//
// You should have received a copy of the GNU Lesser General
// Public License along with this library; if not, write to the
// Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
// Boston, MA 02110-1301 USA
//
#ifndef EDIPTFT_h
#define EDIPTFT_h
#include "Arduino.h"
//Devices
#define EDIP128 1
#define EDIP160 1
#define EDIP240 1
#define EDIP320 2
//Set your device
#define DEVICE EDIP320
#define COORD_SIZE DEVICE //Byte count for coordinates
#define SERIAL_DEV Serial3
#define EA_BLACK 1
#define EA_BLUE 2
#define EA_RED 3
#define EA_GREEN 4
#define EA_PURPLE 5
#define EA_CYAN 6
#define EA_YELLOW 7
#define EA_WHITE 8
#define EA_DARKGREY 9
#define EA_ORANGE 10
#define EA_LILA 11
#define EA_DARKPURPLE 12
#define EA_MINT 13
#define EA_GRASSGREEN 14
#define EA_LIGHTBLUE 15
#define EA_LIGHTGREY 16
// Fonts
#define EA_FONT8X8 0
#define EA_FONT4X6 1
#define EA_FONT6X8 2
#define EA_FONT7X12 3
#define EA_GENEVA10 4
#define EA_CHICAGO14 5
#define EA_SWISS30B 6
#define EA_BIGZIF57 7
#define NAK 0x15
#define ACK 0x06
#define ESC 0x1B
#define uint unsigned int
class EDIPTFT {
public:
EDIPTFT(boolean smallprotocol=true, boolean displaybool=false);
boolean _displaybool;
void begin(long baud=115200);
// helper functions
char readByte();
char waitandreadByte();
unsigned char datainBuffer();
int readBuffer(char* data);
void smallProtoSelect(char address);
void smallProtoDeselect(char address);
void sendData(char* data, char len);
// Basic display functions
/*! \brief Clear display
*
* Clear display contents (all pixels off) and remove touch areas
*/
void clear();
/*! \brief Delete display
*
* Delete display contents (all pixels off). Touch areas are still active.
*/
void deleteDisplay();
/*! \brief Invert display
*
* Invert display contents (invert all pixels)
*/
void invert();
void setDisplayColor(char fg, char bg);
void fillDisplayColor(char bg);
/*! \brief Terminal on
*
* Terminal display is switched on if \a on is true
*
* \param on determine if terminal is switched on
*/
void terminalOn(boolean on);
/*! \brief Load internal image
*
* Load internal image with the \a nr (0..255) from the *EEPROM* memory to
* \a x1, \a y1
*
* \param x1 x position of image on the display
* \param y1 y position of image on the display
* \param nr number of the image on the *EEPROM*
*/
void loadImage(int x1, int y1, int nr);
/*! \brief Cursor on/off
*
* Switch cursor on/off
*
* \param on `n1=0`: cursor is invisible, `n1=1`: cursor flashes
*/
void cursorOn(boolean on);
/*! \brief Position cursor
*
* origin upper-left corner `(1, 1)`
*
* \param col new cursor column
* \param row new cursor row
*/
void setCursor(char col, char row);
void displayLight(char no);
// Bargraph
/*! \brief Define bargraph
*
* Define bargraph to form the rectangle enclosing the
* bargraph. \a sv and \a ev are the values for `0%` and `100%`.
*
* \param dir direction ('L'eft, 'R'ight, 'O'up, 'U'down)
* \param no bargraph number `1..32`
* \param x1 upper left x coordinate
* \param y1 upper left y coordinate
* \param x2 lower right x coordinate
* \param y2 lower right y coordinate
* \param sv start value (0%)
* \param ev end value (100%)
* \param type set the style of the bargraph:\n
* `type=0`: pattern bar, \a mst=bar pattern,\n
* `type=1`: pattern bar in rectangle, \a mst=bar pattern,\n
* `type=2`: pattern line, \a mst=line width,\n
* `type=3`: pattern line in rectangle, \a mst=line width
*
* \param mst additional parameter for type specification
*/
void defineBargraph(char dir, char no, int x1, int y1, int x2, int y2,
byte sv, byte ev, char type, char mst);
/*! \brief Update bargraph
*
* Set and draw the bargraph *no* to the new *value*
*
* \param no number of the bargraph `1..32`
* \param val new value of the bargraph
*/
void updateBargraph(char no, char val);
void setBargraphColor(char no, char fg, char bg, char fr);
/*! \brief Set bargraph by touch
*
* The bargraph with number *no* is defined for input by touch panel
*
* \param no number of the bargraph `1..32`
*/
void makeBargraphTouch(char no);
void linkBargraphLight(char no);
/*! \brief Delete bargraph
*
* The definition of the bargraph with number *no* becomes invalid. If the
* bargraph was defined as input with touch, the touchfield will also be
* deleted.
*
* \param no number of the bargraph `1..32`
* \param n1 additional parameter\n
* `n1=0`: bargraph remains visible\n
* `n1=1`: bargraph is deleted
*/
void deleteBargraph(char no, char n1);
// Instrument
void defineInstrument(char no, int x1, int y1, char image,
char angle, char sv, char ev);
void updateInstrument(char no, char val);
void redrawInstrument(char no);
void deleteInstrument(char no, char n1, char n2);
// Text
void setTextColor(char fg, char bg);
/*! \brief Set font
*
* Set font with the number *font*
*
* \param font font number `font=0..15`, use font defines here
*/
void setTextFont(char font);
void setTextSize(int xsize, int ysize);
/*! \brief Set text angle
*
* Set text output angle
*
* \param angle text output angle\n
`angle=0`: 0°
`angle=1`: 90°
*/
void setTextAngle(char angle);
/*! \brief Draw text on display
*
* Draw a *text* on screen. Several lines are separated by the character `|`
* ($7C).
* * place text between `~`: characters flash on/off
* * place text between `@`: characters flash inversely
* * use `\\` as to escape special characters
*
* \param x1: x coordinate
* \param y1: y coordinate
* \param justification set text justification to `L`(eft), `R`(ight),
* `C`(enter)
* \param text text to draw on display
*/
void drawText(uint16_t x1, uint16_t y1, char justification, const char* text);
// Rectangle and Line
void setLineColor(char fg, char bg);
/*! \brief Point size/line thickness
*
* \param x x-point size (1..15)
* \param y y-point size (1..15)
*/
void setLineThick(char x, char y);
/*! \brief Draw straight line
*
* Draw straight line from point *x1*, *y1* to point *x2*, *y2*
*/
void drawLine(int x1, int y1, int x2, int y2);
/*! \brief Draw rectangle
*
* Draw four straight lines as a rectangle from *x1*, *y1* to *x2*, *y2*
*/
void drawRect(int x1, int y1, int x2, int y2);
void drawRectf(int x1, int y1, int x2, int y2, char color);
// Touch keys
/*! \brief Define touch key
*
* Key remains pressed as long as there is contact. The area from *x1*, *y1*
* to *x2*, *y2* is drawn with actual border and defined as a key.
* The label is drawn with the current touch font. The first character
* determines the alignment of the text (`L`(eft), `R`(ight), `C`(enter)).
* Multiline texts are separated by the character `|`.
*
* \param down return/touchmacro (1-255) if pressed
* \param up return/touchmacro (1-255) if released
* \param text label of the touch key
*/
void defineTouchKey(int x1, int y1, int x2, int y2,
char down, char up, const char* text);
/*! \brief Define touch switch
*
* Status of the switch toggles after each contact. The area from *x1*, *y1*
* to *x2*, *y2* is drawn with actual border and defined as a key.
* The label is drawn with the current touch font. The first character
* determines the alignment of the text (`L`(eft), `R`(ight), `C`(enter)).
* Multiline texts are separated by the character `|`.
*
* \param down return/touchmacro (1-255) if pressed
* \param up return/touchmacro (1-255) if released
* \param text label of the touch key
*/
void defineTouchSwitch(int x1, int y1, int x2, int y2,
char down, char up, const char* text);
/*! \brief Define touch switch with image
*
* Status of the switch toggles after each contact. Image number *img* is
* loaded to *x*, *y* and defined as a switch.
* The label is drawn with the current touch font. The first character
* determines the alignment of the text (`L`(eft), `R`(ight), `C`(enter)).
* Multiline texts are separated by the character `|`.
*
* \param down return/touchmacro (1-255) if pressed
* \param up return/touchmacro (1-255) if released
* \param text label of the touch switch
*/
void defineTouchSwitch(int x, int y, int img, char downcode,
char upcode, const char* text);
/*! \brief Set touch switch
*
* Set the status of the touch switch with the return code *code*
* to *value*.
*
* \param code Return code of the switch
* \param value `value=0`: OFF, `value=1`: ON
*/
void setTouchSwitch(char code,char value);
void setTouchkeyColors(char n1, char n2, char n3,
char s1, char s2, char s3);
/*! \brief Label font
*
* Apply font with number *font* for touch key labels
*/
void setTouchkeyFont(char font);
void setTouchkeyLabelColors(char nf,char sf);
/*! \brief Radio group for switches
*
* `group=0`: newly defined switches don't belong to a group
* `group=1..255`: newly defined switches are assigned to the group with
* the given number
* Only one switch in a group is active at once. All others are deactivated.
* For switches only the *down code* is applicable. The *up code* will be
* ignored.
*/
void setTouchGroup(char group);
/*! \brief Delete toch area by up- or downcode
*
* The touch area with the return code is removed from the touch query
*
* \param code the code of the touch area (code=0: all touch areas)
* \param n1 n1==0: the area remains visible on the display,
* n1==1: the area is deleted
*/
void removeTouchArea(char code,char n1);
// Macro Calls
/*! \brief Run macro
*
* Call the (normal) macro with number *nr* (max. 7 levels).
*/
void callMacro(uint nr);
/*! \brief Run touch macro
*
* Call touch macro with number *nr* (max. 7 levels)
*/
void callTouchMacro(uint nr);
/*! \brief Run menu macro
*
* Call menu macro with number *nr* (max. 7 levels)
*/
void callMenuMacro(uint nr);
/*! \brief Define touch key with menu function
*
* Define the area from *x1*, *y1* to *x2*, *y2* as a menu key.
* The first character determines the direction in which the menu opens (R=right,L=left,O=up,U=down)
* The second character determines the alignment of the touch text (C=center,L=left-,R=right justified)
* The menu items are separated by the character '|' ($7C,dec:124) (e.g. "UCkey|item1|item2|item3".
* The key text is written with the current touch font and the menu items are written with the current menu font. The background of the menu is saved automatically.
* \param downcode `1-255` return/touchmacro if pressed
* \param upcode `1-255` return/touchmacro if released
* \param mnucode return/menumacro+(item nr - 1) after selection of a
* menu item
* \param text string with the key text and menu items
*/
void defineTouchMenu(int x1, int y1, int x2, int y2,
char downcode, char upcode, char mnucode,
const char *text);
/*! \brief Send *open* signal after a Menu open request has been sent from TFT.
*
* If a touch menu is not set to open automatically the TFT sends a
* request 'ESC T 0'. This function sends 'ESC N T 2' to open the menu.
*/
void openTouchMenu();
/*! \brief Set menu font
*
* Set font with number *font* (`0..15`) for menu display
*/
void setMenuFont(char font);
/*! \brief enable/disable touchmenu automation
*
* if val==true touch menu opens automatically, if val==false touchmenu
* doesn' t open automatically, instead a request is sent to the
* host computer, which can then open the menu with openTouchMenu()
*/
void setTouchMenuAutomation(bool val);
private:
boolean _smallprotocol;
int _counter;
unsigned char bytesAvailable();
void waitBytesAvailable();
void sendByte(char data);
void sendSmall(char* data, char len);
void sendSmallDC2(char* data, char len);
};
#endif

View File

@ -0,0 +1,165 @@
GNU LESSER GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
This version of the GNU Lesser General Public License incorporates
the terms and conditions of version 3 of the GNU General Public
License, supplemented by the additional permissions listed below.
0. Additional Definitions.
As used herein, "this License" refers to version 3 of the GNU Lesser
General Public License, and the "GNU GPL" refers to version 3 of the GNU
General Public License.
"The Library" refers to a covered work governed by this License,
other than an Application or a Combined Work as defined below.
An "Application" is any work that makes use of an interface provided
by the Library, but which is not otherwise based on the Library.
Defining a subclass of a class defined by the Library is deemed a mode
of using an interface provided by the Library.
A "Combined Work" is a work produced by combining or linking an
Application with the Library. The particular version of the Library
with which the Combined Work was made is also called the "Linked
Version".
The "Minimal Corresponding Source" for a Combined Work means the
Corresponding Source for the Combined Work, excluding any source code
for portions of the Combined Work that, considered in isolation, are
based on the Application, and not on the Linked Version.
The "Corresponding Application Code" for a Combined Work means the
object code and/or source code for the Application, including any data
and utility programs needed for reproducing the Combined Work from the
Application, but excluding the System Libraries of the Combined Work.
1. Exception to Section 3 of the GNU GPL.
You may convey a covered work under sections 3 and 4 of this License
without being bound by section 3 of the GNU GPL.
2. Conveying Modified Versions.
If you modify a copy of the Library, and, in your modifications, a
facility refers to a function or data to be supplied by an Application
that uses the facility (other than as an argument passed when the
facility is invoked), then you may convey a copy of the modified
version:
a) under this License, provided that you make a good faith effort to
ensure that, in the event an Application does not supply the
function or data, the facility still operates, and performs
whatever part of its purpose remains meaningful, or
b) under the GNU GPL, with none of the additional permissions of
this License applicable to that copy.
3. Object Code Incorporating Material from Library Header Files.
The object code form of an Application may incorporate material from
a header file that is part of the Library. You may convey such object
code under terms of your choice, provided that, if the incorporated
material is not limited to numerical parameters, data structure
layouts and accessors, or small macros, inline functions and templates
(ten or fewer lines in length), you do both of the following:
a) Give prominent notice with each copy of the object code that the
Library is used in it and that the Library and its use are
covered by this License.
b) Accompany the object code with a copy of the GNU GPL and this license
document.
4. Combined Works.
You may convey a Combined Work under terms of your choice that,
taken together, effectively do not restrict modification of the
portions of the Library contained in the Combined Work and reverse
engineering for debugging such modifications, if you also do each of
the following:
a) Give prominent notice with each copy of the Combined Work that
the Library is used in it and that the Library and its use are
covered by this License.
b) Accompany the Combined Work with a copy of the GNU GPL and this license
document.
c) For a Combined Work that displays copyright notices during
execution, include the copyright notice for the Library among
these notices, as well as a reference directing the user to the
copies of the GNU GPL and this license document.
d) Do one of the following:
0) Convey the Minimal Corresponding Source under the terms of this
License, and the Corresponding Application Code in a form
suitable for, and under terms that permit, the user to
recombine or relink the Application with a modified version of
the Linked Version to produce a modified Combined Work, in the
manner specified by section 6 of the GNU GPL for conveying
Corresponding Source.
1) Use a suitable shared library mechanism for linking with the
Library. A suitable mechanism is one that (a) uses at run time
a copy of the Library already present on the user's computer
system, and (b) will operate properly with a modified version
of the Library that is interface-compatible with the Linked
Version.
e) Provide Installation Information, but only if you would otherwise
be required to provide such information under section 6 of the
GNU GPL, and only to the extent that such information is
necessary to install and execute a modified version of the
Combined Work produced by recombining or relinking the
Application with a modified version of the Linked Version. (If
you use option 4d0, the Installation Information must accompany
the Minimal Corresponding Source and Corresponding Application
Code. If you use option 4d1, you must provide the Installation
Information in the manner specified by section 6 of the GNU GPL
for conveying Corresponding Source.)
5. Combined Libraries.
You may place library facilities that are a work based on the
Library side by side in a single library together with other library
facilities that are not Applications and are not covered by this
License, and convey such a combined library under terms of your
choice, if you do both of the following:
a) Accompany the combined library with a copy of the same work based
on the Library, uncombined with any other library facilities,
conveyed under the terms of this License.
b) Give prominent notice with the combined library that part of it
is a work based on the Library, and explaining where to find the
accompanying uncombined form of the same work.
6. Revised Versions of the GNU Lesser General Public License.
The Free Software Foundation may publish revised and/or new versions
of the GNU Lesser General Public License from time to time. Such new
versions will be similar in spirit to the present version, but may
differ in detail to address new problems or concerns.
Each version is given a distinguishing version number. If the
Library as you received it specifies that a certain numbered version
of the GNU Lesser General Public License "or any later version"
applies to it, you have the option of following the terms and
conditions either of that published version or of any later version
published by the Free Software Foundation. If the Library as you
received it does not specify a version number of the GNU Lesser
General Public License, you may choose any version of the GNU Lesser
General Public License ever published by the Free Software Foundation.
If the Library as you received it specifies that a proxy can decide
whether future versions of the GNU Lesser General Public License shall
apply, that proxy's public statement of acceptance of any version is
permanent authorization for you to choose that version for the
Library.

View File

@ -0,0 +1,36 @@
------------------------------------------------------------------------------
Library for controlling Electronic Assembly eDIPTFT displays
Copyright (c) 2013 Stefan Gofferje. All rights reserved.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 3 of the License, or (at your option) any later
version.
This library is distributed in the hope that it will be
useful, but WITHOUT ANY WARRANTY; without even the implied
warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the GNU Lesser General Public License for more
details.
You should have received a copy of the GNU Lesser General
Public License along with this library; if not, write to the
Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
Boston, MA 02110-1301 USA
------------------------------------------------------------------------------
There isn't much documentation yet. I have started to write the functions on
25JAN2013 and converted them into a library on 01FEB2013. I'm mainly
developing this library inside another projects, so functions are added as
they are needed in that other project. Once the other project is ready, I
might complete this library.
Documentation on the eDIPTFT series is available from
http://www.lcd-module.com/
CAVEAT: When using Smallprotocol to communicate with the display (highly
recommended!) via RS232, the display MUST be selected by with a select
command, otherwise it will ignore ANY communication!

View File

@ -0,0 +1,55 @@
A library for controlling Electronic Assembly eDIPTFT displays.
* copyright (c) 2015 by Stefan Lehmann
* licensed under the GNU Lesser General Public Licens (LGPL)
This is a fork of the [ediptft library][edip1] written by *Stefan Gofferje*.
As its original it is licensed under the GNU Lesser General Public License
(LGPL). See the original copyright note at the bottom of this file.
## Features
* draw text, lines, rectangles
* define touch areas
* define radio touch groups
* define menus
* call macros, touch macros and menu macros
* draw bargraphs and define them as touch areas
## Usage
#include <ediptft.h>
EDIPTFT tft = EDIPTFT();
void main() {
tft.begin(115200); // start display communication
tft.clear(); // clear display
tft.setTextFont(EA_GENEVA10); // set a text font
tft.drawText(100, 30, 'C', "Hello World"); // draw some text
}
## Original copyright note
Copyright (c) 2013 Stefan Gofferje. All rights reserved.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 3 of the License, or (at your option) any later
version.
This library is distributed in the hope that it will be
useful, but WITHOUT ANY WARRANTY; without even the implied
warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the GNU Lesser General Public License for more
details.
You should have received a copy of the GNU Lesser General
Public License along with this library; if not, write to the
Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
Boston, MA 02110-1301 USA
[edip1]:https://github.com/sgofferj/EDIPTFT

View File

@ -0,0 +1,31 @@
EDIPTFT KEYWORD1
ESC KEYWORD1
ACK KEYWORD1
NAK KEYWORD1
sendData KEYWORD2
clear KEYWORD2
invert KEYWORD2
setDisplayColor KEYWORD2
fillDisplayColor KEYWORD2
terminalOn KEYWORD2
cursorOn KEYWORD2
setCursor KEYWORD2
defineBargraph KEYWORD2
updateBargraph KEYWORD2
setBargraphColor KEYWORD2
makeBargraphTouch KEYWORD2
linkBargraphLight KEYWORD2
deleteBargraph KEYWORD2
setTextColor KEYWORD2
setTextFont KEYWORD2
setTextAngle KEYWORD2
drawText KEYWORD2
setLineColor KEYWORD2
drawLine KEYWORD2
drawRect KEYWORD2
drawRectf KEYWORD2
defineTouchKey KEYWORD2
setTouchkeyColors KEYWORD2
setTouchkeyFont KEYWORD2
setTouchkeyLabelColors KEYWORD2
removeTouchArea KEYWORD2