Skip to content
5 changes: 5 additions & 0 deletions libs/hw---rpi-raw-elf/config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@

namespace config {
export const DISPLAY_WIDTH = 160;
export const DISPLAY_HEIGHT = 120;
}
7 changes: 7 additions & 0 deletions libs/hw---rpi-raw-elf/device.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
declare namespace input {
}

declare namespace control {
//% shim=control::programList
function programList() : string[];
}
37 changes: 37 additions & 0 deletions libs/hw---rpi-raw-elf/enums.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
// Auto-generated. Do not edit.


declare const enum Key {
LEFT = 1,
UP = 2,
RIGHT = 3,
DOWN = 4,
A = 5,
B = 6,
MENU = 7,
LEFT2 = 8,
UP2 = 9,
RIGHT2 = 10,
DOWN2 = 11,
A2 = 12,
B2 = 13,
MENU2 = 14,
LEFT3 = 15,
UP3 = 16,
RIGHT3 = 17,
DOWN3 = 18,
A3 = 19,
B3 = 20,
MENU3 = 21,
LEFT4 = 22,
UP4 = 23,
RIGHT4 = 24,
DOWN4 = 25,
A4 = 26,
B4 = 27,
MENU4 = 28,
RESET = 29,
EXIT = 30,
}

// Auto-generated. Do not edit. Really.
60 changes: 60 additions & 0 deletions libs/hw---rpi-raw-elf/gamesel.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
#include "pxt.h"

#include <sys/types.h>
#include <dirent.h>
#include <sys/stat.h>
#include <stdio.h>
#include <unistd.h>

namespace control {


//%
RefCollection *programList() {
DIR *d = opendir(PROGDIR);
auto res = Array_::mk();
registerGCObj(res);
for (;;) {
struct dirent *ent = readdir(d);
if (!ent)
break;
int len = strlen(ent->d_name);
if (len <= 4)
continue;
if (strcmp(ent->d_name + len - 4, ".elf") != 0)
continue;
ent->d_name[len - 4] = 0; // chop extension
//DMESG("add: '%s'", ent->d_name);
auto tmp = (TValue)mkString(ent->d_name, -1);
registerGCPtr(tmp);
res->head.push(tmp);
unregisterGCPtr(tmp);
}
closedir(d);
unregisterGCObj(res);
return res;
}

/** Run specified user program. */
//%
void runProgram(String prog) {
char *p;
asprintf(&p, "%s/%s.elf", PROGDIR, prog->getUTF8Data());
initialArgv = new char*[3];
initialArgv[0] = p;
initialArgv[1] = (char*)"--run";
initialArgv[2] = 0;
target_reset();
}

/**
* Deletes a user program
*/
//%
void deleteProgram(String prog) {
char *p;
asprintf(&p, "%s/%s.elf", PROGDIR, prog->getUTF8Data());
unlink(p);
}

} // namespace control
9 changes: 9 additions & 0 deletions libs/hw---rpi-raw-elf/gdb.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/sh

USB=`ls /dev/cu.usbmodem*`

arm-linux-gnueabihf-gdb \
--eval "dir built/dockermake" \
--eval "symbol-file built/dockermake/bld/pxt-app.full" \
--eval "target extended-remote $USB" \
--eval "set remote exec-file /sd/prj/pxt.elf"
Loading