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

A little bit code cleaning...

This commit is contained in:
Bertrand Songis 2015-10-08 18:23:34 +02:00
parent 2902ae1887
commit c92909f7c5
15 changed files with 42 additions and 107 deletions

View file

@ -21,7 +21,7 @@ add_custom_target(commondeps
set_directory_properties(PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES ${RADIO_SRC_DIRECTORY}/stamp-opentx.h)
add_custom_target(lua_exports
make PCB=TARANIS lua_exports.inc
make PCB=TARANIS lua_exports_taranis.inc
WORKING_DIRECTORY ${RADIO_SRC_DIRECTORY}
)

View file

@ -116,80 +116,14 @@ void lcdDrawBitmapPattern(coord_t x, coord_t y, const uint8_t * img, LcdFlags fl
#define FONT_MAX_HEIGHT 42
void lcdPutFontPattern(coord_t x, coord_t y, const uint8_t * font, const uint16_t * spec, int index, LcdFlags flags)
{
bool blink = false;
bool inv = false;
if (flags & BLINK) {
if (BLINK_ON_PHASE) {
if (flags & INVERS)
inv = true;
else {
blink = true;
}
}
}
else if (flags & INVERS) {
inv = true;
}
coord_t w = *((uint16_t *)font);
coord_t width = getFontPatternWidth(spec, index);
coord_t height = *(((uint16_t *)font)+1);
assert(height <= FONT_MAX_HEIGHT);
for (int i=0; i<width+2; i++) {
if (x < LCD_W) {
uint8_t b[FONT_MAX_HEIGHT] = { 0 };
if (i == 0) {
if (x==0 || !inv) {
lcdNextPos++;
continue;
}
else {
// we need to work on the previous x when INVERS
x--;
}
}
else if (i <= width) {
for (coord_t j=0; j<height; ++j) {
uint8_t p = *(font + 4 + j*w + spec[index] + i - 1);
b[j] = p;
}
}
for (int j=-1; j<=height; ++j) {
uint8_t plot;
if (j < 0 || j == height) {
plot = 0;
if (j<0 && !inv) continue;
if (y+j < 0) continue;
}
else {
plot = b[j];
}
if (inv) plot = !plot;
if (!blink) {
if (plot) {
lcdDrawTransparentPixel(x, y+j, plot, lcdColorTable[COLOR_IDX(flags)]);
}
// TODO needed?
// else if (flags & ERASEBG) {
// lcdDrawPoint(x, y+j, 0x0FFF0000);
// }
}
}
}
x++;
lcdNextPos++;
}
lcdNextPos--;
coord_t offset = spec[index];
coord_t width = spec[index+1] - offset;
lcdDrawBitmapPattern(x, y, font, flags, offset, width);
lcdNextPos = x + width;
}
void lcd_putcAtt(coord_t x, coord_t y, const unsigned char c, LcdFlags flags)
{
lcdNextPos = x-1;
int fontindex = FONTSIZE(flags) >> 8;
const pm_uchar * font = fontsTable[fontindex];
const uint16_t * fontspecs = fontspecsTable[fontindex];
@ -236,9 +170,11 @@ void lcd_putsnAtt(coord_t x, coord_t y, const pm_char * s, uint8_t len, LcdFlags
{
int width = getTextWidth(s, len, flags);
int height = getFontHeight(flags);
int fontindex = FONTSIZE(flags) >> 8;
const pm_uchar * font = fontsTable[fontindex];
const uint16_t * fontspecs = fontspecsTable[fontindex];
if ((flags&INVERS) && ((~flags & BLINK) || BLINK_ON_PHASE)) {
if ((COLOR_IDX(flags) == TEXT_COLOR_INDEX)) {
if ((flags&INVERS) && ((~flags & BLINK) || BLINK_ON_PHASE) && (COLOR_IDX(flags) == TEXT_COLOR_INDEX)) {
flags += TEXT_INVERTED_COLOR - TEXT_COLOR;
if (FONTSIZE(flags) == TINSIZE)
lcdDrawFilledRect(x-INVERT_HORZ_MARGIN+2, y-INVERT_VERT_MARGIN+2, width+2*INVERT_HORZ_MARGIN-5, INVERT_LINE_HEIGHT-7, TEXT_INVERTED_BGCOLOR);
@ -247,8 +183,6 @@ void lcd_putsnAtt(coord_t x, coord_t y, const pm_char * s, uint8_t len, LcdFlags
else
lcdDrawFilledRect(x-INVERT_HORZ_MARGIN, y-INVERT_VERT_MARGIN, width+2*INVERT_HORZ_MARGIN, INVERT_LINE_HEIGHT, TEXT_INVERTED_BGCOLOR);
}
flags &= ~(INVERS|BLINK);
}
char str[256];
if (flags & ZCHAR)
@ -272,7 +206,7 @@ void lcd_putsnAtt(coord_t x, coord_t y, const pm_char * s, uint8_t len, LcdFlags
break;
}
else if (c >= 0x20) {
lcd_putcAtt(x, y, c, flags);
lcdPutFontPattern(x, y, font, fontspecs, getMappedChar(c), flags);
x = lcdNextPos;
}
else if (c == 0x1F) { // X-coord prefix

View file

@ -238,7 +238,7 @@ void lcd_line(coord_t x1, coord_t y1, coord_t x2, coord_t y2, uint8_t pat=SOLID,
#if !defined(SIMU)
inline void lcdDrawFilledRect(coord_t x, scoord_t y, coord_t w, coord_t h, LcdFlags att)
{
lcdFillRectangle(x, y, w, h, lcdColorTable[COLOR_IDX(att)]);
lcdDrawFilledRectDMA(x, y, w, h, lcdColorTable[COLOR_IDX(att)]);
}
#else
void lcdDrawFilledRect(coord_t x, scoord_t y, coord_t w, coord_t h, LcdFlags att);
@ -266,9 +266,10 @@ void lcdDrawFilledRectWithAttributes(coord_t x, scoord_t y, coord_t w, coord_t h
void drawBlackOverlay();
void lcd_rect(coord_t x, coord_t y, coord_t w, coord_t h, uint8_t pat=SOLID, LcdFlags att=0);
inline void lcd_square(coord_t x, coord_t y, coord_t w, LcdFlags att=0) { lcd_rect(x, y, w, w, SOLID, att); }
void lcdDrawTelemetryTopBar();
inline void lcdDrawSquare(coord_t x, coord_t y, coord_t w, LcdFlags att=0)
{
lcdDrawRect(x, y, w, w, att);
}
#define V_BAR(xx, yy, ll) \
lcd_vline(xx-1,yy-ll,ll); \
@ -283,10 +284,8 @@ void lcdDrawBitmapPattern(coord_t x, coord_t y, const uint8_t * img, LcdFlags fl
#define lcdSetRefVolt(...)
void lcdSetContrast();
void lcdInit();
#define lcdOff(...)
void lcdRefresh();
void lcdSendByte(uint8_t data);
void lcdSend(const uint8_t * data, uint32_t size);
void lcdSendString(const char * s);

View file

@ -138,7 +138,7 @@ void displayTrims(uint8_t phase)
lcd_vline(xm, ym-1, 3);
}
}
lcd_square(xm-3, ym-3, 7, att);
lcdDrawSquare(xm-3, ym-3, 7, att);
}
}

View file

@ -53,10 +53,10 @@ void drawStick(coord_t centrex, int16_t xval, int16_t yval)
#define BOX_CENTERY (170 - FH - BOX_WIDTH/2)
#define MARKER_WIDTH 5
lcd_square(centrex-BOX_WIDTH/2, BOX_CENTERY-BOX_WIDTH/2, BOX_WIDTH, TEXT_COLOR);
lcdDrawSquare(centrex-BOX_WIDTH/2, BOX_CENTERY-BOX_WIDTH/2, BOX_WIDTH, TEXT_COLOR);
lcd_vlineStip(centrex, BOX_CENTERY-1, 3, SOLID, TEXT_COLOR);
lcd_hlineStip(centrex-1, BOX_CENTERY, 3, SOLID, TEXT_COLOR);
lcd_square(centrex + (xval/((2*RESX)/(BOX_WIDTH-MARKER_WIDTH))) - MARKER_WIDTH/2, BOX_CENTERY - (yval/((2*RESX)/(BOX_WIDTH-MARKER_WIDTH))) - MARKER_WIDTH/2, MARKER_WIDTH, ROUND|TEXT_COLOR);
lcdDrawSquare(centrex + (xval/((2*RESX)/(BOX_WIDTH-MARKER_WIDTH))) - MARKER_WIDTH/2, BOX_CENTERY - (yval/((2*RESX)/(BOX_WIDTH-MARKER_WIDTH))) - MARKER_WIDTH/2, MARKER_WIDTH, ROUND|TEXT_COLOR);
#undef BOX_CENTERY
#undef MARKER_WIDTH

View file

@ -61,7 +61,7 @@ void setupPulsesPPM(unsigned int port) // Don't enable interru
PpmPulsesData * ppmPulsesData = (port == TRAINER_MODULE ? &trainerPulsesData.ppm : &modulePulsesData[port].ppm);
uint16_t * ptr = ppmPulsesData->pulses;
#if defined(PCBSKY9X)
#if defined(PPM_PIN_HW_SERIAL)
ppmPulsesData->index = 0;
#else
ppmPulsesData->ptr = ptr;

View file

@ -47,7 +47,7 @@ extern uint8_t s_current_protocol[NUM_MODULES];
extern uint8_t s_pulses_paused;
extern uint16_t failsafeCounter[NUM_MODULES];
#if defined(PCBSKY9X)
#if defined(PPM_PIN_HW_SERIAL)
PACK(struct PpmPulsesData {
uint16_t pulses[20];
uint32_t index;

View file

@ -250,7 +250,9 @@ void ledRed(void);
void ledBlue(void);
// LCD driver
void lcdDrawFullRect(uint16_t x, uint16_t y, uint16_t w, uint16_t h, uint16_t color);
void lcdInit(void);
void lcdRefresh(void);
void lcdDrawFilledRectDMA(uint16_t x, uint16_t y, uint16_t w, uint16_t h, uint16_t color);
// Backlight driver
#define setBacklight(xx)

View file

@ -439,7 +439,7 @@ void lcdInit(void)
LCD_SetTransparency(255);
}
void lcdDrawFullRect(uint16_t x, uint16_t y, uint16_t w, uint16_t h, uint16_t color)
void lcdDrawFilledRectDMA(uint16_t x, uint16_t y, uint16_t w, uint16_t h, uint16_t color)
{
uint32_t addr = CurrentFrameBuffer + 2*(LCD_PIXEL_WIDTH*y + x);
uint16_t red = (0xF800 & color) >> 11;
@ -476,5 +476,4 @@ void lcdRefresh()
else
LCD_SetLayer(LCD_BACKGROUND_LAYER);
LCD_SetTransparency(0);
// memcpy((void *)(SDRAM_BANK_ADDR+FRAME_BUFFER_OFFSET), (void *)SDRAM_BANK_ADDR, 480*272*2);
}

View file

@ -197,7 +197,8 @@ void menusTask(void * pdata)
BACKLIGHT_OFF();
#if defined(PCBTARANIS)
#if defined(COLORLCD)
#elif defined(PCBTARANIS)
displaySleepBitmap();
#else
lcd_clear();

View file

@ -30,7 +30,7 @@
#define __USBD_CORE_H
/* Includes ------------------------------------------------------------------*/
#include "../../../../../../targets/Flamenco/usbd_conf.h"
#include "usbd_conf.h"
#include "../../../STM32_USB_OTG_Driver/inc/usb_dcd.h"
#include "usbd_def.h"

View file

@ -31,7 +31,7 @@
#define __USB_REQUEST_H_
/* Includes ------------------------------------------------------------------*/
#include "../../../../../../targets/Flamenco/usbd_conf.h"
#include "usbd_conf.h"
#include "usbd_def.h"
#include "usbd_core.h"

View file

@ -28,7 +28,7 @@
/* Includes ------------------------------------------------------------------*/
#include "usbd_req.h"
#include "../../../../../../targets/Flamenco/usbd_desc.h"
#include "usbd_desc.h"
#include "usbd_ioreq.h"

View file

@ -30,7 +30,7 @@
#define __USB_DEF_H__
/* Includes ------------------------------------------------------------------*/
#include "../../../../../targets/Flamenco/usb_conf.h"
#include "usb_conf.h"
/** @addtogroup USB_OTG_DRIVER
* @{

View file

@ -30,7 +30,7 @@
#define __USB_OTG_REGS_H__
/* Includes ------------------------------------------------------------------*/
#include "../../../../../targets/Flamenco/usb_conf.h"
#include "usb_conf.h"
/** @addtogroup USB_OTG_DRIVER