UI: Add VFO frequency to main screen

replace/3febb6e8540d0c8945bddd8109fe93d9c146b941
Federico Amedeo Izzo 2020-10-31 14:40:02 +01:00 zatwierdzone przez Niccolò Izzo
rodzic 46add610e1
commit a19ba1785e
5 zmienionych plików z 72 dodań i 6 usunięć

Wyświetl plik

@ -0,0 +1,42 @@
/***************************************************************************
* 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 DATATYPES_H
#define DATATYPES_H
/**
* \brief CTCSS and DCS type definition.
*
* Continuous Tone Controlled Squelch System (CTCSS)
* sub-audible tone frequency are expressed in \em tenth of Hz.
* For example, the subaudible tone of 88.5 Hz is represented within
* Hamlib by 885.
*
* Digitally-Coded Squelch codes are simple direct integers.
*/
typedef unsigned int tone_t;
/**
* \brief Frequency type,
*
* Frequency type unit in Hz, able to hold SHF frequencies.
*/
typedef float freq_t;
#endif /* DATATYPES_H */

Wyświetl plik

@ -20,6 +20,8 @@
#ifndef STATE_H
#define STATE_H
#include <datatypes.h>
/**
* Part of this structure has been commented because the corresponding
* functionality is not yet implemented.
@ -37,8 +39,8 @@ typedef struct state_t {
//time_t tx_status_tv;
//bool tx_status;
//freq_t rx_freq;
//freq_t tx_freq;
freq_t rx_freq;
freq_t tx_freq;
//float tx_power;

Wyświetl plik

@ -33,6 +33,9 @@ int main(void)
{
OS_ERR os_err;
// Initialize the radio state
state_init();
// Init the graphic stack
gfx_init();
platform_setBacklightLevel(255);
@ -52,7 +55,6 @@ int main(void)
gfx_render();
while(gfx_renderingInProgress());
// UI update infinite loop
while(1)
{

Wyświetl plik

@ -24,6 +24,10 @@ state_t current_state;
void state_init()
{
/*TODO: Read current state parameters from hardware,
* or initialize them to sane defaults */
current_state.rx_freq = 0.0;
current_state.tx_freq = 0.0;
}
state_t state_update()

Wyświetl plik

@ -77,13 +77,29 @@ void ui_drawTopBar()
// TODO: Replace with battery icon
char bat_buf[6] = "";
float v_bat = platform_getVbat();
snprintf(bat_buf, sizeof(bat_buf), "%.1fV", v_bat);
snprintf(bat_buf, sizeof(bat_buf), "%.1fV ", v_bat);
gfx_print(top_bar_pos, bat_buf, FONT_SIZE_1, TEXT_ALIGN_RIGHT, color_white);
}
void ui_drawMainScreen()
void ui_drawVFO(state_t state)
{
// Middle line printing positions, uses 8 px padding
point_t line1_pos = {0, 25};
point_t line2_pos = {0, 57};
point_t line3_pos = {0, 89};
// Print VFO frequencies
char freq_buf[20] = "";
snprintf(freq_buf, sizeof(freq_buf), "Rx: %09.5f", state.rx_freq);
gfx_print(line1_pos, freq_buf, FONT_SIZE_3, TEXT_ALIGN_CENTER, color_white);
snprintf(freq_buf, sizeof(freq_buf), "Tx: %09.5f", state.tx_freq);
gfx_print(line2_pos, freq_buf, FONT_SIZE_3, TEXT_ALIGN_CENTER, color_white);
}
void ui_drawMainScreen(state_t state)
{
ui_drawTopBar();
ui_drawVFO(state);
}
void ui_init()
@ -93,7 +109,7 @@ void ui_init()
bool ui_update(state_t state, uint32_t keys)
{
gfx_clearScreen();
ui_drawMainScreen();
ui_drawMainScreen(state);
return true;
}