Search found 24 matches
- Thu Dec 23, 2021 1:04 am
- Forum: MicroPython pyboard
- Topic: Hard fault when using USB HID with no USB connection
- Replies: 1
- Views: 13892
Hard fault when using USB HID with no USB connection
I have an application that needs to send HID reports (joystick) when connected to a computer, but still has to work when not connected to a computer. My Pyboard V1.1 is always powered from an external 5V power supply connected to V+. However, when I start my program and it tries to send the first HI...
- Sat Dec 18, 2021 8:01 pm
- Forum: General Discussion and Questions
- Topic: Why cant I escape this function?
- Replies: 3
- Views: 7417
Re: Why cant I escape this function?
Printing from an interrupt handler is problematic. Try removing your print statements or moving them to your main loop.
- Fri Dec 17, 2021 1:59 am
- Forum: MicroPython pyboard
- Topic: Can't use VCP+HID mode
- Replies: 6
- Views: 26442
Re: Can't use VCP+HID mode
Thanks. I just made a simple 3-axis (X,Y,Z) joystick emulator. Here's my code in boot.py: # simple joystick with 8-bit x,y,z pyb.usb_mode('VCP+HID', hid=(1, 2, 3, 8, bytes([0x05, 0x01, 0x09, 0x04, 0xa1, 0x01, 0x09, 0x01, 0xa1, 0x00, 0x09, 0x30, 0x09, 0x31, 0x09, 0x32, 0x25, 0x7f, 0x15, 0x81, 0x75, 0...
- Fri Dec 17, 2021 1:58 am
- Forum: General Discussion and Questions
- Topic: emulating joystick USB-HID
- Replies: 4
- Views: 13893
Re: emulating joystick USB-HID
I just made a simple 3-axis (X,Y,Z) joystick emulator. Here's my code in boot.py: # simple joystick with 8-bit x,y,z pyb.usb_mode('VCP+HID', hid=(1, 2, 3, 8, bytes([0x05, 0x01, 0x09, 0x04, 0xa1, 0x01, 0x09, 0x01, 0xa1, 0x00, 0x09, 0x30, 0x09, 0x31, 0x09, 0x32, 0x25, 0x7f, 0x15, 0x81, 0x75, 0x08, 0x9...
- Thu Dec 16, 2021 11:22 pm
- Forum: MicroPython pyboard
- Topic: Can't use VCP+HID mode
- Replies: 6
- Views: 26442
Re: Can't use VCP+HID mode
Thanks!
I figured out what happened: I had a blank micro SD card installed, and therefore my /flash/boot.py wasn't being loaded.
Now to figure out how to set up the descriptor for a joystick...
I figured out what happened: I had a blank micro SD card installed, and therefore my /flash/boot.py wasn't being loaded.
Now to figure out how to set up the descriptor for a joystick...
- Thu Dec 16, 2021 9:22 pm
- Forum: MicroPython pyboard
- Topic: Can't use VCP+HID mode
- Replies: 6
- Views: 26442
Re: Can't use VCP+HID mode
You need to change usb_mode in boot.py. Changing it in main.py or later (like in the REPL) has no effect. I've done this and it doesn't work. Here's my boot.py: # boot.py -- run on boot-up import pyb pyb.country('US') # ISO 3166-1 Alpha-2 code, eg US, GB, DE, AU #pyb.main('main.py') # main script t...
- Thu Dec 16, 2021 7:08 pm
- Forum: MicroPython pyboard
- Topic: MicroPython startup, No flash drive
- Replies: 6
- Views: 26241
Re: MicroPython startup, No flash drive
Openned Python 3.6 and input "import pyb". reply: ModuleNotFoundError: No module named 'pyb'. What am I doing wrong? You're opening Python on your PC, for one thing. You need to talk to the MicroPython on the pyboard instead, over the USB serial link. For this you need a communications program.
- Thu Dec 16, 2021 6:45 pm
- Forum: MicroPython pyboard
- Topic: Can't use VCP+HID mode
- Replies: 6
- Views: 26442
Can't use VCP+HID mode
I have a Pyboard v1.1 and have loaded firmware v1.17. When I do this: >>> import pyb >>> pyb.usb_mode() 'VCP+MSC' >>> pyb.usb_mode('VCP+HID') >>> pyb.usb_mode() 'VCP+MSC' I see that the usb mode has not changed. Am I missing something obvious? Should this work? I have also tried this code in boot.py...
- Wed Sep 01, 2021 1:27 am
- Forum: Development of MicroPython
- Topic: how to access a uctypes.struct in a C function?
- Replies: 1
- Views: 2280
Re: how to access a uctypes.struct in a C function?
This seems to work:
Code: Select all
STATIC inline stepper* get_stepper_struct(mp_obj_t str) {
mp_buffer_info_t bufinfo;
mp_get_buffer_raise(str, &bufinfo, MP_BUFFER_READ);
return (stepper *)(bufinfo.buf);
}
stepper *s = get_stepper_struct(mp_load_attr(self, MP_QSTR__s));
- Wed Sep 01, 2021 1:09 am
- Forum: Development of MicroPython
- Topic: how to access a uctypes.struct in a C function?
- Replies: 1
- Views: 2280
how to access a uctypes.struct in a C function?
I have a uctypes.struct() structure that I'm holding in an object attribute (called _s ) that's being passed to a C function (a timer callback). In the C function I'm doing this to get the pointer to the structure: size_t len; stepper *s = (stepper *)mp_obj_str_get_data(mp_load_attr(self, MP_QSTR__s...