Split UI sources in a default one for the radios and the Module17 one.

pull/139/head
Silvano Seva 2022-12-08 21:53:45 +01:00
rodzic bd8585c45d
commit 76ded06751
10 zmienionych plików z 276 dodań i 224 usunięć

Wyświetl plik

@ -30,7 +30,7 @@ def += {'FONT_UBUNTU_REGULAR': ''}
##
##
## OpenRTX sources
## OpenRTX core sources
##
openrtx_src = ['openrtx/src/core/state.c',
@ -54,10 +54,6 @@ openrtx_src = ['openrtx/src/core/state.c',
'openrtx/src/core/voicePrompts.c',
'openrtx/src/core/voicePromptUtils.c',
'openrtx/src/core/voicePromptData.S',
'openrtx/src/ui/ui.c',
'openrtx/src/ui/ui_strings.c',
'openrtx/src/ui/ui_main.c',
'openrtx/src/ui/ui_menu.c',
'openrtx/src/rtx/rtx.cpp',
'openrtx/src/rtx/OpMode_FM.cpp',
'openrtx/src/rtx/OpMode_M17.cpp',
@ -85,6 +81,21 @@ openrtx_inc = ['openrtx/include',
'platform/drivers/backlight',
'platform/drivers/chSelector']
##
## OpenRTX UI sources
##
openrtx_ui_default = ['openrtx/src/ui/default/ui.c',
'openrtx/src/ui/default/ui_main.c',
'openrtx/src/ui/default/ui_menu.c',
'openrtx/src/ui/default/ui_strings.c']
openrtx_ui_module17 = []
##
## Selection of main entrypoint
##
main_src = []
# Add to sources either the main executable or a platform test
@ -159,6 +170,8 @@ mdx_src = ['openrtx/src/core/xmodem.c',
'platform/drivers/backlight/backlight_MDx.c',
'platform/drivers/tones/toneGenerator_MDx.cpp']
mdx_src = mdx_src + openrtx_ui_default
##
## GDx family: Radioddity GD-77 and Baofeng DM-1801
##
@ -182,6 +195,8 @@ gdx_src = ['openrtx/src/core/xmodem.c',
'platform/drivers/audio/inputStream_GDx.c',
'platform/drivers/audio/outputStream_GDx.c']
gdx_src = gdx_src + openrtx_ui_default
##
## --------------------- MCU-dependent source files ----------------------------
##
@ -270,11 +285,17 @@ linux_platform_src = ['platform/targets/linux/emulator/emulator.c',
linux_src = src + linux_platform_src
#
# Select which UI to use
#
linux_src = linux_src + openrtx_ui_default
# linux_src = linux_src + openrtx_ui_module17
# GDx family display emulation
#linux_def = def + {'SCREEN_WIDTH': '128', 'SCREEN_HEIGHT': '64', 'PIX_FMT_BW': ''}
# MDx family display emulation
#
# Select which screen type to emulate
#
linux_def = def + {'SCREEN_WIDTH': '160', 'SCREEN_HEIGHT': '128', 'PIX_FMT_RGB565': ''}
#linux_def = def + {'SCREEN_WIDTH': '128', 'SCREEN_HEIGHT': '64', 'PIX_FMT_BW': ''}
linux_def += {'VP_USE_FILESYSTEM':''}
linux_inc = inc + ['platform/targets/linux',
@ -356,18 +377,19 @@ dm1801_def = def + mk22fn512_def + {'PLATFORM_DM1801': ''}
##
## Module 17
##
mod17_src = src + stm32f405_src + ['platform/targets/Module17/platform.c',
'platform/drivers/display/SH110x_Mod17.c',
'platform/drivers/ADC/ADC1_Mod17.c',
'platform/drivers/keyboard/keyboard_Mod17.c',
'platform/drivers/NVM/nvmem_Mod17.c',
'platform/drivers/CPS/cps_io_native_Mod17.c',
'platform/drivers/baseband/radio_Mod17.cpp',
'platform/drivers/audio/inputStream_Mod17.cpp',
'platform/drivers/audio/outputStream_Mod17.cpp',
'platform/drivers/audio/audio_Mod17.c',
'platform/drivers/baseband/MCP4551_Mod17.cpp']
mod17_src = ['platform/targets/Module17/platform.c',
'platform/drivers/display/SH110x_Mod17.c',
'platform/drivers/ADC/ADC1_Mod17.c',
'platform/drivers/keyboard/keyboard_Mod17.c',
'platform/drivers/NVM/nvmem_Mod17.c',
'platform/drivers/CPS/cps_io_native_Mod17.c',
'platform/drivers/baseband/radio_Mod17.cpp',
'platform/drivers/audio/inputStream_Mod17.cpp',
'platform/drivers/audio/outputStream_Mod17.cpp',
'platform/drivers/audio/audio_Mod17.c',
'platform/drivers/baseband/MCP4551_Mod17.cpp']
mod17_src = src + openrtx_ui_module17 + mod17_src + stm32f405_src
mod17_inc = inc + stm32f405_inc + ['platform/targets/Module17']
mod17_def = def + stm32f405_def + {'PLATFORM_MOD17': ''}
@ -625,7 +647,7 @@ foreach t : targets
# Module17 also uses dfu-tool for flashing
elif name == 'openrtx_mod17'
# Wrap target for Module17 for consistency, same output as bin target
custom_target(name+'_wrap',
output : name+'_wrap',

Wyświetl plik

@ -21,206 +21,7 @@
#define UI_H
#include <stdbool.h>
#include <state.h>
#include <graphics.h>
#include <interfaces/keyboard.h>
#include <stdint.h>
#include <event.h>
#include <hwconfig.h>
// Maximum menu entry length
#define MAX_ENTRY_LEN 21
// Frequency digits
#define FREQ_DIGITS 7
// Time & Date digits
#define TIMEDATE_DIGITS 10
// Max number of UI events
#define MAX_NUM_EVENTS 16
enum uiScreen
{
MAIN_VFO = 0,
MAIN_VFO_INPUT,
MAIN_MEM,
MODE_VFO,
MODE_MEM,
MENU_TOP,
MENU_BANK,
MENU_CHANNEL,
MENU_CONTACTS,
MENU_GPS,
MENU_SETTINGS,
MENU_BACKUP_RESTORE,
MENU_BACKUP,
MENU_RESTORE,
MENU_INFO,
MENU_ABOUT,
SETTINGS_TIMEDATE,
SETTINGS_TIMEDATE_SET,
SETTINGS_DISPLAY,
SETTINGS_GPS,
SETTINGS_M17,
SETTINGS_VOICE,
SETTINGS_RESET2DEFAULTS,
LOW_BAT
};
enum SetRxTx
{
SET_RX = 0,
SET_TX
};
// This enum is needed to have item numbers that match
// menu elements even if some elements may be missing (GPS)
enum menuItems
{
M_BANK = 0,
M_CHANNEL,
M_CONTACTS,
#ifdef GPS_PRESENT
M_GPS,
#endif
M_SETTINGS,
M_BACKUP_RESTORE,
M_INFO,
M_ABOUT
};
enum settingsItems
{
S_DISPLAY = 0
#ifdef RTC_PRESENT
,S_TIMEDATE
#endif
#ifdef GPS_PRESENT
,S_GPS
#endif
,S_M17
,S_VOICE
,S_RESET2DEFAULTS
};
enum backupRestoreItems
{
BR_BACKUP = 0,
BR_RESTORE
};
enum displayItems
{
D_BRIGHTNESS = 0
#ifdef SCREEN_CONTRAST
,D_CONTRAST
#endif
,D_TIMER
};
#ifdef GPS_PRESENT
enum settingsGPSItems
{
G_ENABLED = 0,
G_SET_TIME,
G_TIMEZONE
};
#endif
enum settingsVoicePromptItems
{
VP_LEVEL = 0,
VP_PHONETIC,
};
/**
* Struct containing a set of positions and sizes that get
* calculated for the selected display size.
* Using these parameters make the UI automatically adapt
* To displays of different sizes
*/
typedef struct layout_t
{
uint16_t hline_h;
uint16_t top_h;
uint16_t line1_h;
uint16_t line2_h;
uint16_t line3_h;
uint16_t menu_h;
uint16_t bottom_h;
uint16_t bottom_pad;
uint16_t status_v_pad;
uint16_t horizontal_pad;
uint16_t text_v_offset;
point_t top_pos;
point_t line1_pos;
point_t line2_pos;
point_t line3_pos;
point_t bottom_pos;
fontSize_t top_font;
fontSize_t line1_font;
fontSize_t line2_font;
fontSize_t line3_font;
fontSize_t bottom_font;
fontSize_t input_font;
fontSize_t menu_font;
fontSize_t mode_font_big;
fontSize_t mode_font_small;
} layout_t;
/**
* This structs contains state variables internal to the
* UI that need to be kept between executions of the UI
* This state does not need to be saved on device poweroff
*/
typedef struct ui_state_t
{
// Index of the currently selected menu entry
uint8_t menu_selected;
// If true we can change a menu entry value with UP/DOWN
bool edit_mode;
// Variables used for VFO input
uint8_t input_number;
uint8_t input_position;
uint8_t input_set;
long long last_keypress;
freq_t new_rx_frequency;
freq_t new_tx_frequency;
char new_rx_freq_buf[14];
char new_tx_freq_buf[14];
#ifdef RTC_PRESENT
// Variables used for Time & Date input
datetime_t new_timedate;
char new_date_buf[9];
char new_time_buf[9];
#endif
char new_callsign[10];
// Which state to return to when we exit menu
uint8_t last_main_state;
}
ui_state_t;
extern layout_t layout;
// Copy of the radio state
extern state_t last_state;
extern const char *menu_items[];
extern const char *settings_items[];
extern const char *display_items[];
extern const char *settings_gps_items[];
extern const char * settings_voice_items[];
extern const char *backup_restore_items[];
extern const char *info_items[];
extern const char *authors[];
extern const uint8_t menu_num;
extern const uint8_t settings_num;
extern const uint8_t display_num;
extern const uint8_t settings_gps_num;
extern const uint8_t settings_voice_num;
extern const uint8_t backup_restore_num;
extern const uint8_t info_num;
extern const uint8_t author_num;
extern const color_t color_black;
extern const color_t color_grey;
extern const color_t color_white;
extern const color_t yellow_fab413;
/**
* This function initialises the User Interface, starting the

Wyświetl plik

@ -0,0 +1,226 @@
/***************************************************************************
* Copyright (C) 2022 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_DEFAULT_H
#define UI_DEFAULT_H
#include <stdbool.h>
#include <state.h>
#include <graphics.h>
#include <interfaces/keyboard.h>
#include <stdint.h>
#include <event.h>
#include <hwconfig.h>
#include <ui.h>
// Maximum menu entry length
#define MAX_ENTRY_LEN 21
// Frequency digits
#define FREQ_DIGITS 7
// Time & Date digits
#define TIMEDATE_DIGITS 10
// Max number of UI events
#define MAX_NUM_EVENTS 16
enum uiScreen
{
MAIN_VFO = 0,
MAIN_VFO_INPUT,
MAIN_MEM,
MODE_VFO,
MODE_MEM,
MENU_TOP,
MENU_BANK,
MENU_CHANNEL,
MENU_CONTACTS,
MENU_GPS,
MENU_SETTINGS,
MENU_BACKUP_RESTORE,
MENU_BACKUP,
MENU_RESTORE,
MENU_INFO,
MENU_ABOUT,
SETTINGS_TIMEDATE,
SETTINGS_TIMEDATE_SET,
SETTINGS_DISPLAY,
SETTINGS_GPS,
SETTINGS_M17,
SETTINGS_VOICE,
SETTINGS_RESET2DEFAULTS,
LOW_BAT
};
enum SetRxTx
{
SET_RX = 0,
SET_TX
};
// This enum is needed to have item numbers that match
// menu elements even if some elements may be missing (GPS)
enum menuItems
{
M_BANK = 0,
M_CHANNEL,
M_CONTACTS,
#ifdef GPS_PRESENT
M_GPS,
#endif
M_SETTINGS,
M_BACKUP_RESTORE,
M_INFO,
M_ABOUT
};
enum settingsItems
{
S_DISPLAY = 0
#ifdef RTC_PRESENT
,S_TIMEDATE
#endif
#ifdef GPS_PRESENT
,S_GPS
#endif
,S_M17
,S_VOICE
,S_RESET2DEFAULTS
};
enum backupRestoreItems
{
BR_BACKUP = 0,
BR_RESTORE
};
enum displayItems
{
D_BRIGHTNESS = 0
#ifdef SCREEN_CONTRAST
,D_CONTRAST
#endif
,D_TIMER
};
#ifdef GPS_PRESENT
enum settingsGPSItems
{
G_ENABLED = 0,
G_SET_TIME,
G_TIMEZONE
};
#endif
enum settingsVoicePromptItems
{
VP_LEVEL = 0,
VP_PHONETIC,
};
/**
* Struct containing a set of positions and sizes that get
* calculated for the selected display size.
* Using these parameters make the UI automatically adapt
* To displays of different sizes
*/
typedef struct layout_t
{
uint16_t hline_h;
uint16_t top_h;
uint16_t line1_h;
uint16_t line2_h;
uint16_t line3_h;
uint16_t menu_h;
uint16_t bottom_h;
uint16_t bottom_pad;
uint16_t status_v_pad;
uint16_t horizontal_pad;
uint16_t text_v_offset;
point_t top_pos;
point_t line1_pos;
point_t line2_pos;
point_t line3_pos;
point_t bottom_pos;
fontSize_t top_font;
fontSize_t line1_font;
fontSize_t line2_font;
fontSize_t line3_font;
fontSize_t bottom_font;
fontSize_t input_font;
fontSize_t menu_font;
fontSize_t mode_font_big;
fontSize_t mode_font_small;
} layout_t;
/**
* This structs contains state variables internal to the
* UI that need to be kept between executions of the UI
* This state does not need to be saved on device poweroff
*/
typedef struct ui_state_t
{
// Index of the currently selected menu entry
uint8_t menu_selected;
// If true we can change a menu entry value with UP/DOWN
bool edit_mode;
// Variables used for VFO input
uint8_t input_number;
uint8_t input_position;
uint8_t input_set;
long long last_keypress;
freq_t new_rx_frequency;
freq_t new_tx_frequency;
char new_rx_freq_buf[14];
char new_tx_freq_buf[14];
#ifdef RTC_PRESENT
// Variables used for Time & Date input
datetime_t new_timedate;
char new_date_buf[9];
char new_time_buf[9];
#endif
char new_callsign[10];
// Which state to return to when we exit menu
uint8_t last_main_state;
}
ui_state_t;
extern layout_t layout;
// Copy of the radio state
extern state_t last_state;
extern const char *menu_items[];
extern const char *settings_items[];
extern const char *display_items[];
extern const char *settings_gps_items[];
extern const char * settings_voice_items[];
extern const char *backup_restore_items[];
extern const char *info_items[];
extern const char *authors[];
extern const uint8_t menu_num;
extern const uint8_t settings_num;
extern const uint8_t display_num;
extern const uint8_t settings_gps_num;
extern const uint8_t settings_voice_num;
extern const uint8_t backup_restore_num;
extern const uint8_t info_num;
extern const uint8_t author_num;
extern const color_t color_black;
extern const color_t color_grey;
extern const color_t color_white;
extern const color_t yellow_fab413;
#endif /* UI_DEFAULT_H */

Wyświetl plik

@ -19,6 +19,7 @@
***************************************************************************/
#include <interfaces/platform.h>
#include <interfaces/keyboard.h>
#include <interfaces/display.h>
#include <interfaces/delays.h>
#include <interfaces/cps_io.h>
@ -27,6 +28,7 @@
#include <graphics.h>
#include <openrtx.h>
#include <threads.h>
#include <state.h>
#include <ui.h>
#ifdef PLATFORM_LINUX
#include <stdlib.h>

Wyświetl plik

@ -22,6 +22,7 @@
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <event.h>
#include <state.h>
#include <battery.h>
#include <hwconfig.h>

Wyświetl plik

@ -30,7 +30,7 @@
#include <stdlib.h>
#include <string.h>
#include <utils.h>
#include <ui.h>
#include <ui/ui_default.h>
#include <beeps.h>
#include "interfaces/cps_io.h"

Wyświetl plik

@ -64,7 +64,7 @@
#include <stdio.h>
#include <stdint.h>
#include <math.h>
#include <ui.h>
#include <ui/ui_default.h>
#include <rtx.h>
#include <interfaces/platform.h>
#include <interfaces/display.h>

Wyświetl plik

@ -22,9 +22,9 @@
#include <interfaces/cps_io.h>
#include <stdio.h>
#include <stdint.h>
#include <ui.h>
#include <ui/ui_default.h>
#include <string.h>
#include "ui/ui_strings.h"
#include <ui/ui_strings.h>
void _ui_drawMainBackground()
{

Wyświetl plik

@ -22,7 +22,7 @@
#include <stdint.h>
#include <string.h>
#include <utils.h>
#include <ui.h>
#include <ui/ui_default.h>
#include <interfaces/nvmem.h>
#include <interfaces/cps_io.h>
#include <interfaces/platform.h>