Open JackAtKitronik opened 2 years ago
I don't think there's much that can be done about this, the micro:bit V1 just doesn't have enough memory.
If you really need to get it working on a V1, it might be possible to optimise the code so that it does fit. But in general that's not possible to do, and the way to resolve it is either:
@JackAtKitronik was this the issue where the code worked fine in a single file but it was running out of memory (in this case by ~400 bytes) when using a module?
@dpgeorge if that's the case, would that be expected? that separating the code into a module could consume that much extra memory?
I got this working and used it with a move:mini https://github.com/rhubarbdog/microbit-servo
if that's the case, would that be expected? that separating the code into a module could consume that much extra memory?
Yes that's expected, simply because you now have two .py files: the main one which imports the second one. And some memory is already used by the first at the point where the second is imported and compiled.
This case would definitely benefit from being able to import .mpy files.
@JackAtKitronik was this the issue where the code worked fine in a single file but it was running out of memory (in this case by ~400 bytes) when using a module?
@microbit-carlos almost. Putting it into a single file did make it smaller but not small enough to work.
I got this working and used it with a move:mini https://github.com/rhubarbdog/microbit-servo
@rhubarbdog great I'll have a look.
Describe the bug Using the micro:bit Python Editor, we were trying to add servo and LED functionality to the Kitronik MOVE Motor MicroPython library. Upon adding the servo code (about 20 lines of code) the code is now too big and when put on the V1 micro:bit it causes a memory allocation error saying memeory allocation failed, allocating 398 bytes.
To Reproduce Steps to reproduce the behavior:
memory error, memeory allocation failed, allocating 398 bytes
appearsExpected behavior Following the same steps on as above but the program works on a V1 micro:bit. On a V2 micro:bit then the code works as expected.
micro:bit version V1 micro:bit