kopia lustrzana https://github.com/OpenRTX/OpenRTX
UI: Add clock to top bar, add rtc.c for Linux
rodzic
a36fbc97a1
commit
c0e4115482
|
@ -106,6 +106,7 @@ linux_src = src + ['platform/drivers/display/display_libSDL.c',
|
|||
'platform/drivers/keyboard/keyboard_linux.c',
|
||||
'platform/mcu/x86_64/drivers/gpio.c',
|
||||
'platform/mcu/x86_64/drivers/delays.c',
|
||||
'platform/mcu/x86_64/drivers/rtc.c',
|
||||
'platform/targets/linux/platform.c',
|
||||
'openrtx/src/graphics/graphics_rgb565.c',
|
||||
'rtos/uC-OS3/Ports/POSIX/os_cpu_c.c',
|
||||
|
|
|
@ -45,7 +45,7 @@ int main(void)
|
|||
gfx_print(splash_origin, splash_buf, FONT_SIZE_4, TEXT_ALIGN_CENTER, color_yellow_fab413);
|
||||
gfx_render();
|
||||
while(gfx_renderingInProgress());
|
||||
OSTimeDlyHMSM(0u, 0u, 0u, 500u, OS_OPT_TIME_HMSM_STRICT, &os_err);
|
||||
OSTimeDlyHMSM(0u, 0u, 1u, 0u, OS_OPT_TIME_HMSM_STRICT, &os_err);
|
||||
|
||||
// Clear screen
|
||||
gfx_clearScreen();
|
||||
|
|
|
@ -28,34 +28,53 @@
|
|||
*
|
||||
* Below is shown the row height for two common display densities.
|
||||
*
|
||||
* 160x128 display (MD380)
|
||||
* 160x128 display (MD380) Recommended font size
|
||||
* ┌─────────────────────────┐
|
||||
* │ top_status_bar (16px) │
|
||||
* │ top_status_bar (16 px) │ 8 pt font with 4 px vertical padding
|
||||
* ├─────────────────────────┤
|
||||
* │ Line 1 (32px) │
|
||||
* │ Line 1 (32px) │ 16 pt font with 8 px vertical padding
|
||||
* │ │
|
||||
* │ Line 2 (32px) │
|
||||
* │ Line 2 (32px) │ 16 pt font with 8 px vertical padding
|
||||
* │ │
|
||||
* │ Line 3 (32px) │
|
||||
* │ Line 3 (32px) │ 16 pt font with 8 px vertical padding
|
||||
* │ │
|
||||
* ├─────────────────────────┤
|
||||
* │bottom_status_bar (16px) │
|
||||
* │bottom_status_bar (16 px)│ 8 pt font with 4 px vertical padding
|
||||
* └─────────────────────────┘
|
||||
*
|
||||
* 128x64 display (GD77)
|
||||
* ┌─────────────────────────┐
|
||||
* │ top_status_bar (8px) │
|
||||
* │ top_status_bar (8 px) │ 8 pt font without vertical padding
|
||||
* ├─────────────────────────┤
|
||||
* │ Line 1 (16px) │
|
||||
* │ Line 2 (16px) │
|
||||
* │ Line 3 (16px) │
|
||||
* ├─────────────────────────┤
|
||||
* │ bottom_status_bar (8px) │
|
||||
* │ bottom_status_bar (8 px)│ 8 pt font without vertical padding
|
||||
* └─────────────────────────┘
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <ui.h>
|
||||
#include "ui.h"
|
||||
#include "graphics.h"
|
||||
#include "rtc.h"
|
||||
|
||||
color_t color_white = {255, 255, 255};
|
||||
|
||||
void ui_drawTopBar()
|
||||
{
|
||||
// Print clock on top bar, use 4 px padding
|
||||
point_t clock_pos = {0, 5};
|
||||
char clock_buf[6] = "";
|
||||
curTime_t time = rtc_getTime();
|
||||
snprintf(clock_buf, sizeof(clock_buf), "%2d:%2d", time.hour, time.minute);
|
||||
gfx_print(clock_pos, clock_buf, FONT_SIZE_1, TEXT_ALIGN_CENTER, color_white);
|
||||
}
|
||||
|
||||
void ui_drawMainScreen()
|
||||
{
|
||||
ui_drawTopBar();
|
||||
}
|
||||
|
||||
void ui_init()
|
||||
{
|
||||
|
@ -63,6 +82,8 @@ void ui_init()
|
|||
|
||||
bool ui_update(state_t state, uint32_t keys)
|
||||
{
|
||||
gfx_clearScreen();
|
||||
ui_drawMainScreen();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,76 @@
|
|||
/***************************************************************************
|
||||
* Copyright (C) 2020 by Federico Amedeo Izzo IU2NUO, *
|
||||
* Niccolò Izzo IU2KIN, *
|
||||
* Silvano Seva IU2KWO *
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation; either version 3 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* *
|
||||
* This program is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with this program; if not, see <http://www.gnu.org/licenses/> *
|
||||
***************************************************************************/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <time.h>
|
||||
#include "rtc.h"
|
||||
|
||||
void rtc_init()
|
||||
{
|
||||
printf("rtc_init()\n");
|
||||
}
|
||||
|
||||
void rtc_shutdown()
|
||||
{
|
||||
printf("rtc_shutdown()\n");
|
||||
}
|
||||
|
||||
void rtc_setTime(curTime_t t)
|
||||
{
|
||||
printf("rtc_setTime(t)\n");
|
||||
}
|
||||
|
||||
void rtc_setHour(uint8_t hours, uint8_t minutes, uint8_t seconds)
|
||||
{
|
||||
printf("rtc_setHour(%d, %d, %d)\n", hours, minutes, seconds);
|
||||
}
|
||||
|
||||
void rtc_setDate(uint8_t date, uint8_t month, uint8_t year)
|
||||
{
|
||||
printf("rtc_setDate(%d, %d, %d)\n", date, month, year);
|
||||
}
|
||||
|
||||
curTime_t rtc_getTime()
|
||||
{
|
||||
curTime_t t;
|
||||
|
||||
time_t rawtime;
|
||||
struct tm * timeinfo;
|
||||
time ( &rawtime );
|
||||
timeinfo = localtime ( &rawtime );
|
||||
|
||||
t.hour = timeinfo->tm_hour;
|
||||
t.minute = timeinfo->tm_min;
|
||||
t.second = timeinfo->tm_sec;
|
||||
t.year = timeinfo->tm_year + 1900;
|
||||
t.day = timeinfo->tm_mday;
|
||||
t.month = timeinfo->tm_mon + 1;
|
||||
|
||||
return t;
|
||||
}
|
||||
|
||||
void rtc_dstSet()
|
||||
{
|
||||
printf("rtc_dstSet()\n");
|
||||
}
|
||||
|
||||
void rtc_dstClear()
|
||||
{
|
||||
printf("rtc_dstClear()\n");
|
||||
}
|
Ładowanie…
Reference in New Issue