Hi all,
I have designed a keyboard on the M5Paper to type in letters and to display the content on the ePaper display. Currently I use "canvas.pushCanvas(0,0,UPDATE_MODE_DU4);" which seems to me to be the fastest update mode.
However when I type in the letters, I still have to wait "too long" until the display is updated.
What can you recommend being the fastest way to display the new letters? Is there a possibility to partially update the display? I tried "M5.EPD.UpdateArea(0,60,540,400,UPDATE_MODE_GL16);" but nothing changes.
Thanks.
DiWa
CODE (needful part of it):
void Tastatur(){
canvas.fillCanvas(0);
Header();
canvas.setTextArea(10, 60, 520, 460);
canvas.setTextSize(48);
canvas.print(Eingabe);
//Raster
canvas.setTextSize(32);
canvas.drawRoundRect( 10, 430, 168, 80, 10, 15);
canvas.drawRoundRect(186, 430, 168, 80, 10, 15);
canvas.drawRoundRect(362, 430, 168, 80, 10, 15);
canvas.fillRoundRect( 11, 431, 166, 78, 9, 2);
canvas.fillRoundRect(187, 431, 166, 78, 9, 2);
canvas.fillRoundRect(363, 431, 166, 78, 9, 2);
canvas.drawString("wiki", 65, 455);
canvas.drawString("wo", 250, 455);
canvas.drawString("123", 415, 455);
//canvas.createRender(48, 256);
canvas.setTextSize(48);
canvas.drawRoundRect( 10, 518, 80, 80, 10, 15); canvas.drawString("a", 35, 538);
canvas.drawRoundRect( 98, 518, 80, 80, 10, 15); canvas.drawString("b", 123, 538);
canvas.drawRoundRect(186, 518, 80, 80, 10, 15); canvas.drawString("c", 211, 538);
canvas.drawRoundRect(274, 518, 80, 80, 10, 15); canvas.drawString("d", 299, 538);
canvas.drawRoundRect(362, 518, 80, 80, 10, 15); canvas.drawString("e", 387, 538);
canvas.drawRoundRect(450, 518, 80, 80, 10, 15); canvas.drawString("f", 475, 538);
canvas.drawRoundRect( 10, 606, 80, 80, 10, 15); canvas.drawString("g", 35, 626);
canvas.drawRoundRect( 98, 606, 80, 80, 10, 15); canvas.drawString("h", 123, 626);
canvas.drawRoundRect(186, 606, 80, 80, 10, 15); canvas.drawString("i", 216, 626);
canvas.drawRoundRect(274, 606, 80, 80, 10, 15); canvas.drawString("j", 305, 626);
canvas.drawRoundRect(362, 606, 80, 80, 10, 15); canvas.drawString("k", 387, 626);
canvas.drawRoundRect(450, 606, 80, 80, 10, 15); canvas.drawString("l", 475, 626);
canvas.drawRoundRect( 10, 694, 80, 80, 10, 15); canvas.drawString("m", 33, 714);
canvas.drawRoundRect( 98, 694, 80, 80, 10, 15); canvas.drawString("n", 123, 714);
canvas.drawRoundRect(186, 694, 80, 80, 10, 15); canvas.drawString("o", 211, 714);
canvas.drawRoundRect(274, 694, 80, 80, 10, 15); canvas.drawString("p", 299, 714);
canvas.drawRoundRect(362, 694, 80, 80, 10, 15); canvas.drawString("q", 387, 714);
canvas.drawRoundRect(450, 694, 80, 80, 10, 15); canvas.drawString("r", 475, 714);
canvas.drawRoundRect( 10, 782, 80, 80, 10, 15); canvas.drawString("s", 35, 802);
canvas.drawRoundRect( 98, 782, 80, 80, 10, 15); canvas.drawString("t", 123, 802);
canvas.drawRoundRect(186, 782, 80, 80, 10, 15); canvas.drawString("u", 211, 802);
canvas.drawRoundRect(274, 782, 80, 80, 10, 15); canvas.drawString("v", 299, 802);
canvas.drawRoundRect(362, 782, 80, 80, 10, 15); canvas.drawString("w", 387, 802);
canvas.drawRoundRect(450, 782, 80, 80, 10, 15); canvas.drawString("x", 475, 802);
canvas.drawRoundRect( 10, 870, 80, 80, 10, 15); canvas.drawString("y", 35, 890);
canvas.drawRoundRect( 98, 870, 80, 80, 10, 15); canvas.drawString("z", 123, 890);
canvas.drawRoundRect(186, 870, 80, 80, 10, 15); canvas.drawString("?", 211, 890);
canvas.drawRoundRect(275, 870, 80, 80, 10, 15); canvas.fillRoundRect(276, 871, 78, 78, 9, 2); canvas.drawString("_", 305, 890);
canvas.drawRoundRect(362, 870, 80, 80, 10, 15); canvas.fillRoundRect(363, 871, 78, 78, 9, 2); canvas.drawString("<-", 375, 890);
canvas.drawRoundRect(450, 870, 80, 80, 10, 15); canvas.fillRoundRect(451, 871, 78, 78, 9, 2); canvas.drawString("OK", 455, 890);
canvas.pushCanvas(0,0,UPDATE_MODE_GC16);
int touch = 0;
int Auswahl = 0;
int Leer_Stelle = 0;
int Zeichen = 0;
while(Auswahl == 0){
if(M5.TP.avaliable()){
if(!M5.TP.isFingerUp()){
M5.TP.update();
bool is_update = false;
for(int i=0;i<2; i++){
tp_finger_t FingerItem = M5.TP.readFinger(i);
if((point[i][0]!=FingerItem.x)||(point[i][1]!=FingerItem.y)){
is_update = true;
point[i][0] = FingerItem.x;
point[i][1] = FingerItem.y;
if (FingerItem.x >= 430 && FingerItem.x < 510 && FingerItem.y >= 360 && FingerItem.y <= 530) {
Serial.println("wiki");
canvas.setTextSize(32);
Eingabe = "Schreib einen wiki\nArtikel über\n";
canvas.pushCanvas(0,0,UPDATE_MODE_DU4);
}
if (FingerItem.x >= 430 && FingerItem.x < 510 && FingerItem.y >= 274 && FingerItem.y <= 352) {
Serial.println("wo");
canvas.setTextSize(32);
Eingabe = "wo finde ich ";
canvas.pushCanvas(0,0,UPDATE_MODE_GC16);
}
if (FingerItem.x >= 430 && FingerItem.x < 510 && FingerItem.y >= 98 && FingerItem.y <= 178) {
Serial.println("123");
Sonderzeichen();
}
if (FingerItem.x >= 518 && FingerItem.x < 598 && FingerItem.y >= 450 && FingerItem.y <= 530) Eingabe = Eingabe + "a"; //Serial.print("a");
if (FingerItem.x >= 518 && FingerItem.x < 598 && FingerItem.y >= 362 && FingerItem.y <= 442) Eingabe = Eingabe + "b"; //Serial.print("b");
if (FingerItem.x >= 518 && FingerItem.x < 598 && FingerItem.y >= 274 && FingerItem.y <= 352) Eingabe = Eingabe + "c"; //Serial.print("c");
if (FingerItem.x >= 518 && FingerItem.x < 598 && FingerItem.y >= 186 && FingerItem.y <= 266) Eingabe = Eingabe + "d"; //Serial.print("d");
if (FingerItem.x >= 518 && FingerItem.x < 598 && FingerItem.y >= 98 && FingerItem.y <= 178) Eingabe = Eingabe + "e"; //Serial.print("e");
if (FingerItem.x >= 518 && FingerItem.x < 598 && FingerItem.y >= 10 && FingerItem.y <= 90) Eingabe = Eingabe + "f"; //Serial.print("f");
if (FingerItem.x >= 606 && FingerItem.x < 686 && FingerItem.y >= 450 && FingerItem.y <= 530) Eingabe = Eingabe + "g"; //Serial.print("g");
if (FingerItem.x >= 606 && FingerItem.x < 686 && FingerItem.y >= 362 && FingerItem.y <= 442) Eingabe = Eingabe + "h"; //Serial.print("h");
if (FingerItem.x >= 606 && FingerItem.x < 686 && FingerItem.y >= 274 && FingerItem.y <= 352) Eingabe = Eingabe + "i"; //Serial.print("i");
if (FingerItem.x >= 606 && FingerItem.x < 686 && FingerItem.y >= 186 && FingerItem.y <= 266) Eingabe = Eingabe + "j"; //Serial.print("j");
if (FingerItem.x >= 606 && FingerItem.x < 686 && FingerItem.y >= 98 && FingerItem.y <= 178) Eingabe = Eingabe + "k"; //Serial.print("k");
if (FingerItem.x >= 606 && FingerItem.x < 686 && FingerItem.y >= 10 && FingerItem.y <= 90) Eingabe = Eingabe + "l"; //Serial.print("l");
if (FingerItem.x >= 694 && FingerItem.x < 774 && FingerItem.y >= 450 && FingerItem.y <= 530) Eingabe = Eingabe + "m"; //Serial.print("m");
if (FingerItem.x >= 694 && FingerItem.x < 774 && FingerItem.y >= 362 && FingerItem.y <= 442) Eingabe = Eingabe + "n"; //Serial.print("n");
if (FingerItem.x >= 694 && FingerItem.x < 774 && FingerItem.y >= 274 && FingerItem.y <= 352) Eingabe = Eingabe + "o"; //Serial.print("o");
if (FingerItem.x >= 694 && FingerItem.x < 774 && FingerItem.y >= 186 && FingerItem.y <= 266) Eingabe = Eingabe + "p"; //Serial.print("p");
if (FingerItem.x >= 694 && FingerItem.x < 774 && FingerItem.y >= 98 && FingerItem.y <= 178) Eingabe = Eingabe + "q"; //Serial.print("q");
if (FingerItem.x >= 694 && FingerItem.x < 774 && FingerItem.y >= 10 && FingerItem.y <= 90) Eingabe = Eingabe + "r"; //Serial.print("r");
if (FingerItem.x >= 782 && FingerItem.x < 862 && FingerItem.y >= 450 && FingerItem.y <= 530) Eingabe = Eingabe + "s"; //Serial.print("s");
if (FingerItem.x >= 782 && FingerItem.x < 862 && FingerItem.y >= 362 && FingerItem.y <= 442) Eingabe = Eingabe + "t"; //Serial.print("t");
if (FingerItem.x >= 782 && FingerItem.x < 862 && FingerItem.y >= 274 && FingerItem.y <= 352) Eingabe = Eingabe + "u"; //Serial.print("u");
if (FingerItem.x >= 782 && FingerItem.x < 862 && FingerItem.y >= 186 && FingerItem.y <= 266) Eingabe = Eingabe + "v"; //Serial.print("v");
if (FingerItem.x >= 782 && FingerItem.x < 862 && FingerItem.y >= 98 && FingerItem.y <= 178) Eingabe = Eingabe + "w"; //Serial.print("w");
if (FingerItem.x >= 782 && FingerItem.x < 862 && FingerItem.y >= 10 && FingerItem.y <= 90) Eingabe = Eingabe + "x"; //Serial.print("x");
if (FingerItem.x >= 870 && FingerItem.x < 950 && FingerItem.y >= 450 && FingerItem.y <= 530) Eingabe = Eingabe + "y"; //Serial.print("y");
if (FingerItem.x >= 870 && FingerItem.x < 950 && FingerItem.y >= 362 && FingerItem.y <= 442) Eingabe = Eingabe + "z"; //Serial.print("z");
if (FingerItem.x >= 870 && FingerItem.x < 950 && FingerItem.y >= 274 && FingerItem.y <= 352) Eingabe = Eingabe + "?"; //Serial.print("z");
if (FingerItem.x >= 870 && FingerItem.x < 950 && FingerItem.y >= 186 && FingerItem.y <= 266) { //Serial.print("Leer");
Eingabe = Eingabe + " ";
Leer_Stelle = Eingabe.length() - 1;
}
if (FingerItem.x >= 870 && FingerItem.x < 950 && FingerItem.y >= 98 && FingerItem.y <= 178) { //Serial.print("<-");
Eingabe_len = Eingabe.length();
if (Eingabe_len >= 1) Eingabe = Eingabe.substring(0, Eingabe_len - 1);
canvas.fillRect(0, 52, 540, 360, 0);
}
if (FingerItem.x >= 870 && FingerItem.x < 950 && FingerItem.y >= 10 && FingerItem.y <= 90) {
Auswahl = 1;
Serial.println("OK"); Serial.println();
}
int Zeilenlaenge = 20;
canvas.setTextSize(48);
canvas.setTextArea(10, 60, 520, 460);
Zeichen = Zeichen + 1;
if (Zeichen > Zeilenlaenge){
Eingabe.setCharAt(Leer_Stelle, '\n');
canvas.fillRect(0, 60, 540, 360, 0);
Zeichen = Eingabe.length() - Leer_Stelle;
}
canvas.print(Eingabe);
canvas.pushCanvas(0,0,UPDATE_MODE_DU4);
}
}
}
}
}
Eingabe.replace('\n', ' ');
Serial.println(Eingabe);
monitorWiFi();
canvas.setTextArea(10, 60, 520, 460);
canvas.drawRect(100, 300, 330, 80, 15); canvas.fillRect(101, 301, 328, 78, 2);
canvas.drawString("processing ...", 110, 320);
canvas.pushCanvas(0,0,UPDATE_MODE_GL16);
Serial.println(openAI_text(Eingabe));
}