1
0
Fork 0
mirror of https://github.com/opentx/opentx.git synced 2025-07-24 16:55:20 +03:00

[Horus] Cosmetics

This commit is contained in:
Bertrand Songis 2016-04-08 09:07:56 +02:00
parent 79fcaec78f
commit 1fc0525636
7 changed files with 56 additions and 42 deletions

View file

@ -267,33 +267,40 @@ void BitmapBuffer::drawBitmapPattern(coord_t x, coord_t y, const uint8_t * bmp,
display_t color = lcdColorTable[COLOR_IDX(flags)];
for (coord_t row=0; row<height; row++) {
display_t * p = getPixelPtr(x, y+row);
const uint8_t * q = bmp + 4 + row*w + offset;
for (coord_t col=0; col<width; col++) {
display_t * p;
if (flags & VERTICAL)
p = getPixelPtr(x+row, y-col);
else
p = getPixelPtr(x+col, y+row);
drawAlphaPixel(p, *q, color);
p++; q++;
q++;
}
}
}
void BitmapBuffer::drawCharWithoutCache(coord_t x, coord_t y, const uint8_t * font, const uint16_t * spec, int index, LcdFlags flags)
uint8_t BitmapBuffer::drawCharWithoutCache(coord_t x, coord_t y, const uint8_t * font, const uint16_t * spec, int index, LcdFlags flags)
{
coord_t offset = spec[index];
coord_t width = spec[index+1] - offset;
if (width > 0) drawBitmapPattern(x, y, font, flags, offset, width);
lcdNextPos = x + width;
return width;
}
void BitmapBuffer::drawCharWithCache(coord_t x, coord_t y, const BitmapBuffer * font, const uint16_t * spec, int index, LcdFlags flags)
uint8_t BitmapBuffer::drawCharWithCache(coord_t x, coord_t y, const BitmapBuffer * font, const uint16_t * spec, int index, LcdFlags flags)
{
coord_t offset = spec[index];
coord_t width = spec[index+1] - offset;
drawBitmap(x, y, font, offset, 0, width);
lcdNextPos = x + width;
return width;
}
void BitmapBuffer::drawSizedText(coord_t x, coord_t y, const char * s, uint8_t len, LcdFlags flags)
{
#define INCREMENT_POS(delta) \
do { if (flags & VERTICAL) y -= delta; else x += delta; } while(0)
int width = getTextWidth(s, len, flags);
int height = getFontHeight(flags);
int fontindex = FONTSIZE(flags) >> 8;
@ -302,9 +309,11 @@ void BitmapBuffer::drawSizedText(coord_t x, coord_t y, const char * s, uint8_t l
BitmapBuffer * fontcache = NULL;
if (flags & RIGHT)
x -= width;
INCREMENT_POS(-width);
else if (flags & CENTERED)
x -= width/2;
INCREMENT_POS(-width/2);
coord_t & pos = (flags & VERTICAL) ? y : x;
if ((flags&INVERS) && ((~flags & BLINK) || BLINK_ON_PHASE)) {
flags = TEXT_INVERTED_COLOR | (flags & 0x0ffff);
@ -339,19 +348,14 @@ void BitmapBuffer::drawSizedText(coord_t x, coord_t y, const char * s, uint8_t l
}
}
const coord_t orig_x = x;
bool setx = false;
const coord_t orig_pos = pos;
while (len--) {
unsigned char c;
if (flags & ZCHAR)
c = idx2char(*s);
else
c = pgm_read_byte(s);
if (setx) {
x = c;
setx = false;
}
else if (!c) {
if (!c) {
break;
}
else if (c >= 0x20) {
@ -359,31 +363,34 @@ void BitmapBuffer::drawSizedText(coord_t x, coord_t y, const char * s, uint8_t l
if (c >= 0x80 && c <= 0x85) {
c = 0x20 + 115 + c - 0x80;
}
#elif defined(TRANSLATIONS_DE)
if (c >= 0x80 && c <= 0x86) {
c = 0x20 + 121 + c - 0x80;
}
#endif
if (fontcache) {
drawCharWithCache(x, y, fontcache, fontspecs, getMappedChar(c), flags);
}
else {
drawCharWithoutCache(x, y, font, fontspecs, getMappedChar(c), flags);
}
x = lcdNextPos;
}
else if (c == 0x1F) { // X-coord prefix
setx = true;
uint8_t width;
if (fontcache)
width = drawCharWithCache(x, y, fontcache, fontspecs, getMappedChar(c), flags);
else
width = drawCharWithoutCache(x, y, font, fontspecs, getMappedChar(c), flags);
INCREMENT_POS(width);
}
else if (c == 0x1E) {
x = orig_x;
y += height;
pos = orig_pos;
if (flags & VERTICAL)
x += height;
else
y += height;
}
else if (c == 1) {
x += 1;
INCREMENT_POS(1);
}
else {
x += 2*(c-1);
INCREMENT_POS(2*(c-1));
}
s++;
}
lcdNextPos = x;
lcdNextPos = pos;
}
void BitmapBuffer::drawBitmapPie(int x0, int y0, const uint16_t * img, int startAngle, int endAngle)

View file

@ -180,9 +180,9 @@ class BitmapBuffer: public BitmapBufferBase<uint16_t>
void drawBitmapPattern(coord_t x, coord_t y, const uint8_t * bmp, LcdFlags flags, coord_t offset=0, coord_t width=0);
void drawCharWithoutCache(coord_t x, coord_t y, const uint8_t * font, const uint16_t * spec, int index, LcdFlags flags);
uint8_t drawCharWithoutCache(coord_t x, coord_t y, const uint8_t * font, const uint16_t * spec, int index, LcdFlags flags);
void drawCharWithCache(coord_t x, coord_t y, const BitmapBuffer * font, const uint16_t * spec, int index, LcdFlags flags);
uint8_t drawCharWithCache(coord_t x, coord_t y, const BitmapBuffer * font, const uint16_t * spec, int index, LcdFlags flags);
void drawText(coord_t x, coord_t y, const char * s, LcdFlags flags)
{

View file

@ -24,10 +24,6 @@
* Header bitmaps
*/
const uint8_t LBM_TOPMENU_POLYGON[] = {
#include "mask_topmenu_polygon.lbm"
};
const uint8_t LBM_DOT[] = {
#include "mask_dot.lbm"
};

View file

@ -22,7 +22,6 @@
#define _BITMAPS_H_
// Header bitmaps
extern const uint8_t LBM_TOPMENU_POLYGON[];
extern const uint8_t LBM_DOT[];
// Main view icons

View file

@ -65,14 +65,21 @@ void drawTrims(uint8_t flightMode)
if (vert[i]) {
drawVerticalSlider(xm, TRIM_V_Y, 160, trim, -125, 125, 0, OPTION_SLIDER_EMPTY_BAR|OPTION_SLIDER_TRIM_BUTTON);
if (g_model.displayTrims != DISPLAY_TRIMS_NEVER && trim != 0) {
if (g_model.displayTrims == DISPLAY_TRIMS_ALWAYS || (trimsDisplayTimer > 0 && (trimsDisplayMask & (1<<i)))) {
uint16_t y = TRIM_V_Y + TRIM_LEN + (trim<0 ? -TRIM_LEN/2 : TRIM_LEN/2);
lcdDrawNumber(xm+2, y, trim, TINSIZE | CENTERED | VERTICAL);
}
}
}
else {
drawHorizontalSlider(xm, TRIM_H_Y, 160, trim, -125, 125, 0, OPTION_SLIDER_EMPTY_BAR|OPTION_SLIDER_TRIM_BUTTON);
/* if (g_model.displayTrims != DISPLAY_TRIMS_NEVER && trim != 0) {
if (g_model.displayTrims != DISPLAY_TRIMS_NEVER && trim != 0) {
if (g_model.displayTrims == DISPLAY_TRIMS_ALWAYS || (trimsDisplayTimer > 0 && (trimsDisplayMask & (1<<i)))) {
lcdDrawNumber((stickIndex==0 ? TRIM_LH_X : TRIM_RH_X)+(trim>0 ? -20 : 50), ym+1, trim, TINSIZE);
uint16_t x = xm + TRIM_LEN + (trim>0 ? -TRIM_LEN/2 : TRIM_LEN/2);
lcdDrawNumber(x, TRIM_H_Y+2, trim, TINSIZE | CENTERED);
}
}*/
}
}
}
}

View file

@ -18,8 +18,8 @@
* GNU General Public License for more details.
*/
#include "../../opentx.h"
#include "../../timers.h"
#include "opentx.h"
#include "timers.h"
#if defined(REVPLUS) && defined(LCD_DUAL_BUFFER)
display_t displayBuf1[DISPLAY_BUFFER_SIZE] __DMA;

View file

@ -234,6 +234,11 @@ void storageEraseAll(bool warn)
{
TRACE("storageEraseAll()");
#if defined(COLORLCD)
// the theme has not been loaded before
theme->load();
#endif
generalDefault();
modelDefault(1);