Hello,
I try to get the coordinates from a touch TFT. I have 4 wires X-and X+, Y- and Y+ (IO33-IO26-IO25-IO32). My supply voltage is 3v3. I can get with the ADC the position for X alone, the postion for Y alone as well. The problem is when I want the both position, I can't get any value from the ADC: X=Y=0!
int abscis() {
int X=0;
gpio_set_direction(GPIO_NUM_26, GPIO_MODE_OUTPUT); //X+
gpio_set_level(GPIO_NUM_26, 1);
gpio_set_direction(GPIO_NUM_32, GPIO_MODE_INPUT); //Y+
gpio_set_direction(GPIO_NUM_25, GPIO_MODE_OUTPUT); //Y-
gpio_set_level(GPIO_NUM_25, 0);
gpio_set_direction(GPIO_NUM_33, GPIO_MODE_OUTPUT); //X-
gpio_set_level(GPIO_NUM_33, 0);
adc1_config_width(3); //12 bits
adc1_config_channel_atten(ADC1_CHANNEL_4, ADC_ATTEN_11db); // value on Y+ - for 3V3
X=adc1_get_raw(ADC1_CHANNEL_4)/(4096/240);//reads X axis touch position 240 pixels
return X;
}
int ordon() {
int Y=0;
gpio_set_direction(GPIO_NUM_32, GPIO_MODE_OUTPUT); //Y+
gpio_set_level(GPIO_NUM_32, 1);
gpio_set_direction(GPIO_NUM_26, GPIO_MODE_INPUT); //X+
gpio_set_direction(GPIO_NUM_33, GPIO_MODE_OUTPUT); //X-
gpio_set_level(GPIO_NUM_33, 0);
gpio_set_direction(GPIO_NUM_25, GPIO_MODE_OUTPUT); //Y-
gpio_set_level(GPIO_NUM_25, 0);
adc2_config_channel_atten( ADC2_CHANNEL_9, ADC_ATTEN_11db ); //value on X+ - for 3V3
adc2_get_raw( ADC2_CHANNEL_9, ADC_WIDTH_12Bit, &Y);
return (Y/(4096/320)); //reads Y axis touch position 320 pixels
}
while (1){
int X=abscis();
int Y=ordon();
printf ("X=%d Y=%d\r\n", X,Y);
Wait(300);
}
I have read all I could find on the web but nothing helped and I am stucked!
Any advice would be appreciate
Thanks and regards!
ADC Behavior Issue
-
- Posts: 11
- Joined: Mon Nov 13, 2017 1:28 pm
Return to “General Discussion”
Jump to
- English Forum
- Explore
- News
- General Discussion
- FAQ
- Documentation
- Documentation
- Sample Code
- Discussion Forum
- Hardware
- ESP-IDF
- ESP-BOX
- ESP-ADF
- ESP-MDF
- ESP-WHO
- ESP-SkaiNet
- ESP32 Arduino
- IDEs for ESP-IDF
- ESP-AT
- ESP IoT Solution
- ESP RainMaker
- Rust
- ESP8266
- Report Bugs
- Showcase
- Chinese Forum 中文社区
- 活动区
- 乐鑫活动专区
- 讨论区
- 全国大学生物联网设计竞赛乐鑫答疑专区
- ESP-IDF 中文讨论版
- 《ESP32-C3 物联网工程开发实战》书籍讨论版
- 中文文档讨论版
- ESP-AT 中文讨论版
- ESP-BOX 中文讨论版
- ESP IoT Solution 中文讨论版
- ESP-ADF 中文讨论版
- ESP Mesh 中文讨论版
- ESP Cloud 中文讨论版
- ESP-WHO 中文讨论版
- ESP-SkaiNet 中文讨论版
- ESP 生产支持讨论版
- 硬件问题讨论
- 项目展示
Who is online
Users browsing this forum: Bing [Bot] and 90 guests
- All times are UTC
- Top
- Delete cookies
About Us
Espressif Systems is a fabless semiconductor company providing cutting-edge low power WiFi SoCs and wireless solutions for wireless communications and Internet of Things applications. ESP8266EX and ESP32 are some of our products.