Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -75,12 +75,15 @@ openrtx_inc = ['openrtx/include', 'platform']
## OpenRTX UI sources
##

ui_src_default = ['openrtx/src/ui/default/ui.c',
ui_src_common = ['openrtx/src/ui/common/ui_events.cpp',
'openrtx/src/ui/common/ui_nav.cpp',
'openrtx/src/ui/default/ui_strings.c']

ui_src_default = ui_src_common + ['openrtx/src/ui/default/ui.cpp',
'openrtx/src/ui/default/ui_main.c',
'openrtx/src/ui/default/ui_menu.c',
'openrtx/src/ui/default/ui_strings.c']
'openrtx/src/ui/default/ui_menu.c']

ui_src_module17 = ['openrtx/src/ui/module17/ui.c',
ui_src_module17 = ui_src_common + ['openrtx/src/ui/module17/ui.cpp',
'openrtx/src/ui/module17/ui_main.c',
'openrtx/src/ui/module17/ui_menu.c']

Expand Down
8 changes: 8 additions & 0 deletions openrtx/include/core/battery.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,19 @@

#include <stdint.h>

#ifdef __cplusplus
extern "C" {
#endif

/**
* This function computes the battery's state of charge given its current voltage.
* @param vbat: battery voltage in millivolt.
* @return state of charge percentage, from 0% to 100%.
*/
uint8_t battery_getCharge(uint16_t vbat);

#ifdef __cplusplus
} // extern "C"
#endif

#endif /* BATTERY_H */
8 changes: 8 additions & 0 deletions openrtx/include/core/beeps.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@

#ifndef BEEPS_H_INCLUDED
#define BEEPS_H_INCLUDED

#ifdef __cplusplus
extern "C" {
#endif
// Duration in tenths of a second.
#define SHORT_BEEP 3
#define LONG_BEEP 7
Expand All @@ -18,4 +22,8 @@
#define BEEP_KEY_GENERIC 750
extern const uint16_t BOOT_MELODY[];

#ifdef __cplusplus
} // extern "C"
#endif

#endif // BEEPS_H_INCLUDED
8 changes: 8 additions & 0 deletions openrtx/include/core/input.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@
#include <inttypes.h>
#include <stdbool.h>

#ifdef __cplusplus
extern "C" {
#endif

/**
* Time interval in milliseconds after which a keypress is considered a long-press
*/
Expand Down Expand Up @@ -82,4 +86,8 @@ uint8_t input_getPressedNumber(kbd_msg_t msg);
*/
uint8_t input_getPressedChar(kbd_msg_t msg);

#ifdef __cplusplus
} // extern "C"
#endif

#endif /* INPUT_H */
8 changes: 8 additions & 0 deletions openrtx/include/core/state.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@
#include "core/cps.h"
#include "core/gps.h"

#ifdef __cplusplus
extern "C" {
#endif

/**
* Part of this structure has been commented because the corresponding
* functionality is not yet implemented.
Expand Down Expand Up @@ -103,4 +107,8 @@ void state_task();
*/
void state_resetSettingsAndVfo();

#ifdef __cplusplus
} // extern "C"
#endif

#endif /* STATE_H */
8 changes: 8 additions & 0 deletions openrtx/include/core/ui.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@
#include <stdbool.h>
#include <stdint.h>

#ifdef __cplusplus
extern "C" {
#endif

/**
* This function initialises the User Interface, starting the
* Finite State Machine describing the user interaction.
Expand Down Expand Up @@ -58,4 +62,8 @@ bool ui_pushEvent(const uint8_t type, const uint32_t data);
*/
void ui_terminate();

#ifdef __cplusplus
}
#endif

#endif /* UI_H */
8 changes: 8 additions & 0 deletions openrtx/include/core/voicePromptUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@
#include "ui/ui_strings.h"
#include "core/voicePrompts.h"

#ifdef __cplusplus
extern "C" {
#endif

/*
Please Note!

Expand Down Expand Up @@ -225,4 +229,8 @@ void vp_announceSplashScreen();
*/
void vp_announceTimeZone(const int8_t timeZone, const vpQueueFlags_t flags);

#ifdef __cplusplus
} // extern "C"
#endif

#endif // VOICE_PROMPT_UTILS_H
8 changes: 8 additions & 0 deletions openrtx/include/core/voicePrompts.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@
#include "core/datatypes.h"
#include <stdbool.h>

#ifdef __cplusplus
extern "C" {
#endif

/**
* List of voice prompts for spoken words or phrases which are not in the UI
* string table. The voice prompt data file stores these first, then after the
Expand Down Expand Up @@ -328,4 +332,8 @@ void vp_beep(uint16_t freq, uint16_t duration);
*/
void vp_beepSeries(const uint16_t* beepSeries);

#ifdef __cplusplus
} // extern "C"
#endif

#endif
27 changes: 27 additions & 0 deletions openrtx/include/ui/Screen.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/*
* SPDX-FileCopyrightText: Copyright 2020-2026 OpenRTX Contributors
*
* SPDX-License-Identifier: GPL-3.0-or-later
*/

#pragma once

#include "core/event.h"

/**
* Abstract base class for UI screens.
*
* Mirrors the OpMode hierarchy used in rtx/: concrete screens are
* stack-allocated static instances; dispatch goes through a Screen* pointer.
* No RTTI, no exceptions, no dynamic_cast — consistent with the rest of the
* embedded codebase.
*/
class Screen
{
public:
virtual void enter() {}
virtual void exit() {}
virtual bool handleInput(event_t ev) = 0;
virtual void render() = 0;
virtual ~Screen() = default;
};
48 changes: 48 additions & 0 deletions openrtx/include/ui/ui_common.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
/*
* SPDX-FileCopyrightText: Copyright 2020-2026 OpenRTX Contributors
*
* SPDX-License-Identifier: GPL-3.0-or-later
*/

#ifndef UI_COMMON_H
#define UI_COMMON_H

#include "core/graphics.h"
#include <stdbool.h>
#include <stdint.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 SetRxTx
{
SET_RX = 0,
SET_TX
};

enum backupRestoreItems
{
BR_BACKUP = 0,
BR_RESTORE
};

#ifdef __cplusplus
extern "C" {
#endif

extern const color_t color_black;
extern const color_t color_grey;
extern const color_t color_white;
extern const color_t yellow_fab413;

#ifdef __cplusplus
}
#endif

#endif /* UI_COMMON_H */
32 changes: 2 additions & 30 deletions openrtx/include/ui/ui_default.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,24 +7,13 @@
#ifndef UI_DEFAULT_H
#define UI_DEFAULT_H

#include <stdbool.h>
#include "ui/ui_common.h"
#include "core/state.h"
#include "core/graphics.h"
#include "interfaces/keyboard.h"
#include <stdint.h>
#include "core/event.h"
#include "hwconfig.h"
#include "core/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,
Expand Down Expand Up @@ -55,12 +44,6 @@ enum uiScreen
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
Expand Down Expand Up @@ -94,12 +77,6 @@ enum settingsItems
S_RESET2DEFAULTS,
};

enum backupRestoreItems
{
BR_BACKUP = 0,
BR_RESTORE
};

enum displayItems
{
#ifdef CONFIG_SCREEN_BRIGHTNESS
Expand Down Expand Up @@ -237,7 +214,7 @@ typedef struct ui_state_t
}
ui_state_t;

extern layout_t layout;
extern const layout_t layout;
extern state_t last_state;
extern bool macro_latched;
extern const char *menu_items[];
Expand All @@ -262,9 +239,4 @@ extern const uint8_t settings_accessibility_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 */
61 changes: 61 additions & 0 deletions openrtx/include/ui/ui_draw.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
/*
* SPDX-FileCopyrightText: Copyright 2020-2026 OpenRTX Contributors
*
* SPDX-License-Identifier: GPL-3.0-or-later
*/

#ifndef UI_DRAW_H
#define UI_DRAW_H

/*
* Forward declarations for all _ui_draw* functions implemented in ui_main.c
* and ui_menu.c. These are C functions called from C++ translation units, so
* the extern "C" linkage specification is mandatory.
*
* Each variant (default, module17) includes this header and declares only its
* variant-specific draw functions in its own extern "C" block.
*/

// ui_state_t is defined in the variant header (ui_default.h or ui_mod17.h).
// A forward declaration is sufficient here since all parameters are pointers.
struct ui_state_t;

#ifdef __cplusplus
extern "C" {
#endif

/* ---- ui_main.c ---- */
void _ui_drawMainBackground();
void _ui_drawVFOMiddle();
void _ui_drawMEMMiddle();
void _ui_drawVFOBottom();
void _ui_drawMEMBottom();
void _ui_drawMainVFO(ui_state_t *ui_state);
void _ui_drawMainVFOInput(ui_state_t *ui_state);
void _ui_drawMainMEM(ui_state_t *ui_state);

/* ---- ui_menu.c ---- */
void _ui_drawMenuTop(ui_state_t *ui_state);
void _ui_drawMenuSettings(ui_state_t *ui_state);
void _ui_drawMenuInfo(ui_state_t *ui_state);
void _ui_drawMenuAbout(ui_state_t *ui_state);
void _ui_drawSettingsDisplay(ui_state_t *ui_state);
void _ui_drawSettingsM17(ui_state_t *ui_state);
void _ui_drawSettingsReset2Defaults(ui_state_t *ui_state);
bool _ui_drawMacroMenu(ui_state_t *ui_state);

#ifdef CONFIG_GPS
void _ui_drawMenuGPS();
void _ui_drawSettingsGPS(ui_state_t *ui_state);
#endif

#ifdef CONFIG_RTC
void _ui_drawSettingsTimeDate();
void _ui_drawSettingsTimeDateSet(ui_state_t *ui_state);
#endif

#ifdef __cplusplus
} // extern "C"
#endif

#endif /* UI_DRAW_H */
Loading