int s_gt911_w_point_coordinate(int cnt, gt9xx_coord_t* pcd) { int reg_size; gt9xx_coord_t *pintput; uint16_t reg_offset = 0x814e; uint8_t* preg = get_start_reg(reg_offset, ®_size); if (preg == NULL) { _error("reg_offset error: %x ", reg_offset); return -1; } uint8_t* preg_status = preg; *preg_status = 0x80; uint8_t* pstart_coord = preg + 1; int i; uint8_t press = 0; for (i = 0; i < cnt; i++) { pintput = &pcd[i]; if(pintput->track_id == 0xff) { continue; } else if (pintput->track_id > POINT_NM) { _error("track_id error: %x ", pintput->track_id); return -1; } if(pintput->reserved){ press++; } gt9xx_coord_t* ram_start = (gt9xx_coord_t*)pstart_coord; ram_start = ram_start + pintput->track_id; memcpy(ram_start, pintput, sizeof(gt9xx_coord_t)); } *preg_status = 0x80 | (press & 0x0f); // for(i= 0; i < 40; i++) { // printf(" 0x%x ", reg_81xx[i]); // } // printf("\r\n"); //dump_reg_hex(); return 0; }
时间: 2023-05-18 07:05:52 浏览: 85
该函数的作用是获取GT911触摸屏的坐标信息,其中cnt表示坐标点的数量,pcd是一个指向坐标点结构体的指针。函数中定义了reg_size、pintput、reg_offset和preg等变量,其中reg_offset表示寄存器的偏移地址。get_start_reg函数用于获取寄存器的起始地址,该函数的实现需要根据具体的硬件平台来确定。
相关问题
读取触摸屏幕的输入事件int Ts_Read()函数怎么写
读取触摸屏幕的输入事件可以通过 Linux 下的 tslib 库来实现。下面是一个简单的示例代码,可以帮助你读取触摸屏幕的输入事件:
```c
#include <stdio.h>
#include <stdlib.h>
#include <fcntl.h>
#include <linux/input.h>
#include <tslib.h>
#define DEV_NAME "/dev/input/event0" // 触摸屏设备节点
int main()
{
int fd, ret;
struct tsdev *ts;
struct ts_sample samp;
// 打开触摸屏设备节点
fd = open(DEV_NAME, O_RDWR);
if (fd < 0) {
perror("open");
exit(1);
}
// 初始化 tslib 库
ts = ts_open(DEV_NAME, 0);
if (!ts) {
perror("ts_open");
exit(1);
}
// 设置触摸屏参数
ts_config(ts);
// 不断读取触摸屏事件
while (1) {
ret = ts_read(ts, &samp, 1);
if (ret < 0) {
perror("ts_read");
exit(1);
}
if (samp.pressure > 0) {
printf("X coordinate: %d\n", samp.x);
printf("Y coordinate: %d\n", samp.y);
}
}
// 关闭 tslib 库和设备文件
ts_close(ts);
close(fd);
return 0;
}
```
这个示例代码中,首先打开触摸屏设备节点,并使用 tslib 库来初始化触摸屏参数。然后在一个无限循环中读取触摸屏事件,并将读取到的触摸坐标打印出来。注意,这个示例代码中的坐标值是相对值,需要结合实际情况转换为绝对值。
AttributeError: 'int' object has no attribute 'data_type'報這個
抱歉,我之前的回答有误,cell 对象没有 data_type 属性。您可以使用 openpyxl 库中的 is_date_format 方法来判断单元格是否为日期格式,如果是则将日期格式转换为字符串。以下是修改后的代码:
```python
import openpyxl.utils.cell as cell_utils
for row in self.record_sheet.iter_rows(min_row=2, values_only=True):
row_values = []
for cell in row:
if cell is not None:
if cell_utils.is_date_format(cell.number_format): # 判断单元格是否为日期格式
cell_value = cell.value.strftime('%Y-%m-%d %H:%M:%S') # 将日期格式转换为字符串
elif cell.data_type == 'f': # 判断单元格是否为公式
cell_value = cell.value # 获取公式
cell_value = self.record_sheet[cell.coordinate].value # 获取公式计算结果
else:
cell_value = str(cell)
else:
cell_value = ""
row_values.append(cell_value)
if all(not bool(cell) for cell in row_values):
continue
treeview1.insert("", tk.END, values=row_values)
```
同样的,您也可以将相同的代码添加到第二个工作表的 for 循环中。
相关推荐
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)