not logged in | [Login]
This section to be deleted/reformatted/made politically correct at a later date
Creating a pyboard module is a complicated task all by itself and I don't want to try and learn both C -> pyboard at the same time as ST's CAN hardware all while struggling to push my compiled code to the board (dfu-util is giving me trouble at the moment). Because of all this complexity, I will start by simply creating a "Hello, world!" pyboard module within the stmhal implementation. I'm a Saab fan, so my module consists of the 6 different Saabs that I've owned and allows you to create more on-the-fly.
<
and >
) is a variable of your choosing<root>/
refers to the top level directory of micropython. I am referring to the directory with README.md
in it.<root>/stmhal/<name>.c
and <root>/stmhal/<name>.h
. Compiling these into the executable is as simple as adding one line below line 112 of <root>/stmhal/Makefile
. The new line should simply read saab.c \
.<name>
with saab
or form of that with different capitalization depending on the use. Any time you see saab
, you should replace it with the name of your module and whatever capitalization you see fit.const mp_obj_type_t pyb_saab_type = {...};
See line 292 of the LED module for reference. This variable contains lots of metadata about our object: its name, a function that can be used for printing our object, a function to create a new instance and a dictionary with the names of each public method. Lots more metadata can be filled in - just take a look at the definition of mp_obj_type_t.{&mp_type_type }
. So, at a minimum, we have const mp_obj_type_t pyb_saab_type = { {&mp_type_type } };
. This is essentially inheritance - giving a base type to our class. The output of Python's type
function will depend on what we give this first field. I think it's a bit confusing and not very important for continuing on, so just type that line and move forward with life. :)This code will be inserted when I get home
Last edited by David Zemon, 2014-07-01 01:32:19