Cleanup, reduce size

Removed_REF_marker
DiSlord 5 years ago
parent 2aed400a47
commit f50d7e7f47

@ -1316,77 +1316,8 @@ cell_drawchar_size(uint8_t ch, int x, int y, int size)
} }
#endif #endif
/*
void
cell_drawstring(char *str, int x, int y)
{
if ((uint32_t)(y+FONT_GET_HEIGHT) >= CELLHEIGHT + FONT_GET_HEIGHT)
return;
while (*str) {
if (x >= CELLWIDTH)
return;
uint16_t ch = *str++;
uint16_t w = FONT_GET_WIDTH(ch);
cell_blit_bitmap(x, y, w, FONT_GET_HEIGHT, FONT_GET_DATA(ch));
x += w;
}
}
static void
cell_drawstring_7x13(char *str, int x, int y)
{
if ((uint32_t)(y+bFONT_GET_HEIGHT) >= CELLHEIGHT + bFONT_GET_HEIGHT)
return;
while (*str) {
if (x >= CELLWIDTH)
return;
uint8_t ch = *str++;
uint16_t w = bFONT_GET_WIDTH(ch);
cell_blit_bitmap(x, y, w, bFONT_GET_HEIGHT, bFONT_GET_DATA(ch));
x += w;
}
}
#ifndef wFONT_GET_DATA
void
cell_drawstring_size(char *str, int x, int y, int size)
{
if (y <= -FONT_GET_HEIGHT*2 || y >= CELLHEIGHT)
return;
while (*str) {
if (x >= CELLWIDTH)
return;
x += cell_drawchar_size(*str++, x, y, size);
}
}
#endif
void
cell_drawstring_10x14(char *str, int x, int y)
{
#ifdef wFONT_GET_DATA
if ((uint32_t)(y+wFONT_GET_HEIGHT) >= CELLHEIGHT + wFONT_GET_HEIGHT)
return;
while (*str) {
if (x >= CELLWIDTH)
return;
uint8_t ch = *str++;
uint16_t w = wFONT_GET_WIDTH(ch);
cell_blit_bitmap(x, y, w <=8 ? 9 : w, wFONT_GET_HEIGHT, wFONT_GET_DATA(ch));
x+=w;
}
#else
cell_drawstring_size(str, x, y, 2);
#endif
}
*/
struct cellprintStreamVMT {
_base_sequential_stream_methods
};
typedef struct { typedef struct {
const struct cellprintStreamVMT *vmt; const void *vmt;
int16_t x; int16_t x;
int16_t y; int16_t y;
} screenPrintStream; } screenPrintStream;
@ -1400,7 +1331,6 @@ static msg_t cellPut(void *ip, uint8_t ch) {
} }
return MSG_OK; return MSG_OK;
} }
static const struct cellprintStreamVMT cell_vmt_s = {NULL, NULL, cellPut, NULL};
static msg_t cellPut7x13(void *ip, uint8_t ch) { static msg_t cellPut7x13(void *ip, uint8_t ch) {
screenPrintStream *ps = ip; screenPrintStream *ps = ip;
@ -1411,10 +1341,8 @@ static msg_t cellPut7x13(void *ip, uint8_t ch) {
} }
return MSG_OK; return MSG_OK;
} }
static const struct cellprintStreamVMT cell_vmt_b = {NULL, NULL, cellPut7x13, NULL};
//#define ENABLE_WIDE_FONT_ON_CELL //#define ENABLE_WIDE_FONT_ON_CELL
#ifdef ENABLE_WIDE_FONT_ON_CELL #ifdef ENABLE_WIDE_FONT_ON_CELL
static msg_t cellPut10x14(void *ip, uint8_t ch) { static msg_t cellPut10x14(void *ip, uint8_t ch) {
screenPrintStream *ps = ip; screenPrintStream *ps = ip;
@ -1429,25 +1357,27 @@ static msg_t cellPut10x14(void *ip, uint8_t ch) {
} }
return MSG_OK; return MSG_OK;
} }
static const struct cellprintStreamVMT cell_vmt_w = {NULL, NULL, cellPut10x14, NULL};
#endif #endif
// Simple print in buffer function // Simple print in buffer function
int cell_printf(int16_t x, int16_t y, const char *fmt, ...) { int cell_printf(int16_t x, int16_t y, const char *fmt, ...) {
// skip always if right // skip always if right
if (x>=CELLWIDTH) return 0; if (x>=CELLWIDTH) return 0;
uint8_t font_type = *fmt++; // Init small cell print stream
screenPrintStream ps; struct cellprintStreamVMT {
_base_sequential_stream_methods
} cell_vmt = {NULL, NULL, NULL, NULL};
screenPrintStream ps = {&cell_vmt, x, y};
// Select font and skip print if not on cell (at top/bottom) // Select font and skip print if not on cell (at top/bottom)
switch (font_type){ switch (*fmt++){
case _FONT_s: case _FONT_s:
if ((uint32_t)(y+FONT_GET_HEIGHT) >= CELLHEIGHT + FONT_GET_HEIGHT) return 0; if ((uint32_t)(y+FONT_GET_HEIGHT) >= CELLHEIGHT + FONT_GET_HEIGHT) return 0;
ps.vmt = &cell_vmt_s; cell_vmt.put = cellPut;
break; break;
#ifdef ENABLE_WIDE_FONT_ON_CELL #ifdef ENABLE_WIDE_FONT_ON_CELL
case _FONT_w: case _FONT_w:
if ((uint32_t)(y+FONT_GET_HEIGHT) >= CELLHEIGHT + FONT_GET_HEIGHT) return 0; if ((uint32_t)(y+FONT_GET_HEIGHT) >= CELLHEIGHT + FONT_GET_HEIGHT) return 0;
ps.vmt = &cell_vmt_w; cell_vmt.put = cellPut10x14;
break; break;
#endif #endif
default: default:
@ -1455,14 +1385,11 @@ int cell_printf(int16_t x, int16_t y, const char *fmt, ...) {
__attribute__ ((fallthrough)); // prevent warning __attribute__ ((fallthrough)); // prevent warning
case _FONT_b: case _FONT_b:
if ((uint32_t)(y+bFONT_GET_HEIGHT) >= CELLHEIGHT + bFONT_GET_HEIGHT) return 0; if ((uint32_t)(y+bFONT_GET_HEIGHT) >= CELLHEIGHT + bFONT_GET_HEIGHT) return 0;
ps.vmt = &cell_vmt_b; cell_vmt.put = cellPut7x13;
break; break;
} }
va_list ap;
// Init small cell print stream
ps.x = x;
ps.y = y;
// Performing the print operation using the common code. // Performing the print operation using the common code.
va_list ap;
va_start(ap, fmt); va_start(ap, fmt);
int retval = chvprintf((BaseSequentialStream *)(void *)&ps, fmt, ap); int retval = chvprintf((BaseSequentialStream *)(void *)&ps, fmt, ap);
va_end(ap); va_end(ap);
@ -1491,8 +1418,8 @@ static void trace_print_value_string( // Only used at one place
int xpos, int ypos, int xpos, int ypos,
bool bold, bool bold,
int mi, // Marker number int mi, // Marker number
int ri, // reference Marker number int ri, // reference Marker number
float coeff[POINTS_COUNT]) float coeff[POINTS_COUNT])
{ {
(void) bold; (void) bold;
int mtype = markers[mi].mtype; int mtype = markers[mi].mtype;

Loading…
Cancel
Save

Powered by TurnKey Linux.