1
0
Fork 0
mirror of https://github.com/opentx/opentx.git synced 2025-07-25 17:25:13 +03:00
This commit is contained in:
bsongis 2014-06-06 11:54:02 +02:00
parent 3d4d6ba313
commit 6511ae173d
5 changed files with 53 additions and 27 deletions

View file

@ -44,7 +44,7 @@
#endif
#if defined(FRSKY_HUB) && defined(GAUGES)
uint8_t barsThresholds[THLD_MAX];
bar_threshold_t barsThresholds[THLD_MAX];
#endif
enum FrskyViews {
@ -58,6 +58,14 @@ enum FrskyViews {
static uint8_t s_frsky_view = e_frsky_custom_screen_1;
#if LCD_W >= 212
#define BAR_LEFT 26
#define BAR_WIDTH 157
#else
#define BAR_LEFT 25
#define BAR_WIDTH 100
#endif
#if defined(PCBTARANIS)
void displayRssiLine()
{
@ -65,8 +73,8 @@ void displayRssiLine()
lcd_hline(0, 55, 212, 0); // separator
uint8_t rssi = min((uint8_t)99, frskyData.rssi[0].value);
lcd_putsn(0, STATUS_BAR_Y, STR_RX, 2); lcd_outdezNAtt(4*FW, STATUS_BAR_Y, rssi, LEADING0, 2);
lcd_rect(25, 57, 78, 7);
lcd_filled_rect(26, 58, 19*rssi/25, 5, (rssi < getRssiAlarmValue(0)) ? DOTTED : SOLID);
lcd_rect(BAR_LEFT, 57, 78, 7);
lcd_filled_rect(BAR_LEFT+1, 58, 19*rssi/25, 5, (rssi < getRssiAlarmValue(0)) ? DOTTED : SOLID);
}
else {
lcd_putsAtt(7*FW, STATUS_BAR_Y, STR_NODATA, BLINK);
@ -80,8 +88,8 @@ void displayRssiLine()
lcd_hline(0, 55, 128, 0); // separator
uint8_t rssi = min((uint8_t)99, frskyData.rssi[1].value);
lcd_putsLeft(STATUS_BAR_Y, STR_TX); lcd_outdezNAtt(4*FW+1, STATUS_BAR_Y, rssi, LEADING0, 2);
lcd_rect(25, 57, 38, 7);
lcd_filled_rect(26, 58, 4*rssi/11, 5, (rssi < getRssiAlarmValue(0)) ? DOTTED : SOLID);
lcd_rect(BAR_LEFT+1, 57, 38, 7);
lcd_filled_rect(BAR_LEFT+1, 58, 4*rssi/11, 5, (rssi < getRssiAlarmValue(0)) ? DOTTED : SOLID);
rssi = min((uint8_t)99, frskyData.rssi[0].value);
lcd_puts(104, STATUS_BAR_Y, STR_RX); lcd_outdezNAtt(105+4*FW, STATUS_BAR_Y, rssi, LEADING0, 2);
lcd_rect(65, 57, 38, 7);
@ -157,12 +165,6 @@ void displayVoltageScreenLine(uint8_t y, uint8_t index)
}
}
#if LCD_W >= 212
#define BAR_WIDTH 150
#else
#define BAR_WIDTH 100
#endif
uint8_t barCoord(int16_t value, int16_t min, int16_t max)
{
return limit((uint8_t)0, (uint8_t)(((int32_t)(BAR_WIDTH-1) * (value - min)) / (max - min)), (uint8_t)BAR_WIDTH);
@ -220,10 +222,10 @@ void menuTelemetryFrsky(uint8_t event)
if (source && barMax > barMin) {
uint8_t y = barHeight+6+i*(barHeight+6);
lcd_putsiAtt(0, y+barHeight-5, STR_VTELEMCHNS, source, 0);
lcd_rect(25, y, BAR_WIDTH+1, barHeight+2);
lcd_rect(BAR_LEFT, y, BAR_WIDTH+1, barHeight+2);
getvalue_t value = getValue(MIXSRC_FIRST_TELEM+source-1);
#if LCD_W >= 212
putsTelemetryChannel(27+BAR_WIDTH, y+barHeight-6, source-1, value, LEFT);
putsTelemetryChannel(BAR_LEFT+2+BAR_WIDTH, y+barHeight-5, source-1, value, LEFT);
#endif
getvalue_t threshold = 0;
uint8_t thresholdX = 0;
@ -234,9 +236,14 @@ void menuTelemetryFrsky(uint8_t event)
else if (source <= TELEM_A2)
threshold = g_model.frsky.channels[source-TELEM_A1].alarms_value[0];
#if defined(FRSKY_HUB)
else
else {
#if defined(CPUARM)
threshold = barsThresholds[source-TELEM_ALT];
#else
threshold = convertBarTelemValue(source, barsThresholds[source-TELEM_ALT]);
#endif
}
#endif
if (threshold) {
thresholdX = barCoord(threshold, barMin, barMax);
@ -251,14 +258,17 @@ void menuTelemetryFrsky(uint8_t event)
if (source == TELEM_T1 || source == TELEM_T2)
barShade = -barShade;
lcd_filled_rect(26, y+1, width, barHeight, barShade);
lcd_filled_rect(BAR_LEFT+1, y+1, width, barHeight, barShade);
for (uint8_t j=24; j<99; j+=25)
if (j>thresholdX || j>width) lcd_vline(j*BAR_WIDTH/100+26, y+1, barHeight);
for (uint8_t j=24; j<99; j+=25) {
if (j>thresholdX || j>width) {
lcd_vline(j*BAR_WIDTH/100+BAR_LEFT+1, y+1, barHeight);
}
}
if (thresholdX) {
lcd_vlineStip(26+thresholdX, y-2, barHeight+3, DOTTED);
lcd_hline(25+thresholdX, y-2, 3);
lcd_vlineStip(BAR_LEFT+1+thresholdX, y-2, barHeight+3, DOTTED);
lcd_hline(BAR_LEFT+thresholdX, y-2, 3);
}
}
else {

View file

@ -262,6 +262,9 @@ void lcd_putcAtt(xcoord_t x, uint8_t y, const unsigned char c, LcdFlags flags)
if (inv) bb = 0xff;
#endif
#endif
uint8_t *lineEnd = &displayBuf[ y / 8 * LCD_W + LCD_W ];
for (int8_t i=0; i<=6; i++) {
uint8_t b = 0;
if (i==0) {
@ -298,7 +301,7 @@ void lcd_putcAtt(xcoord_t x, uint8_t y, const unsigned char c, LcdFlags flags)
}
#endif
if (p<DISPLAY_END && !BLINKING_CHAR) {
if (p<lineEnd && !BLINKING_CHAR) {
ASSERT_IN_DISPLAY(p);
uint8_t mask = ~(0xff << ym8);
LCD_BYTE_FILTER(p, mask, b << ym8);

View file

@ -1564,11 +1564,24 @@ enum BarThresholdIdx {
THLD_DIST,
THLD_GPSALT,
THLD_CELL,
THLD_CELLS_SUM,
THLD_VFAS,
THLD_CURRENT,
THLD_CONSUMPTION,
THLD_MAX,
};
extern uint8_t barsThresholds[THLD_MAX];
#if defined(CPUARM)
typedef uint16_t bar_threshold_t;
#define FILL_THRESHOLD(idx, val) barsThresholds[idx] = (val)
#else
typedef uint8_t bar_threshold_t;
#define FILL_THRESHOLD(idx, val) barsThresholds[idx] = 128 + (val)
#endif
extern bar_threshold_t barsThresholds[THLD_MAX];
#else
#define FILL_THRESHOLD(idx, val)
#endif
#if defined(FRSKY)

View file

@ -249,15 +249,13 @@ bool getLogicalSwitch(uint8_t idx)
y = convertLswTelemValue(ls);
#if defined(FRSKY_HUB) && defined(GAUGES)
// Fill the telemetry bars threshold array
if (s == LS_FAMILY_OFS) {
uint8_t idx = v1-MIXSRC_FIRST_TELEM+1-TELEM_ALT;
if (idx < THLD_MAX) {
// Fill the threshold array
barsThresholds[idx] = 128 + ls->v2;
FILL_THRESHOLD(idx, ls->v2);
}
}
#endif
}
else if (v1 >= MIXSRC_GVAR1) {
y = ls->v2;

View file

@ -503,8 +503,10 @@ void telemetryInterrupt10ms()
frskyStreaming--;
}
else {
#if !defined(SIMU)
frskyData.rssi[0].set(0);
frskyData.rssi[1].set(0);
#endif
}
}
@ -571,8 +573,8 @@ void telemetryReset()
frskyData.hub.temperature1 = -30;
frskyData.hub.maxTemperature1 = 100;
frskyData.hub.current = 5;
frskyData.hub.maxCurrent = 56;
frskyData.hub.current = 55;
frskyData.hub.maxCurrent = 65;
#endif
}