Fixes in exit code
This commit is contained in:
parent
7ccdabb4d4
commit
ddc53df7f8
@ -119,8 +119,9 @@ void *buttonPoll(void *arg) {
|
||||
auto state = readButtons();
|
||||
if (state == prevState)
|
||||
continue;
|
||||
if (state & BUTTON_ID_ESCAPE)
|
||||
exit(0);
|
||||
if ((prevState & BUTTON_ID_ESCAPE) && !(state & BUTTON_ID_ESCAPE))
|
||||
target_reset();
|
||||
prevState = state;
|
||||
for (int i = 0; i < LastButtonID; ++i) {
|
||||
auto btn = &wb->buttons[i];
|
||||
btn->setPressed(!!(state & btn->id));
|
||||
@ -134,6 +135,13 @@ Button *getButton(int id) {
|
||||
target_panic(42);
|
||||
return &getWButtons()->buttons[id];
|
||||
}
|
||||
|
||||
void target_init() {
|
||||
InitEV3();
|
||||
getWButtons(); // always on - handles ESCAPE key
|
||||
DMESG("runtime started [%s]", HardwareVersionString());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
namespace control {
|
||||
@ -145,7 +153,6 @@ namespace control {
|
||||
String deviceFirmwareVersion() {
|
||||
return mkString(HardwareVersionString());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// TODO rename this? move it somewhere?
|
||||
|
@ -262,17 +262,14 @@ void dumpDmesg() {
|
||||
// TODO
|
||||
}
|
||||
|
||||
extern "C" void InitEV3();
|
||||
|
||||
void initRuntime() {
|
||||
startTime = currTime();
|
||||
DMESG("runtime starting...");
|
||||
pthread_t disp;
|
||||
pthread_create(&disp, NULL, evtDispatcher, NULL);
|
||||
pthread_detach(disp);
|
||||
InitEV3();
|
||||
target_init();
|
||||
startUser();
|
||||
DMESG("runtime started");
|
||||
}
|
||||
|
||||
void dmesg(const char *format, ...) {
|
||||
|
@ -12,6 +12,7 @@ void sleep_core_us(uint64_t us);
|
||||
class Button;
|
||||
typedef Button *Button_;
|
||||
|
||||
extern "C" void target_init();
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -1,11 +1,10 @@
|
||||
screen.clear()
|
||||
screen.setFont(ScreenFont.Large)
|
||||
//screen.drawText(10, 30, "Hello PXT!")
|
||||
for (let i = 0; i < 10; ++i)
|
||||
screen.drawText(10, 30, "Hello PXT!")
|
||||
screen.drawRect(10, 70, 20, 10, Draw.Fill)
|
||||
//screen.drawEllipse(40, 40, 20, 10)
|
||||
screen.drawEllipse(40, 40, 20, 10)
|
||||
|
||||
output.setLights(LightsPattern.GreenFlash)
|
||||
output.setLights(LightsPattern.GreenPulse)
|
||||
|
||||
input.buttonDown.onEvent(ButtonEvent.Click, () => {
|
||||
screen.scroll(10)
|
||||
|
Loading…
Reference in New Issue
Block a user