Skip to content

Commit a8b282e

Browse files
authored
Merge pull request #56 from Fire-boy/main
wiki BC25PA接口说明以及keypad接口说明调整
2 parents 0bc8fbe + 9885e48 commit a8b282e

File tree

2 files changed

+229
-118
lines changed

2 files changed

+229
-118
lines changed

en-us/api/QuecPythonClasslib.md

Lines changed: 110 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -2676,7 +2676,6 @@ This function sets the current modem functionality.
26762676
#### checkNet - Wait for Network to be Ready
26772677

26782678
Function: The checkNet module is mainly used for the script programs [auto-startup], and provides APIs to wait for the network to be ready. If it times out or exits abnormally, the program returns an error code. Therefore, if there are network-related operations in the your program, the method in the checkNet module should be called at the beginning of the user program to wait for the network to be ready. Of course, you can also implement the functions of this module by yourselves.
2679-
Note: The BC25PA platform does not support this module function.
26802679
##### Create checkNet Object
26812680

26822681
> **import checkNet**
@@ -3076,7 +3075,6 @@ if __name__ == '__main__':
30763075
#### app_fota - Upgrade User File
30773076

30783077
Module function: Upgrade user file
3079-
Note: The BC25PA platform does not support this module function.
30803078
##### Create an app_fota Object
30813079

30823080
1. Import app_fota module
@@ -4772,11 +4770,11 @@ usb.setCallback(usb_callback)
47724770

47734771
It provides the USB network adapter function.
47744772

4775-
NOTE:Currently, only the ASR platform and Unisoc supports it.
4773+
NOTE:Currently, only the ASR platform supports it.
47764774

47774775
###### Setting the USBNET working type (Take effect after restart)
47784776

4779-
> **USBNET.set_worktype(type)**
4777+
USBNET.set_worktype(type)
47804778

47814779
- Parameter
47824780

@@ -4788,46 +4786,6 @@ NOTE:Currently, only the ASR platform and Unisoc supports it.
47884786

47894787
Return 0 if the setting is successful, otherwise return -1.
47904788

4791-
4792-
4793-
###### Getting the USBNET working type (Take effect after restart)
4794-
4795-
> **USBNET.get_worktype()**
4796-
4797-
* Parameter
4798-
4799-
None
4800-
4801-
* Return Value
4802-
4803-
Return the USBNET working type if successful, otherwise return -1.
4804-
4805-
1 - ECM type
4806-
4807-
3 - RNDIS type
4808-
4809-
4810-
4811-
###### Getting the USBNET status
4812-
4813-
> **USBNET.get_status()**
4814-
4815-
* Parameter
4816-
4817-
None
4818-
4819-
* Return Value
4820-
4821-
Return the USBNET status if successful, otherwise return -1.
4822-
4823-
status:
4824-
4825-
0 - Not connected
4826-
4827-
1 - connected
4828-
4829-
4830-
48314789
###### Open USBNET
48324790

48334791
> **USBNET.open()**
@@ -5734,7 +5692,7 @@ Row number of the pin map.
57345692

57355693
##### RTC
57365694

5737-
Class function: It provides methods to get and set RTC time.
5695+
Class function: It provides methods to get and set RTC time. For bc25pa platform, it can wake up the module from deep sleep or software shutdown.
57385696

57395697
###### Create RTC Object
57405698

@@ -5786,7 +5744,79 @@ When getting the time, return a tuple containing the date and time in the follow
57865744
(2020, 3, 12, 4, 12, 12, 14, 0)
57875745
```
57885746

5747+
###### Set callback function
5748+
5749+
> **rtc.register_callback(usrFun)**
5750+
5751+
When RTC expiration time callback function is set (for BC25PA platform, if it is recovered from deep sleep or software shutdown, calling this function will immediately call usrfun once)
5752+
* Parameter
5753+
5754+
| Parameter | Type | Description |
5755+
| ------ | -------- | ------------------------------------------ |
5756+
| usrFun | function | Callback function, which is called when the set RTC time arrives. |
5757+
5758+
Note: usrFun requires parameters
5759+
5760+
* Return Value
5761+
0 Successful execution.
57895762

5763+
-1 Failed execution.
5764+
* Example
5765+
5766+
```python
5767+
>>> def test(df):
5768+
... print('rtc test...',df)
5769+
...
5770+
...
5771+
...
5772+
>>>
5773+
>>> rtc.register_callback(test)
5774+
0
5775+
```
5776+
###### Set RTC expiration time
5777+
rtc.set_alarm(data_e)
5778+
Set the RTC expiration time. When the expiration time is reached, the registered callback function will be called
5779+
* Parameter
5780+
| Parameter | Type | Description |
5781+
| ----------- | ---- | ------------------------------------------------------------ |
5782+
| year | int | year |
5783+
| month | int | month,Range1 ~ 12 |
5784+
| day | int | day,Range1 ~ 31 |
5785+
| week | int | week,Range0 ~ 6,Where 0 means Sunday and 1 ~ 6 means Monday to Saturday respectively. When setting time,this parameter does not work and is reserved. This parameter is valid when getting time |
5786+
| hour | int | hour,Range0 ~ 23 |
5787+
| minute | int | minute,Range0 ~ 59 |
5788+
| second | int | second,Range0 ~ 59 |
5789+
| microsecond | int | microsecond,The parameter is reserved and not used yet. When setting the time, the parameter can be written as 0 |
5790+
5791+
* Return Value
5792+
0 Successful execution.
5793+
-1 Failed execution.
5794+
* Example
5795+
```python
5796+
>>> data_e=rtc.datetime()
5797+
>>> data_l=list(data_e)
5798+
>>> data_l[6] +=30
5799+
>>> data_e=tuple(data_l)
5800+
>>> rtc.set_alarm(data_e)
5801+
0
5802+
```
5803+
###### Start / stop RTC timer
5804+
rtc.enable_alarm(on_off)
5805+
The timer can be started only when the callback function is set (bc25pa platform)
5806+
* Parameter
5807+
5808+
| Parameter | Type | Description |
5809+
| ----------- | ---- | ------------------------------------------------------------ |
5810+
| on_off | int | 0 - Turn off RTC timer. 1 - Start RTC timer. |
5811+
5812+
* Return Value
5813+
0 Successful execution.
5814+
-1 Failed execution.
5815+
* Example
5816+
```python
5817+
>>> rtc.enable_alarm(1)
5818+
0
5819+
```
57905820

57915821
##### I2C
57925822

@@ -5955,7 +5985,7 @@ Adaptation version: EC100Y (V0009) and above; EC600S (V0002) and above.
59555985
| EC600S/EC600N | port0:<br />CS:Pin number 58<br />CLK:Pin number 61<br />MOSI:Pin number 60<br />MISO:Pin number 59<br />port1:<br />CS:Pin number 4<br />CLK:Pin number 1<br />MOSI:Pin number 3<br />MISO:Pin number 2 |
59565986
| EC100Y | port0:<br />CS:Pin number 25<br />CLK:Pin number 26<br />MOSI:Pin number 27<br />MISO:Pin number 28<br />port1:<br />CS:Pin number 105<br />CLK:Pin number 104<br />MOSI:Pin number 107<br />MISO:Pin number 106 |
59575987
| BC25PA | port0:<br />CS:Pin number 6<br />CLK:Pin number 5<br />MOSI:Pin number 4<br />MISO:Pin number 3|
5958-
5988+
* Note:Bc25pa platform does not support 1 and 2 modes.
59595989
- Example
59605990

59615991
```python
@@ -6465,6 +6495,14 @@ Module function: provide matrix keyboard interface and support platform ec600scn
64656495
###### Create keypad object
64666496

64676497
> **keypad=machine.KeyPad()**
6498+
*Parameter
6499+
| Parameter | Type | Description |
6500+
| ------ | -------- | ----------------------------------- |
6501+
|Row | int | row (if it is greater than 0 and less than 8, and neither row nor column is set, the default is 4)|
6502+
|Col | int | column (greater than 0 and less than 8. If the column is not set, the default is 4)|
6503+
Note: if row and col are not set, the default is 4X4..
6504+
6505+
*Example:
64686506
>
64696507
> ```python
64706508
> >>>import machine
@@ -6495,7 +6533,9 @@ After the key is connected to the module, press and release the key to trigger t
64956533

64966534
* Parameters
64976535

6498-
| Parameter | parameter type | parameter description |
6536+
- Parameter
6537+
6538+
| Parameter | Type | Description |
64996539
| ------ | -------- | ------------------------------------------ |
65006540
| usrFun | function | callback function. This function will be triggered when the external keyboard key is pressed and placed |
65016541

@@ -6504,35 +6544,17 @@ Note: the usrfun parameter is list.
65046544

65056545
List contains five parameters. It has the following meanings:
65066546

6507-
list[0] - 90 means press and non-90 means lift
6547+
list[0] - 1 means press and 0 means lift
65086548

65096549
list[1] - row
65106550

65116551
list[2] - col
65126552

6513-
List [3] - reserved, 0 by default, not used for the time being
6514-
6515-
List [4] - the bottom layer outputs the key value, which is generally not used.
65166553

65176554
* Return value
65186555

65196556
0
65206557

6521-
###### Set pin reuse
6522-
6523-
> **keypad.setMuliKeyen(enbale)**
6524-
6525-
* Parameters
6526-
6527-
| Parameter | parameter type | parameter description |
6528-
| ------ | -------- | ----------------------------------- |
6529-
| Enbale | int | 1-enable multi-function keys, 0-ignore multi-function keys |
6530-
6531-
Note: only ec600ncnlc platform needs to call this function.
6532-
6533-
* Return value
6534-
6535-
0
65366558

65376559
###### Uninitialization
65386560

@@ -6557,12 +6579,11 @@ keypad=machine.KeyPad()
65576579
keypad.init()
65586580
def userfun(l_list):
65596581
global is_loop
6560-
if l_list[0] != 90 and l_list[1] == 4 and l_list[2] == 4 :
6582+
if l_list[0] != 1 :
65616583
is_loop = 0
65626584
print('will exit')
65636585
print(l_list)
65646586

6565-
keypad.setMuliKeyen(1)
65666587
keypad.set_callback(userfun)
65676588
loop_num = 0
65686589

@@ -6571,7 +6592,6 @@ while is_loop == 1 and loop_num < 10:
65716592
loop_num = loop_num +1
65726593
print(" running..... ",is_loop,loop_num)
65736594

6574-
keypad.setMuliKeyen(0)
65756595
keypad.deinit()
65766596
print('exit!')
65776597
```
@@ -10506,7 +10526,23 @@ None.
1050610526
>>> aep.connect()
1050710527
0
1050810528
```
10529+
###### Query data to be read
10530+
10531+
> **aep.check()**
1050910532
10533+
- **Parameter**
10534+
None
10535+
- **Return Value**
10536+
Returns the number of pieces of data to be read distributed by the cloud platform
10537+
10538+
- Example
10539+
10540+
```python
10541+
>>> from nb import AEP
10542+
>>> aep=AEP("221.229.214.202","5683")
10543+
>>> aep.check()
10544+
0
10545+
```
1051010546
###### Receive data
1051110547

1051210548
> **aep.recv(data_len,data)**
@@ -10549,8 +10585,7 @@ Failed - not 0
1054910585

1055010586
- Note
1055110587

10552-
The sent data is a hexadecimal string, and the data length is even.
10553-
10588+
The sending data is a hexadecimal string, the data length is an even number, blocking (timeout 3 minutes), and returning success indicates that the sending instruction is executed successfully.
1055410589
- **Return Value**
1055510590

1055610591
Success - 0
@@ -10621,7 +10656,7 @@ def HexToStr(source, t=None):
1062110656
def StrToHex(source):
1062210657
return int(source)
1062310658

10624-
#对照物模型定义打包解包根据相应的服务id中的属性进行解析
10659+
#对照物模型定义,打包解包根据相应的服务id中的属性进行解析
1062510660
serid_dict={'阀门开关控制':8001,
1062610661
'故障上报':1001,
1062710662
'设备信息上报':3,
@@ -10639,7 +10674,7 @@ dict_cmd={'数据上报':0x02,
1063910674
send_type={
1064010675
'RAI_NONE':0,
1064110676
'RAI_1':1,
10642-
'RAI_2':1
10677+
'RAI_2':2
1064310678
}
1064410679
servcei_info={
1064510680
'ip':"221.229.214.202",
@@ -10650,14 +10685,14 @@ def aep_pack_cmdtype02(service_id,data_in):
1065010685
data=HexToStr(dict_cmd['数据上报'],1)
1065110686
data+=HexToStr(service_id,2) #serviceid转成字符串
1065210687
if service_id == 1:
10653-
data+=HexToStr(4,2) #发送数据8.14float类型四个字节长度,此处只举例一个情况
10688+
data+=HexToStr(4,2) #发送数据8.14,float类型四个字节长度,此处只举例一个情况
1065410689
data+=HexToStr(aep_htonf(data_in),4) #float数据转成字符串
1065510690
else:
1065610691
print('not support') #
1065710692
return data
1065810693

1065910694
def aep_pack(cmdtype,service_id,data):
10660-
if cmdtype == dict_cmd['数据上报']: #数据上报-0x02此处只举例一个情况
10695+
if cmdtype == dict_cmd['数据上报']: #数据上报-0x02,此处只举例一个情况
1066110696
return aep_pack_cmdtype02(service_id,data)
1066210697
else:
1066310698
print('not support')

0 commit comments

Comments
 (0)