Post the code that does not work and describe what should happen and what actually happens.
I dont have now with me, later at home i will posted but i think i used string not array ( i cant understand how fill arrays..)
if (page == 70 && p.y > 211 && p.y < 231 && p.x > 84 && p.x <104 ){
tft.setTextSize(3);
tft.fillRect(82, 201, 25, 25, BLUE);
tft.setCursor(82, 201);
tft.println ("0");
myString +=0;
}
else if (page == 70 && p.y > 290 && p.y < 310 && p.x > 190 && p.x <215){
tft.setTextSize(3);
tft.fillRect(110, 201, 25, 25, BLUE);
tft.setCursor(110, 201);
tft.println ("1");
myString +=1;
}
if (page == 70 && p.y > 126 && p.y < 146 && p.x > 83 && p.x <103){
tft.fillRect(30, 201, 220, 21, BLUE);
tft.drawString(100, 201, "VALIDADO", WHITE, 3);
tft.fillRect(1, 50, 25, 25, RED);
tft.setTextSize(3);
tft.setCursor(1, 50);
a=atoi(myString);
ds1307setup();
}
Please teach me,
I need example 4 bytes i declare:
int myInts[4];
if (page == 70 && p.y > 211 && p.y < 231 && p.x > 84 && p.x <104 ){
tft.setTextSize(3);
tft.fillRect(82, 201, 25, 25, BLUE);
tft.setCursor(82, 201);
tft.println ("0");
myInts[0] == 0,
}
else if (page == 70 && p.y > 290 && p.y < 310 && p.x > 190 && p.x <215 && q==1){
tft.setTextSize(3);
tft.fillRect(110, 201, 25, 25, BLUE);
tft.setCursor(110, 201);
tft.println ("1");
myInts[1] == 1,
}
if (page == 70 && p.y > 126 && p.y < 146 && p.x > 83 && p.x <103){
tft.fillRect(30, 201, 220, 21, BLUE);
tft.drawString(100, 201, "VALIDADO", WHITE, 3);
tft.fillRect(1, 50, 25, 25, RED);
tft.setTextSize(3);
tft.setCursor(1, 50);
a=atoi( myInts[0] ,myInts[1]);
ds1307setup();
}
int myInts[4];
does declare an array of 4 ints but
myInts[0] == 0,
does not store a value in the array
a = atoi(myInts);
You should check for a special character button like * or # and if any of those are pressed it convert the array to an int. If those are NOT pressed, use a variable (int counter;) to add number to the array.
Example.
if(press != '*' || press != '#') {
myInts[counter++] = press;
}
else {
a = atoi(myInts);
}
Thanks master,
One question how do i store a value in the array afther number 0 is pressed?
if (page == 70 && p.y > 211 && p.y < 231 && p.x > 84 && p.x <104 ){
tft.setTextSize(3);
tft.fillRect(82, 201, 25, 25, BLUE);
tft.setCursor(82, 201);
tft.println ("0");
myInts ????
}
Same way. the only time it stops entering number is when one of those special characters are pressed. You should also clear the array afterwards with a while loop.
while(counter != 0) { // this can be used for any size array.
myInts[counter--] = 0;
}
@HazardsMind
Why would you call atoi(), which expects a NULL terminated array of chars, with an array of ints?
If he researched the atoi function, then he should know that it needs to be char null terminated. What I gave him was just an example to build on.
OP, your numbers must be chars, not actual ints. '1','2','3'... and so on.
HazardsMind:
Same way
}
My doubts is afther pressing a number how do i store it? in the array in a char??
Please write example they way i talking about (my Inglish is not very good)
thankz
You said you already made a map of the buttons.
if (page == 70 && p.y > 211 && p.y < 231 && p.x > 84 && p.x <104 ){ // im guessing button ZERO
tft.setTextSize(3);
tft.fillRect(82, 201, 25, 25, BLUE);
tft.setCursor(82, 201);
tft.println ("0");
myInts[counter++] = '0'; // *** this is the setup needed *** the numbers must go between single quotes ' '
// Everytime you press a button, counter updates and the char is stored
// If special button is pressed, convert data in array.
}
else if (page == 70 && p.y > 290 && p.y < 310 && p.x > 190 && p.x <215 && q==1){ // Button ONE
tft.setTextSize(3);
tft.fillRect(110, 201, 25, 25, BLUE);
tft.setCursor(110, 201);
tft.println ("1");
myInts[counter++] = '1';
}
. TWO
. THREE
. FOUR
And so on
Added: You also need to make sure you set the counter back to zero after you convert the array to an int.
Thankz a lot, afther i press 0 and then 1 i press the special button convert data in array i get myInts[0] = 0 and myInts[1] = 1 and myInts[] = 01 write? then a = atoi(myInts);
ok?
myInts[0] = '0' single quotes.
The first zero will drop out, leaving you with just 1, not 01.
I need to "store" the 01 how can i do this?
I need to "store" the 01 how can i do this?
Why? There is ABSOLUTELY no difference between 1, 01, 0x01, 0x0001, 0b00000001, and B00000001.
PaulS:
I need to "store" the 01 how can i do this?
Why? There is ABSOLUTELY no difference between 1, 01, 0x01, 0x0001, 0b00000001, and B00000001.
If i press 1 and then 1 again i will get 11? because let me say i want to set the day for 11 in rtc
Thanks
If i press 1 and then 1 again i will get 11?
Maybe. Or, maybe you'll get "11" or maybe an old banana. We can't see what code you are now using.
[quote author=PaulS link=topic=147319.msg1107087#msg1107087 date=1360178171]
[quote]If i press 1 and then 1 again i will get 11?[/quote]
Maybe. Or, maybe you'll get "11" or maybe an old banana. We can't see what code you are now using.
[/quote]
There are the "old banana" ..... many thanks to HazardsMind
[code if (page == 70 && p.y > 134 && p.y < 162 && p.x > 145 && p.x <185 && x==1){
if (setC==1){
qx=100;
qw=193;
}
if (setC==2){
qx=130;
qw=193;
}
tft.setTextSize(4);
tft.fillRect(qx, qw, 21, 29, BLACK);
tft.setCursor(qx, qw);
// tft.setCursor(100, 193);
myInts[counterrtc++] = '0';
tft.println ("0");
setC = setC + 1;
delay(1000);
}
if (page == 70 && p.y > 290 && p.y < 337 && p.x > 195 && p.x <230 && x==1){
if (setC==1){
qx=100;
qw=193;
}
if (setC==2){
qx=130;
qw=193;
}
tft.setTextSize(4);
tft.fillRect(qx, qw, 21, 29, BLACK);
tft.setCursor(qx, qw);
myInts[counterrtc++] = '1';
tft.println ("1");
setC = setC + 1;
delay(1000);
}
if (page == 70 && p.y > 238 && p.y < 275 && p.x > 195 && p.x <230 && x==1){
if (setC==1){
qx=100;
qw=193;
}
if (setC==2){
qx=130;
qw=193;
}
tft.setTextSize(4);
tft.fillRect(qx, qw, 21, 29, BLACK);
tft.setCursor(qx, qw);
myInts[counterrtc++] = '2';
tft.println ("2");
setC = setC + 1;
delay(1000);
}
if (page == 70 && p.y > 187 && p.y < 226 && p.x > 195 && p.x <230 && x==1){
if (setC==1){
qx=100;
qw=193;
}
if (setC==2){
qx=130;
qw=193;
}
tft.setTextSize(4);
tft.fillRect(qx, qw, 21, 29, BLACK);
tft.setCursor(qx, qw);
myInts[counterrtc++] = '3';
tft.println ("3");
setC = setC + 1;
delay(1000);
}
if (page == 70 && p.y > 137 && p.y < 173 && p.x > 195 && p.x <230 && x==1){
if (setC==1){
qx=100;
qw=193;
}
if (setC==2){
qx=130;
qw=193;
}
tft.setTextSize(4);
tft.fillRect(qx, qw, 21, 29, BLACK);
tft.setCursor(qx, qw);
myInts[counterrtc++] = '4';
tft.println ("4");
setC = setC + 1;
delay(1000);
}
if (page == 70 && p.y > 83 && p.y < 119 && p.x > 195 && p.x <230 && x==1){
if (setC==1){
qx=100;
qw=193;
}
if (setC==2){
qx=130;
qw=193;
}
tft.setTextSize(4);
tft.fillRect(qx, qw, 21, 29, BLACK);
tft.setCursor(qx, qw);
myInts[counterrtc++] = '5';
tft.println ("5");
setC = setC + 1;
delay(1000);
}
if (page == 70 && p.y > 30 && p.y < 69 && p.x > 195 && p.x <230 && x==1){
if (setC==1){
qx=100;
qw=193;
}
if (setC==2){
qx=130;
qw=193;
}
tft.setTextSize(4);
tft.fillRect(qx, qw, 21, 29, BLACK);
tft.setCursor(qx, qw);
myInts[counterrtc++] = '6';
tft.println ("6");
setC = setC + 1;
delay(1000);
}
if (page == 70 && p.y > 290 && p.y < 337 && p.x > 145 && p.x <185 && x==1){
if (setC==1){
qx=100;
qw=193;
}
if (setC==2){
qx=130;
qw=193;
}
tft.setTextSize(4);
tft.fillRect(qx, qw, 21, 29, BLACK);
tft.setCursor(qx, qw);
myInts[counterrtc++] = '7';
tft.println ("7");
setC = setC + 1;
delay(1000);
}
if (page == 70 && p.y > 238 && p.y < 275 && p.x > 145 && p.x <185 && x==1){
if (setC==1){
qx=100;
qw=193;
}
if (setC==2){
qx=130;
qw=193;
}
tft.setTextSize(4);
tft.fillRect(qx, qw, 21, 29, BLACK);
tft.setCursor(qx, qw);
myInts[counterrtc++] = '8';
tft.println ("8");
setC = setC + 1;
delay(1000);
}
if (page == 70 && p.y > 187 && p.y < 226 && p.x > 145 && p.x <185 && x==1){
if (setC==1){
qx=100;
qw=193;
}
if (setC==2){
qx=130;
qw=193;
}
tft.setTextSize(4);
tft.fillRect(qx, qw, 21, 29, BLACK);
tft.setCursor(qx, qw);
myInts[counterrtc++] = '9';
tft.println ("9");
setC = setC + 1;
delay(1000);
}
if (page == 70 && p.y > 80 && p.y < 118 && p.x > 145 && p.x <185 && x==1){ // VERDE VALIDA
//tft.fillRect(30, 201, 50, 21, BLUE);
// tft.drawString(100, 201, "VALIDADO", WHITE, 3);
tft.fillRect(180, 193, 42, 29, BLACK);
tft.setTextSize(4);
tft.setCursor(180, 193);
setC = 0;
x=0;
counterrtc = 0;
selec = atoi(myInts);
tft.println (selec);
if (zz==1){
a = selec;
zz=0;
}
if (zz==2){
me = selec;
zz=0;
}
if (zz==3){
ds = selec;
zz=0;
}
if (zz==4){
dm = selec;
zz=0;
}
if (zz==5){
h = selec;
zz=0;
}
if (zz==6){
mi = selec;
zz=0;
}
while(counterrtc != 0) { // this can be used for any size array. myInts[counterrtc] = '\0';
myInts[counterrtc--] = 0;
}
delay(2000);
tft.fillRect(20, 193, 220, 33, BLACK);
}
if (page == 70 && p.y > 34 && p.y < 66 && p.x > 145 && p.x <185 ){ // VERMELHO APGAGA // VERMELHO APGAGA // VERMELHO APGAGA
tft.fillRect(20, 193, 220, 33, BLACK);
tft.setTextSize(4);
tft.setCursor(100, 193);
counterrtc = 0;
selec = '\0';
while(counterrtc != 0) { // this can be used for any size array. myInts[counterrtc] = '\0';
myInts[counterrtc--] = 0;
}
myInts[2] = '\0';
}
if (page == 70 && p.y > 265 && p.y < 330 && p.x > 110 && p.x < 135 ){ // ANO ANO ANO ANO
tft.setTextSize(4);
tft.fillRect(20, 193, 70, 29, BLACK);
tft.setCursor(20, 193);
tft.println ("ANO");
x=1;
setC=1;
zz=1;
delay(1000);
}
if (page == 70 && p.y > 190 && p.y < 250 && p.x > 110 && p.x < 135 ){ // MES MES MES MES Y 190 250 X 110 135
tft.setTextSize(4);
tft.fillRect(20, 193, 70, 29, BLACK);
tft.setCursor(20, 193);
tft.println ("MES");
zz=2;
x=1;
setC=1;
// char mes[2];
// byte coumes;
delay(1000);
}
if (page == 70 && p.y > 105 && p.y < 167 && p.x > 110 && p.x < 135 ){ //DIA SEM DIA SEM DIAS EM
tft.setTextSize(2);
tft.fillRect(20, 193, 80, 31, BLACK);
tft.fillRect(25, 224, 75, 2, BLACK);
tft.setCursor(40, 193);
tft.println ("DIA");
tft.setCursor(25, 210);
tft.println ("SEMANA");
zz=3;
x=1;
setC=1;
// char mes[2];
// byte coumes;
delay(1000);
}
if (page == 70 && p.y > 25 && p.y < 90 && p.x > 110 && p.x < 135 ){ //DIA DIA DIA DIA DIA DIA DIA DIA DIA DIA
tft.setTextSize(4);
tft.fillRect(20, 193, 70, 29, BLACK);
tft.setCursor(20, 193);
tft.println ("DIA");
zz=4;
x=1;
setC=1;
// char mes[2];
// byte coumes;
delay(1000);
}
if (page == 70 && p.y > 265 && p.y < 330 && p.x > 65 && p.x < 100 ){ //HORA HORA HORA HORA HORA
tft.setTextSize(3);
tft.fillRect(20, 193, 70, 29, BLACK);
tft.setCursor(20, 198);
tft.println ("HORA");
zz=5;
x=1;
setC=1;
// char mes[2];
// byte coumes;
delay(1000);
}
if (page == 70 && p.y > 190 && p.y < 250 && p.x > 65 && p.x < 100 ){ // MINUTO MINUTO MINUTO MINUTO
tft.setTextSize(4);
tft.fillRect(20, 193, 70, 29, BLACK);
tft.setCursor(20, 193);
tft.println ("MIN");
zz=6;
x=1;
setC=1;
// char mes[2];
// byte coumes;
delay(1000);
}
if (page == 70 && p.y > 105 && p.y < 167 && p.x > 65 && p.x < 100 ){ // EVENTO EVENTO EVENTO EVENTO
tft.setTextSize(3);
tft.fillRect(20, 193, 220, 33, BLACK);
tft.setCursor(20, 198);
tft.println ("EVENTO");
delay(1500);
tft.fillRect(20, 193, 220, 33, BLACK);
}
if (page == 70 && p.y > 25 && p.y < 90 && p.x > 65 && p.x < 100 ){ // ENTER ENTER ENTER ENTER ENTER
tft.setTextSize(4);
tft.fillRect(20, 193, 220, 33, BLACK);
tft.setCursor(20, 193);
tft.println ("ENTER");
counterrtc = 0;
selec = '\0';
while(counterrtc != 0) { // this can be used for any size array. myInts[counterrtc] = '\0';
myInts[counterrtc--] = 0;
}
myInts[2] = '\0';
ds1307setup();
delay(2000);
tft.fillRect(20, 193, 220, 33, BLACK);
}]
If i can hellp any one please let me know