Advertisement
Tempist

DataReturn (R_Wr)

Oct 22nd, 2019
247
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.95 KB | None | 0 0
  1. int16 x,y,x1,y1;
  2. int16 GetX() {
  3. //reading X
  4.  
  5. output_high(PIN_C2);
  6. output_low(PIN_E0);
  7. outpUT_float(PIN_C3);
  8. outpUT_float(PIN_E1);
  9. // DRIVEB = 0 (BOTTOM drive off )
  10. set_adc_channel(0);
  11. Delay_ms(10);
  12. return read_adc(); // reading X value from RA0 (BOTTOM)
  13. }
  14. int16 GetY() {
  15. //reading Y
  16.  
  17. output_high(PIN_C3);
  18. output_low(PIN_E1);
  19. outpUT_float(PIN_C2);
  20. outpUT_float(PIN_E0);
  21. set_adc_channel(1);
  22. Delay_ms(10);
  23. return read_adc(); // reading Y value from RA1 (from LEFT)
  24. }
  25.  
  26. char getval()
  27. {int row,col;
  28. char p;
  29. char val[3][4]={'*', '0', '9', '#', '5', '6', '7', '8', '1', '2', '3', '4'};
  30. setup_adc_ports(RA0_RA1_RA3_ANALOG);
  31. setup_adc(ADC_CLOCK_INTERNAL );
  32. do
  33. {x= GETX();
  34. Delay_ms(10);
  35. y= GETY();
  36. Delay_ms(100);
  37. row=y/330;
  38. col=x/220;
  39. x1= GETX();
  40. Delay_ms(10);
  41. y1= GETY();
  42. Delay_ms(10);
  43. output_high(pin_c1);
  44. delay_ms(100);
  45. output_low(pin_c1);
  46. } while(x<20 || y<20 || (x1/10)!=(x/10) || (y1/10)!=(y/10));
  47. return(val[row][col]);
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement