2019-11-29 02:05:30 -07:00
|
|
|
#include <stdlib.h>
|
|
|
|
#include "gpio.h"
|
|
|
|
#include "log.h"
|
2019-12-01 01:02:08 -07:00
|
|
|
#include "time_func.h"
|
|
|
|
#include "sysinput.h"
|
2019-11-29 02:05:30 -07:00
|
|
|
|
|
|
|
int main(int argc, char *argv[])
|
|
|
|
{
|
2019-12-01 01:40:28 -07:00
|
|
|
int running = 1;
|
2019-12-01 01:02:08 -07:00
|
|
|
MSG msg;
|
|
|
|
|
|
|
|
TimeInit();
|
2019-11-29 02:05:30 -07:00
|
|
|
if (Gpio_setup() != 0)
|
|
|
|
return EXIT_FAILURE;
|
|
|
|
atexit(Gpio_cleanup);
|
2019-12-01 01:02:08 -07:00
|
|
|
if (SysEnableInput() != 0)
|
|
|
|
return EXIT_FAILURE;
|
|
|
|
atexit(SysDisableInput);
|
2019-11-29 02:05:30 -07:00
|
|
|
|
2019-11-29 02:18:02 -07:00
|
|
|
Log(LINFO, "System ready.");
|
2019-11-29 02:05:30 -07:00
|
|
|
|
2019-12-01 01:40:28 -07:00
|
|
|
while (running)
|
2019-12-01 01:02:08 -07:00
|
|
|
{
|
|
|
|
if (MqPeek(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]));
|
2019-12-01 01:40:28 -07:00
|
|
|
if (msg.attrs[0] == 4)
|
|
|
|
{
|
|
|
|
Log(LINFO, "Quitting the message loop.");
|
|
|
|
running = 0;
|
|
|
|
}
|
2019-12-01 01:02:08 -07:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2019-11-29 02:05:30 -07:00
|
|
|
}
|
2019-12-01 01:02:08 -07:00
|
|
|
|
|
|
|
return EXIT_SUCCESS;
|
2019-11-29 02:05:30 -07:00
|
|
|
}
|