Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitc1023b6

Browse files
committed
updates the gt911 driver
1 parenteded288 commitc1023b6

File tree

2 files changed

+32
-39
lines changed

2 files changed

+32
-39
lines changed

‎api_drivers/common_api_drivers/indev/gt911.py‎

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,12 +44,10 @@ def _read_reg(self, reg, num_bytes=None, buf=None):
4444

4545
def_write_reg(self,reg,value=None,buf=None):
4646
ifvalueisnotNone:
47-
self._tx_buf[0]=reg>>8
48-
self._tx_buf[1]=reg&0xFF
49-
self._tx_buf[2]=value
50-
self._device.write(self._tx_mv[:3])
47+
self._tx_buf[0]=value
48+
self._device.write_mem(reg,self._tx_mv[:1])
5149
elifbufisnotNone:
52-
self._device.write(buf)
50+
self._device.write_mem(reg,buf)
5351

5452
def__init__(
5553
self,

‎api_drivers/common_api_drivers/indev/gt911_extension.py‎

Lines changed: 29 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -36,105 +36,100 @@ def __init__(self, indev, i2c):
3636
self._indev=indev
3737
self._i2c=i2c
3838

39-
self._config_data=bytearray(186)
39+
self._config_data=bytearray(_CONFIG_FRESH_REG-_CONFIG_START_REG)
4040
self._config_mv=memoryview(self._config_data)
4141

4242
self._indev._read_reg(_CONFIG_START_REG,buf=self._config_mv[2:])
4343

4444
@property
4545
defwidth(self):
4646
return (
47-
(self._config_data[_X_OUTPUT_MAX_HIGH_POS+2]<<8)|
48-
self._config_data[_X_OUTPUT_MAX_LOW_POS+2]
47+
(self._config_data[_X_OUTPUT_MAX_HIGH_POS]<<8)|
48+
self._config_data[_X_OUTPUT_MAX_LOW_POS]
4949
)
5050

5151
@width.setter
5252
defwidth(self,value):
53-
self._config_data[_X_OUTPUT_MAX_LOW_POS+2]=value&0xFF
54-
self._config_data[_X_OUTPUT_MAX_HIGH_POS+2]= (value>>8)&0xFF
53+
self._config_data[_X_OUTPUT_MAX_LOW_POS]=value&0xFF
54+
self._config_data[_X_OUTPUT_MAX_HIGH_POS]= (value>>8)&0xFF
5555

5656
@property
5757
defheight(self):
5858
return (
59-
(self._config_data[_Y_OUTPUT_MAX_HIGH_POS+2]<<8)|
60-
self._config_data[_Y_OUTPUT_MAX_LOW_POS+2]
59+
(self._config_data[_Y_OUTPUT_MAX_HIGH_POS]<<8)|
60+
self._config_data[_Y_OUTPUT_MAX_LOW_POS]
6161
)
6262

6363
@height.setter
6464
defheight(self,value):
65-
self._config_data[_Y_OUTPUT_MAX_LOW_POS+2]=value&0xFF
66-
self._config_data[_Y_OUTPUT_MAX_HIGH_POS+2]= (value>>8)&0xFF
65+
self._config_data[_Y_OUTPUT_MAX_LOW_POS]=value&0xFF
66+
self._config_data[_Y_OUTPUT_MAX_HIGH_POS]= (value>>8)&0xFF
6767

6868
@property
6969
defnoise_reduction(self):
70-
returnself._config_data[_NOISE_REDUCTION_POS+2]&0x0F
70+
returnself._config_data[_NOISE_REDUCTION_POS]&0x0F
7171

7272
@noise_reduction.setter
7373
defnoise_reduction(self,value):
74-
upper_val=self._config_data[_NOISE_REDUCTION_POS+2]>>4
74+
upper_val=self._config_data[_NOISE_REDUCTION_POS]>>4
7575
self._config_data[_NOISE_REDUCTION_POS+2]= (upper_val<<4)| (value&0x0F)
7676

7777
@property
7878
deftouch_press_level(self):
79-
returnself._config_data[_TOUCH_PRESS_LEVEL_POS+2]
79+
returnself._config_data[_TOUCH_PRESS_LEVEL_POS]
8080

8181
@touch_press_level.setter
8282
deftouch_press_level(self,value):
83-
self._config_data[_TOUCH_PRESS_LEVEL_POS+2]=value&0xFF
83+
self._config_data[_TOUCH_PRESS_LEVEL_POS]=value&0xFF
8484

8585
@property
8686
deftouch_leave_level(self):
87-
returnself._config_data[_TOUCH_LEAVE_LEVEL_POS+2]
87+
returnself._config_data[_TOUCH_LEAVE_LEVEL_POS]
8888

8989
@touch_leave_level.setter
9090
deftouch_leave_level(self,value):
91-
self._config_data[_TOUCH_LEAVE_LEVEL_POS+2]=value&0xFF
91+
self._config_data[_TOUCH_LEAVE_LEVEL_POS]=value&0xFF
9292

9393
@property
9494
defpad_left(self):
95-
returnself._config_data[_HOR_SPACE_POS+2]>>4
95+
returnself._config_data[_HOR_SPACE_POS]>>4
9696

9797
@pad_left.setter
9898
defpad_left(self,value):
99-
self._config_data[_HOR_SPACE_POS+2]= (value<<4)|self.pad_right
99+
self._config_data[_HOR_SPACE_POS]= (value<<4)|self.pad_right
100100

101101
@property
102102
defpad_right(self):
103-
returnself._config_data[_HOR_SPACE_POS+2]&0xF
103+
returnself._config_data[_HOR_SPACE_POS]&0xF
104104

105105
@pad_right.setter
106106
defpad_right(self,value):
107-
self._config_data[_HOR_SPACE_POS+2]= (self.pad_left<<4)| (value&0xF)
107+
self._config_data[_HOR_SPACE_POS]= (self.pad_left<<4)| (value&0xF)
108108

109109
@property
110110
defpad_top(self):
111-
returnself._config_data[_VER_SPACE_POS+2]>>4
111+
returnself._config_data[_VER_SPACE_POS]>>4
112112

113113
@pad_top.setter
114114
defpad_top(self,value):
115-
self._config_data[_VER_SPACE_POS+2]= (value<<4)|self.pad_bottom
115+
self._config_data[_VER_SPACE_POS]= (value<<4)|self.pad_bottom
116116

117117
@property
118118
defpad_bottom(self):
119-
returnself._config_data[_VER_SPACE_POS+2]&0xF
119+
returnself._config_data[_VER_SPACE_POS]&0xF
120120

121121
@pad_bottom.setter
122122
defpad_bottom(self,value):
123-
self._config_data[_VER_SPACE_POS+2]= (self.pad_top<<4)| (value&0xF)
123+
self._config_data[_VER_SPACE_POS]= (self.pad_top<<4)| (value&0xF)
124124

125125
defsave(self):
126-
checksum= ((~sum(self._config_data[2:]))+1)&0xFF
126+
# calculate the checksum
127+
self._config_data[_CONFIG_CHKSUM_REG-_CONFIG_START_REG]= ((~sum(self._config_data[:-2]))+1)&0xFF
127128

128-
self._config_data[0]=_CONFIG_CHKSUM_REG>>8
129-
self._config_data[1]=_CONFIG_CHKSUM_REG&0xFF
130-
self._indev._write_reg(_CONFIG_CHKSUM_REG,buf=self._config_mv)
129+
# set the flag to save the data the data
130+
self._config_data[-1]=0x01# _CONFIG_FRESH_REG
131131

132-
self._config_data[2]=checksum
133-
self._indev._write_reg(_CONFIG_CHKSUM_REG,buf=self._config_mv[:3])
134-
135-
self._config_data[0]=_CONFIG_FRESH_REG>>8
136-
self._config_data[1]=_CONFIG_FRESH_REG&0xFF
137-
self._config_data[2]=0x01
138-
self._indev._write_reg(_CONFIG_FRESH_REG,buf=self._config_mv[:3])
132+
# write all config data to the touch IC
133+
self._indev._write_reg(_CONFIG_START_REG,buf=self._config_mv)
139134

140135
self._indev.hw_reset()

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp