#include #include #include #include "scode.h" #include "config.h" #include "gpio.h" #include "log.h" #include "fbinit.h" #include "fbprimitive.h" #include "fontengine.h" #include "time_func.h" #include "ep_init.h" #include "sysinput.h" static void log_touch(const char *event, UINT_PTR x, UINT_PTR y) { Log(LINFO, "Touch %s at (%u, %u)", event, x, y); } int main(int argc, char *argv[]) { HRESULT hr; int running = 1; MSG msg; /* initialization sequence */ Time_init(); hr = Config_setup(argc, argv); if (FAILED(hr)) return EXIT_FAILURE; else if (hr != S_OK) return EXIT_SUCCESS; if (FAILED(Fb_setup())) return EXIT_FAILURE; if (FAILED(FontEng_setup())) return EXIT_FAILURE; if (FAILED(Gpio_setup())) return EXIT_FAILURE; if (FAILED(Epython_setup())) return EXIT_FAILURE; if (FAILED(Sys_enable_input())) return EXIT_FAILURE; Log(LINFO, "Pausing at startup."); sleep(2); /* wait to show off splash screen */ Fb_clear(); if (FAILED(Epython_run())) return EXIT_FAILURE; Log(LINFO, "Script returned and event loop ready."); while (running) { if (Mq_peek(Sys_Queue, &msg, PEEK_REMOVE)) { switch (msg.message) { case WM_HWBUTTONDOWN: Log(LINFO, "Button %d was pressed.", (int)(msg.attrs[0])); break; case WM_HWBUTTONUP: Log(LINFO, "Button %d was released.", (int)(msg.attrs[0])); if (msg.attrs[0] == 1) { Log(LINFO, "Backlight ON."); Gpio_set_backlight(GSB_BACKLIGHT_MAX); } if (msg.attrs[0] == 2) { Log(LINFO, "Backlight OFF."); Gpio_set_backlight(0); } if (msg.attrs[0] == 4) { Log(LINFO, "Quitting the message loop."); running = 0; } break; case WM_TOUCHDOWN: log_touch("DOWN", msg.attrs[0], msg.attrs[1]); break; case WM_TOUCHMOVE: log_touch("MOVE", msg.attrs[0], msg.attrs[1]); break; case WM_TOUCHUP: log_touch("UP", msg.attrs[0], msg.attrs[1]); break; default: break; } } } return EXIT_SUCCESS; }