Microsoft MakeCode

Defining constants used in both .cpp and .ts?

I don’t fully understand how the .ts, .h and .cpp files are sewn together and how best to declare a constant, let’s say LPWIDTH = 6 which I would like to use within both a .ts file and a .cpp file of an extension I would like to write, with its own namespace. Do I have to declare it separately? The constant won’t need to be referred to outside the extension by the calling code.

And what if I want another constant which is DigitalPin.P16 so that I can use the name RST_PIN rather than refer directly to the pin number either in Typescript or C?

And let’s say I have another constant which is, say, an enum animals { Dog = 1, Cat =2 } etc which I wish to used as a drop-down list in a Makecode block and which I will also want to use within the cpp file, the ts file of the extension, and also visible to the external code.

I understand how to make a block work with the drop-down list, by putting this at the top of the .ts of the extension and outside the namespace {}:

enum Animals {
//% block="dog"
Dog = 1,
//% block="cat
Cat  = 2

and so on, and creating a shim function to use with the blocks that require the drop-down list. I think I may want to have this visible within to C code.

Lastly, what exactly does declare const do which const doesn’t?