kopia lustrzana https://github.com/OpenRTX/OpenRTX
Add initial UI main
rodzic
90023459f5
commit
a2b2b602dd
|
@ -58,6 +58,8 @@ def = {'DONT_USE_CMSIS_INIT': ''}
|
||||||
## Linux
|
## Linux
|
||||||
linux_src = src + ['openrtx/src/main.c',
|
linux_src = src + ['openrtx/src/main.c',
|
||||||
'openrtx/src/bootstrap.c',
|
'openrtx/src/bootstrap.c',
|
||||||
|
'openrtx/src/state.c',
|
||||||
|
'openrtx/src/ui.c',
|
||||||
'platform/drivers/display/display_libSDL.c',
|
'platform/drivers/display/display_libSDL.c',
|
||||||
'platform/mcu/x86_64/drivers/gpio.c',
|
'platform/mcu/x86_64/drivers/gpio.c',
|
||||||
'platform/mcu/x86_64/drivers/delays.c',
|
'platform/mcu/x86_64/drivers/delays.c',
|
||||||
|
@ -85,6 +87,8 @@ endif
|
||||||
## TYT MD380
|
## TYT MD380
|
||||||
md380_src = src + ['openrtx/src/main.c',
|
md380_src = src + ['openrtx/src/main.c',
|
||||||
'openrtx/src/bootstrap.c',
|
'openrtx/src/bootstrap.c',
|
||||||
|
'openrtx/src/state.c',
|
||||||
|
'openrtx/src/ui.c',
|
||||||
'platform/mcu/STM32F4xx/boot/startup.c',
|
'platform/mcu/STM32F4xx/boot/startup.c',
|
||||||
'platform/mcu/STM32F4xx/boot/libc_integration.c',
|
'platform/mcu/STM32F4xx/boot/libc_integration.c',
|
||||||
'platform/mcu/STM32F4xx/drivers/usb/usb_bsp.c',
|
'platform/mcu/STM32F4xx/drivers/usb/usb_bsp.c',
|
||||||
|
@ -125,6 +129,8 @@ md380_inc = inc + ['platform/mcu/CMSIS/Include',
|
||||||
## TYT MD-UV380
|
## TYT MD-UV380
|
||||||
mduv380_src = src + ['openrtx/src/main.c',
|
mduv380_src = src + ['openrtx/src/main.c',
|
||||||
'openrtx/src/bootstrap.c',
|
'openrtx/src/bootstrap.c',
|
||||||
|
'openrtx/src/state.c',
|
||||||
|
'openrtx/src/ui.c',
|
||||||
'platform/mcu/STM32F4xx/boot/startup.c',
|
'platform/mcu/STM32F4xx/boot/startup.c',
|
||||||
'platform/mcu/STM32F4xx/boot/libc_integration.c',
|
'platform/mcu/STM32F4xx/boot/libc_integration.c',
|
||||||
'platform/mcu/STM32F4xx/drivers/usb/usb_bsp.c',
|
'platform/mcu/STM32F4xx/drivers/usb/usb_bsp.c',
|
||||||
|
|
|
@ -0,0 +1,77 @@
|
||||||
|
/***************************************************************************
|
||||||
|
* 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/> *
|
||||||
|
***************************************************************************/
|
||||||
|
|
||||||
|
#ifndef STATE_H
|
||||||
|
#define STATE_H
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Part of this structure has been commented because the corresponding
|
||||||
|
* functionality is not yet implemented.
|
||||||
|
* Uncomment once the related feature is ready
|
||||||
|
*/
|
||||||
|
|
||||||
|
typedef struct state_t {
|
||||||
|
//enum ui_screen;
|
||||||
|
//enum tuner_mode;
|
||||||
|
//enum radio_mode;
|
||||||
|
|
||||||
|
//time_t rx_status_tv;
|
||||||
|
//bool rx_status;
|
||||||
|
|
||||||
|
//time_t tx_status_tv;
|
||||||
|
//bool tx_status;
|
||||||
|
|
||||||
|
//freq_t rx_freq;
|
||||||
|
//freq_t tx_freq;
|
||||||
|
|
||||||
|
//float tx_power;
|
||||||
|
|
||||||
|
//uint8_t squelch;
|
||||||
|
|
||||||
|
//tone_t rx_tone;
|
||||||
|
//tone_t tx_tone;
|
||||||
|
|
||||||
|
//ch_t *channel;
|
||||||
|
|
||||||
|
//#ifdef DMR_ENABLED
|
||||||
|
//uint8_t dmr_color;
|
||||||
|
//uint8_t dmr_timeslot;
|
||||||
|
//dmr_contact_t *dmr_contact;
|
||||||
|
//#endif
|
||||||
|
} state_t;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This function initialises the Radio state, acquiring the information
|
||||||
|
* needed to populate it from device drivers.
|
||||||
|
*/
|
||||||
|
void state_init();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This function updates the state information by sourcing the
|
||||||
|
* updated values of the various fields of the state_t struct
|
||||||
|
* from corresponding device drivers.
|
||||||
|
*/
|
||||||
|
state_t state_update();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This function terminates the Radio state.
|
||||||
|
*/
|
||||||
|
void state_terminate();
|
||||||
|
|
||||||
|
#endif /* STATE_H */
|
|
@ -0,0 +1,44 @@
|
||||||
|
/***************************************************************************
|
||||||
|
* 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/> *
|
||||||
|
***************************************************************************/
|
||||||
|
|
||||||
|
#ifndef UI_H
|
||||||
|
#define UI_H
|
||||||
|
|
||||||
|
#include <stdbool.h>
|
||||||
|
#include <state.h>
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This function initialises the User Interface, starting the
|
||||||
|
* Finite State Machine describing the user interaction.
|
||||||
|
*/
|
||||||
|
void ui_init();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This function advances the User Interface FSM, basing on the
|
||||||
|
* current radio state and the keys pressed.
|
||||||
|
* @return true if a screen refresh is needed after the update
|
||||||
|
*/
|
||||||
|
bool ui_update(state_t state, uint16_t keys);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This function terminates the User Interface.
|
||||||
|
*/
|
||||||
|
void ui_terminate();
|
||||||
|
|
||||||
|
#endif /* UI_H */
|
|
@ -24,55 +24,46 @@
|
||||||
#include "graphics.h"
|
#include "graphics.h"
|
||||||
#include "hwconfig.h"
|
#include "hwconfig.h"
|
||||||
#include "platform.h"
|
#include "platform.h"
|
||||||
|
#include "state.h"
|
||||||
|
#include "keyboard.h"
|
||||||
|
#include "ui.h"
|
||||||
|
|
||||||
void platform_test()
|
|
||||||
{
|
|
||||||
gpio_togglePin(GREEN_LED);
|
|
||||||
OS_ERR os_err;
|
|
||||||
point_t pos_line1 = {0, 0};
|
|
||||||
point_t pos_line2 = {0, 9};
|
|
||||||
point_t pos_line3 = {0, 17};
|
|
||||||
color_t color_white = {255, 255, 255};
|
|
||||||
char *buf = "Platform Test";
|
|
||||||
gfx_print(pos_line1, buf, FONT_SIZE_1, TEXT_ALIGN_LEFT, color_white);
|
|
||||||
float vBat = platform_getVbat();
|
|
||||||
float micLevel = platform_getMicLevel();
|
|
||||||
float volumeLevel = platform_getVolumeLevel();
|
|
||||||
uint8_t currentCh = platform_getChSelector();
|
|
||||||
bool ptt = platform_getPttStatus();
|
|
||||||
char buf2[26] = "";
|
|
||||||
snprintf(buf2, sizeof(buf2), "bat:%.2f mic:%.2f", vBat, micLevel);
|
|
||||||
char buf3[26] = "";
|
|
||||||
snprintf(buf3, sizeof(buf3), "vol:%.2f ch:%d ptt:%s", volumeLevel, currentCh, ptt?"on":"off");
|
|
||||||
gfx_print(pos_line2, buf2, FONT_SIZE_1, TEXT_ALIGN_LEFT, color_white);
|
|
||||||
gfx_print(pos_line3, buf3, FONT_SIZE_1, TEXT_ALIGN_LEFT, color_white);
|
|
||||||
gfx_render();
|
|
||||||
while(gfx_renderingInProgress());
|
|
||||||
OSTimeDlyHMSM(0u, 0u, 0u, 250u, OS_OPT_TIME_HMSM_STRICT, &os_err);
|
|
||||||
}
|
|
||||||
|
|
||||||
int main(void)
|
int main(void)
|
||||||
{
|
{
|
||||||
gpio_setMode(GREEN_LED, OUTPUT);
|
OS_ERR os_err;
|
||||||
|
|
||||||
// Init the graphic stack
|
// Init the graphic stack
|
||||||
gfx_init();
|
gfx_init();
|
||||||
platform_setBacklightLevel(255);
|
platform_setBacklightLevel(255);
|
||||||
|
|
||||||
point_t origin = {0, SCREEN_HEIGHT / 2};
|
// Print splash screen
|
||||||
color_t color_yellow = {250, 180, 19};
|
point_t splash_origin = {0, SCREEN_HEIGHT / 2};
|
||||||
char *buffer = "OpenRTX";
|
color_t color_yellow_fab413 = {250, 180, 19};
|
||||||
|
char *splash_buf = "OpenRTX";
|
||||||
|
gfx_clearScreen();
|
||||||
|
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);
|
||||||
|
|
||||||
|
// Clear screen
|
||||||
|
gfx_clearScreen();
|
||||||
|
gfx_render();
|
||||||
|
while(gfx_renderingInProgress());
|
||||||
|
|
||||||
OS_ERR os_err;
|
|
||||||
|
|
||||||
// Task infinite loop
|
// UI update infinite loop
|
||||||
while(1)
|
while(1)
|
||||||
{
|
{
|
||||||
gfx_clearScreen();
|
state_t state = state_update();
|
||||||
gfx_print(origin, buffer, FONT_SIZE_4, TEXT_ALIGN_CENTER, color_yellow);
|
uint32_t keys = kbd_getKeys();
|
||||||
//gfx_render();
|
bool renderNeeded = ui_update(state, keys);
|
||||||
//while(gfx_renderingInProgress());
|
if(renderNeeded)
|
||||||
platform_test();
|
{
|
||||||
|
gfx_render();
|
||||||
|
while(gfx_renderingInProgress());
|
||||||
|
}
|
||||||
OSTimeDlyHMSM(0u, 0u, 0u, 100u, OS_OPT_TIME_HMSM_STRICT, &os_err);
|
OSTimeDlyHMSM(0u, 0u, 0u, 100u, OS_OPT_TIME_HMSM_STRICT, &os_err);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,36 @@
|
||||||
|
/***************************************************************************
|
||||||
|
* 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 <state.h>
|
||||||
|
|
||||||
|
state_t current_state;
|
||||||
|
|
||||||
|
void state_init()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
state_t state_update()
|
||||||
|
{
|
||||||
|
return current_state;
|
||||||
|
}
|
||||||
|
|
||||||
|
void state_terminate()
|
||||||
|
{
|
||||||
|
}
|
|
@ -0,0 +1,34 @@
|
||||||
|
/***************************************************************************
|
||||||
|
* 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 <ui.h>
|
||||||
|
|
||||||
|
void ui_init()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
bool ui_update(state_t state, uint16_t keys)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ui_terminate()
|
||||||
|
{
|
||||||
|
}
|
Ładowanie…
Reference in New Issue