2016-11-30 06:51:14 +01:00
|
|
|
#ifndef __PXT_H
|
|
|
|
#define __PXT_H
|
|
|
|
|
2017-01-19 20:30:06 +01:00
|
|
|
//#define DEBUG_MEMLEAKS 1
|
2016-11-30 06:51:14 +01:00
|
|
|
|
|
|
|
#pragma GCC diagnostic ignored "-Wunused-parameter"
|
|
|
|
|
2019-12-02 05:58:26 +01:00
|
|
|
#include "pxtbase.h"
|
2016-11-30 06:51:14 +01:00
|
|
|
|
|
|
|
namespace pxt {
|
|
|
|
|
2019-12-02 05:58:26 +01:00
|
|
|
class RefMImage : public RefObject {
|
2016-11-30 06:51:14 +01:00
|
|
|
public:
|
2019-12-02 05:58:26 +01:00
|
|
|
ImageData *img;
|
2017-01-19 20:30:06 +01:00
|
|
|
|
2019-12-02 05:58:26 +01:00
|
|
|
RefMImage(ImageData *d);
|
|
|
|
void makeWritable();
|
|
|
|
static void destroy(RefMImage *map);
|
|
|
|
static void print(RefMImage *map);
|
|
|
|
static void scan(RefMImage *t);
|
|
|
|
static unsigned gcsize(RefMImage *t);
|
|
|
|
};
|
2017-01-19 20:30:06 +01:00
|
|
|
|
2019-12-02 05:58:26 +01:00
|
|
|
#define MSTR(s) ManagedString((s)->getUTF8Data(), (s)->getUTF8Size())
|
2017-01-19 20:30:06 +01:00
|
|
|
|
2019-12-02 05:58:26 +01:00
|
|
|
static inline String PSTR(ManagedString s) {
|
|
|
|
return mkString(s.toCharArray(), s.length());
|
|
|
|
}
|
2016-11-30 06:51:14 +01:00
|
|
|
|
2019-12-02 05:58:26 +01:00
|
|
|
typedef uint32_t ImageLiteral_;
|
2016-11-30 06:51:14 +01:00
|
|
|
|
2019-12-02 05:58:26 +01:00
|
|
|
static inline ImageData *imageBytes(ImageLiteral_ lit) {
|
|
|
|
return (ImageData *)lit;
|
|
|
|
}
|
2016-11-30 06:51:14 +01:00
|
|
|
|
2020-08-19 22:03:58 +02:00
|
|
|
#if MICROBIT_CODAL
|
|
|
|
// avoid clashes with codal-defined classes
|
|
|
|
#define Image MImage
|
|
|
|
#define Button MButton
|
|
|
|
#endif
|
|
|
|
|
|
|
|
typedef MicroBitPin DevicePin;
|
|
|
|
|
2019-12-02 05:58:26 +01:00
|
|
|
typedef RefMImage *Image;
|
2016-11-30 06:51:14 +01:00
|
|
|
|
2019-12-02 05:58:26 +01:00
|
|
|
extern MicroBit uBit;
|
|
|
|
extern MicroBitEvent lastEvent;
|
2016-11-30 06:51:14 +01:00
|
|
|
|
2016-11-30 06:55:37 +01:00
|
|
|
MicroBitPin *getPin(int id);
|
|
|
|
|
2019-12-02 05:58:26 +01:00
|
|
|
static inline int min_(int a, int b) {
|
|
|
|
if (a < b)
|
|
|
|
return a;
|
|
|
|
else
|
|
|
|
return b;
|
|
|
|
}
|
2016-11-30 06:51:14 +01:00
|
|
|
|
2019-12-02 05:58:26 +01:00
|
|
|
static inline int max_(int a, int b) {
|
|
|
|
if (a > b)
|
|
|
|
return a;
|
|
|
|
else
|
|
|
|
return b;
|
|
|
|
}
|
2016-11-30 06:51:14 +01:00
|
|
|
|
2019-12-02 05:58:26 +01:00
|
|
|
void initMicrobitGC();
|
2016-11-30 06:51:14 +01:00
|
|
|
|
2019-12-02 05:58:26 +01:00
|
|
|
} // namespace pxt
|
2016-11-30 06:51:14 +01:00
|
|
|
|
2019-12-02 05:58:26 +01:00
|
|
|
using namespace pxt;
|
2016-11-30 06:51:14 +01:00
|
|
|
|
2019-12-02 05:58:26 +01:00
|
|
|
#define DEVICE_EVT_ANY 0
|
2016-11-30 06:51:14 +01:00
|
|
|
|
2019-12-02 05:58:26 +01:00
|
|
|
#undef PXT_MAIN
|
|
|
|
#define PXT_MAIN \
|
|
|
|
int main() { \
|
|
|
|
pxt::initMicrobitGC(); \
|
|
|
|
pxt::start(); \
|
|
|
|
return 0; \
|
|
|
|
}
|
2016-11-30 06:51:14 +01:00
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
// vim: ts=2 sw=2 expandtab
|