diff --git a/meson.build b/meson.build index f348d1df..d30441f8 100644 --- a/meson.build +++ b/meson.build @@ -58,6 +58,8 @@ def = {'DONT_USE_CMSIS_INIT': ''} ## Linux linux_src = src + ['openrtx/src/main.c', 'openrtx/src/bootstrap.c', + 'openrtx/src/state.c', + 'openrtx/src/ui.c', 'platform/drivers/display/display_libSDL.c', 'platform/mcu/x86_64/drivers/gpio.c', 'platform/mcu/x86_64/drivers/delays.c', @@ -85,6 +87,8 @@ endif ## TYT MD380 md380_src = src + ['openrtx/src/main.c', 'openrtx/src/bootstrap.c', + 'openrtx/src/state.c', + 'openrtx/src/ui.c', 'platform/mcu/STM32F4xx/boot/startup.c', 'platform/mcu/STM32F4xx/boot/libc_integration.c', 'platform/mcu/STM32F4xx/drivers/usb/usb_bsp.c', @@ -125,6 +129,8 @@ md380_inc = inc + ['platform/mcu/CMSIS/Include', ## TYT MD-UV380 mduv380_src = src + ['openrtx/src/main.c', 'openrtx/src/bootstrap.c', + 'openrtx/src/state.c', + 'openrtx/src/ui.c', 'platform/mcu/STM32F4xx/boot/startup.c', 'platform/mcu/STM32F4xx/boot/libc_integration.c', 'platform/mcu/STM32F4xx/drivers/usb/usb_bsp.c', diff --git a/openrtx/include/interfaces/state.h b/openrtx/include/interfaces/state.h new file mode 100644 index 00000000..ec023b32 --- /dev/null +++ b/openrtx/include/interfaces/state.h @@ -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 * + ***************************************************************************/ + +#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 */ diff --git a/openrtx/include/interfaces/ui.h b/openrtx/include/interfaces/ui.h new file mode 100644 index 00000000..f916abcc --- /dev/null +++ b/openrtx/include/interfaces/ui.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 * + ***************************************************************************/ + +#ifndef UI_H +#define UI_H + +#include +#include + +/** + * 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 */ diff --git a/openrtx/src/main.c b/openrtx/src/main.c index 7883a669..d0890913 100644 --- a/openrtx/src/main.c +++ b/openrtx/src/main.c @@ -24,55 +24,46 @@ #include "graphics.h" #include "hwconfig.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) { - gpio_setMode(GREEN_LED, OUTPUT); + OS_ERR os_err; // Init the graphic stack gfx_init(); platform_setBacklightLevel(255); - point_t origin = {0, SCREEN_HEIGHT / 2}; - color_t color_yellow = {250, 180, 19}; - char *buffer = "OpenRTX"; + // Print splash screen + point_t splash_origin = {0, SCREEN_HEIGHT / 2}; + 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) { - gfx_clearScreen(); - gfx_print(origin, buffer, FONT_SIZE_4, TEXT_ALIGN_CENTER, color_yellow); - //gfx_render(); - //while(gfx_renderingInProgress()); - platform_test(); + state_t state = state_update(); + uint32_t keys = kbd_getKeys(); + bool renderNeeded = ui_update(state, keys); + if(renderNeeded) + { + gfx_render(); + while(gfx_renderingInProgress()); + } OSTimeDlyHMSM(0u, 0u, 0u, 100u, OS_OPT_TIME_HMSM_STRICT, &os_err); } } diff --git a/openrtx/src/state.c b/openrtx/src/state.c new file mode 100644 index 00000000..bfe6a8fe --- /dev/null +++ b/openrtx/src/state.c @@ -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 * + ***************************************************************************/ + +#include +#include + +state_t current_state; + +void state_init() +{ +} + +state_t state_update() +{ + return current_state; +} + +void state_terminate() +{ +} diff --git a/openrtx/src/ui.c b/openrtx/src/ui.c new file mode 100644 index 00000000..ef7ceae7 --- /dev/null +++ b/openrtx/src/ui.c @@ -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 * + ***************************************************************************/ + +#include +#include + +void ui_init() +{ +} + +bool ui_update(state_t state, uint16_t keys) +{ + return true; +} + +void ui_terminate() +{ +}