commit
fea7f3a67f
17 changed files with 353 additions and 346 deletions
103
demos/notepad/main.c
Executable file
103
demos/notepad/main.c
Executable file
|
@ -0,0 +1,103 @@
|
|||
#include "ch.h"
|
||||
#include "hal.h"
|
||||
#include "gdisp.h"
|
||||
#include "touchpad.h"
|
||||
|
||||
#define COLOR_SIZE 20
|
||||
#define PEN_SIZE 20
|
||||
#define OFFSET 3
|
||||
|
||||
#define COLOR_BOX(a) (x >= a && x <= a + COLOR_SIZE)
|
||||
#define PEN_BOX(a) (y >= a && y <= a + COLOR_SIZE)
|
||||
#define GET_COLOR(a) (COLOR_BOX(a * COLOR_SIZE + OFFSET))
|
||||
#define GET_PEN(a) (PEN_BOX(a * 2 * PEN_SIZE + OFFSET))
|
||||
#define DRAW_COLOR(a) (a * COLOR_SIZE + OFFSET)
|
||||
#define DRAW_PEN(a) (a * 2 * PEN_SIZE + OFFSET)
|
||||
#define DRAW_AREA(x, y) (x >= PEN_SIZE + OFFSET + 3 && x <= gdispGetWidth() && \
|
||||
y >= COLOR_SIZE + OFFSET + 3 && y <= gdispGetHeight())
|
||||
|
||||
static const SPIConfig spicfg = {
|
||||
NULL,
|
||||
TP_CS_PORT,
|
||||
TP_CS,
|
||||
/* SPI_CR1_BR_2 | */ SPI_CR1_BR_1 | SPI_CR1_BR_0,
|
||||
};
|
||||
|
||||
TOUCHPADDriver TOUCHPADD1 = {
|
||||
&SPID1,
|
||||
&spicfg,
|
||||
TP_IRQ_PORT,
|
||||
TP_IRQ,
|
||||
TRUE
|
||||
};
|
||||
|
||||
void drawScreen(void) {
|
||||
char *msg = "ChibiOS/GFX";
|
||||
uint16_t colorsize = COLOR_SIZE;
|
||||
uint16_t pensize = PEN_SIZE;
|
||||
|
||||
gdispSetOrientation(landscape);
|
||||
gdispClear(White);
|
||||
gdispDrawString(gdispGetWidth()-gdispGetStringWidth(msg, &fontUI2Double)-3, 3, msg, &fontUI2Double, Black);
|
||||
|
||||
/* colors */
|
||||
gdispFillArea(0 * COLOR_SIZE + 3, 3, COLOR_SIZE, COLOR_SIZE, Black); /* Black */
|
||||
gdispFillArea(1 * COLOR_SIZE + 3, 3, COLOR_SIZE, COLOR_SIZE, Red); /* Red */
|
||||
gdispFillArea(2 * COLOR_SIZE + 3, 3, COLOR_SIZE, COLOR_SIZE, Yellow); /* Yellow */
|
||||
gdispFillArea(3 * COLOR_SIZE + 3, 3, COLOR_SIZE, COLOR_SIZE, Green); /* Green */
|
||||
gdispFillArea(4 * COLOR_SIZE + 3, 3, COLOR_SIZE, COLOR_SIZE, Blue); /* Blue */
|
||||
gdispDrawBox (5 * COLOR_SIZE + 3, 3, COLOR_SIZE, COLOR_SIZE, Black); /* White */
|
||||
|
||||
/* pens */
|
||||
gdispDrawString(OFFSET * 2, DRAW_PEN(1), "1", &fontLargeNumbers, Black);
|
||||
gdispDrawString(OFFSET * 2, DRAW_PEN(2), "2", &fontLargeNumbers, Black);
|
||||
gdispDrawString(OFFSET * 2, DRAW_PEN(3), "3", &fontLargeNumbers, Black);
|
||||
gdispDrawString(OFFSET * 2, DRAW_PEN(4), "4", &fontLargeNumbers, Black);
|
||||
gdispDrawString(OFFSET * 2, DRAW_PEN(5), "5", &fontLargeNumbers, Black);
|
||||
}
|
||||
|
||||
int main(void) {
|
||||
volatile uint16_t x, y;
|
||||
color_t color = Black;
|
||||
uint16_t pen = 0;
|
||||
|
||||
halInit();
|
||||
chSysInit();
|
||||
|
||||
gdispInit();
|
||||
tpInit(&TOUCHPADD1);
|
||||
tpCalibrate();
|
||||
|
||||
drawScreen();
|
||||
|
||||
while (TRUE) {
|
||||
x = tpReadX();
|
||||
y = tpReadY();
|
||||
|
||||
/* inside color box ? */
|
||||
if(y >= OFFSET && y <= COLOR_SIZE) {
|
||||
if(GET_COLOR(0)) color = Black;
|
||||
else if(GET_COLOR(1)) color = Red;
|
||||
else if(GET_COLOR(2)) color = Yellow;
|
||||
else if(GET_COLOR(3)) color = Green;
|
||||
else if(GET_COLOR(4)) color = Blue;
|
||||
else if(GET_COLOR(5)) color = White;
|
||||
|
||||
/* inside pen box ? */
|
||||
} else if(x >= OFFSET && x <= PEN_SIZE) {
|
||||
if(GET_PEN(1)) pen = 0;
|
||||
else if(GET_PEN(2)) pen = 1;
|
||||
else if(GET_PEN(3)) pen = 2;
|
||||
else if(GET_PEN(4)) pen = 3;
|
||||
else if(GET_PEN(5)) pen = 4;
|
||||
|
||||
/* inside drawing area ? */
|
||||
} else if(DRAW_AREA(x, y)) {
|
||||
if(pen == 0)
|
||||
gdispDrawPixel(x, y, color);
|
||||
else
|
||||
gdispFillCircle(x, y, pen, color);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -23,8 +23,19 @@
|
|||
#include "gdisp.h"
|
||||
#include "touchpad.h"
|
||||
|
||||
static const SPIConfig spicfg = {
|
||||
NULL, // no callback
|
||||
GPIOC, // CS PORT
|
||||
6, // CS PIN
|
||||
SPI_CR1_BR_1 | SPI_CR1_BR_0,
|
||||
};
|
||||
|
||||
TOUCHPADDriver TOUCHPADD1 = {
|
||||
&SPID1,
|
||||
&SPID1, // SPI driver
|
||||
&spicfg, // SPI config
|
||||
GPIO, // IRQ PORT
|
||||
4, // IRQ PIN
|
||||
TRUE // start SPI
|
||||
};
|
||||
|
||||
int main(void) {
|
||||
|
@ -32,15 +43,14 @@ int main(void) {
|
|||
chSysInit();
|
||||
|
||||
gdispInit();
|
||||
gdispClear(Lime);
|
||||
|
||||
tpInit(&TOUCHPADD1);
|
||||
tpCalibrate();
|
||||
|
||||
gdispClear(Lime);
|
||||
gdispClear(Black);
|
||||
|
||||
while (TRUE) {
|
||||
gdispDrawFillCircle(tpReadX(), tpReadY(), 3, Black);
|
||||
gdispDrawPixel(tpReadX(), tpReadY(), Green);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -13,5 +13,4 @@ To use this driver:
|
|||
Olimex SAM7-EX256
|
||||
|
||||
2. To your makefile add the following lines:
|
||||
include $(CHIBIOS)/os/halext/halext.mk
|
||||
include $(CHIBIOS)/os/halext/drivers/gdispXXXXX/gdisp_lld.mk
|
||||
include $(LCDLIB)/drivers/gdisp/Nokia6610/gdisp_lld.mk
|
||||
|
|
|
@ -12,5 +12,4 @@ To use this driver:
|
|||
#define SCREEN_HEIGHT 240
|
||||
|
||||
2. To your makefile add the following lines:
|
||||
include $(CHIBIOS)/os/halext/halext.mk
|
||||
include $(CHIBIOS)/os/halext/drivers/gdispS6d1121/gdisp_lld.mk
|
||||
include $(LCDLIB)/drivers/gdisp/S6D1121/gdisp_lld.mk
|
||||
|
|
|
@ -73,8 +73,6 @@
|
|||
* @notapi
|
||||
*/
|
||||
bool_t GDISP_LLD(init)(void) {
|
||||
uint16_t deviceCode;
|
||||
|
||||
#ifdef LCD_USE_FSMC
|
||||
/* FSMC setup. TODO: this only works for STM32F1 */
|
||||
rccEnableAHB(RCC_AHBENR_FSMCEN, 0);
|
||||
|
@ -94,8 +92,6 @@ bool_t GDISP_LLD(init)(void) {
|
|||
FSMC_Bank1->BTCR[FSMC_Bank] = FSMC_BCR1_MWID_0 | FSMC_BCR1_WREN | FSMC_BCR1_MBKEN;
|
||||
#endif
|
||||
|
||||
deviceCode = lld_lcdReadReg(0x0000);
|
||||
|
||||
lld_lcdWriteReg(0x0000,0x0001); lld_lcdDelay(5);
|
||||
lld_lcdWriteReg(0x0003,0xA8A4); lld_lcdDelay(5);
|
||||
lld_lcdWriteReg(0x000C,0x0000); lld_lcdDelay(5);
|
||||
|
@ -484,7 +480,7 @@ void GDISP_LLD(drawpixel)(coord_t x, coord_t y, color_t color) {
|
|||
}
|
||||
#endif
|
||||
|
||||
#if GDISP_HARDWARE_CONTROL || defined(__DOXYGEN__)
|
||||
#if (GDISP_NEED_CONTROL && GDISP_HARDWARE_CONTROL) || defined(__DOXYGEN__)
|
||||
/**
|
||||
* @brief Driver Control
|
||||
* @detail Unsupported control codes are ignored.
|
||||
|
|
|
@ -12,5 +12,4 @@ To use this driver:
|
|||
#define SCREEN_HEIGHT 240
|
||||
|
||||
2. To your makefile add the following lines:
|
||||
include $(CHIBIOS)/os/halext/halext.mk
|
||||
include $(CHIBIOS)/os/halext/drivers/gdispSsd1289/gdisp_lld.mk
|
||||
include $(LCDLIB)/drivers/gdisp/SSD1289/gdisp_lld.mk
|
||||
|
|
|
@ -96,6 +96,8 @@
|
|||
|
||||
dummy = lld_lcdReadData();
|
||||
for(i = 0; i < size; i++) buffer[i] = lld_lcdReadData();
|
||||
|
||||
(void)dummy;
|
||||
}
|
||||
|
||||
#elif defined(LCD_USE_FSMC)
|
||||
|
|
|
@ -13,5 +13,4 @@ To use this driver:
|
|||
you want to compile test eg: GDISP_NEED_MULTITHREAD
|
||||
|
||||
2. To your makefile add the following lines:
|
||||
include $(CHIBIOS)/os/halext/halext.mk
|
||||
include $(CHIBIOS)/os/halext/drivers/gdispTestStub/gdisp_lld.mk
|
||||
include $(LCDLIB)/drivers/gdisp/TestStub/gdisp_lld.mk
|
||||
|
|
|
@ -4,6 +4,5 @@ To use this driver:
|
|||
a) #define HAL_USE_TOUCHPAD TRUE
|
||||
|
||||
2. To your makefile add the following lines:
|
||||
include $(LCDLIB)/lcd.mk
|
||||
include $(LCDLIB)/halext/drivers/touchpad/touchpadADS7843/touchpad_lld.mk
|
||||
include $(LCDLIB)/drivers/touchpadADS7843/touchpad_lld.mk
|
||||
|
||||
|
|
|
@ -4,6 +4,5 @@ To use this driver:
|
|||
a) #define HAL_USE_TOUCHPAD TRUE
|
||||
|
||||
2. To your makefile add the following lines:
|
||||
include $(LCDLIB)/lcd.mk
|
||||
include $(LCDLIB)/halext/drivers/touchpad/touchpadXPT2046/touchpad_lld.mk
|
||||
include $(LCDLIB)/drivers/touchpad/XPT2046/touchpad_lld.mk
|
||||
|
||||
|
|
|
@ -227,6 +227,8 @@ extern "C" {
|
|||
#endif
|
||||
|
||||
void gdispDrawBox(coord_t x, coord_t y, coord_t cx, coord_t cy, color_t color);
|
||||
void gdispDrawArc(coord_t x, coord_t y, coord_t radius, uint16_t start, uint16_t end, color_t color);
|
||||
void gdispFillArc(coord_t x, coord_t y, coord_t radius, uint16_t start, uint16_t end, color_t color);
|
||||
|
||||
/* Extra Text Functions */
|
||||
#if GDISP_NEED_TEXT
|
||||
|
@ -245,7 +247,7 @@ void gdispDrawBox(coord_t x, coord_t y, coord_t cx, coord_t cy, color_t color);
|
|||
|
||||
/* Macro definitions for common gets and sets */
|
||||
#define gdispSetPowerMode(powerMode) gdispControl(GDISP_CONTROL_POWER, (void *)(unsigned)(powerMode))
|
||||
#define gdispSetOrientation(newOrientation) gdispControl(GDISP_CONTROL_ORITENTATION, (void *)(unsigned)(newOrientation))
|
||||
#define gdispSetOrientation(newOrientation) gdispControl(GDISP_CONTROL_ORIENTATION, (void *)(unsigned)(newOrientation))
|
||||
#define gdispSetBacklight(percent) gdispControl(GDISP_CONTROL_BACKLIGHT, (void *)(unsigned)(percent))
|
||||
#define gdispSetContrast(percent) gdispControl(GDISP_CONTROL_CONTRAST, (void *)(unsigned)(percent))
|
||||
|
||||
|
|
|
@ -501,7 +501,7 @@
|
|||
/**
|
||||
* @brief The type for a coordinate or length on the screen.
|
||||
*/
|
||||
typedef uint16_t coord_t;
|
||||
typedef int16_t coord_t;
|
||||
/**
|
||||
* @brief The type of a pixel.
|
||||
*/
|
||||
|
|
136
include/glcd.h
136
include/glcd.h
|
@ -1,136 +0,0 @@
|
|||
/*
|
||||
ChibiOS/RT - Copyright (C) 2012
|
||||
Joel Bodenmann aka Tectu <joel@unormal.org>
|
||||
|
||||
This file is part of ChibiOS-LCD-Driver.
|
||||
|
||||
ChibiOS-LCD-Driver is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
ChibiOS-LCD-Driver is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/*
|
||||
This file is an emulation of the GLCD interface using the
|
||||
new GDISP interface. It is probably not a perfect replica,
|
||||
some code changes may be necessary.
|
||||
Note it does not replicate the GLCD low level driver, just
|
||||
the high level interface.
|
||||
You may also need to define the various GDISP_NEED_XXX in your
|
||||
halconf.h in order to turn on the functionality you need.
|
||||
*/
|
||||
|
||||
#ifndef GLCD_H
|
||||
#define GLCD_H
|
||||
|
||||
#include "ch.h"
|
||||
#include "hal.h"
|
||||
#include "gdisp.h"
|
||||
|
||||
#define PORTRAIT (lcdGetOrientation() == portrait || lcdGetOrientation() == portraitInv)
|
||||
#define LANDSCAPE (lcdGetOrientation() == landscape || lcdGetOrientation() == landscapeInv)
|
||||
|
||||
#define RGB565CONVERT(r, g, b) RGB2COLOR(r,g,b)
|
||||
|
||||
enum filled {frame, filled};
|
||||
enum transparency {solid, transparent};
|
||||
#define sleepOn powerSleep
|
||||
#define sleepOff powerOn
|
||||
|
||||
#define font_Small (&fontSmall)
|
||||
#define font_SmallDouble (&fontSmallDouble)
|
||||
#define font_SmallNarrow (&fontSmall)
|
||||
#define font_Larger (&fontLarger)
|
||||
#define font_LargerDouble (&fontLargerDouble)
|
||||
#define font_LargerNarrow (&fontLargerNarrow)
|
||||
#define font_MediumBold (&fontUI1)
|
||||
#define font_MediumBoldDouble (&fontUI1Double)
|
||||
#define font_MediumBoldNarrow (&fontUI1Narrow)
|
||||
#define font_LargeNumbers (&fontLargeNumbers)
|
||||
#define font_LargeNumbersDouble (&fontLargeNumbersDouble)
|
||||
#define font_LargeNumbersNarrow (&fontLargeNumbersNarrow)
|
||||
|
||||
enum glcd_result { GLCD_DONE,
|
||||
GLCD_FAILED,
|
||||
GLCD_PROGRESS,
|
||||
};
|
||||
|
||||
typedef enum glcd_result glcd_result_t;
|
||||
|
||||
/* Core functions */
|
||||
#define lcdInit(dvr) gdispInit(dvr)
|
||||
static __inline glcd_result_t lcdClear(color_t color) {
|
||||
gdispClear(color);
|
||||
return GLCD_DONE;
|
||||
}
|
||||
static __inline glcd_result_t lcdSetOrientation(enum orientation newO) {
|
||||
gdispControl(GDISP_CONTROL_ORIENTATION, (void *)(int)newO);
|
||||
return ((enum orientation)(unsigned)gdispQuery(GDISP_QUERY_ORIENTATION)) == (newO) ? GLCD_DONE : GLCD_FAILED;
|
||||
}
|
||||
static __inline glcd_result_t lcdFillArea(coord_t x0, coord_t y0, coord_t x1, coord_t y1,color_t c) {
|
||||
gdispFillArea((x0),(y0),(x1)-(x0)+1,(y1)-(y0)+1,(c));
|
||||
return GLCD_DONE;
|
||||
}
|
||||
static __inline glcd_result_t lcdWriteArea(coord_t x0, coord_t y0, coord_t x1, coord_t y1, const pixel_t *b, coord_t n) {
|
||||
(void)n;
|
||||
gdispBlitArea((x0),(y0),(x1)-(x0)+1,(y1)-(y0)+1,(b));
|
||||
return GLCD_DONE;
|
||||
}
|
||||
static __inline glcd_result_t lcdSetPowerMode(enum powermode pm) {
|
||||
gdispControl(GDISP_CONTROL_POWER, (void *)(int)pm);
|
||||
return ((enum powermode)(unsigned)gdispQuery(GDISP_QUERY_POWER)) == (pm) ? GLCD_DONE : GLCD_FAILED;
|
||||
}
|
||||
|
||||
/* Drawing functions */
|
||||
static __inline glcd_result_t lcdDrawPixel(coord_t x, coord_t y, color_t c) {
|
||||
gdispDrawPixel((x),(y),(c));
|
||||
return GLCD_DONE;
|
||||
}
|
||||
#define lcdDrawLine(x0,y0,x1,y1,c) gdispDrawLine((x0),(y0),(x1),(y1),(c))
|
||||
#define lcdDrawRect(x0,y0,x1,y1,f,c) {if(f) gdispFillArea((x0),(y0),(x1)-(x0)+1,(y1)-(y0)+1,(c)); else gdispDrawBox((x0),(y0),(x1)-(x0)+1,(y1)-(y0)+1,(c));}
|
||||
#define lcdDrawRectString(x0,y0,x1,y1,s,f,c,b) gdispFillStringBox((x0),(y0),(x1)-(x0)+1,(y1)-(y0)+1,(s),(f),(c),(b),justifyLeft)
|
||||
#define lcdDrawCircle(x,y,r,f,c) {if(f) gdispFillCircle((x),(y),(r),(c)); else gdispDrawCircle((x),(y),(r),(c));}
|
||||
#define lcdDrawEllipse(x,y,a,b,f,c) {if(f) gdispFillEllipse((x),(y),(a),(b),(c)); else gdispDrawEllipse((x),(y),(a),(b),(c));}
|
||||
|
||||
/* Text Rendering Functions */
|
||||
static __inline coord_t lcdDrawChar(coord_t x, coord_t y, char h, font_t f, color_t c, color_t b, bool_t t) {
|
||||
if (t)
|
||||
gdispDrawChar((x),(y),(h),(f),(c));
|
||||
else
|
||||
gdispFillChar((x),(y),(h),(f),(c),(b));
|
||||
return gdispGetCharWidth((h),(f))+gdispGetFontMetric((f), fontCharPadding);
|
||||
}
|
||||
static __inline coord_t lcdDrawString(coord_t x, coord_t y, const char *s, font_t f, color_t c, color_t b, bool_t t) {
|
||||
if (t)
|
||||
gdispDrawString((x),(y),(s),(f),(c));
|
||||
else
|
||||
gdispFillString((x),(y),(s),(f),(c),(b));
|
||||
return gdispGetStringWidth((s),(f))+gdispGetFontMetric((f), fontCharPadding);
|
||||
}
|
||||
|
||||
/* Character measuring functions */
|
||||
#define lcdMeasureChar(h,f) (gdispGetCharWidth((h),(f))+gdispGetFontMetric((f), fontCharPadding))
|
||||
#define lcdMeasureString(s,f) (gdispGetStringWidth((s),(f))+gdispGetFontMetric((f), fontCharPadding))
|
||||
#define lcdGetFontHeight(f) gdispGetFontMetric((f), fontHeight)
|
||||
|
||||
/* Size and orientation related */
|
||||
#define lcdGetHeight() ((coord_t)(unsigned)gdispQuery(GDISP_QUERY_HEIGHT))
|
||||
#define lcdGetWidth() ((coord_t)(unsigned)gdispQuery(GDISP_QUERY_WIDTH))
|
||||
#define lcdGetOrientation() ((enum orientation)(unsigned)gdispQuery(GDISP_QUERY_ORIENTATION))
|
||||
|
||||
/* BGR->RGB and pixel readback */
|
||||
#define lcdBGR2RGB(c) RGB2COLOR(BLUE_OF(c),GREEN_OF(c),RED_OF(c))
|
||||
#define lcdGetPixelColor(x,y) gdispGetPixelColor((x),(y))
|
||||
|
||||
/* Scrolling function */
|
||||
#define lcdVerticalScroll(x0,y0,x1,y1,l) gdispVerticalScroll((x0),(y0),(x1)-(x0)+1,(y1)-(y0)+1,l,Black)
|
||||
|
||||
#endif
|
2
lcd.mk
2
lcd.mk
|
@ -6,6 +6,6 @@ endif
|
|||
LCDSRC += $(LCDLIB)/src/gdisp.c \
|
||||
$(LCDLIB)/src/gdisp_fonts.c \
|
||||
$(LCDLIB)/src/touchpad.c \
|
||||
$(LCDLIB)/src/console.c
|
||||
$(LCDLIB)/src/console.c \
|
||||
|
||||
LCDINC += $(LCDLIB)/include
|
||||
|
|
|
@ -22,11 +22,8 @@
|
|||
#include "hal.h"
|
||||
|
||||
#include "gdisp.h"
|
||||
#include "gdisp_fonts.h"
|
||||
#include "console.h"
|
||||
|
||||
#if defined(GDISP_NEED_SCROLL)
|
||||
|
||||
/*
|
||||
* Interface implementation. The interface is write only
|
||||
*/
|
||||
|
@ -100,7 +97,7 @@ msg_t lcdConsoleInit(GLCDConsole *console, coord_t x0, coord_t y0, coord_t width
|
|||
|
||||
console->vmt = &vmt;
|
||||
/* read font, get height */
|
||||
console->fy = font->height;
|
||||
console->fy = gdispGetFontMetric(font, fontHeight);
|
||||
|
||||
/* calculate the size of the console as an integer multiple of characters height*/
|
||||
console->sx = width;
|
||||
|
@ -127,7 +124,7 @@ msg_t lcdConsolePut(GLCDConsole *console, char c) {
|
|||
/* clear the text at the end of the line */
|
||||
if(console->cx < console->sx)
|
||||
gdispFillArea(console->x0 + console->cx, console->y0 + console->cy,
|
||||
console->x0 + console->sx, console->y0 + console->cy + console->fy,
|
||||
console->sx - console->cx, console->fy,
|
||||
console->bkcolor);
|
||||
console->cx = 0;
|
||||
console->cy += console->fy;
|
||||
|
@ -135,23 +132,34 @@ msg_t lcdConsolePut(GLCDConsole *console, char c) {
|
|||
/* TODO: work backwards through the buffer to the start of the current line */
|
||||
//console->cx = 0;
|
||||
} else {
|
||||
width = _getCharWidth(console->font, c);
|
||||
width = gdispGetCharWidth(c, console->font) + gdispGetFontMetric(console->font, fontCharPadding);
|
||||
if((console->cx + width) >= console->sx) {
|
||||
/* clear the text at the end of the line */
|
||||
if (console->cy <= console->sy)
|
||||
gdispFillArea(console->x0 + console->cx, console->y0 + console->cy,
|
||||
console->x0 + console->cx + width, console->y0 + console->cy + console->fy,
|
||||
console->sx - (console->cx + width), console->fy,
|
||||
console->bkcolor);
|
||||
console->cx = 0;
|
||||
console->cy += console->fy;
|
||||
}
|
||||
|
||||
if((console->cy > console->sy)) {
|
||||
/* scroll the screen */
|
||||
gdispVerticalScroll(console->x0, console->y0, console->x0 + console->sx,
|
||||
console->y0 + console->sy + console->fy, console->fy, console->bkcolor);
|
||||
/* reset the cursor */
|
||||
#if GDISP_NEED_SCROLL
|
||||
/* scroll the console */
|
||||
gdispVerticalScroll(console->x0, console->y0, console->sx,
|
||||
console->sy + console->fy, console->fy, console->bkcolor);
|
||||
/* reset the cursor to the start of the line */
|
||||
console->cx = 0;
|
||||
console->cy = console->sy;
|
||||
#else
|
||||
/* clear the console */
|
||||
gdispFillArea(console->x0, console->y0,
|
||||
console->sx, console->sy + console->fy,
|
||||
console->bkcolor);
|
||||
/* reset the cursor to the top of the console */
|
||||
console->cx = 0;
|
||||
console->cy = 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
gdispDrawChar(console->x0 + console->cx, console->y0 + console->cy, c,
|
||||
|
@ -170,6 +178,3 @@ msg_t lcdConsoleWrite(GLCDConsole *console, char *bp, size_t n) {
|
|||
|
||||
return RDY_OK;
|
||||
}
|
||||
|
||||
|
||||
#endif /* GDISP_NEED_SCROLL */
|
||||
|
|
39
src/gdisp.c
39
src/gdisp.c
|
@ -28,6 +28,7 @@
|
|||
#include "ch.h"
|
||||
#include "hal.h"
|
||||
#include "gdisp.h"
|
||||
#include <math.h>
|
||||
|
||||
#ifndef _GDISP_C
|
||||
#define _GDISP_C
|
||||
|
@ -658,6 +659,44 @@ void gdispDrawBox(coord_t x, coord_t y, coord_t cx, coord_t cy, color_t color) {
|
|||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* @brief Draw an arc.
|
||||
* @pre The GDISP must be in powerOn or powerSleep mode.
|
||||
*
|
||||
* @param[in] x0,y0 The center point
|
||||
* @param[in] radius The radius of the arc
|
||||
* @param[in] start The start angle (0 to 360)
|
||||
* @param[in] end The end angle (0 to 360)
|
||||
* @param[in] color The color of the arc
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
void gdispDrawArc(coord_t x, coord_t y, coord_t radius, uint16_t start, uint16_t end, color_t color) {
|
||||
uint16_t i;
|
||||
float step = 0.01;
|
||||
|
||||
for(i = 0; i <= (int)((abs(end-start)) / step); i++) {
|
||||
gdispDrawPixel( ((float)x + (float)radius * cosf((float)start * M_PI / 180.0f) + (float)i * step * M_PI / 180.0f),
|
||||
((float)y + (float)radius * sinf((float)start * M_PI / 180.0f) + (float)i * step * M_PI / 180.0f), color);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* @brief Draw a filled arc.
|
||||
* @pre The GDISP must be in powerOn or powerSleep mode.
|
||||
*
|
||||
* @param[in] x0,y0 The center point of the filled arc
|
||||
* @param[in] radius The radius of the filled arc
|
||||
* @param[in] start The start angle (0 to 360)
|
||||
* @param[in] end The end angle (0 to 360)
|
||||
* @param[in] color The color of the filled arc
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
void gdispFillArc(coord_t x, coord_t y, coord_t radius, uint16_t start, uint16_t end, color_t color) {
|
||||
|
||||
}
|
||||
|
||||
#if GDISP_NEED_TEXT || defined(__DOXYGEN__)
|
||||
/**
|
||||
* @brief Draw a text string.
|
||||
|
|
|
@ -158,8 +158,7 @@ uint16_t tpReadX(void) {
|
|||
x = cal.xm * _tpReadRealX() + cal.xn;
|
||||
y = cal.ym * _tpReadRealY() + cal.yn;
|
||||
|
||||
/*
|
||||
switch(gdispGetOrientation()) { // implement gdispGetOrientation()
|
||||
switch(gdispGetOrientation()) {
|
||||
case portrait:
|
||||
return x;
|
||||
case landscape:
|
||||
|
@ -169,9 +168,6 @@ uint16_t tpReadX(void) {
|
|||
case landscapeInv:
|
||||
return y;
|
||||
}
|
||||
*/
|
||||
|
||||
return x;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -187,8 +183,7 @@ uint16_t tpReadY(void) {
|
|||
x = cal.xm * _tpReadRealX() + cal.xn;
|
||||
y = cal.ym * _tpReadRealY() + cal.yn;
|
||||
|
||||
/*
|
||||
switch(gdispGetOrientation()) { // implement gdispGetOrientation()
|
||||
switch(gdispGetOrientation()) {
|
||||
case portrait:
|
||||
return y;
|
||||
case landscape:
|
||||
|
@ -198,9 +193,6 @@ uint16_t tpReadY(void) {
|
|||
case landscapeInv:
|
||||
return SCREEN_WIDTH - x;
|
||||
}
|
||||
*/
|
||||
|
||||
return y;
|
||||
}
|
||||
|
||||
void tpCalibrate(void) {
|
||||
|
|
Loading…
Add table
Reference in a new issue