Porting micropython thumby libraries to C?

casssoft

  • Newbie
  • *
    • Posts: 1
    • View Profile
I'm starting to look into how i want to make games for the thumby but I realized there's a lot of micropython only functionality like saves and sprites. (I'm addicted to C).

Could someone give me a few pointers and how to reimplement the micropython stuff in C? Here's some of the specific stuff I was trying to figure out:

Where in the micropython fork should I be looking for thumby specific stuff? there's a couple of branches and files, is it all just in rp2? Whats actually loaded on the thumby? there's probably something in the code editor repo i haven't found yet...

For hardware interaction I definitely need to figure out how to load littlefs or whatever filesystem abstraction micropython is using. Is there a specific place in the repo that deals with that? I might just try loading up a littlefs C library..

Also is there any other hardware interactions that C is missing besides the filesystem? I see a sprite system but maybe that's just a nice wrapper around loading sprites and writing them to the buffer.

(anyhow thanks for reading)


Jason

  • Administrator
  • Hero Member
  • *****
    • Posts: 107
  • TinyCircuits Employee
    • View Profile
I'm starting to look into how i want to make games for the thumby but I realized there's a lot of micropython only functionality like saves and sprites. (I'm addicted to C).

Could someone give me a few pointers and how to reimplement the micropython stuff in C? Here's some of the specific stuff I was trying to figure out:

Where in the micropython fork should I be looking for thumby specific stuff? there's a couple of branches and files, is it all just in rp2? Whats actually loaded on the thumby? there's probably something in the code editor repo i haven't found yet...

For hardware interaction I definitely need to figure out how to load littlefs or whatever filesystem abstraction micropython is using. Is there a specific place in the repo that deals with that? I might just try loading up a littlefs C library..

Also is there any other hardware interactions that C is missing besides the filesystem? I see a sprite system but maybe that's just a nice wrapper around loading sprites and writing them to the buffer.

(anyhow thanks for reading)

Hi,

We don't actually use a fork of MicroPython for the Thumby firmware, we use the vanilla/regular version from the website (1.19.1: https://micropython.org/download/RPI_PICO/). The version we have on our GitHub is mostly for the emulator and testing.

Although we don't build our own MicroPython, I am very familiar with how it works. If you want to use littlefs from C then you can use version that gets pulled in from MicroPython itself (lib/littlefs/lfs2.h). This isn't exactly simple though as you will have to reimplement the prog/sync/erase functions for the RP2040. The documentation on how to use littlefs is in this header: https://github.com/littlefs-project/littlefs/blob/master/lfs.h

There are a couple of different hardware interactions that would have to be implmented in C:
  • Init and sending data to the display
  • Buttons
  • Sound

The sprite portion of the Thumby library just handles pulling data from a sprite and then copying it into the framebuffer at a location. It also does some simple animation type stuff.


 

SMF spam blocked by CleanTalk