@@ -304,7 +304,7 @@ void menuModelExpoOne(event_t event)
|
||||
|
||||
drawFunction(expoFn);
|
||||
|
||||
int16_t x512 = calibratedStick[ed->chn];
|
||||
int16_t x512 = calibratedAnalogs[ed->chn];
|
||||
lcdDrawNumber(LCD_W-8, 6*FH, calcRESXto100(x512), 0);
|
||||
int16_t y512 = expoFn(x512);
|
||||
lcdDrawNumber(LCD_W-8-6*FW, 1*FH, calcRESXto100(y512), 0);
|
||||
|
||||
@@ -805,26 +805,26 @@ void check(event_t event, uint8_t curr, const MenuHandlerFunc *menuTab, uint8_t
|
||||
// check pot 1 - if changed -> scroll values
|
||||
static int16_t p1val;
|
||||
static int16_t p1valprev;
|
||||
p1valdiff = (p1val-calibratedStick[6]) / SCROLL_POT1_TH;
|
||||
p1valdiff = (p1val-calibratedAnalogs[CALIBRATED_POT1]) / SCROLL_POT1_TH;
|
||||
if (p1valdiff) {
|
||||
p1valdiff = (p1valprev-calibratedStick[6]) / 2;
|
||||
p1val = calibratedStick[6];
|
||||
p1valdiff = (p1valprev-calibratedAnalogs[CALIBRATED_POT1]) / 2;
|
||||
p1val = calibratedAnalogs[CALIBRATED_POT1];
|
||||
}
|
||||
p1valprev = calibratedStick[6];
|
||||
p1valprev = calibratedAnalogs[CALIBRATED_POT1];
|
||||
#endif
|
||||
|
||||
#if defined(NAVIGATION_POT2)
|
||||
// check pot 2 - if changed -> scroll menu
|
||||
static int16_t p2valprev;
|
||||
p2valdiff = (p2valprev-calibratedStick[4]) / SCROLL_TH;
|
||||
if (p2valdiff) p2valprev = calibratedStick[4];
|
||||
p2valdiff = (p2valprev-calibratedAnalogs[CALIBRATED_POT2]) / SCROLL_TH;
|
||||
if (p2valdiff) p2valprev = calibratedAnalogs[CALIBRATED_POT2];
|
||||
#endif
|
||||
|
||||
#if defined(NAVIGATION_POT3)
|
||||
// check pot 3 if changed -> cursor down/up
|
||||
static int16_t p3valprev;
|
||||
int8_t scrollUD = (p3valprev-calibratedStick[5]) / SCROLL_TH;
|
||||
if (scrollUD) p3valprev = calibratedStick[5];
|
||||
int8_t scrollUD = (p3valprev-calibratedAnalogs[CALIBRATED_POT3]) / SCROLL_TH;
|
||||
if (scrollUD) p3valprev = calibratedAnalogs[CALIBRATED_POT3];
|
||||
#else
|
||||
#define scrollUD 0
|
||||
#endif
|
||||
|
||||
@@ -50,9 +50,9 @@ void menuRadioDiagAnalogs(event_t event)
|
||||
#endif
|
||||
lcdDrawHexNumber(x+3*FW-1, y, anaIn(i));
|
||||
#if defined(CPUARM)
|
||||
lcdDrawNumber(x+10*FW-1, y, (int16_t)calibratedStick[CONVERT_MODE(i)]*25/256, RIGHT);
|
||||
lcdDrawNumber(x+10*FW-1, y, (int16_t)calibratedAnalogs[CONVERT_MODE(i)]*25/256, RIGHT);
|
||||
#else
|
||||
lcdDraw8bitsNumber(x+10*FW-1, y, (int16_t)calibratedStick[CONVERT_MODE(i)]*25/256);
|
||||
lcdDraw8bitsNumber(x+10*FW-1, y, (int16_t)calibratedAnalogs[CONVERT_MODE(i)]*25/256);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@@ -51,7 +51,7 @@ void drawPotsBars()
|
||||
// Optimization by Mike Blandford
|
||||
for (uint8_t x=LCD_W/2 - (NUM_POTS+NUM_SLIDERS-1) * 5 / 2, i=NUM_STICKS; i<NUM_STICKS+NUM_POTS+NUM_SLIDERS; x+=5, i++) {
|
||||
if (IS_POT_SLIDER_AVAILABLE(i)) {
|
||||
uint8_t len = ((calibratedStick[i]+RESX)*BAR_HEIGHT/(RESX*2))+1l; // calculate once per loop
|
||||
uint8_t len = ((calibratedAnalogs[i]+RESX)*BAR_HEIGHT/(RESX*2))+1l; // calculate once per loop
|
||||
V_BAR(x, LCD_H-8, len);
|
||||
}
|
||||
}
|
||||
@@ -59,15 +59,15 @@ void drawPotsBars()
|
||||
|
||||
void doMainScreenGraphics()
|
||||
{
|
||||
int16_t calibStickVert = calibratedStick[CONVERT_MODE(1)];
|
||||
int16_t calibStickVert = calibratedAnalogs[CONVERT_MODE(1)];
|
||||
if (g_model.throttleReversed && CONVERT_MODE(1) == THR_STICK)
|
||||
calibStickVert = -calibStickVert;
|
||||
drawStick(LBOX_CENTERX, calibratedStick[CONVERT_MODE(0)], calibStickVert);
|
||||
drawStick(LBOX_CENTERX, calibratedAnalogs[CONVERT_MODE(0)], calibStickVert);
|
||||
|
||||
calibStickVert = calibratedStick[CONVERT_MODE(2)];
|
||||
calibStickVert = calibratedAnalogs[CONVERT_MODE(2)];
|
||||
if (g_model.throttleReversed && CONVERT_MODE(2) == THR_STICK)
|
||||
calibStickVert = -calibStickVert;
|
||||
drawStick(RBOX_CENTERX, calibratedStick[CONVERT_MODE(3)], calibStickVert);
|
||||
drawStick(RBOX_CENTERX, calibratedAnalogs[CONVERT_MODE(3)], calibStickVert);
|
||||
|
||||
drawPotsBars();
|
||||
}
|
||||
|
||||
@@ -38,7 +38,7 @@ void drawPotsBars()
|
||||
// Optimization by Mike Blandford
|
||||
for (uint8_t x=LCD_W/2-(NUM_POTS+NUM_SLIDERS)/2*BAR_SPACING+BAR_SPACING/2, i=NUM_STICKS; i<NUM_STICKS+NUM_POTS+NUM_SLIDERS; x+=BAR_SPACING, i++) {
|
||||
if (IS_POT_SLIDER_AVAILABLE(i)) {
|
||||
uint8_t len = ((calibratedStick[i]+RESX)*BAR_HEIGHT/(RESX*2))+1l; // calculate once per loop
|
||||
uint8_t len = ((calibratedAnalogs[i]+RESX)*BAR_HEIGHT/(RESX*2))+1l; // calculate once per loop
|
||||
V_BAR(x, LCD_H-8, len);
|
||||
putsStickName(x-2, LCD_H-6, i, TINSIZE);
|
||||
}
|
||||
|
||||
@@ -35,9 +35,9 @@ void menuRadioDiagAnalogs(event_t event)
|
||||
#if defined(JITTER_MEASURE)
|
||||
lcdDrawNumber(x+10*FW-1, y, rawJitter[i].get(), RIGHT);
|
||||
lcdDrawNumber(x+13*FW-1, y, avgJitter[i].get(), RIGHT);
|
||||
lcdDrawNumber(x+17*FW-1, y, (int16_t)calibratedStick[CONVERT_MODE(i)]*25/256, RIGHT);
|
||||
lcdDrawNumber(x+17*FW-1, y, (int16_t)calibratedAnalogs[CONVERT_MODE(i)]*25/256, RIGHT);
|
||||
#else
|
||||
lcdDrawNumber(x+10*FW-1, y, (int16_t)calibratedStick[CONVERT_MODE(i)]*25/256, RIGHT);
|
||||
lcdDrawNumber(x+10*FW-1, y, (int16_t)calibratedAnalogs[CONVERT_MODE(i)]*25/256, RIGHT);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@@ -72,15 +72,15 @@ const pm_uchar icons[] PROGMEM = {
|
||||
|
||||
void doMainScreenGraphics()
|
||||
{
|
||||
int16_t calibStickVert = calibratedStick[CONVERT_MODE(1)];
|
||||
int16_t calibStickVert = calibratedAnalogs[CONVERT_MODE(1)];
|
||||
if (g_model.throttleReversed && CONVERT_MODE(1) == THR_STICK)
|
||||
calibStickVert = -calibStickVert;
|
||||
drawStick(LBOX_CENTERX, calibratedStick[CONVERT_MODE(0)], calibStickVert);
|
||||
drawStick(LBOX_CENTERX, calibratedAnalogs[CONVERT_MODE(0)], calibStickVert);
|
||||
|
||||
calibStickVert = calibratedStick[CONVERT_MODE(2)];
|
||||
calibStickVert = calibratedAnalogs[CONVERT_MODE(2)];
|
||||
if (g_model.throttleReversed && CONVERT_MODE(2) == THR_STICK)
|
||||
calibStickVert = -calibStickVert;
|
||||
drawStick(RBOX_CENTERX, calibratedStick[CONVERT_MODE(3)], calibStickVert);
|
||||
drawStick(RBOX_CENTERX, calibratedAnalogs[CONVERT_MODE(3)], calibStickVert);
|
||||
}
|
||||
|
||||
void displayTrims(uint8_t phase)
|
||||
@@ -174,7 +174,7 @@ void drawSliders()
|
||||
lcdDrawSolidVerticalLine(x, y, LCD_H/2-2);
|
||||
lcdDrawSolidVerticalLine(x+1, y, LCD_H/2-2);
|
||||
y += LCD_H/2-4;
|
||||
y -= ((calibratedStick[i]+RESX)*(LCD_H/2-4)/(RESX*2)); // calculate once per loop
|
||||
y -= ((calibratedAnalogs[i]+RESX)*(LCD_H/2-4)/(RESX*2)); // calculate once per loop
|
||||
lcdDrawSolidVerticalLine(x-1, y, 2);
|
||||
lcdDrawSolidVerticalLine(x+2, y, 2);
|
||||
}
|
||||
|
||||
@@ -49,7 +49,7 @@ void BitmapBuffer::drawHorizontalLine(coord_t x, coord_t y, coord_t w, uint8_t p
|
||||
if (pat == SOLID) {
|
||||
while (w--) {
|
||||
drawAlphaPixel(p, opacity, color);
|
||||
p++;
|
||||
MOVE_TO_NEXT_RIGHT_PIXEL(p);
|
||||
}
|
||||
}
|
||||
else {
|
||||
@@ -61,7 +61,7 @@ void BitmapBuffer::drawHorizontalLine(coord_t x, coord_t y, coord_t w, uint8_t p
|
||||
else {
|
||||
pat = pat >> 1;
|
||||
}
|
||||
p++;
|
||||
MOVE_TO_NEXT_RIGHT_PIXEL(p);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -130,7 +130,8 @@ void BitmapBuffer::invertRect(coord_t x, coord_t y, coord_t w, coord_t h, LcdFla
|
||||
for (int j=0; j<w; j++) {
|
||||
// TODO ASSERT_IN_DISPLAY(p);
|
||||
RGB_SPLIT(*p, bgRed, bgGreen, bgBlue);
|
||||
drawPixel(p++, RGB_JOIN(0x1F + red - bgRed, 0x3F + green - bgGreen, 0x1F + blue - bgBlue));
|
||||
drawPixel(p, RGB_JOIN(0x1F + red - bgRed, 0x3F + green - bgGreen, 0x1F + blue - bgBlue));
|
||||
MOVE_TO_NEXT_RIGHT_PIXEL(p);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -256,7 +257,8 @@ void BitmapBuffer::drawMask(coord_t x, coord_t y, BitmapBuffer * mask, LcdFlags
|
||||
display_t * q = mask->getPixelPtr(offset, row);
|
||||
for (coord_t col=0; col<width; col++) {
|
||||
drawAlphaPixel(p, *((uint8_t *)q), color);
|
||||
p++; q++;
|
||||
MOVE_TO_NEXT_RIGHT_PIXEL(p);
|
||||
MOVE_TO_NEXT_RIGHT_PIXEL(q);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -489,10 +491,10 @@ BitmapBuffer * BitmapBuffer::loadMask(const char * filename)
|
||||
{
|
||||
BitmapBuffer * bitmap = BitmapBuffer::load(filename);
|
||||
if (bitmap) {
|
||||
display_t * p = bitmap->getData();
|
||||
display_t * p = bitmap->getPixelPtr(0, 0);
|
||||
for (int i = bitmap->getWidth() * bitmap->getHeight(); i > 0; i--) {
|
||||
*((uint8_t *)p) = OPACITY_MAX - ((*p) >> 12);
|
||||
p++;
|
||||
MOVE_TO_NEXT_RIGHT_PIXEL(p);
|
||||
}
|
||||
}
|
||||
return bitmap;
|
||||
@@ -624,14 +626,13 @@ BitmapBuffer * BitmapBuffer::load_bmp(const char * filename)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
uint16_t * dest = bmp->getData();
|
||||
uint32_t rowSize;
|
||||
bool hasAlpha = false;
|
||||
|
||||
switch (depth) {
|
||||
case 32:
|
||||
for (int i=h-1; i>=0; i--) {
|
||||
uint8_t * dst = ((uint8_t *)dest) + i*w*2;
|
||||
display_t * dst = bmp->getPixelPtr(0, i);
|
||||
for (unsigned int j=0; j<w; j++) {
|
||||
uint32_t pixel;
|
||||
result = f_read(&imgFile, (uint8_t *)&pixel, 4, &read);
|
||||
@@ -641,23 +642,23 @@ BitmapBuffer * BitmapBuffer::load_bmp(const char * filename)
|
||||
return NULL;
|
||||
}
|
||||
if (hasAlpha) {
|
||||
*((uint16_t *)dst) = ARGB(pixel & 0xff, (pixel >> 24) & 0xff, (pixel >> 16) & 0xff, (pixel >> 8) & 0xff);
|
||||
*dst = ARGB(pixel & 0xff, (pixel >> 24) & 0xff, (pixel >> 16) & 0xff, (pixel >> 8) & 0xff);
|
||||
}
|
||||
else {
|
||||
if ((pixel & 0xff) == 0xff) {
|
||||
*((uint16_t *)dst) = RGB(pixel >> 24, (pixel >> 16) & 0xff, (pixel >> 8) & 0xff);
|
||||
*dst = RGB(pixel >> 24, (pixel >> 16) & 0xff, (pixel >> 8) & 0xff);
|
||||
}
|
||||
else {
|
||||
hasAlpha = true;
|
||||
bmp->setFormat(BMP_ARGB4444);
|
||||
for (uint16_t * p = dest + i*w; p<dest + h*w; p++) {
|
||||
uint16_t tmp = *p;
|
||||
for (display_t * p = bmp->getPixelPtr(j, i); p != bmp->getPixelPtr(0, h); MOVE_TO_NEXT_RIGHT_PIXEL(p)) {
|
||||
display_t tmp = *p;
|
||||
*p = ((tmp >> 1) & 0x0f) + (((tmp >> 7) & 0x0f) << 4) + (((tmp >> 12) & 0x0f) << 8);
|
||||
}
|
||||
*((uint16_t *)dst) = ARGB(pixel & 0xff, (pixel >> 24) & 0xff, (pixel >> 16) & 0xff, (pixel >> 8) & 0xff);
|
||||
*dst = ARGB(pixel & 0xff, (pixel >> 24) & 0xff, (pixel >> 16) & 0xff, (pixel >> 8) & 0xff);
|
||||
}
|
||||
}
|
||||
dst += 2;
|
||||
MOVE_TO_NEXT_RIGHT_PIXEL(dst);
|
||||
}
|
||||
}
|
||||
break;
|
||||
@@ -674,12 +675,12 @@ BitmapBuffer * BitmapBuffer::load_bmp(const char * filename)
|
||||
delete bmp;
|
||||
return NULL;
|
||||
}
|
||||
uint8_t * dst = ((uint8_t *)dest) + i*w*2;
|
||||
display_t * dst = bmp->getPixelPtr(0, i);
|
||||
for (uint32_t j=0; j<w; j++) {
|
||||
uint8_t index = (buf[j/2] >> ((j & 1) ? 0 : 4)) & 0x0F;
|
||||
uint8_t val = palette[index];
|
||||
*((uint16_t *)dst) = RGB(val, val, val);
|
||||
dst += 2;
|
||||
*dst = RGB(val, val, val);
|
||||
MOVE_TO_NEXT_RIGHT_PIXEL(dst);
|
||||
}
|
||||
}
|
||||
break;
|
||||
@@ -792,22 +793,22 @@ BitmapBuffer * BitmapBuffer::load_stb(const char * filename)
|
||||
#if 0
|
||||
DMABitmapConvert(bmp->data, img, w, h, n == 4 ? DMA2D_ARGB4444 : DMA2D_RGB565);
|
||||
#else
|
||||
uint16_t * dest = bmp->getData();
|
||||
display_t * dest = bmp->getPixelPtr(0, 0);
|
||||
const uint8_t * p = img;
|
||||
if (n == 4) {
|
||||
for(int row = 0; row < h; ++row) {
|
||||
for(int col = 0; col < w; ++col) {
|
||||
for (int row = 0; row < h; ++row) {
|
||||
for (int col = 0; col < w; ++col) {
|
||||
*dest = ARGB(p[3], p[0], p[1], p[2]);
|
||||
++dest;
|
||||
MOVE_TO_NEXT_RIGHT_PIXEL(dest);
|
||||
p += 4;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
for(int row = 0; row < h; ++row) {
|
||||
for(int col = 0; col < w; ++col) {
|
||||
for (int row = 0; row < h; ++row) {
|
||||
for (int col = 0; col < w; ++col) {
|
||||
*dest = RGB(p[0], p[1], p[2]);
|
||||
++dest;
|
||||
MOVE_TO_NEXT_RIGHT_PIXEL(dest);
|
||||
p += 4;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,6 +24,15 @@
|
||||
#include <inttypes.h>
|
||||
#include "colors.h"
|
||||
|
||||
#if defined(PCBX10)
|
||||
#define MOVE_PIXEL_RIGHT(p, count) p -= count
|
||||
#else
|
||||
#define MOVE_PIXEL_RIGHT(p, count) p += count
|
||||
#endif
|
||||
|
||||
#define MOVE_TO_NEXT_RIGHT_PIXEL(p) MOVE_PIXEL_RIGHT(p, 1)
|
||||
|
||||
|
||||
#define USE_STB
|
||||
|
||||
// TODO should go to lcd.h again
|
||||
@@ -70,6 +79,15 @@ class BitmapBufferBase
|
||||
return data;
|
||||
}
|
||||
|
||||
inline const display_t * getPixelPtr(coord_t x, coord_t y) const
|
||||
{
|
||||
#if defined(PCBX10)
|
||||
x = width - x - 1;
|
||||
y = height - y - 1;
|
||||
#endif
|
||||
return &data[y*width + x];
|
||||
}
|
||||
|
||||
protected:
|
||||
uint8_t format;
|
||||
uint16_t width;
|
||||
@@ -140,8 +158,21 @@ class BitmapBuffer: public BitmapBufferBase<uint16_t>
|
||||
#endif
|
||||
}
|
||||
|
||||
inline const display_t * getPixelPtr(coord_t x, coord_t y) const
|
||||
{
|
||||
#if defined(PCBX10)
|
||||
x = width - x - 1;
|
||||
y = height - y - 1;
|
||||
#endif
|
||||
return &data[y*width + x];
|
||||
}
|
||||
|
||||
inline display_t * getPixelPtr(coord_t x, coord_t y)
|
||||
{
|
||||
#if defined(PCBX10)
|
||||
x = width - x - 1;
|
||||
y = height - y - 1;
|
||||
#endif
|
||||
return &data[y*width + x];
|
||||
}
|
||||
|
||||
@@ -180,7 +211,7 @@ class BitmapBuffer: public BitmapBufferBase<uint16_t>
|
||||
if (!data || h==0 || w==0) return;
|
||||
if (h<0) { y+=h; h=-h; }
|
||||
if (w<0) { x+=w; w=-w; }
|
||||
DMAFillRect(data, width, x, y, w, h, lcdColorTable[COLOR_IDX(flags)]);
|
||||
DMAFillRect(data, width, height, x, y, w, h, lcdColorTable[COLOR_IDX(flags)]);
|
||||
}
|
||||
|
||||
void drawFilledRect(coord_t x, coord_t y, coord_t w, coord_t h, uint8_t pat, LcdFlags att);
|
||||
@@ -242,10 +273,10 @@ class BitmapBuffer: public BitmapBufferBase<uint16_t>
|
||||
h = height - y;
|
||||
}
|
||||
if (bmp->getFormat() == BMP_ARGB4444) {
|
||||
DMACopyAlphaBitmap(data, this->width, x, y, bmp->getData(), srcw, srcx, srcy, w, h);
|
||||
DMACopyAlphaBitmap(data, width, height, x, y, bmp->getData(), srcw, srch, srcx, srcy, w, h);
|
||||
}
|
||||
else {
|
||||
DMACopyBitmap(data, width, x, y, bmp->getData(), srcw, srcx, srcy, w, h);
|
||||
DMACopyBitmap(data, width, height, x, y, bmp->getData(), srcw, srch, srcx, srcy, w, h);
|
||||
}
|
||||
}
|
||||
else {
|
||||
@@ -258,10 +289,11 @@ class BitmapBuffer: public BitmapBufferBase<uint16_t>
|
||||
scaledh = height - y;
|
||||
|
||||
for (int i = 0; i < scaledh; i++) {
|
||||
uint16_t * p = &data[(y + i) * width + x];
|
||||
const uint16_t * qstart = &bmp->getData()[(srcy + int(i / scale)) * bmp->getWidth() + srcx];
|
||||
display_t * p = getPixelPtr(x, y + i);
|
||||
const display_t * qstart = bmp->getPixelPtr(srcx, srcy + int(i / scale));
|
||||
for (int j = 0; j < scaledw; j++) {
|
||||
const uint16_t * q = qstart + int(j / scale);
|
||||
const display_t * q = qstart;
|
||||
MOVE_PIXEL_RIGHT(q, int(j / scale));
|
||||
if (bmp->getFormat() == BMP_ARGB4444) {
|
||||
ARGB_SPLIT(*q, a, r, g, b);
|
||||
drawAlphaPixel(p, a, RGB_JOIN(r<<1, g<<2, b<<1));
|
||||
@@ -269,7 +301,7 @@ class BitmapBuffer: public BitmapBufferBase<uint16_t>
|
||||
else {
|
||||
drawPixel(p, *q);
|
||||
}
|
||||
p++;
|
||||
MOVE_TO_NEXT_RIGHT_PIXEL(p);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -411,8 +411,13 @@ void lcdDrawBlackOverlay()
|
||||
BitmapBuffer _lcd(BMP_RGB565, LCD_W, LCD_H, displayBuf);
|
||||
BitmapBuffer * lcd = &_lcd;
|
||||
|
||||
void DMAFillRect(uint16_t * dest, uint16_t destw, uint16_t x, uint16_t y, uint16_t w, uint16_t h, uint16_t color)
|
||||
void DMAFillRect(uint16_t * dest, uint16_t destw, uint16_t desth, uint16_t x, uint16_t y, uint16_t w, uint16_t h, uint16_t color)
|
||||
{
|
||||
#if defined(PCBX10)
|
||||
x = destw - (x + w);
|
||||
y = desth - (y + h);
|
||||
#endif
|
||||
|
||||
for (int i=0; i<h; i++) {
|
||||
for (int j=0; j<w; j++) {
|
||||
dest[(y+i)*destw+x+j] = color;
|
||||
@@ -420,15 +425,29 @@ void DMAFillRect(uint16_t * dest, uint16_t destw, uint16_t x, uint16_t y, uint16
|
||||
}
|
||||
}
|
||||
|
||||
void DMACopyBitmap(uint16_t * dest, uint16_t destw, uint16_t x, uint16_t y, const uint16_t * src, uint16_t srcw, uint16_t srcx, uint16_t srcy, uint16_t w, uint16_t h)
|
||||
void DMACopyBitmap(uint16_t * dest, uint16_t destw, uint16_t desth, uint16_t x, uint16_t y, const uint16_t * src, uint16_t srcw, uint16_t srch, uint16_t srcx, uint16_t srcy, uint16_t w, uint16_t h)
|
||||
{
|
||||
#if defined(PCBX10)
|
||||
x = destw - (x + w);
|
||||
y = desth - (y + h);
|
||||
srcx = srcw - (srcx + w);
|
||||
srcy = srch - (srcy + h);
|
||||
#endif
|
||||
|
||||
for (int i=0; i<h; i++) {
|
||||
memcpy(dest+(y+i)*destw+x, src+(srcy+i)*srcw+srcx, 2*w);
|
||||
}
|
||||
}
|
||||
|
||||
void DMACopyAlphaBitmap(uint16_t * dest, uint16_t destw, uint16_t x, uint16_t y, const uint16_t * src, uint16_t srcw, uint16_t srcx, uint16_t srcy, uint16_t w, uint16_t h)
|
||||
void DMACopyAlphaBitmap(uint16_t * dest, uint16_t destw, uint16_t desth, uint16_t x, uint16_t y, const uint16_t * src, uint16_t srcw, uint16_t srch, uint16_t srcx, uint16_t srcy, uint16_t w, uint16_t h)
|
||||
{
|
||||
#if defined(PCBX10)
|
||||
x = destw - (x + w);
|
||||
y = desth - (y + h);
|
||||
srcx = srcw - (srcx + w);
|
||||
srcy = srch - (srcy + h);
|
||||
#endif
|
||||
|
||||
for (coord_t line=0; line<h; line++) {
|
||||
uint16_t * p = dest + (y+line)*destw + x;
|
||||
const uint16_t * q = src + (srcy+line)*srcw + srcx;
|
||||
|
||||
@@ -363,6 +363,9 @@ bool menuModelSelect(event_t event)
|
||||
break;
|
||||
|
||||
case EVT_KEY_FIRST(KEY_PGUP):
|
||||
#if defined(PCBX10)
|
||||
case EVT_KEY_LONG(KEY_PGDN):
|
||||
#endif
|
||||
if (selectMode == MODE_SELECT_MODEL) {
|
||||
if (categoriesVerticalPosition == 0)
|
||||
categoriesVerticalPosition = modelslist.categories.size() - 1;
|
||||
@@ -378,9 +381,14 @@ bool menuModelSelect(event_t event)
|
||||
modelslist.moveModel(model, previous_category, currentCategory);
|
||||
setCurrentModel(currentCategory->size()-1);
|
||||
}
|
||||
killEvents(event);
|
||||
break;
|
||||
|
||||
#if defined(PCBX12S)
|
||||
case EVT_KEY_FIRST(KEY_PGDN):
|
||||
#elif defined(PCBX10)
|
||||
case EVT_KEY_BREAK(KEY_PGDN):
|
||||
#endif
|
||||
if (selectMode == MODE_SELECT_MODEL) {
|
||||
categoriesVerticalPosition += 1;
|
||||
if (categoriesVerticalPosition >= modelslist.categories.size())
|
||||
|
||||
@@ -352,14 +352,22 @@ bool check(event_t event, uint8_t curr, const MenuHandlerFunc * menuTab, uint8_t
|
||||
if (menuTab && !menuCalibrationState) {
|
||||
int cc = curr;
|
||||
switch (event) {
|
||||
#if defined(PCBX12S)
|
||||
case EVT_KEY_FIRST(KEY_PGDN):
|
||||
#elif defined(PCBX10)
|
||||
case EVT_KEY_BREAK(KEY_PGDN):
|
||||
#endif
|
||||
if (++cc == menuTabSize)
|
||||
cc = 0;
|
||||
break;
|
||||
|
||||
case EVT_KEY_FIRST(KEY_PGUP):
|
||||
#if defined(PCBX10)
|
||||
case EVT_KEY_LONG(KEY_PGDN):
|
||||
#endif
|
||||
if (cc-- == 0)
|
||||
cc = menuTabSize-1;
|
||||
killEvents(event);
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
@@ -45,15 +45,15 @@ void drawStick(coord_t x, coord_t y, const BitmapBuffer * background, int16_t xv
|
||||
|
||||
void drawSticks()
|
||||
{
|
||||
int16_t calibStickVert = calibratedStick[CONVERT_MODE(1)];
|
||||
int16_t calibStickVert = calibratedAnalogs[CONVERT_MODE(1)];
|
||||
if (g_model.throttleReversed && CONVERT_MODE(1) == THR_STICK)
|
||||
calibStickVert = -calibStickVert;
|
||||
drawStick(STICK_LEFT_X, STICKS_Y, calibStickBackground, calibratedStick[CONVERT_MODE(0)], calibStickVert);
|
||||
drawStick(STICK_LEFT_X, STICKS_Y, calibStickBackground, calibratedAnalogs[CONVERT_MODE(0)], calibStickVert);
|
||||
|
||||
calibStickVert = calibratedStick[CONVERT_MODE(2)];
|
||||
calibStickVert = calibratedAnalogs[CONVERT_MODE(2)];
|
||||
if (g_model.throttleReversed && CONVERT_MODE(2) == THR_STICK)
|
||||
calibStickVert = -calibStickVert;
|
||||
drawStick(STICK_RIGHT_X, STICKS_Y, calibStickBackground, calibratedStick[CONVERT_MODE(3)], calibStickVert);
|
||||
drawStick(STICK_RIGHT_X, STICKS_Y, calibStickBackground, calibratedAnalogs[CONVERT_MODE(3)], calibStickVert);
|
||||
}
|
||||
|
||||
void drawPots()
|
||||
@@ -62,17 +62,19 @@ void drawPots()
|
||||
extern void drawMainPots();
|
||||
drawMainPots();
|
||||
|
||||
#if defined(PCBX12S)
|
||||
// The 2 main front sliders
|
||||
drawVerticalSlider(125, 120, 120, calibratedStick[7], -RESX, RESX, 40, OPTION_SLIDER_TICKS | OPTION_SLIDER_BIG_TICKS |
|
||||
OPTION_SLIDER_SQUARE_BUTTON);
|
||||
drawVerticalSlider(LCD_W-125-12, 120, 120, calibratedStick[8], -RESX, RESX, 40, OPTION_SLIDER_TICKS | OPTION_SLIDER_BIG_TICKS |
|
||||
OPTION_SLIDER_SQUARE_BUTTON);
|
||||
drawVerticalSlider(125, 120, 120, calibratedAnalogs[CALIBRATED_SLIDER_FRONT_LEFT], -RESX, RESX, 40, OPTION_SLIDER_TICKS | OPTION_SLIDER_BIG_TICKS | OPTION_SLIDER_SQUARE_BUTTON);
|
||||
drawVerticalSlider(LCD_W-125-12, 120, 120, calibratedAnalogs[CALIBRATED_SLIDER_FRONT_RIGHT], -RESX, RESX, 40, OPTION_SLIDER_TICKS | OPTION_SLIDER_BIG_TICKS | OPTION_SLIDER_SQUARE_BUTTON);
|
||||
#endif
|
||||
}
|
||||
|
||||
#if defined(PCBX12S)
|
||||
void drawMouse()
|
||||
{
|
||||
drawStick(STICK_LEFT_X, STICKS_Y+100, calibTrackpBackground, calibratedStick[11], calibratedStick[12]);
|
||||
drawStick(STICK_LEFT_X, STICKS_Y+100, calibTrackpBackground, calibratedAnalogs[CALIBRATED_MOUSE1], calibratedAnalogs[CALIBRATED_MOUSE2]);
|
||||
}
|
||||
#endif
|
||||
|
||||
bool menuCommonCalib(event_t event)
|
||||
{
|
||||
@@ -213,7 +215,10 @@ bool menuCommonCalib(event_t event)
|
||||
|
||||
drawSticks();
|
||||
drawPots();
|
||||
|
||||
#if defined(PCBX12S)
|
||||
drawMouse();
|
||||
#endif
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -33,8 +33,10 @@ enum MenuRadioHardwareItems {
|
||||
ITEM_RADIO_HARDWARE_POT3,
|
||||
ITEM_RADIO_HARDWARE_LS,
|
||||
ITEM_RADIO_HARDWARE_RS,
|
||||
#if defined(PCBX12S)
|
||||
ITEM_RADIO_HARDWARE_LS2,
|
||||
ITEM_RADIO_HARDWARE_RS2,
|
||||
#endif
|
||||
ITEM_RADIO_HARDWARE_LABEL_SWITCHES,
|
||||
ITEM_RADIO_HARDWARE_SA,
|
||||
ITEM_RADIO_HARDWARE_SB,
|
||||
@@ -54,14 +56,18 @@ enum MenuRadioHardwareItems {
|
||||
};
|
||||
|
||||
#define HW_SETTINGS_COLUMN 150
|
||||
#if defined(PCBX10)
|
||||
#define POTS_ROWS NAVIGATION_LINE_BY_LINE|1, NAVIGATION_LINE_BY_LINE|1, NAVIGATION_LINE_BY_LINE|1, NAVIGATION_LINE_BY_LINE|1, NAVIGATION_LINE_BY_LINE|1
|
||||
#else
|
||||
#define POTS_ROWS NAVIGATION_LINE_BY_LINE|1, NAVIGATION_LINE_BY_LINE|1, NAVIGATION_LINE_BY_LINE|1, NAVIGATION_LINE_BY_LINE|1, NAVIGATION_LINE_BY_LINE|1, NAVIGATION_LINE_BY_LINE|1, NAVIGATION_LINE_BY_LINE|1
|
||||
#endif
|
||||
#define SWITCHES_ROWS NAVIGATION_LINE_BY_LINE|1, NAVIGATION_LINE_BY_LINE|1, NAVIGATION_LINE_BY_LINE|1, NAVIGATION_LINE_BY_LINE|1, NAVIGATION_LINE_BY_LINE|1, NAVIGATION_LINE_BY_LINE|1, NAVIGATION_LINE_BY_LINE|1, NAVIGATION_LINE_BY_LINE|1
|
||||
#define BLUETOOTH_ROWS 1,
|
||||
#define SWITCH_TYPE_MAX(sw) ((MIXSRC_SF-MIXSRC_FIRST_SWITCH == sw || MIXSRC_SH-MIXSRC_FIRST_SWITCH == sw) ? SWITCH_2POS : SWITCH_3POS)
|
||||
|
||||
bool menuRadioHardware(event_t event)
|
||||
{
|
||||
MENU(STR_HARDWARE, RADIO_ICONS, menuTabGeneral, MENU_RADIO_HARDWARE, ITEM_RADIO_HARDWARE_MAX, { 0, LABEL(Sticks), 0, 0, 0, 0, LABEL(Pots), POTS_ROWS, LABEL(Switches), SWITCHES_ROWS, BLUETOOTH_ROWS 0 });
|
||||
MENU(STR_HARDWARE, RADIO_ICONS, menuTabGeneral, MENU_RADIO_HARDWARE, ITEM_RADIO_HARDWARE_MAX, { 0, LABEL(Sticks), 0, 0, 0, 0, LABEL(Pots), POTS_ROWS, LABEL(Switches), SWITCHES_ROWS, BLUETOOTH_ROWS 0, 0, 0 });
|
||||
|
||||
uint8_t sub = menuVerticalPosition;
|
||||
|
||||
@@ -93,8 +99,10 @@ bool menuRadioHardware(event_t event)
|
||||
|
||||
case ITEM_RADIO_HARDWARE_LS:
|
||||
case ITEM_RADIO_HARDWARE_RS:
|
||||
#if defined(PCBX12S)
|
||||
case ITEM_RADIO_HARDWARE_LS2:
|
||||
case ITEM_RADIO_HARDWARE_RS2:
|
||||
#endif
|
||||
{
|
||||
int idx = k - ITEM_RADIO_HARDWARE_LS;
|
||||
uint8_t mask = (0x01 << idx);
|
||||
|
||||
@@ -48,13 +48,21 @@ bool menuAboutView(event_t event)
|
||||
screenIndex = 0;
|
||||
greyIndex = 0;
|
||||
break;
|
||||
#if defined(PCBX12S)
|
||||
case EVT_KEY_FIRST(KEY_PGDN):
|
||||
#elif defined(PCBX10)
|
||||
case EVT_KEY_BREAK(KEY_PGDN):
|
||||
#endif
|
||||
screenIndex < ABOUT_PARENTS ? screenIndex++ : screenIndex = ABOUT_OPENTX;
|
||||
greyIndex = 0;
|
||||
break;
|
||||
case EVT_KEY_FIRST(KEY_PGUP):
|
||||
#if defined(PCBX10)
|
||||
case EVT_KEY_LONG(KEY_PGDN):
|
||||
#endif
|
||||
screenIndex > ABOUT_OPENTX ? screenIndex-- : screenIndex = ABOUT_PARENTS;
|
||||
greyIndex = 0;
|
||||
killEvents(event);
|
||||
break;
|
||||
case EVT_KEY_FIRST(KEY_EXIT):
|
||||
chainMenu(menuMainView);
|
||||
|
||||
@@ -35,13 +35,13 @@ Topbar * topbar;
|
||||
void drawMainPots()
|
||||
{
|
||||
// The 3 pots
|
||||
drawHorizontalSlider(TRIM_LH_X, POTS_LINE_Y, 160, calibratedStick[4], -RESX, RESX, 40, OPTION_SLIDER_TICKS | OPTION_SLIDER_BIG_TICKS | OPTION_SLIDER_SQUARE_BUTTON);
|
||||
drawHorizontalSlider(TRIM_LH_X, POTS_LINE_Y, 160, calibratedAnalogs[CALIBRATED_POT1], -RESX, RESX, 40, OPTION_SLIDER_TICKS | OPTION_SLIDER_BIG_TICKS | OPTION_SLIDER_SQUARE_BUTTON);
|
||||
drawHorizontalSlider(LCD_W/2-20, POTS_LINE_Y, XPOTS_MULTIPOS_COUNT*5, 1 + (potsPos[1] & 0x0f), 1, XPOTS_MULTIPOS_COUNT + 1, XPOTS_MULTIPOS_COUNT, OPTION_SLIDER_TICKS | OPTION_SLIDER_BIG_TICKS | OPTION_SLIDER_NUMBER_BUTTON);
|
||||
drawHorizontalSlider(TRIM_RH_X, POTS_LINE_Y, 160, calibratedStick[6], -RESX, RESX, 40, OPTION_SLIDER_TICKS | OPTION_SLIDER_BIG_TICKS | OPTION_SLIDER_SQUARE_BUTTON);
|
||||
drawHorizontalSlider(TRIM_RH_X, POTS_LINE_Y, 160, calibratedAnalogs[CALIBRATED_POT3], -RESX, RESX, 40, OPTION_SLIDER_TICKS | OPTION_SLIDER_BIG_TICKS | OPTION_SLIDER_SQUARE_BUTTON);
|
||||
|
||||
// The 2 rear sliders
|
||||
drawVerticalSlider(6, TRIM_V_Y, 160, calibratedStick[9], -RESX, RESX, 40, OPTION_SLIDER_TICKS | OPTION_SLIDER_BIG_TICKS | OPTION_SLIDER_SQUARE_BUTTON);
|
||||
drawVerticalSlider(LCD_W-18, TRIM_V_Y, 160, calibratedStick[10], -RESX, RESX, 40, OPTION_SLIDER_TICKS | OPTION_SLIDER_BIG_TICKS | OPTION_SLIDER_SQUARE_BUTTON);
|
||||
drawVerticalSlider(6, TRIM_V_Y, 160, calibratedAnalogs[CALIBRATED_SLIDER_REAR_LEFT], -RESX, RESX, 40, OPTION_SLIDER_TICKS | OPTION_SLIDER_BIG_TICKS | OPTION_SLIDER_SQUARE_BUTTON);
|
||||
drawVerticalSlider(LCD_W-18, TRIM_V_Y, 160, calibratedAnalogs[CALIBRATED_SLIDER_REAR_RIGHT], -RESX, RESX, 40, OPTION_SLIDER_TICKS | OPTION_SLIDER_BIG_TICKS | OPTION_SLIDER_SQUARE_BUTTON);
|
||||
}
|
||||
|
||||
void drawTrims(uint8_t flightMode)
|
||||
@@ -175,12 +175,19 @@ bool menuMainView(event_t event)
|
||||
pushMenu(menuTabScreensSetup[1]);
|
||||
return false;
|
||||
|
||||
#if defined(PCBX12S)
|
||||
case EVT_KEY_FIRST(KEY_PGDN):
|
||||
#elif defined(PCBX10)
|
||||
case EVT_KEY_BREAK(KEY_PGDN):
|
||||
#endif
|
||||
storageDirty(EE_GENERAL);
|
||||
g_model.view = circularIncDec(g_model.view, +1, 0, getMainViewsCount()-1);
|
||||
break;
|
||||
|
||||
case EVT_KEY_FIRST(KEY_PGUP):
|
||||
#if defined(PCBX10)
|
||||
case EVT_KEY_LONG(KEY_PGDN):
|
||||
#endif
|
||||
killEvents(event);
|
||||
storageDirty(EE_GENERAL);
|
||||
g_model.view = circularIncDec(g_model.view, -1, 0, getMainViewsCount()-1);
|
||||
|
||||
@@ -150,7 +150,7 @@ bool menuStatsAnalogs(event_t event)
|
||||
{
|
||||
MENU("Analogs", STATS_ICONS, menuTabStats, e_StatsAnalogs, 0, { 0 });
|
||||
|
||||
for (uint8_t i=0; i<NUMBER_ANALOG; i++) {
|
||||
for (uint8_t i=0; i<NUM_ANALOGS; i++) {
|
||||
coord_t y = MENU_CONTENT_TOP + (i/2)*FH;
|
||||
coord_t x = MENUS_MARGIN_LEFT + (i & 1 ? LCD_W/2 : 0);
|
||||
lcdDrawNumber(x, y, i+1, LEADING0|LEFT, 2, NULL, ":");
|
||||
@@ -158,12 +158,12 @@ bool menuStatsAnalogs(event_t event)
|
||||
#if defined(JITTER_MEASURE)
|
||||
lcdDrawNumber(x+100, y, rawJitter[i].get());
|
||||
lcdDrawNumber(x+140, y, avgJitter[i].get());
|
||||
lcdDrawNumber(x+180, y, (int16_t)calibratedStick[CONVERT_MODE(i)]*250/256, PREC1);
|
||||
lcdDrawNumber(x+180, y, (int16_t)calibratedAnalogs[CONVERT_MODE(i)]*250/256, PREC1);
|
||||
#else
|
||||
if (i < NUM_STICKS+NUM_POTS+NUM_SLIDERS)
|
||||
lcdDrawNumber(x+100, y, (int16_t)calibratedStick[CONVERT_MODE(i)]*25/256);
|
||||
lcdDrawNumber(x+100, y, (int16_t)calibratedAnalogs[CONVERT_MODE(i)]*25/256);
|
||||
else if (i >= MOUSE1)
|
||||
lcdDrawNumber(x+100, y, (int16_t)calibratedStick[NUM_STICKS+NUM_POTS+NUM_SLIDERS+i-MOUSE1]*25/256);
|
||||
lcdDrawNumber(x+100, y, (int16_t)calibratedAnalogs[CALIBRATED_MOUSE1+i-MOUSE1]*25/256);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@@ -60,7 +60,7 @@ if(ARCH STREQUAL ARM)
|
||||
)
|
||||
endif()
|
||||
|
||||
if(PCB STREQUAL FLAMENCO OR PCB STREQUAL HORUS)
|
||||
if(PCB STREQUAL FLAMENCO OR PCB STREQUAL X12S OR PCB STREQUAL X10)
|
||||
if(HELI)
|
||||
set(HELI_SRC gui/common/colorlcd/model_heli.cpp)
|
||||
endif()
|
||||
|
||||
@@ -147,6 +147,11 @@ bool isSourceAvailable(int source)
|
||||
if (source>=MIXSRC_FIRST_POT && source<=MIXSRC_LAST_POT) {
|
||||
return IS_POT_SLIDER_AVAILABLE(POT1+source-MIXSRC_FIRST_POT);
|
||||
}
|
||||
|
||||
#if defined(PCBX10)
|
||||
if ((source>=MIXSRC_S3 && source<=MIXSRC_S4) || (source>=MIXSRC_MOUSE1 && source<=MIXSRC_MOUSE2))
|
||||
return false;
|
||||
#endif
|
||||
|
||||
if (source>=MIXSRC_FIRST_SWITCH && source<=MIXSRC_LAST_SWITCH) {
|
||||
return SWITCH_EXISTS(source-MIXSRC_FIRST_SWITCH);
|
||||
|
||||
Reference in New Issue
Block a user