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