Digole
Digital Solutions
iDigole Buyer ProtectioniDigole Buyer
Protection
My shopping cart
0 Items:
Secure Checkout
Top Rated Plus
Visit Our Live Auctions
99.9% Customer's Satisfaction
 
Forum : Digole Serial Display :

 Search Forum.. 
 Creat New Topic   Reply 

Joystick position and Digole

Good Morning

I'm testing with their digoles (2.4 '' IPS in Ic2 mode). In my model there is a joystick that according to their position will be sent to digole the coordinate value of the line to paint. The problem is that not delete other lines I want her to have the display only the line of the current value of the function, the concept would be like running a car speedometer:
 
lectura_mando2 void () {
   mydisp.setPrintPos (160, 120, 1); // In center of display
   xAxis int = analogRead (A0);
   payload.velocidad = map (xAxis, 0, 1023, -255, 255);
   delay (1);
   mydisp.setColor (200);
   mydisp.setMode ('!');
   mydisp.setLinePattern (random (0x70, 256));
   mydisp.drawLineTo (120, payload.velocidad);
  
}
 
I have read many things in the forum, not if to erase the old coordinate is better to make a flush or paint it black again, or use a movecirclearea. How you could deal with this problem?
 
Thank you very much for your help

RE:Joystick position and Digole

 Your sketch have to remember the last position and line pattern:

unsigned char pattern_last, pos_last;

lectura_mando2 void () {

   mydisp.setPrintPos (160, 120, 1); // In center of display
   xAxis int = analogRead (A0);
   payload.velocidad = map (xAxis, 0, 1023, -255, 255);
   delay (1);
   mydisp.setColor (200);
   mydisp.setMode ('!');
 
   mydisp.setLinePattern (pattern_last);
   mydisp.drawLineTo (120, pos_last);  //remove old line
   pattern_last=random (0x70, 256);
   pos_last=payload.velocidad;
 
   mydisp.setLinePattern (pattern_last);
   mydisp.drawLineTo (120, pos_last); //draw new line
}
Also, you need to check if it's first time to draw line, you don't need to remove the old line if first time drawing.

 

 

RE:Joystick position and Digole

 Thanks for the reply

Now I understand a little more the operation of the display. With what I said, correctly I erase the last data received, but not delete the entire line.
For me it is easier for me, I do not make a random of setLinePattern and thus use the black base deletion.
 
I attach some pictures, so you understand my problem:
 
 
 http://enrutador.com/IMG_0568.JPG
 http://enrutador.com/IMG_0569.JPG
http://enrutador.com/IMG_0570.JPG
http://enrutador.com/IMG_0571.JPG
 
 
 
 
 
 //http://digole.com/forum.php?topicID=535
unsigned char pos_last, pattern_last;
 
 
void lectura_mando2() {
  mydisp.setPrintPos(160, 120, 1);
  int ejeX = analogRead(A0);
  int contador = 0;
  payload.velocidad = map(ejeX, 0, 1023, -255, 255);
  delay(1);
  //mydisp.setColor(70);
  //mydisp.setRotation(3);
  mydisp.setMode('!');
  //mydisp.setLinePattern (pattern_last);
  mydisp.drawLineTo (120, pos_last);  //remove old line
  // pattern_last=random (0x70, 256);
  pos_last = payload.velocidad;
  //mydisp.setLinePattern (pattern_last);
  mydisp.drawLineTo (120, pos_last); //draw new line
}

RE:Joystick position and Digole

 delay(1) may be too short, try to use delay(100) first, then reduce it until the drawline still work.

Please refer to our 3D cube sample code.

Also, there is a bug in your sketch too, you should do like this:

void lectura_mando2() {
  mydisp.setPrintPos(160, 120, 1);
  int ejeX = analogRead(A0);
  int contador = 0;
  payload.velocidad = map(ejeX, 0, 1023, -255, 255);
  delay(100);
  mydisp.setMode('!');
  mydisp.drawLineTo (120, pos_last);  //remove old line,or use drawLine(160,120,120,pos_last)
  pos_last = payload.velocidad;
  mydisp.setPrintPos(160, 120, 1); //set the current position, the current position was changed after last drawLineTo
mydisp.drawLineTo (120, pos_last); //draw new line, or use drawLine(160,120,120,pos_last)
}
 

 

RE:Joystick position and Digole

 A lot of thanks ¡¡¡¡

This is good example  for me  to understand the display, i see the fantastic code of 3D cube , congratulations for the big work. I will study your code to learn more.

A lot of thanks ¡¡¡¡

Copyright Digole Digital Solutions, 2008-2017. All rights reserved.
Powered by Victor Sun