2019-11-29 02:05:30 -07:00
|
|
|
#include <stdlib.h>
|
2019-12-01 19:39:14 -07:00
|
|
|
#include <string.h>
|
2019-12-06 20:57:44 -07:00
|
|
|
#include <unistd.h>
|
2019-12-05 18:21:37 -07:00
|
|
|
#include "scode.h"
|
2019-12-06 22:06:05 -07:00
|
|
|
#include "config.h"
|
2019-11-29 02:05:30 -07:00
|
|
|
#include "gpio.h"
|
|
|
|
#include "log.h"
|
2019-12-01 18:53:54 -07:00
|
|
|
#include "fbinit.h"
|
2019-12-01 01:02:08 -07:00
|
|
|
#include "time_func.h"
|
|
|
|
#include "sysinput.h"
|
2019-11-29 02:05:30 -07:00
|
|
|
|
2019-12-01 20:57:36 -07:00
|
|
|
static void do_draw(void)
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
tmp = (char *)Fb_Ptr;
|
|
|
|
memset(tmp, 0xFF, Fb_Info->screenbytes / 2);
|
|
|
|
memset(tmp + (Fb_Info->screenbytes / 2), 0x1B, Fb_Info->screenbytes / 2);
|
|
|
|
*/
|
2019-12-05 18:21:37 -07:00
|
|
|
UINT16 pixel = Fb_Info->green_mask;
|
|
|
|
unsigned npix = Fb_Info->screenbytes / sizeof(UINT16);
|
|
|
|
UINT16 *p = Fb_Ptr;
|
2019-12-01 20:57:36 -07:00
|
|
|
unsigned i;
|
|
|
|
|
|
|
|
for (i=0; i<npix; i++)
|
|
|
|
*p++ = pixel;
|
|
|
|
}
|
|
|
|
|
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;
|
2019-12-01 19:39:14 -07:00
|
|
|
char *tmp;
|
2019-12-06 22:06:05 -07:00
|
|
|
|
2019-12-01 15:43:05 -07:00
|
|
|
Time_init();
|
2019-12-06 22:06:05 -07:00
|
|
|
if (FAILED(Config_setup()))
|
|
|
|
return EXIT_FAILURE;
|
2019-12-05 18:21:37 -07:00
|
|
|
if (FAILED(Fb_setup()))
|
2019-12-01 18:53:54 -07:00
|
|
|
return EXIT_FAILURE;
|
2019-12-05 18:21:37 -07:00
|
|
|
if (FAILED(Gpio_setup()))
|
2019-11-29 02:05:30 -07:00
|
|
|
return EXIT_FAILURE;
|
2019-12-05 18:21:37 -07:00
|
|
|
if (FAILED(Sys_enable_input()))
|
2019-12-01 01:02:08 -07:00
|
|
|
return EXIT_FAILURE;
|
2019-12-06 20:57:44 -07:00
|
|
|
Log(LINFO, "Pausing at startup.");
|
|
|
|
sleep(5); /* wait to show off splash screen */
|
2019-11-29 02:05:30 -07:00
|
|
|
|
2019-12-06 20:57:44 -07:00
|
|
|
Fb_clear();
|
2019-12-01 19:39:14 -07:00
|
|
|
/* temporary drawing here */
|
2019-12-01 20:57:36 -07:00
|
|
|
do_draw();
|
|
|
|
|
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
|
|
|
{
|
2019-12-01 15:43:05 -07:00
|
|
|
if (Mq_peek(Sys_Queue, &msg, PEEK_REMOVE))
|
2019-12-01 01:02:08 -07:00
|
|
|
{
|
|
|
|
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 14:34:57 -07:00
|
|
|
if (msg.attrs[0] == 1)
|
|
|
|
{
|
|
|
|
Log(LINFO, "Backlight ON.");
|
2019-12-01 15:45:46 -07:00
|
|
|
Gpio_set_backlight(GSB_BACKLIGHT_MAX);
|
2019-12-01 14:34:57 -07:00
|
|
|
}
|
|
|
|
if (msg.attrs[0] == 2)
|
|
|
|
{
|
|
|
|
Log(LINFO, "Backlight OFF.");
|
|
|
|
Gpio_set_backlight(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
|
|
|
}
|