[Horus] UI continued

This commit is contained in:
Bertrand Songis
2015-11-18 22:07:48 +01:00
parent 22a24d67c9
commit b7c09d703c
40 changed files with 535 additions and 244 deletions
+1 -1
View File
@@ -65,7 +65,7 @@ point_t getPoint(uint8_t i)
void DrawCurve(uint8_t offset=0)
{
DrawFunction(curveFn, offset);
drawFunction(curveFn, offset);
uint8_t i = 0;
do {
+2 -2
View File
@@ -82,7 +82,7 @@ int16_t expoFn(int16_t x)
return anas[ed->chn];
}
void DrawFunction(FnFuncP fn, uint8_t offset)
void drawFunction(FnFuncP fn, uint8_t offset)
{
lcdDrawVerticalLine(X0-offset, 0, LCD_H, 0xee);
lcdDrawHorizontalLine(X0-WCHART-offset, Y0, WCHART*2, 0xee);
@@ -368,7 +368,7 @@ void menuModelExpoOne(uint8_t event)
y += FH;
}
DrawFunction(expoFn);
drawFunction(expoFn);
int16_t x512 = calibratedStick[ed->chn];
lcd_outdezAtt(LCD_W-8, 6*FH, calcRESXto100(x512), 0);
+1 -1
View File
@@ -460,6 +460,6 @@ void displayWarning(uint8_t event);
#define EDIT_MODE_INIT -1
typedef int16_t (*FnFuncP) (int16_t x);
void DrawFunction(FnFuncP fn, uint8_t offset=0);
void drawFunction(FnFuncP fn, uint8_t offset=0);
#endif // _MENUS_H_
+4
View File
@@ -263,3 +263,7 @@ const uint8_t LBM_CURVE_POINT[] = {
const uint8_t LBM_CURVE_POINT_CENTER[] = {
#include "../../bitmaps/Horus/mask_cvpoint_center.lbm"
};
const uint8_t LBM_CURVE_COORD_SHADOW[] = {
#include "../../bitmaps/Horus/mask_coord_shadow.lbm"
};
+111
View File
@@ -0,0 +1,111 @@
/*
* Authors (alphabetical order)
* - Andre Bernet <bernet.andre@gmail.com>
* - Andreas Weitl
* - Bertrand Songis <bsongis@gmail.com>
* - Bryan J. Rentoul (Gruvin) <gruvin@gmail.com>
* - Cameron Weeks <th9xer@gmail.com>
* - Erez Raviv
* - Gabriel Birkus
* - Jean-Pierre Parisy
* - Karl Szmutny
* - Michael Blandford
* - Michal Hlavinka
* - Pat Mackenzie
* - Philip Moss
* - Rob Thomson
* - Romolo Manfredini <romolo.manfredini@gmail.com>
* - Thomas Husterer
*
* opentx is based on code named
* gruvin9x by Bryan J. Rentoul: http://code.google.com/p/gruvin9x/,
* er9x by Erez Raviv: http://code.google.com/p/er9x/,
* and the original (and ongoing) project by
* Thomas Husterer, th9x: http://code.google.com/p/th9x/
*
* 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.
*
*/
coord_t getCurveYCoord(FnFuncP fn, coord_t x)
{
return limit(0, CURVE_CENTER_Y - divRoundClosest(fn(divRoundClosest(x * RESX, CURVE_SIDE_WIDTH)) * CURVE_SIDE_WIDTH, RESX), LCD_H-1);
}
void drawFunction(FnFuncP fn, int offset)
{
int left = CURVE_CENTER_X-offset-CURVE_SIDE_WIDTH;
int right = CURVE_CENTER_X-offset+CURVE_SIDE_WIDTH;
int center = CURVE_CENTER_X-offset;
// Axis
lcdDrawSolidHorizontalLine(left, CURVE_CENTER_Y, CURVE_SIDE_WIDTH*2+1, CURVE_AXIS_COLOR);
lcdDrawSolidVerticalLine(center, CURVE_CENTER_Y-CURVE_SIDE_WIDTH, CURVE_SIDE_WIDTH*2, CURVE_AXIS_COLOR);
// Extra lines
lcdDrawVerticalLine(left+CURVE_SIDE_WIDTH/2, CURVE_CENTER_Y-CURVE_SIDE_WIDTH, CURVE_SIDE_WIDTH*2, STASHED, CURVE_AXIS_COLOR);
lcdDrawVerticalLine(right-CURVE_SIDE_WIDTH/2, CURVE_CENTER_Y-CURVE_SIDE_WIDTH, CURVE_SIDE_WIDTH*2, STASHED, CURVE_AXIS_COLOR);
lcdDrawHorizontalLine(left, CURVE_CENTER_Y-CURVE_SIDE_WIDTH/2, CURVE_SIDE_WIDTH*2+1, STASHED, CURVE_AXIS_COLOR);
lcdDrawHorizontalLine(left, CURVE_CENTER_Y+CURVE_SIDE_WIDTH/2, CURVE_SIDE_WIDTH*2+1, STASHED, CURVE_AXIS_COLOR);
// Outside border
lcdDrawSolidVerticalLine(left, CURVE_CENTER_Y-CURVE_SIDE_WIDTH, CURVE_SIDE_WIDTH*2, TEXT_COLOR);
lcdDrawSolidVerticalLine(right, CURVE_CENTER_Y-CURVE_SIDE_WIDTH, CURVE_SIDE_WIDTH*2, TEXT_COLOR);
lcdDrawSolidHorizontalLine(left, CURVE_CENTER_Y-CURVE_SIDE_WIDTH, CURVE_SIDE_WIDTH*2+1, TEXT_COLOR);
lcdDrawSolidHorizontalLine(left, CURVE_CENTER_Y+CURVE_SIDE_WIDTH, CURVE_SIDE_WIDTH*2+1, TEXT_COLOR);
coord_t prev_yv = (coord_t)-1;
for (int xv=-CURVE_SIDE_WIDTH; xv<=CURVE_SIDE_WIDTH; xv+=1) {
coord_t yv = getCurveYCoord(fn, xv);
if (prev_yv != (coord_t)-1) {
if (prev_yv < yv) {
for (int y=prev_yv; y<=yv; y+=1) {
lcdDrawBitmapPattern(CURVE_CENTER_X+xv-offset-2, y-2, LBM_POINT, TEXT_COLOR);
}
}
else {
for (int y=yv; y<=prev_yv; y+=1) {
lcdDrawBitmapPattern(CURVE_CENTER_X+xv-offset-2, y-2, LBM_POINT, TEXT_COLOR);
}
}
}
prev_yv = yv;
}
}
void drawCurveVerticalScale(int x)
{
for (int i=0; i<=20; i++) {
lcdDrawSolidHorizontalLine(x, CURVE_CENTER_Y-CURVE_SIDE_WIDTH+i*CURVE_SIDE_WIDTH/10, 10, TEXT_COLOR);
}
}
void drawCurveHorizontalScale()
{
for (int i=0; i<=20; i++) {
lcdDrawSolidVerticalLine(CURVE_CENTER_X-CURVE_SIDE_WIDTH+i*CURVE_SIDE_WIDTH/10, CURVE_CENTER_Y+CURVE_SIDE_WIDTH+5, 10, TEXT_COLOR);
}
}
void drawCurveCoord(int x, int y, const char * text, bool active)
{
lcdDrawSolidFilledRect(x, y, CURVE_COORD_WIDTH, CURVE_COORD_HEIGHT, CURVE_CURSOR_COLOR);
lcdDrawText(x+3+(CURVE_COORD_WIDTH-1-getTextWidth(text, SMLSIZE))/2, y+1, text, LEFT|SMLSIZE|TEXT_BGCOLOR);
if (active) {
lcdDrawBitmapPattern(x, y, LBM_CURVE_COORD_SHADOW, TEXT_COLOR);
}
}
void drawCurvePoint(int x, int y, LcdFlags color)
{
lcdDrawBitmapPattern(x, y, LBM_CURVE_POINT, color);
lcdDrawBitmapPattern(x, y, LBM_CURVE_POINT_CENTER, TEXT_BGCOLOR);
}
+32 -22
View File
@@ -37,34 +37,36 @@
#include "lcd.h"
#include "menus.h"
#define MENU_HEADER_HEIGHT 45
#define MENU_TITLE_TOP 48
#define MENU_TITLE_HEIGHT 21
#define MENU_BODY_TOP 69 // MENU_TITLE_TOP + MENU_TITLE_HEIGHT
#define MENU_CONTENT_TOP 72
#define MENU_BODY_HEIGHT 182
#define MENU_FOOTER_TOP 251 // MENU_BODY_TOP + MENU_BODY_HEIGHT
#define MENU_FOOTER_HEIGHT 21
#define MENU_HEADER_HEIGHT 45
#define MENU_TITLE_TOP 48
#define MENU_TITLE_HEIGHT 21
#define MENU_BODY_TOP 69 // MENU_TITLE_TOP + MENU_TITLE_HEIGHT
#define MENU_CONTENT_TOP 72
#define MENU_BODY_HEIGHT 182
#define MENU_FOOTER_TOP 251 // MENU_BODY_TOP + MENU_BODY_HEIGHT
#define MENU_FOOTER_HEIGHT 21
#define MENUS_MARGIN_LEFT 6
#define MENUS_MARGIN_LEFT 6
#define DEFAULT_SCROLLBAR_X LCD_W-10
#define DEFAULT_SCROLLBAR_Y MENU_CONTENT_TOP
#define DEFAULT_SCROLLBAR_H (MENU_FOOTER_TOP - DEFAULT_SCROLLBAR_Y - 6)
#define DEFAULT_SCROLLBAR_X LCD_W-10
#define DEFAULT_SCROLLBAR_Y MENU_CONTENT_TOP
#define DEFAULT_SCROLLBAR_H (MENU_FOOTER_TOP - DEFAULT_SCROLLBAR_Y - 6)
#define NUM_BODY_LINES 9
#define FH 20
#define NUM_BODY_LINES 9
#define FH 20
#define INVERT_HORZ_MARGIN 3
#define INVERT_VERT_MARGIN 1
#define INVERT_LINE_HEIGHT 18
#define INVERT_HORZ_MARGIN 3
#define INVERT_VERT_MARGIN 1
#define INVERT_LINE_HEIGHT 18
#define CURVE_SIDE_WIDTH 100
#define CURVE_CENTER_X (LCD_W-CURVE_SIDE_WIDTH-7)
#define CURVE_CENTER_Y 151
#define CURVE_SIDE_WIDTH 100
#define CURVE_CENTER_X (LCD_W-CURVE_SIDE_WIDTH-7)
#define CURVE_CENTER_Y 151
#define CURVE_COORD_WIDTH 36
#define CURVE_COORD_HEIGHT 17
#define MENU_TITLE_NEXT_POS (lcdNextPos + 10)
#define MENU_INIT_VPOS -1
#define MENU_TITLE_NEXT_POS (lcdNextPos + 10)
#define MENU_INIT_VPOS -1
void displaySplash();
void displayScreenIndex(uint8_t index, uint8_t count);
@@ -76,6 +78,13 @@ void drawProgressBar(const char *label);
void updateProgressBar(int num, int den);
void drawTopmenuDatetime();
// Curve functions
coord_t getCurveYCoord(FnFuncP fn, coord_t x);
void drawFunction(FnFuncP fn, int offset);
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[];
@@ -114,3 +123,4 @@ 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[];
+38 -19
View File
@@ -114,21 +114,25 @@ static int8_t s_copyTgtOfs;
static uint8_t editNameCursorPos = 0;
void editName(coord_t x, coord_t y, char * name, uint8_t size, evt_t event, uint8_t active)
void editName(coord_t x, coord_t y, char * name, uint8_t size, evt_t event, uint8_t active, LcdFlags flags)
{
uint8_t flags = 0;
if (active && s_editMode <= 0) {
flags = INVERS;
flags |= INVERS;
}
if (!active || s_editMode <= 0) {
uint8_t len = zlen(name, size);
if (len == 0) {
char tmp[] = "---";
lcdDrawTextWithLen(x, y, tmp, size, flags);
if (flags & ZCHAR) {
uint8_t len = zlen(name, size);
if (len == 0) {
char tmp[] = "---";
lcdDrawTextWithLen(x, y, tmp, size, flags-ZCHAR);
}
else {
lcdDrawTextWithLen(x, y, name, len, flags);
}
}
else {
lcdDrawTextWithLen(x, y, name, len, ZCHAR | flags);
lcdDrawText(x, y, name, flags);
}
}
@@ -138,8 +142,13 @@ void editName(coord_t x, coord_t y, char * name, uint8_t size, evt_t event, uint
int8_t v = c;
if (event==EVT_ROTARY_RIGHT || event==EVT_ROTARY_LEFT) {
v = checkIncDec(event, abs(v), 0, ZCHAR_MAX, 0);
if (c <= 0) v = -v;
if (flags & ZCHAR) {
v = checkIncDec(event, abs(v), 0, ZCHAR_MAX, 0);
if (c <= 0) v = -v;
}
else {
v = checkIncDec(event, abs(v), '0', 'z', 0);
}
}
switch (event) {
@@ -163,7 +172,7 @@ void editName(coord_t x, coord_t y, char * name, uint8_t size, evt_t event, uint
break;
case EVT_KEY_LONG(KEY_ENTER):
if (v==0) {
if (v == ((flags & ZCHAR) ? 0 : ' ')) {
s_editMode = 0;
killEvents(event);
break;
@@ -172,10 +181,20 @@ void editName(coord_t x, coord_t y, char * name, uint8_t size, evt_t event, uint
case EVT_KEY_LONG(KEY_LEFT):
case EVT_KEY_LONG(KEY_RIGHT):
if (v>=-26 && v<=26) {
v = -v; // toggle case
if (event==EVT_KEY_LONG(KEY_LEFT))
killEvents(KEY_LEFT);
if (flags & ZCHAR) {
if (v>=-26 && v<=26) {
v = -v; // toggle case
if (event==EVT_KEY_LONG(KEY_LEFT))
killEvents(KEY_LEFT);
}
}
else {
if (v>='A' && v<='Z') {
v = 'a'+v-'A'; // toggle case
}
else if (v>='a' && v<='z') {
v = 'A'+v-'a'; // toggle case
}
}
break;
}
@@ -185,10 +204,10 @@ void editName(coord_t x, coord_t y, char * name, uint8_t size, evt_t event, uint
storageDirty(g_menuPos[0] == 0 ? EE_MODEL : EE_GENERAL);
}
lcdDrawTextWithLen(x, y, name, size, ZCHAR | flags);
coord_t w = (editNameCursorPos == 0 ? 0 : getTextWidth(name, editNameCursorPos, ZCHAR));
char s[] = { idx2char(name[editNameCursorPos]), '\0' };
lcdDrawSolidFilledRect(x+w-1, y-INVERT_VERT_MARGIN, getTextWidth(s, 1)+1, INVERT_LINE_HEIGHT, TEXT_INVERTED_BGCOLOR);
lcdDrawTextWithLen(x, y, name, size, flags);
coord_t w = (editNameCursorPos == 0 ? 0 : getTextWidth(name, editNameCursorPos, flags));
char s[] = { (flags & ZCHAR) ? idx2char(name[editNameCursorPos]) : name[editNameCursorPos], '\0' };
lcdDrawSolidFilledRect(x+w-1, y-INVERT_VERT_MARGIN, getTextWidth(s, 1, flags)+1, INVERT_LINE_HEIGHT, TEXT_INVERTED_BGCOLOR);
lcdDrawText(x+w, y, s, TEXT_INVERTED_COLOR);
}
else {
+47 -13
View File
@@ -65,14 +65,14 @@ point_t getPoint(uint8_t i)
void DrawCurve(int offset=0)
{
DrawFunction(curveFn, offset);
drawFunction(curveFn, offset);
int i = 0;
/*int i = 0;
do {
point_t point = getPoint(i++);
if (point.x == 0) break;
lcdDrawSolidFilledRect(point.x-offset, point.y-1, 3, 3, TEXT_COLOR); // do markup square
} while(1);
} while(1);*/
}
extern int8_t * curveEnd[MAX_CURVES];
@@ -143,11 +143,13 @@ bool menuModelCurveOne(evt_t event)
SIMPLE_SUBMENU(STR_MENUCURVE, 4 + 5+crv.points + (crv.type==CURVE_TYPE_CUSTOM ? 5+crv.points-2 : 0), 0);
lcdDrawNumber(MENU_TITLE_NEXT_POS, MENU_TITLE_TOP+2, s_curveChan+1, LEFT|HEADER_COLOR);
lcdDrawNumber(MENU_TITLE_NEXT_POS, MENU_TITLE_TOP+1, s_curveChan+1, LEFT|TEXT_COLOR);
// Curve name
lcdDrawText(MENUS_MARGIN_LEFT, MENU_CONTENT_TOP, STR_NAME);
editName(MENUS_MARGIN_LEFT+INDENT_WIDTH, MENU_CONTENT_TOP + FH, g_model.curveNames[s_curveChan], sizeof(g_model.curveNames[s_curveChan]), event, m_posVert==0);
// Curve type
LcdFlags attr = (m_posVert==1 ? (s_editMode>0 ? INVERS|BLINK : INVERS) : 0);
lcdDrawText(MENUS_MARGIN_LEFT, MENU_CONTENT_TOP + 2*FH, "Type");
lcdDrawTextAtIndex(MENUS_MARGIN_LEFT+INDENT_WIDTH, MENU_CONTENT_TOP + 3*FH, STR_CURVE_TYPES, crv.type, attr);
@@ -165,6 +167,7 @@ bool menuModelCurveOne(evt_t event)
}
}
// Curve points count
attr = (m_posVert==2 ? (s_editMode>0 ? INVERS|BLINK : INVERS) : 0);
lcdDrawText(MENUS_MARGIN_LEFT, MENU_CONTENT_TOP + 4*FH, STR_COUNT);
lcdDrawNumber(MENUS_MARGIN_LEFT+INDENT_WIDTH, MENU_CONTENT_TOP + 5*FH, 5+crv.points, LEFT|attr, 0, NULL, STR_PTS);
@@ -186,6 +189,7 @@ bool menuModelCurveOne(evt_t event)
}
}
// Curve smooth
lcdDrawText(MENUS_MARGIN_LEFT, MENU_CONTENT_TOP + 6*FH, STR_SMOOTH);
drawCheckBox(lcdNextPos + 10, MENU_CONTENT_TOP + 6*FH, crv.smooth, m_posVert==3 ? INVERS : 0);
if (m_posVert==3) crv.smooth = checkIncDecModel(event, crv.smooth, 0, 1);
@@ -209,12 +213,11 @@ bool menuModelCurveOne(evt_t event)
}
if (m_posVert >= 0) {
DrawCurve(6);
DrawCurve();
drawCurveHorizontalScale();
if (m_posVert < 4) drawCurveVerticalScale(CURVE_CENTER_X-CURVE_SIDE_WIDTH-15);
}
// lcdDrawText(115, MENU_FOOTER_TOP, "X", HEADER_COLOR);
// lcdDrawText(145, MENU_FOOTER_TOP, "Y", HEADER_COLOR);
coord_t posY = MENU_CONTENT_TOP;
attr = (s_editMode > 0 ? INVERS|BLINK : INVERS);
for (int i=0; i<5+crv.points; i++) {
@@ -230,9 +233,10 @@ bool menuModelCurveOne(evt_t event)
selectionMode = 2;
}
int8_t x = -100 + 200*i/(5+crv.points-1);
if (crv.type==CURVE_TYPE_CUSTOM && i>0 && i<5+crv.points-1) x = points[5+crv.points+i-1];
if (i>=pointsOfs && i<pointsOfs+NUM_BODY_LINES) {
int8_t x = -100 + 200*i/(5+crv.points-1);
if (crv.type==CURVE_TYPE_CUSTOM && i>0 && i<5+crv.points-1) x = points[5+crv.points+i-1];
lcdDrawNumber(120, posY, i+1, LEFT|TEXT_DISABLE_COLOR);
lcdDrawNumber(150, posY, x, LEFT|(selectionMode==1 ? attr : 0));
lcdDrawNumber(200, posY, points[i], LEFT|(selectionMode==2 ? attr : 0));
@@ -240,8 +244,35 @@ bool menuModelCurveOne(evt_t event)
}
if (selectionMode > 0) {
// do selection square
lcdDrawSolidFilledRect(point.x-7, point.y-2, 5, 5, TEXT_INVERTED_BGCOLOR);
lcdDrawSolidFilledRect(point.x, CURVE_CENTER_Y-CURVE_SIDE_WIDTH, 2, 2*CURVE_SIDE_WIDTH+2, CURVE_CURSOR_COLOR);
char text[5];
sprintf(text, "%d", points[i]);
if (point.x >= CURVE_CENTER_X) {
drawCurveVerticalScale(point.x-15);
if (points[i-1] > points[i]) {
drawCurveCoord(point.x+1-CURVE_COORD_WIDTH, point.y, text, selectionMode==2);
}
else {
drawCurveCoord(point.x+1-CURVE_COORD_WIDTH, point.y-CURVE_COORD_HEIGHT-1, text, selectionMode==2);
}
}
else {
drawCurveVerticalScale(point.x+7);
if (points[i+1] > points[i]) {
drawCurveCoord(point.x+1, point.y, text, selectionMode==2);
}
else {
drawCurveCoord(point.x+1, point.y-CURVE_COORD_HEIGHT-1, text, selectionMode==2);
}
}
drawCurvePoint(point.x-3, point.y-4, CURVE_CURSOR_COLOR);
sprintf(text, "%d", x);
drawCurveCoord(limit(CURVE_CENTER_X-CURVE_SIDE_WIDTH-1, point.x-CURVE_COORD_WIDTH/2, CURVE_CENTER_X+CURVE_SIDE_WIDTH-CURVE_COORD_WIDTH+1), CURVE_CENTER_Y+CURVE_SIDE_WIDTH+2, text, selectionMode==1);
if (s_editMode > 0) {
if (selectionMode == 1)
CHECK_INCDEC_MODELVAR(event, points[5+crv.points+i-1], i==1 ? -100 : points[5+crv.points+i-2], i==5+crv.points-2 ? 100 : points[5+crv.points+i]); // edit X
@@ -253,9 +284,12 @@ bool menuModelCurveOne(evt_t event)
else if (i > pointsOfs+NUM_BODY_LINES-1)
pointsOfs = i-NUM_BODY_LINES+1;
}
else {
drawCurvePoint(point.x-3, point.y-4, TEXT_COLOR);
}
}
drawScrollbar(250, DEFAULT_SCROLLBAR_Y, DEFAULT_SCROLLBAR_H, pointsOfs, 5+crv.points, NUM_BODY_LINES);
drawScrollbar(240, DEFAULT_SCROLLBAR_Y, DEFAULT_SCROLLBAR_H+MENU_FOOTER_HEIGHT, pointsOfs, 5+crv.points, NUM_BODY_LINES+1);
return true;
}
+10 -70
View File
@@ -79,67 +79,6 @@ int expoFn(int x)
return anas[ed->chn];
}
int divRound(int num, int den)
{
if (num < 0)
return (num - den/2) / den;
else
return (num + den/2) / den;
}
coord_t getYCoord(FnFuncP fn, coord_t x)
{
return limit(0, CURVE_CENTER_Y - divRound(fn(divRound(x * RESX, CURVE_SIDE_WIDTH)) * CURVE_SIDE_WIDTH, RESX), LCD_H-1);
}
void DrawFunction(FnFuncP fn, int offset)
{
int left = CURVE_CENTER_X-offset-CURVE_SIDE_WIDTH;
int right = CURVE_CENTER_X-offset+CURVE_SIDE_WIDTH;
int center = CURVE_CENTER_X-offset;
// Axis
lcdDrawSolidHorizontalLine(left, CURVE_CENTER_Y, CURVE_SIDE_WIDTH*2+1, CURVE_AXIS_COLOR);
lcdDrawSolidVerticalLine(center, CURVE_CENTER_Y-CURVE_SIDE_WIDTH, CURVE_SIDE_WIDTH*2, CURVE_AXIS_COLOR);
// Extra lines
lcdDrawVerticalLine(left+CURVE_SIDE_WIDTH/2, CURVE_CENTER_Y-CURVE_SIDE_WIDTH, CURVE_SIDE_WIDTH*2, STASHED, CURVE_AXIS_COLOR);
lcdDrawVerticalLine(right-CURVE_SIDE_WIDTH/2, CURVE_CENTER_Y-CURVE_SIDE_WIDTH, CURVE_SIDE_WIDTH*2, STASHED, CURVE_AXIS_COLOR);
lcdDrawHorizontalLine(left, CURVE_CENTER_Y-CURVE_SIDE_WIDTH/2, CURVE_SIDE_WIDTH*2+1, STASHED, CURVE_AXIS_COLOR);
lcdDrawHorizontalLine(left, CURVE_CENTER_Y+CURVE_SIDE_WIDTH/2, CURVE_SIDE_WIDTH*2+1, STASHED, CURVE_AXIS_COLOR);
// Outside border
lcdDrawSolidVerticalLine(left, CURVE_CENTER_Y-CURVE_SIDE_WIDTH, CURVE_SIDE_WIDTH*2, TEXT_COLOR);
lcdDrawSolidVerticalLine(right, CURVE_CENTER_Y-CURVE_SIDE_WIDTH, CURVE_SIDE_WIDTH*2, TEXT_COLOR);
lcdDrawSolidHorizontalLine(left, CURVE_CENTER_Y-CURVE_SIDE_WIDTH, CURVE_SIDE_WIDTH*2+1, TEXT_COLOR);
lcdDrawSolidHorizontalLine(left, CURVE_CENTER_Y+CURVE_SIDE_WIDTH, CURVE_SIDE_WIDTH*2+1, TEXT_COLOR);
// Horizontal / Vertical scale
for (int i=0; i<=20; i++) {
lcdDrawSolidHorizontalLine(left-15, CURVE_CENTER_Y-CURVE_SIDE_WIDTH+i*CURVE_SIDE_WIDTH/10, 10, TEXT_COLOR);
lcdDrawSolidVerticalLine(left+i*CURVE_SIDE_WIDTH/10, CURVE_CENTER_Y+CURVE_SIDE_WIDTH+5, 10, TEXT_COLOR);
}
coord_t prev_yv = (coord_t)-1;
for (int xv=-CURVE_SIDE_WIDTH; xv<=CURVE_SIDE_WIDTH; xv+=1) {
coord_t yv = getYCoord(fn, xv);
if (prev_yv != (coord_t)-1) {
if (prev_yv < yv) {
for (int y=prev_yv; y<=yv; y+=1) {
lcdDrawBitmapPattern(CURVE_CENTER_X+xv-offset-2, y-2, LBM_POINT, TEXT_COLOR);
}
}
else {
for (int y=yv; y<=prev_yv; y+=1) {
lcdDrawBitmapPattern(CURVE_CENTER_X+xv-offset-2, y-2, LBM_POINT, TEXT_COLOR);
}
}
}
prev_yv = yv;
}
}
int getLinesCount(uint8_t expo)
{
int lastch = -1;
@@ -371,7 +310,10 @@ bool menuModelExpoOne(evt_t event)
coord_t y = MENU_CONTENT_TOP;
DrawFunction(expoFn);
drawFunction(expoFn);
drawCurveHorizontalScale();
drawCurveVerticalScale(CURVE_CENTER_X-CURVE_SIDE_WIDTH-15);
{
char textx[5];
@@ -390,20 +332,18 @@ bool menuModelExpoOne(evt_t event)
int y = limit<int>(-1024, expoFn(x), 1024);
sprintf(texty, "%d", calcRESXto100(y));
x = divRound(x*CURVE_SIDE_WIDTH, RESX);
y = getYCoord(expoFn, x);
x = divRoundClosest(x*CURVE_SIDE_WIDTH, RESX);
y = getCurveYCoord(expoFn, x);
lcdDrawSolidFilledRect(CURVE_CENTER_X+x, CURVE_CENTER_Y-CURVE_SIDE_WIDTH, 2, 2*CURVE_SIDE_WIDTH+2, CURVE_CURSOR_COLOR);
lcdDrawSolidFilledRect(CURVE_CENTER_X-CURVE_SIDE_WIDTH-2, y-1, 2*CURVE_SIDE_WIDTH+2, 2, CURVE_CURSOR_COLOR);
lcdDrawBitmapPattern(CURVE_CENTER_X+x-4, y-4, LBM_CURVE_POINT, CURVE_CURSOR_COLOR);
lcdDrawBitmapPattern(CURVE_CENTER_X+x-4, y-4, LBM_CURVE_POINT_CENTER, TEXT_BGCOLOR);
int left = (x < -30 ? CURVE_CENTER_X+x : (x > 30 ? CURVE_CENTER_X+x-34 : CURVE_CENTER_X-17+x/2));
lcdDrawSolidFilledRect(left, CURVE_CENTER_Y+CURVE_SIDE_WIDTH+2, 36, 17, CURVE_CURSOR_COLOR);
lcdDrawText(left+3+(35-getTextWidth(textx, SMLSIZE))/2, CURVE_CENTER_Y+CURVE_SIDE_WIDTH+3, textx, LEFT|SMLSIZE|TEXT_BGCOLOR);
int top = (y < CURVE_CENTER_Y-8 ? y-1 : (y > CURVE_CENTER_Y+8 ? y-16 : CURVE_CENTER_Y-8+(y-CURVE_CENTER_Y)/2));
lcdDrawSolidFilledRect(CURVE_CENTER_X-CURVE_SIDE_WIDTH-37, top, 36, 17, CURVE_CURSOR_COLOR);
lcdDrawText(CURVE_CENTER_X-CURVE_SIDE_WIDTH-34+(35-getTextWidth(texty, SMLSIZE))/2, top+1, texty, LEFT|SMLSIZE|TEXT_BGCOLOR);
int left = limit(CURVE_CENTER_X-CURVE_SIDE_WIDTH, CURVE_CENTER_X-CURVE_COORD_WIDTH/2+x, CURVE_CENTER_X+CURVE_SIDE_WIDTH-CURVE_COORD_WIDTH+2);
drawCurveCoord(left, CURVE_CENTER_Y+CURVE_SIDE_WIDTH+2, textx);
int top = limit(CURVE_CENTER_Y-CURVE_SIDE_WIDTH-1, -CURVE_COORD_HEIGHT/2+y, CURVE_CENTER_Y+CURVE_SIDE_WIDTH-CURVE_COORD_HEIGHT+1);
drawCurveCoord(CURVE_CENTER_X-CURVE_SIDE_WIDTH-37, top, texty);
}
for (int i=0; i<NUM_BODY_LINES+1; i++) {
+43 -3
View File
@@ -43,11 +43,13 @@
enum ModelSelectMode {
MODE_SELECT_CATEGORY,
MODE_SELECT_MODEL,
MODE_RENAME_CATEGORY,
};
uint8_t selectMode;
uint8_t currentCategory;
char selectedFilename[LEN_MODEL_FILENAME+1];
char selectedCategory[LEN_MODEL_FILENAME+1];
void drawCategory(coord_t y, const char * name, bool selected)
{
@@ -85,6 +87,19 @@ void drawModel(coord_t x, coord_t y, const char * name, bool selected)
}
}
void onCategorySelectMenu(const char * result)
{
if (result == STR_CREATE_CATEGORY) {
storageAppendCategory("Category");
}
else if (result == STR_RENAME_CATEGORY) {
selectMode = MODE_RENAME_CATEGORY;
}
else if (result == STR_DELETE_CATEGORY) {
storageRemoveCategory(currentCategory--);
}
}
void onModelSelectMenu(const char * result)
{
if (result == STR_SELECT_MODEL) {
@@ -160,8 +175,16 @@ bool menuModelSelect(evt_t event)
break;
case EVT_KEY_LONG(KEY_ENTER):
killEvents(event);
if (selectMode == MODE_SELECT_MODEL) {
if (selectMode == MODE_SELECT_CATEGORY) {
killEvents(event);
MENU_ADD_ITEM(STR_CREATE_CATEGORY);
MENU_ADD_ITEM(STR_RENAME_CATEGORY);
if (currentCategory > 0)
MENU_ADD_ITEM(STR_DELETE_CATEGORY);
menuHandler = onCategorySelectMenu;
}
else if (selectMode == MODE_SELECT_MODEL) {
killEvents(event);
ModelHeader header;
const char * error = readModel(selectedFilename, (uint8_t *)&header, sizeof(header));
if (!error) {
@@ -204,8 +227,25 @@ bool menuModelSelect(evt_t event)
if (!result)
break;
if (y < LCD_H) {
drawCategory(y, line, currentCategory==index);
if (selectMode == MODE_RENAME_CATEGORY && currentCategory == index) {
s_editMode = EDIT_MODIFY_STRING;
lcdDrawSolidFilledRect(0, y-INVERT_VERT_MARGIN, CATEGORIES_WIDTH, INVERT_LINE_HEIGHT, TEXT_BGCOLOR);
editName(MENUS_MARGIN_LEFT, y, selectedCategory, LEN_MODEL_FILENAME, event, 1, 0);
if (s_editMode == 0 || event == EVT_KEY_BREAK(KEY_EXIT)) {
storageRenameCategory(currentCategory, selectedCategory);
selectMode = MODE_SELECT_CATEGORY;
putEvent(EVT_REFRESH);
}
}
else {
if (currentCategory == index) {
memcpy(selectedCategory, line, sizeof(selectedCategory));
}
drawCategory(y, line, currentCategory==index);
}
}
y += FH;
index++;
}
+2 -2
View File
@@ -247,7 +247,7 @@ int8_t switchMenuItem(coord_t x, coord_t y, int8_t value, LcdFlags attr, evt_t e
#define displayGVar(x, y, v, min, max) lcdDrawNumber(x, y, v)
#endif
void editName(coord_t x, coord_t y, char *name, uint8_t size, evt_t event, uint8_t active);
void editName(coord_t x, coord_t y, char *name, uint8_t size, evt_t event, uint8_t active, LcdFlags flags=ZCHAR);
#define WARNING_TYPE_ASTERISK 0
#define WARNING_TYPE_CONFIRM 1
@@ -318,6 +318,6 @@ void pushModelNotes();
#define EDIT_MODE_INIT 0 // TODO enum
typedef int (*FnFuncP) (int x);
void DrawFunction(FnFuncP fn, int offset=0);
void drawFunction(FnFuncP fn, int offset=0);
#endif // _MENUS_H_
+1 -1
View File
@@ -65,7 +65,7 @@ point_t getPoint(uint8_t i)
void DrawCurve(uint8_t offset=0)
{
DrawFunction(curveFn, offset);
drawFunction(curveFn, offset);
uint8_t i = 0;
do {
@@ -81,7 +81,7 @@ int16_t expoFn(int16_t x)
return anas[ed->chn];
}
void DrawFunction(FnFuncP fn, uint8_t offset)
void drawFunction(FnFuncP fn, uint8_t offset)
{
lcdDrawVerticalLine(X0-offset, 0/*TODO Y0-WCHART*/, WCHART*2, 0xee);
lcdDrawHorizontalLine(X0-WCHART-offset, Y0, WCHART*2, 0xee);
@@ -396,7 +396,7 @@ void menuModelExpoOne(uint8_t event)
y += FH;
}
DrawFunction(expoFn);
drawFunction(expoFn);
int x512 = getValue(ed->srcRaw);
if (ed->srcRaw >= MIXSRC_FIRST_TELEM) {
+1 -1
View File
@@ -356,6 +356,6 @@ void menuChannelsView(uint8_t event);
#define EDIT_MODE_INIT 0 // TODO enum
typedef int16_t (*FnFuncP) (int16_t x);
void DrawFunction(FnFuncP fn, uint8_t offset=0);
void drawFunction(FnFuncP fn, uint8_t offset=0);
#endif // _MENUS_H_