Files
@ 1c5909c633fa
Branch filter:
Location: therm/libraries/oleddrv/DrawText.c
1c5909c633fa
7.5 KiB
text/plain
Add new olddrv
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 | /*******************************************************************************
* File Name : DrawText.c
* Author : lxyppc
* Version : V1.0
* Date : 10-01-21
* Description : Text output implemention file
*******************************************************************************/
/* Includes ------------------------------------------------------------------*/
#include "DrawText.h"
#include "font.h"
#include "SSD1303.h"
/* Private typedef -----------------------------------------------------------*/
/* Private define ------------------------------------------------------------*/
/* Private macro -------------------------------------------------------------*/
/* Private variables ---------------------------------------------------------*/
/* Private function prototypes -----------------------------------------------*/
/* Private functions ---------------------------------------------------------*/
Pos_t DrawChar(Device* pDev, Pos_t x, Pos_t y, char ch);
/*******************************************************************************
* Function Name : TextOut
* Description : Output a text at specify position
* Input : Device* device
* Pos_t x location
* Pos_t y location
* char* text
* Size_t text length
* Output : None
* Return : End x position for the last character
*******************************************************************************/
Pos_t TextOut(Device* pDev, Pos_t x, Pos_t y, const char* text, Size_t len)
{
while(*text && len){
x += DrawChar(pDev,x,y,*text);
text++;
len--;
}
return x;
}
/*******************************************************************************
* Function Name : HightLightArea
* Description : Hight Light the specify Area
* Input : Device* device
* Pos_t x location
* Pos_t y location
Pos_t width
* Pos_t length
* Output : None
* Return : End x position for the last character
*******************************************************************************/
unsigned long HightLightArea(
Pos_t x,
Pos_t y,
Pos_t cx,
Pos_t cy)
{
return SSD1303_DrawBlock(x,y,cx,cy,0);
}
/*******************************************************************************
* Function Name : TextOut_HighLight
* Description : Output a text at specify position, then hight them
* Input : Device* device
* Pos_t x location
* Pos_t y location
* char* text
* Size_t text length
* Output : None
* Return : End x position for the last character
*******************************************************************************/
unsigned long TextOut_HighLight(
Device* pDev,
Pos_t x,
Pos_t y,
const char* text,
Size_t len)
{
Pos_t res = TextOut(pDev, x, y, text, len);
SSD1303_DrawBlock(x,y,res-x,GetFontTextHeight(pDev->pfnFont,*text),0);
return res;
}
/*******************************************************************************
* Function Name : SpecTextOut_HighLight
* Description : Output a specify text at specify position then high light them
* Input : Device* device
* Pos_t x location
* Pos_t y location
* const FontData* text dotmatrix data
* Size_t text length
* Output : None
* Return : End x position for the last character
*******************************************************************************/
unsigned long SpecTextOut_HighLight(
Device* pDev,
Pos_t x,
Pos_t y,
const pfnFontDrawChar pfnFont,
Size_t len)
{
Pos_t res = SpecTextOut(pDev, x, y, pfnFont, len);
SSD1303_DrawBlock(x,y,res-x,GetFontTextHeight(pfnFont,0),0);
return res;
}
/*******************************************************************************
* Function Name : SpecTextOut
* Description : Output a specify text at specify position
* Input : Device* device
* Pos_t x location
* Pos_t y location
* const FontData* text dotmatrix data
* Size_t text length
* Output : None
* Return : End x position for the last character
*******************************************************************************/
Pos_t SpecTextOut(Device* pDev, Pos_t x, Pos_t y,const pfnFontDrawChar pfnFont, Size_t len)
{
pfnFontDrawChar old = pDev->pfnFont;
pDev->pfnFont = pfnFont;
for(unsigned long i=0;i<len;i++){
x += DrawChar(pDev,x,y,i);
}
pDev->pfnFont = old;
return x;
}
/*******************************************************************************
* Function Name : DrawChar
* Description : Output a character at specify position
* Input : Device* device
* Pos_t x location
* Pos_t y location
* char character
* Output : None
* Return : End x position for the last character
*******************************************************************************/
Pos_t DrawChar(Device* pDev, Pos_t x, Pos_t y, char ch)
{
return pDev->pfnFont(pDev->pDevProp->pfnDrawBlok,x,y,(unsigned char)ch);
//FontData ft = &pDev->font[ch];
//pDev->pDevProp->pfnDrawBlok(x,y,ft->width,ft->height,ft->data);
//return ft->width;
}
/*******************************************************************************
* Function Name : InitialDevice
* Description : Initialize the device strcture
* Input : const DeviceProp* device properties
* const FontData* font
* Output : Device* device pointer
* Return : End x position for the last character
*******************************************************************************/
void InitialDevice(Device* pDev, const DeviceProp* pDevProp, pfnFontDrawChar pfnFont)
{
pDev->pDevProp = pDevProp;
pDev->pfnFont = pfnFont;
pDev->curX = 0;
pDev->curY = 0;
}
/*******************************************************************************
* Function Name : SetPoint
* Description : Draw a point at specify position
* Input : Device* device
* Pos_t x location
* Pos_t y location
* Output : None
* Return : End x position for the last character
*******************************************************************************/
unsigned long SetPoint(
Device* pDev,
Pos_t x,
Pos_t y)
{
return pDev->pDevProp->pfnDrawPoint(x,y,1);
}
/*******************************************************************************
* Function Name : ClearPoint
* Description : Clear a point at specify position
* Input : Device* device
* Pos_t x location
* Pos_t y location
* Output : None
* Return : End x position for the last character
*******************************************************************************/
unsigned long ClearPoint(
Device* pDev,
Pos_t x,
Pos_t y)
{
return pDev->pDevProp->pfnDrawPoint(x,y,0);
}
|