2490 views|6 replies

424

Posts

8

Resources
The OP
 

Bug in pyboardCN V2's built-in firmware [Copy link]

 I found some minor bugs in the V2 firmware. I couldn't use main.py to port the official mouse example. Later, I added LED debugging and found a problem with the while statement. Commenting out the while statement will allow it to run.
  1. import pyb switch = pyb.Switch() accel = pyb.Accel() while not switch(): pyb.hid((0, accel.x(), accel.y(), 0)) pyb.delay(20)
复制代码
Then I changed the while condition to True, but still couldn't run. After commenting out the delay statement, I found that it would execute if the LED statement was removed, as shown below. (switch = pyb.Switch() This statement will not work when switch is not used)
  1. import pyb while True: pyb.LED(2),on()
复制代码
Also, LED3 will be uncontrollable after adding switch
  1. pyb.hid((0, 10, 0, 0))
复制代码
This code is even more powerful, and 4 LEDs will flash during operation. The above bugs have not been found and solved. I have exams these days, so I'll do this for now



Latest reply

I'm wondering if it's an indentation problem. I've encountered this before, where the code looked fine, but in the editor notepad++ I used 4 spaces for one line, and after pressing enter on another line notepad++ defaulted to alignment (should be a tab), and then the program wouldn't run.  Details Published on 2018-7-19 15:55
 
 

1w

Posts

25

Resources
2
 
This is not a bug, it's just a wrong way of using it. First, you need to set the USB mode in boot.py by setting pyb.usb_mode('VCP+HID') or uncommenting the corresponding line. Then in main.py, add a delay before calling the hid.send() function.
  1. import pyb pyb.delay(500) switch = pyb.Switch() accel = pyb.Accel() hid = pyb.USB_HID() while not switch(): hid.send((0, accel.x(), accel.y(), 0)) pyb.delay(20)
复制代码


 
 
 

1w

Posts

25

Resources
3
 
The example you are looking at is from an old version. The hid function is now obsolete and has been replaced by the send() function. The USB mode can only be changed in boot.py. Changing it in main.py is invalid. To restore the mode, please refer to the official document's safe mode. The official reference document is as follows: http://docs.micropython.org/en/l ... rial/usb_mouse.html

Comments

Thanks for the reply. I have tried both the new and old versions, but they don't work. Sometimes I see that the driver cannot be installed and it still doesn't work. I change the computer and it's the same. This string of code, whether it is new or old, will make the LED light up, but the same program on the Nano board will not work.  Details Published on 2018-7-6 15:55
 
 
 

424

Posts

8

Resources
4
 
dcexpert posted on 2018-7-6 14:31 The example you are looking at is the old version. Now the hid function has been deprecated and replaced by the send() function. The USB mode can only be changed in boot.py, in m ...
Thank you for your reply. I have tried both the new and old versions, and neither works. Sometimes I see that the driver cannot be installed or does not work, and the same is true when I change a computer.
  1. hid = pyb.USB_HID() hid.send((0, 10, 0, 0))
复制代码
This string of code, whether it is new or old, will make the LED light up, but the same program will not work on the Nano board.

Comments

I just tested it and it works. Is it because boot.py was not saved successfully?  Details Published on 2018-7-6 23:10
 
 
 

1w

Posts

25

Resources
5
 
lehuijie posted on 2018-7-6 15:55 Thanks for the reply. I have tried both the new and old versions, but they don't work. Sometimes I see that the driver cannot be installed or cannot work, so I change a computer...
I just tested it and it works. Is it because boot.py was not saved successfully?
 
 
 

256

Posts

0

Resources
6
 
I'm wondering if it's an indentation problem. I've encountered this before, where the code looked fine, but in the editor notepad++ I used 4 spaces for one line, and after pressing enter on another line notepad++ defaulted to alignment (should be a tab), and then the program wouldn't run.

Comments

This is not an indentation problem. The indentation has been tested. I will study the specific problem in a few days. I suspect it is a layout or firmware problem.  Details Published on 2018-7-19 23:09
 
 
 

424

Posts

8

Resources
7
 
viphotman posted on 2018-7-19 15:55 I am wondering if it is an indentation problem. I have encountered a situation where the code seems to be fine. In the editor notepad++, I use 4 spaces in one line, and...
This is not an indentation problem. The indentation has been tested. The specific problem will be studied in a few days. I suspect it is a layout or firmware problem.
 
 
 

Guess Your Favourite
Find a datasheet?

EEWorld Datasheet Technical Support

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京B2-20211791 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号
快速回复 返回顶部 Return list