My daughter has just made her first app.
- It is very slow to start - is there a minimum library include option that makes it quicker to compile? (we are not using any functions except: drawing color and text, buttons)
- We are unable to get supprot for UTF8 (Swedish characters ÄÀö)
- We couldnt find âinputâ or similar command
Any other advice would be greatly appreciated!
#include <MAKERphone.h>
#include <math.h>
MAKERphone mp;
//berÀkna vilken veckodag ett valfritt datum Àr - en app för Ringo av Selma och Astor
int vilkenRad = 1;
void ritaUpp() {
mp.display.fillScreen(TFT_YELLOW);
mp.display.setTextColor(TFT_BLACK);
String rad1 = âAr:â;
String rad2 = âManad:â;
String rad3 = âDatum:â;
String rad4 = âVeckodag:â;
String rad5 = âA for att ga till nastaâ;
String punkt = â.â;
//skriv alla rader
mp.display.drawString(rad1, 10, 20);
mp.display.drawString(rad2, 10, 35);
mp.display.drawString(rad3, 10, 50);
mp.display.drawString(rad4, 10, 65);
mp.display.drawString(rad5, 10, 85);
//gör ett Ă
, A Àr pÄ position 10,20
mp.display.drawString(punkt, 13, 9);
mp.display.drawString(punkt, 12, 9);
//gör ett Ä, a Àr pÄ position 10+11,35
mp.display.drawString(punkt, 10+11+1, 35-8);
//gör ett Ä, a Àr pÄ position 10+71,85
mp.display.drawString(punkt, 10+71+1, 85-8);
//gör ett À,a Àr pÄ position 135-10,35
mp.display.drawString(punkt, 135-10-2, 85-8);
mp.display.drawString(punkt, 135-10+3-2, 85-8);
//gör ett ö, o Àr pÄ position 135-10,35
mp.display.drawString(punkt, 31, 85-8);
mp.display.drawString(punkt, 31+3, 85-8);
mp.display.setCursor(70, 20);
}
int beraknaDag(int aar, int maanad, int dag) {
int f = floor((14-maanad)/(12));
int y = aar - f;
int m = maanad + (12 * f) - 2;
int veckodag = int(
(dag + y + floor(31*m/12) + floor(y/4) - floor(y/100) + floor(y/400) )) % 7;
return veckodag;
}
void setup() {
Serial.begin(115200);
mp.begin(1);
ritaUpp();
vilkenRad = 1;
}
String inputText="";
int inputTal = 0;
int aar=-1;
int maanad=-1;
int dag=-1;
int veckodag=-1;
void inputCapture() {
int btn=-1;
//check buttons
if (mp.buttons.pressed(BTN_1)) {btn=1;}
if (mp.buttons.pressed(BTN_2)) {btn=2;}
if (mp.buttons.pressed(BTN_3)) {btn=3;}
if (mp.buttons.pressed(BTN_4)) {btn=4;}
if (mp.buttons.pressed(BTN_5)) {btn=5;}
if (mp.buttons.pressed(BTN_6)) {btn=6;}
if (mp.buttons.pressed(BTN_7)) {btn=7;}
if (mp.buttons.pressed(BTN_8)) {btn=8;}
if (mp.buttons.pressed(BTN_9)) {btn=9;}
if (mp.buttons.pressed(BTN_0)) {btn=0;}
if (btn!=-1) {
inputTal = btn+inputTal * 10;
if (vilkenRad == 1) {aar = inputTal;}
if (vilkenRad == 2) {maanad = inputTal;}
if (vilkenRad == 3) {dag = inputTal;}
mp.display.print(btn);
}
if (mp.buttons.pressed(BTN_A)) {
vilkenRad += 1;
inputTal=0;
if (vilkenRad == 4) {
//0 = söndag, 1= mĂ„ndag, âŠ
veckodag = beraknaDag(aar, maanad, dag);
String dagnamn[] = {" Sunday"," Monday"," Tuesday", " Wednesday", " Thursday", " Friday", " Saturday"};
mp.display.drawString(dagnamn[veckodag], 70, 65);
}
mp.display.setCursor(70, vilkenRad*15+5);
if (vilkenRad == 5) {
aar = -1;
maanad = -1;
dag = -1;
vilkenRad = 1;
ritaUpp();
}
}
}
void loop() {
mp.update();
inputCapture();
if (mp.buttons.pressed(BTN_B)) {
//GĂ„ ur programmet
mp.loader();
}
Serial.printf(âhej hej %d %d %d %d\nâ,aar,maanad,dag, veckodag);
}