[Horus] Button widget added (still not finished)

This commit is contained in:
Bertrand Songis
2016-01-27 22:17:51 +01:00
parent 5ff4d8829a
commit 4c8789106d
14 changed files with 207 additions and 117 deletions
+1
View File
@@ -8,6 +8,7 @@ add_custom_target(ttf_horus_fonts DEPENDS ttf_horus_tinsize ttf_horus_smlsize tt
add_bitmaps_target(horus_bitmaps "${RADIO_SRC_DIRECTORY}/bitmaps/horus/bmp_*.png" 480 5/6/5)
add_bitmaps_target(horus_calibration_bitmaps "${RADIO_SRC_DIRECTORY}/bitmaps/horus/calibration/bmp_*.png" 480 5/6/5)
add_bitmaps_target(horus_button_bitmaps "${RADIO_SRC_DIRECTORY}/bitmaps/horus/button/bmp_*.png" 480 5/6/5)
add_bitmaps_target(horus_alpha_bitmaps "${RADIO_SRC_DIRECTORY}/bitmaps/horus/alpha_*.png" 480 5/6/5/8)
add_bitmaps_target(horus_alpha_calibration_bitmaps "${RADIO_SRC_DIRECTORY}/bitmaps/horus/calibration/alpha_*.png" 480 5/6/5/8)
add_bitmaps_target(horus_masks ${RADIO_SRC_DIRECTORY}/bitmaps/horus/mask_*.png 480 8bits)
+12 -2
View File
@@ -2,7 +2,7 @@
* Copyright (C) OpenTX
*
* Based on code named
* th9x - http://code.google.com/p/th9x
* th9x - http://code.google.com/p/th9x
* er9x - http://code.google.com/p/er9x
* gruvin9x - http://code.google.com/p/gruvin9x
*
@@ -78,7 +78,7 @@ const uint8_t LBM_TIMER_BACKGROUND[] = {
const uint8_t LBM_TIMER[] = {
#include "mask_timer.lbm"
};
};
const uint8_t LBM_RSCALE[] = {
#include "mask_rscale.lbm"
@@ -304,4 +304,14 @@ const uint8_t LBM_SLIDER_POINT_IN[] __DMA = {
#include "point_in.lbm"
};
const uint8_t LBM_BUTTON_LEFT[] __DMA = {
#include "bmp_left.lbm"
};
const uint8_t LBM_BUTTON_MID[] __DMA = {
#include "bmp_mid.lbm"
};
const uint8_t LBM_BUTTON_RIGHT[] __DMA = {
#include "bmp_right.lbm"
};
+85
View File
@@ -0,0 +1,85 @@
/*
* Copyright (C) OpenTX
*
* Based on code named
* th9x - http://code.google.com/p/th9x
* er9x - http://code.google.com/p/er9x
* gruvin9x - http://code.google.com/p/gruvin9x
*
* License GPLv2: http://www.gnu.org/licenses/gpl-2.0.html
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*
* 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.
*/
#ifndef _BITMAPS_H_
#define _BITMAPS_H_
// Header bitmaps
extern const uint8_t LBM_TOPMENU_POLYGON[];
extern const uint8_t LBM_DOT[];
extern const uint8_t LBM_CURRENT_BG[];
extern const uint8_t LBM_CURRENT_SHADOW[];
extern const uint8_t LBM_CURRENT_DOT[];
// Main view icons
extern const uint8_t LBM_MAINVIEW_BACKGROUND[];
extern const uint8_t LBM_TOPMENU_OPENTX[];
extern const uint8_t LBM_TOPMENU_USB[];
extern const uint8_t LBM_HTRIM_FRAME[];
extern const uint8_t LBM_VTRIM_FRAME[];
extern const uint8_t LBM_TRIM_SHADOW[];
extern const uint8_t LBM_RADIO_ICON[];
extern const uint8_t LBM_MODEL_ICON[];
extern const uint8_t LBM_TIMER_BACKGROUND[];
extern const uint8_t LBM_TIMER[];
extern const uint8_t LBM_RSCALE[];
// Menu icons
extern const uint8_t * const LBM_RADIO_ICONS[];
extern const uint8_t * const LBM_MODEL_ICONS[];
// Model selection icons
extern const uint8_t LBM_LIBRARY_ICON[];
extern const uint8_t LBM_LIBRARY_SLOT[];
extern const uint8_t LBM_LIBRARY_CURSOR[];
extern const uint8_t LBM_SCORE0[];
extern const uint8_t LBM_SCORE1[];
extern const uint8_t LBM_STAR0[];
extern const uint8_t LBM_STAR1[];
// Calibration screen
extern const uint8_t LBM_HORUS[];
extern const uint8_t LBM_STICK_BACKGROUND[];
extern const uint8_t LBM_STICK_POINTER[];
// Other icons
extern const uint8_t LBM_SPLASH[];
extern const uint8_t LBM_ASTERISK[];
extern const uint8_t LBM_POINT[];
extern const uint8_t LBM_CURVE_POINT[];
extern const uint8_t LBM_CURVE_POINT_CENTER[];
extern const uint8_t LBM_CURVE_COORD_SHADOW[];
extern const uint8_t LBM_SHUTDOWN[];
extern const uint8_t LBM_SLEEP[];
extern const uint8_t LBM_SHUTDOWN_CIRCLE[];
// Button bitmaps
extern const uint8_t LBM_BUTTON_LEFT[];
extern const uint8_t LBM_BUTTON_MID[];
extern const uint8_t LBM_BUTTON_RIGHT[];
// Slider bitmaps
extern const uint8_t LBM_SLIDER_BAR_LEFT[];
extern const uint8_t LBM_SLIDER_BAR_RIGHT[];
extern const uint8_t LBM_SLIDER_POINT_OUT[];
extern const uint8_t LBM_SLIDER_POINT_MID[];
extern const uint8_t LBM_SLIDER_POINT_IN[];
#endif // _BITMAPS_H_
+3 -71
View File
@@ -2,7 +2,7 @@
* Copyright (C) OpenTX
*
* Based on code named
* th9x - http://code.google.com/p/th9x
* th9x - http://code.google.com/p/th9x
* er9x - http://code.google.com/p/er9x
* gruvin9x - http://code.google.com/p/gruvin9x
*
@@ -20,6 +20,8 @@
#include "lcd.h"
#include "menus.h"
#include "widgets.h"
#include "bitmaps.h"
#define MENU_HEADER_HEIGHT 45
#define MENU_TITLE_TOP 48
@@ -63,21 +65,6 @@ extern uint8_t modelBitmap[MODEL_BITMAP_SIZE];
bool loadModelBitmap(char * name, uint8_t * bitmap);
#define LOAD_MODEL_BITMAP() loadModelBitmap(g_model.header.bitmap, modelBitmap)
void drawSplash();
void drawScreenIndex(uint8_t index, uint8_t count);
void drawVerticalScrollbar(coord_t x, coord_t y, coord_t h, uint16_t offset, uint16_t count, uint8_t visible);
void drawHorizontalScrollbar(coord_t x, coord_t y, coord_t w, uint16_t offset, uint16_t count, uint8_t visible);
void drawHeader(int index);
void drawColumnHeader(const char * const * headers, uint8_t index);
void drawFooter();
#define drawStatusLine(...)
void drawProgressBar(const char *label);
void updateProgressBar(int num, int den);
void drawTopmenuDatetime();
void drawSubmenuTemplate(const char * name, uint16_t scrollbar_X=0);
void drawStick(coord_t x, coord_t y, int16_t xval, int16_t yval);
void drawSticks();
#if defined(FLIGHT_MODES)
void displayFlightModes(coord_t x, coord_t y, FlightModesType value, uint8_t attr);
FlightModesType editFlightModes(coord_t x, coord_t y, evt_t event, FlightModesType value, uint8_t attr);
@@ -92,58 +79,3 @@ void drawCurveVerticalScale(int x);
void drawCurveHorizontalScale();
void drawCurveCoord(int x, int y, const char * text, bool active=false);
void drawCurvePoint(int x, int y, LcdFlags color);
// Header bitmaps
extern const uint8_t LBM_TOPMENU_POLYGON[];
extern const uint8_t LBM_DOT[];
extern const uint8_t LBM_CURRENT_BG[];
extern const uint8_t LBM_CURRENT_SHADOW[];
extern const uint8_t LBM_CURRENT_DOT[];
// Main view icons
extern const uint8_t LBM_MAINVIEW_BACKGROUND[];
extern const uint8_t LBM_TOPMENU_OPENTX[];
extern const uint8_t LBM_TOPMENU_USB[];
extern const uint8_t LBM_HTRIM_FRAME[];
extern const uint8_t LBM_VTRIM_FRAME[];
extern const uint8_t LBM_TRIM_SHADOW[];
extern const uint8_t LBM_RADIO_ICON[];
extern const uint8_t LBM_MODEL_ICON[];
extern const uint8_t LBM_TIMER_BACKGROUND[];
extern const uint8_t LBM_TIMER[];
extern const uint8_t LBM_RSCALE[];
// Menu icons
extern const uint8_t * const LBM_RADIO_ICONS[];
extern const uint8_t * const LBM_MODEL_ICONS[];
// Model selection icons
extern const uint8_t LBM_LIBRARY_ICON[];
extern const uint8_t LBM_LIBRARY_SLOT[];
extern const uint8_t LBM_LIBRARY_CURSOR[];
extern const uint8_t LBM_SCORE0[];
extern const uint8_t LBM_SCORE1[];
extern const uint8_t LBM_STAR0[];
extern const uint8_t LBM_STAR1[];
// Calibration screen
extern const uint8_t LBM_HORUS[];
extern const uint8_t LBM_STICK_BACKGROUND[];
extern const uint8_t LBM_STICK_POINTER[];
// Other icons
extern const uint8_t LBM_SPLASH[];
extern const uint8_t LBM_ASTERISK[];
extern const uint8_t LBM_POINT[];
extern const uint8_t LBM_CURVE_POINT[];
extern const uint8_t LBM_CURVE_POINT_CENTER[];
extern const uint8_t LBM_CURVE_COORD_SHADOW[];
extern const uint8_t LBM_SHUTDOWN[];
extern const uint8_t LBM_SLEEP[];
extern const uint8_t LBM_SHUTDOWN_CIRCLE[];
extern const uint8_t LBM_SLIDER_BAR_LEFT[];
extern const uint8_t LBM_SLIDER_BAR_RIGHT[];
extern const uint8_t LBM_SLIDER_POINT_OUT[];
extern const uint8_t LBM_SLIDER_POINT_MID[];
extern const uint8_t LBM_SLIDER_POINT_IN[];
+1 -4
View File
@@ -2,7 +2,7 @@
* Copyright (C) OpenTX
*
* Based on code named
* th9x - http://code.google.com/p/th9x
* th9x - http://code.google.com/p/th9x
* er9x - http://code.google.com/p/er9x
* gruvin9x - http://code.google.com/p/gruvin9x
*
@@ -311,9 +311,6 @@ void lcdSetContrast();
const char * bmpLoad(uint8_t * dest, const char * filename, uint16_t width, uint16_t height);
const char * imgLoad(uint8_t * dest, const char * filename, uint16_t width, uint16_t height);
void drawSleepBitmap();
void drawShutdownBitmap(uint32_t index);
#if defined(BOOT)
#define BLINK_ON_PHASE (0)
#else
@@ -2,7 +2,7 @@
* Copyright (C) OpenTX
*
* Based on code named
* th9x - http://code.google.com/p/th9x
* th9x - http://code.google.com/p/th9x
* er9x - http://code.google.com/p/er9x
* gruvin9x - http://code.google.com/p/gruvin9x
*
+1 -1
View File
@@ -2,7 +2,7 @@
* Copyright (C) OpenTX
*
* Based on code named
* th9x - http://code.google.com/p/th9x
* th9x - http://code.google.com/p/th9x
* er9x - http://code.google.com/p/er9x
* gruvin9x - http://code.google.com/p/gruvin9x
*
+6 -6
View File
@@ -2,7 +2,7 @@
* Copyright (C) OpenTX
*
* Based on code named
* th9x - http://code.google.com/p/th9x
* th9x - http://code.google.com/p/th9x
* er9x - http://code.google.com/p/er9x
* gruvin9x - http://code.google.com/p/gruvin9x
*
@@ -80,9 +80,9 @@ enum menuModelSetupItems {
#define FIELD_PROTOCOL_MAX 1
#define MODEL_SETUP_2ND_COLUMN 200
#define MODEL_SETUP_BIND_OFS 20
#define MODEL_SETUP_RANGE_OFS 40
#define MODEL_SETUP_SET_FAILSAFE_OFS 60
#define MODEL_SETUP_BIND_OFS 40
#define MODEL_SETUP_RANGE_OFS 80
#define MODEL_SETUP_SET_FAILSAFE_OFS 100
void onModelSetupBitmapMenu(const char *result)
{
@@ -646,8 +646,8 @@ bool menuModelSetup(evt_t event)
if (attr && l_posHorz==0 && s_editMode>0) {
CHECK_INCDEC_MODELVAR_ZERO(event, g_model.header.modelId[moduleIdx], IS_MODULE_DSM2(moduleIdx) ? 20 : 63);
}
lcdDrawText(MODEL_SETUP_2ND_COLUMN+xOffsetBind, y, STR_MODULE_BIND, l_posHorz==1 ? attr : 0);
lcdDrawText(MODEL_SETUP_2ND_COLUMN+MODEL_SETUP_RANGE_OFS+xOffsetBind, y, STR_MODULE_RANGE, l_posHorz==2 ? attr : 0);
drawButton(MODEL_SETUP_2ND_COLUMN+xOffsetBind, y, STR_MODULE_BIND, l_posHorz==1 ? attr : 0);
drawButton(MODEL_SETUP_2ND_COLUMN+MODEL_SETUP_RANGE_OFS+xOffsetBind, y, STR_MODULE_RANGE, l_posHorz==2 ? attr : 0);
uint8_t newFlag = 0;
if (attr && l_posHorz>0 && s_editMode>0) {
if (l_posHorz == 1)
-23
View File
@@ -52,8 +52,6 @@ extern uint8_t noHighlightCounter;
#define NO_HIGHLIGHT() (noHighlightCounter > 0)
#define START_NO_HIGHLIGHT() do { noHighlightCounter = 25; } while(0)
void drawCheckBox(coord_t x, coord_t y, uint8_t value, LcdFlags attr);
typedef bool (*MenuHandlerFunc)(evt_t event);
extern MenuHandlerFunc menuHandlers[5];
@@ -267,27 +265,6 @@ bool check_submenu_simple(check_event_t event, uint8_t maxrow);
#define MENU_TAB(...) const uint8_t mstate_tab[] = __VA_ARGS__
void drawShadow(coord_t x, coord_t y, coord_t w, coord_t h);
void drawScreenTemplate(const char * title, uint32_t options=0);
#define OPTION_MENU_NO_FOOTER 0x01
void drawMenuTemplate(const char * title, uint16_t scrollbar_X=0, uint32_t options=0);
#define OPTION_SLIDER_INVERS INVERS
#define OPTION_SLIDER_BLINK BLINK
#define OPTION_SLIDER_VERTICAL 0x04
#define OPTION_SLIDER_EMPTY_BAR 0x08
#define OPTION_SLIDER_DBL_COLOR 0x10
#define OPTION_SLIDER_TICKS 0x20
#define OPTION_SLIDER_BIG_TICKS 0x40
#define OPTION_SLIDER_TRIM_BUTTON 0x80
#define OPTION_SLIDER_NUMBER_BUTTON 0x100
#define OPTION_SLIDER_SQUARE_BUTTON 0x200
void drawVerticalSlider(coord_t x, coord_t y, int len, int val, int min, int max, uint8_t steps, uint32_t options);
void drawHorizontalSlider(coord_t x, coord_t y, int len, int val, int min, int max, uint8_t steps, uint32_t options);
void drawSlider(coord_t x, coord_t y, int len, int val, int min, int max, uint8_t steps, uint32_t options);
#define MENU(title, tab, menu, lines_count, scrollbar_X, ...) \
MENU_TAB(__VA_ARGS__); \
if (event == EVT_ENTRY || event == EVT_ENTRY_UP) TRACE("Menu %s displayed ...", title); \
+11 -5
View File
@@ -21,11 +21,6 @@
#include "../../opentx.h"
#include <stdio.h>
void drawHeader(const char * header)
{
// TODO ? lcdDrawText(COLUMN_HEADER_X, MENU_FOOTER_TOP, header, HEADER_COLOR);
}
void drawColumnHeader(const char * const * headers, uint8_t index)
{
// TODO ? displayHeader(headers[index]);
@@ -59,6 +54,17 @@ void drawStick(coord_t x, coord_t y, int16_t xval, int16_t yval)
lcdDrawAlphaBitmap(x + 2 + STICK_PANEL_WIDTH/2 + STICK_PANEL_WIDTH/2 * xval/RESX, y + 2 + STICK_PANEL_WIDTH/2 - STICK_PANEL_WIDTH/2 * yval/RESX, LBM_STICK_POINTER);
}
void drawButton(coord_t x, coord_t y, const char * label, LcdFlags attr)
{
int width = getTextWidth(label, attr);
lcdDrawBitmap(x, y, LBM_BUTTON_LEFT);
for (int i=0; i<width; i++) {
lcdDrawBitmap(x+20+i, y, LBM_BUTTON_MID);
}
lcdDrawBitmap(x+20+width, y, LBM_BUTTON_RIGHT);
lcdDrawText(x+23, y+1, label, attr);
}
void drawCheckBox(coord_t x, coord_t y, uint8_t value, LcdFlags attr)
{
if (attr) {
+76
View File
@@ -0,0 +1,76 @@
/*
* Copyright (C) OpenTX
*
* Based on code named
* th9x - http://code.google.com/p/th9x
* er9x - http://code.google.com/p/er9x
* gruvin9x - http://code.google.com/p/gruvin9x
*
* License GPLv2: http://www.gnu.org/licenses/gpl-2.0.html
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*
* 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.
*/
#ifndef _WIDGETS_H_
#define _WIDGETS_H_
#include "../../opentx.h"
#include <stdio.h>
#define OPTION_MENU_NO_FOOTER 0x01
#define OPTION_SLIDER_INVERS INVERS
#define OPTION_SLIDER_BLINK BLINK
#define OPTION_SLIDER_VERTICAL 0x04
#define OPTION_SLIDER_EMPTY_BAR 0x08
#define OPTION_SLIDER_DBL_COLOR 0x10
#define OPTION_SLIDER_TICKS 0x20
#define OPTION_SLIDER_BIG_TICKS 0x40
#define OPTION_SLIDER_TRIM_BUTTON 0x80
#define OPTION_SLIDER_NUMBER_BUTTON 0x100
#define OPTION_SLIDER_SQUARE_BUTTON 0x200
void drawColumnHeader(const char * const * headers, uint8_t index);
void drawTopmenuDatetime();
void drawStick(coord_t x, coord_t y, int16_t xval, int16_t yval);
void drawButton(coord_t x, coord_t y, const char * label, LcdFlags attr);
void drawCheckBox(coord_t x, coord_t y, uint8_t value, LcdFlags attr);
void drawVerticalScrollbar(coord_t x, coord_t y, coord_t h, uint16_t offset, uint16_t count, uint8_t visible);
void drawHorizontalScrollbar(coord_t x, coord_t y, coord_t w, uint16_t offset, uint16_t count, uint8_t visible);
void drawProgressBar(const char * label);
void updateProgressBar(int num, int den);
void drawShadow(coord_t x, coord_t y, coord_t w, coord_t h);
void drawTrimSquare(coord_t x, coord_t y);
void drawHorizontalTrimPosition(coord_t x, coord_t y, int16_t dir);
void drawVerticalTrimPosition(coord_t x, coord_t y, int16_t dir);
void drawVerticalSlider(coord_t x, coord_t y, int len, int val, int min, int max, uint8_t steps, uint32_t options);
void drawHorizontalSlider(coord_t x, coord_t y, int len, int val, int min, int max, uint8_t steps, uint32_t options);
void drawSlider(coord_t x, coord_t y, int len, int val, int min, int max, uint8_t steps, uint32_t options);
#define drawStatusLine(...)
select_menu_value_t selectMenuItem(coord_t x, coord_t y, const pm_char * values, select_menu_value_t value, select_menu_value_t min, select_menu_value_t max, LcdFlags attr, evt_t event);
uint8_t editCheckBox(uint8_t value, coord_t x, coord_t y, LcdFlags attr, evt_t event);
int8_t switchMenuItem(coord_t x, coord_t y, int8_t value, LcdFlags attr, evt_t event);
#if defined(GVARS)
int16_t editGVarFieldValue(coord_t x, coord_t y, int16_t value, int16_t min, int16_t max, LcdFlags attr, uint8_t editflags, evt_t event);
#else
int16_t editGVarFieldValue(coord_t x, coord_t y, int16_t value, int16_t min, int16_t max, LcdFlags attr, evt_t event);
#endif
// Screen templates
void drawScreenTemplate(const char * title, uint32_t options=0);
void drawSubmenuTemplate(const char * name, uint16_t scrollbar_X);
void drawMenuTemplate(const char * title, uint16_t scrollbar_X=0, uint32_t options=0);
void drawSplash();
void drawSleepBitmap();
void drawShutdownBitmap(uint32_t index);
#endif // _WIDGETS_H_
+1 -1
View File
@@ -9,7 +9,7 @@ if(EXISTS "${GTEST_SRCDIR}/src/gtest-all.cc")
include(${QT_USE_FILE})
add_definitions(-DSIMU)
set(TESTS_PATH ${RADIO_SRC_DIRECTORY})
configure_file(${RADIO_SRC_DIRECTORY}/tests/location.h.in ${CMAKE_CURRENT_SOURCE_DIR}/location.h @ONLY)
configure_file(${RADIO_SRC_DIRECTORY}/tests/location.h.in ${CMAKE_CURRENT_BINARY_DIR}/location.h @ONLY)
foreach(FILE ${SRC})
set(RADIO_SRC ${RADIO_SRC} ../${FILE})
+7 -1
View File
@@ -2,7 +2,7 @@
* Copyright (C) OpenTX
*
* Based on code named
* th9x - http://code.google.com/p/th9x
* th9x - http://code.google.com/p/th9x
* er9x - http://code.google.com/p/er9x
* gruvin9x - http://code.google.com/p/gruvin9x
*
@@ -65,6 +65,12 @@
#define TR(x, y) x
#endif
#if defined(COLORLCD)
#define BUTTON(x) x
#else
#define BUTTON(x) "[" x "]"
#endif
// The non-0-terminated-strings
extern const pm_char STR_OPEN9X[];
+2 -2
View File
@@ -948,8 +948,8 @@
#define TR_SPEAKER INDENT "Speaker"
#define TR_BUZZER INDENT "Buzzer"
#define TR_BYTES "bytes"
#define TR_MODULE_BIND TR("[Bnd]", "[Bind]")
#define TR_MODULE_RANGE TR("[Rng]", "[Range]")
#define TR_MODULE_BIND BUTTON(TR("Bnd", "Bind"))
#define TR_MODULE_RANGE BUTTON(TR("Rng", "Range"))
#define TR_RESET_BTN "[Reset]"
#define TR_SET "[Set]"
#define TR_TRAINER "Trainer Port"