📄 bsptsprnt.c
字号:
/* 横向水平打印起始位置调整 */
if (_ucCNSign)
{
k = CN_LENGTH;
}
else
{
k = ASCII_LENGTH;
}
for (i = 0; i < (k + _ucCharSpace)*( s_ucTSDoubleWidth + 1); i ++)
{
s_usprntHoriPosition ++; /* 一行已处理的点数(单行最大384点) */
s_ucprntBitInByte = s_ucprntBitInByte >> 1;
if (s_ucprntBitInByte == 0)
{
s_ucprntBitInByte = 0x80;
s_ucprntHoriByte ++; /* 二维缓冲区列向座标(最多48字节)*/
}
}
return SUCCESS;
}
#pragma arm section code
/*
*****************************************************
*
* 函数名:bspTSPrntDealArabia
*
* 功 能:热敏打印机处理阿拉伯语字模函数
*
* 输 入:g_ucprntCharPattern
* s_ucprntBitInByte
* s_usprntDotLine
*
* 输 出:g_ucprntPrintLineBuffer
*
* 返 回:SUCCESS---处理成功
*
******************************************************
*/
INT1 bspTSPrntDealArabia
(
UINT1 _ucCharSpace, /* 字符间距 */
UINT1* _pBuffer /* [in]存放显示字模数据缓存首地址 */
)
{
UINT1 i,j;
UINT1 ucReadByteOne;
UINT1 ucReadByteTwo;
UINT1 ucDealOneBit;
UINT1 ucDotLinePos;
UINT1 ucDotRowPos;
UINT1 ucDotBitPos;
ucDotLinePos = s_usprntDotLine; /* 保存起始打印行位置(增加1个字符字模后,回到初始位置) */
ucDotRowPos = s_ucprntHoriByte; /* 存起始打印列位置(以字节为单位) */
ucDotBitPos = s_ucprntBitInByte; /* 当前处理的位在打印列位置相对位置 */
for (i = 0; i < ARABIA_PATTERN_LEN/2; i ++)
{
ucReadByteOne = *(_pBuffer + 2*i); /* 从字模缓存取1字节 */
ucReadByteTwo = *(_pBuffer + 2*i + 1); /* 从字模缓存取第2字节 */
for (j = 0; j < 4; j ++)
{
ucDealOneBit = (ucReadByteTwo>>4) & 0x01;
ucReadByteTwo = ucReadByteTwo >> 1;
bspTSPrntPatternShift(ucDealOneBit, 1);
}
for (j = 0; j < 8; j ++) /* 将字模单字节移位处理存取打印缓冲区 */
{
ucDealOneBit = ucReadByteOne & 0x01;
ucReadByteOne = ucReadByteOne >> 1;
bspTSPrntPatternShift(ucDealOneBit, 1);
}
if (s_ucTSDoubleHigh)
{
INC(s_usprntDotLine, DOTLINE_LIMIT);
}
INC(s_usprntDotLine, DOTLINE_LIMIT);
s_ucprntHoriByte = ucDotRowPos; /* 换点行后,恢复起始打印列字节位置 */
s_ucprntBitInByte = ucDotBitPos; /* 换点行后,恢复当前字模处理位在打印列字节中的位置 */
}
s_usprntDotLine = ucDotLinePos;
/* 横向水平打印起始位置调整 */
for (i = 0; i < (ASCII_LENGTH + _ucCharSpace)*( s_ucTSDoubleWidth + 1); i ++)
{
s_usprntHoriPosition ++; /* 一行已处理的点数(单行最大384点) */
s_ucprntBitInByte = s_ucprntBitInByte << 1;
if (s_ucprntBitInByte == 0)
{
s_ucprntBitInByte = 0x01;
s_ucprntHoriByte --; /* 二维缓冲区列向座标(最多48字节)*/
}
}
return SUCCESS;
}
#pragma arm section code = "bspTSPrntPatternShift"
/*
*****************************************************
*
* 函数名:bspTSPrntPatternShift
*
* 功 能:热敏打印机处理字模移位操作
*
* 输 入:g_ucprntCharPattern
* s_ucprntBitInByte
* s_usprntDotLine
*
* 输 出:g_ucprntPrintLineBuffer
*
* 返 回:SUCCESS---处理成功
*
******************************************************
*/
INT1 bspTSPrntPatternShift
(
UINT1 _ucShiftBit, /* 处理移位数据位 */
UINT1 _ucOrderMode /* 字模存取对齐模式(0 左对齐,1右对齐)*/
)
{
UINT1 k,l;
if (_ucShiftBit) /* 字模移位处理 */
{
for (k = 0; k < ( s_ucTSDoubleWidth + 1); k ++)
{
g_ucprntPrintLineBuffer[s_usprntDotLine][s_ucprntHoriByte] |= s_ucprntBitInByte;
if (_ucOrderMode)
{
/* 存入打印缓冲区字模,从右向左移位处理 */
s_ucprntBitInByte = (s_ucprntBitInByte << 1);
if (s_ucprntBitInByte == 0)
{
s_ucprntBitInByte = 0x01;
s_ucprntHoriByte --;
}
}
else
{
/* 存入打印缓冲区字模,从左向右移位处理 */
s_ucprntBitInByte = (s_ucprntBitInByte >> 1);
if (s_ucprntBitInByte == 0)
{
s_ucprntBitInByte = 0x80;
s_ucprntHoriByte ++;
}
}
}
if (s_ucTSDoubleHigh > 0) /* 倍高打印操作处理 */
{
s_ucTSRequestDoubleHigh = 1;
l = s_usprntDotLine;
l ++;
g_ucprntPrintLineBuffer[l][s_ucprntHoriByte] |=
g_ucprntPrintLineBuffer[s_usprntDotLine][s_ucprntHoriByte];
g_ucprntPrintLineBuffer[l][s_ucprntHoriByte - 1] |=
g_ucprntPrintLineBuffer[s_usprntDotLine][s_ucprntHoriByte - 1];
}
}
else
{
for (k = 0; k < (s_ucTSDoubleWidth + 1); k ++)
{
if (_ucOrderMode)
{
s_ucprntBitInByte = (s_ucprntBitInByte << 1);
if (s_ucprntBitInByte == 0)
{
s_ucprntBitInByte = 0x01;
s_ucprntHoriByte --;
}
}
else
{
s_ucprntBitInByte = (s_ucprntBitInByte >> 1);
if (s_ucprntBitInByte == 0)
{
s_ucprntBitInByte = 0x80;
s_ucprntHoriByte ++;
}
}
}
}
return SUCCESS;
}
#pragma arm section code
/*
*******************************************************
*
* 函数名:bspTSPrntFillBuffer
*
* 功 能:热敏打印机取字模填充缓冲区
*
* 输 入:s_uiprntHoriPosition
*
* 输 出:s_ucTSDealedLineCounter
*
* 返 回:SUCCESS----处理成功
* FAULT------非法字模
* TS_DEAL_DATA-剩余空间不足以保存字模
*
*******************************************************
*/
INT1 bspTSPrntFillBuffer
(
const UINT1* _pStr, /* [in]要打印的字符区位码 */
UINT1 _ucCharSpace, /* 字符间距 */
UINT1 _ucLineSpace, /* 热敏打印行间距 */
UINT1 _ucStartPos /* 热敏打印确定横向起始位置(精确mm) */
)
{
UINT1 ucPatternLen;
UINT1 ucPrntPatternBuffer[72] = {0};
UINT1 ucRet = 0;
UINT1 ucCNSign;
ucCNSign = bspTSPrntGetPattern(_pStr, ucPrntPatternBuffer,g_ucPrntChoiceLang);
if (ucCNSign == 1)
{
ucPatternLen = CN_LENGTH; /* 汉字字模填充缓冲区单行长度 */
}
else if (ucCNSign == 0)
{
ucPatternLen = ASCII_LENGTH;/* ASCII字符字模填充缓冲区单行长度 */
}
else
{
return FAULT;/* 非法区位码,取字模失败 */
}
if ((s_usprntHoriPosition + (s_ucTSDoubleWidth + 1)*(ucPatternLen + _ucCharSpace)) > ONE_LINE_DOT)
{
ucRet = bspTSPrntDealState(_ucLineSpace);
if (ucRet) /* 剩余缓存空间足以保存下一行的处理数据 */
{
bspTSPrntChangeLine (_ucLineSpace, _ucStartPos);
bspTSPrntEraseLineBuffer(_ucLineSpace);
if (!g_ucPrntOrderMode)
{
bspTSPrntDealWord(ucCNSign, _ucCharSpace, ucPrntPatternBuffer);
}
else
{
bspTSPrntDealArabia(_ucCharSpace, ucPrntPatternBuffer);
}
}
else
{
return TS_DEAL_DATA; /* 剩余空间不够处理下一行数据 */
}
}
else
{
if (!g_ucPrntOrderMode)
{
bspTSPrntDealWord(ucCNSign, _ucCharSpace, ucPrntPatternBuffer);
}
else
{
bspTSPrntDealArabia(_ucCharSpace, ucPrntPatternBuffer);
}
}
return SUCCESS;
}
/*
******************************************************
*
* 函数名:bspTSPrntChangeLine
*
* 功 能:热敏打印换行处理
*
* 输 入:s_uiprntDotLineDealed
*
* 输 出:s_uiprntDotLine
*
* 返 回:无
*
******************************************************
*/
void bspTSPrntChangeLine
(
UINT1 _ucLineSpace, /* 热敏打印行间距 */
UINT1 _ucStartPos /* 热敏打印确定横向起始位置(精确mm) */
)
{
UINT1 i;
for (i = 0; i < _ucLineSpace; i ++)
{
INC(s_usprntDotLineDealed, DOTLINE_LIMIT);
}
/* 单行含有倍高处理需求 */
if (s_ucTSRequestDoubleHigh)
{
for (i = 0; i < 24; i ++)
{
INC(s_usprntDotLineDealed, DOTLINE_LIMIT);
}
}
s_ucTSRequestDoubleHigh = 0;
/* 换行后打印起始位置初始定位 */
s_usprntDotLine = s_usprntDotLineDealed;
bspTSPrntSetIntPos (_ucStartPos);
return;
}
/*
******************************************************
*
* 函数名:bspTSPrntChangeLine
*
* 功 能:热敏打印清空下一行缓存
*
* 输 入:s_uiprntDotLineDealed
*
* 输 出:g_ucprntPrintLineBuffer
*
* 返 回:无
*
******************************************************
*/
void bspTSPrntEraseLineBuffer
(
UINT1 _ucLineSpace /* 热敏打印行间距 */
)
{
UINT1 i,j,k;
i = s_usprntDotLineDealed;
for (k = 0; k < _ucLineSpace; k ++)
{
for(j = 0; j < TS_ONE_LINE_BYTE; j++)
{
g_ucprntPrintLineBuffer[i][j] = 0;
}
INC(i, DOTLINE_LIMIT);
}
if (s_ucTSDoubleHigh)
{
for (k = 0; k < 24; k ++)
{
for(j = 0; j < TS_ONE_LINE_BYTE; j++)
{
g_ucprntPrintLineBuffer[i][j] = 0;
}
INC(i, DOTLINE_LIMIT);
}
}
return;
}
/*
******************************************************
*
* 函数名:bspTSPrntDealState
*
* 功 能:剩余存储空间是否允许处理数据状态判断
*
* 输 入:s_usprntDotLineDealed
* s_usTSprntLinePrinted
*
* 输 出:无
*
* 返 回:DISABLE_DEAL_DATA 不能继续处理数据
* ENABLE_DEAL_DATA 可以处理一行打印数据
*
******************************************************
*/
UINT1 bspTSPrntDealState
(
UINT1 _ucLineSpace /* 热敏打印行间距 */
)
{
if (s_usprntDotLineDealed < s_usTSprntLinePrinted)
{
if (s_usTSprntLinePrinted > (s_usprntDotLineDealed + ENABLE_DEAL_LIMIT *_ucLineSpace))
{
return ENABLE_DEAL_DATA;
}
else
{
return DISABLE_DEAL_DATA;
}
}
else
{
if ((s_usprntDotLineDealed + ENABLE_DEAL_LIMIT *_ucLineSpace)<= (s_usTSprntLinePrinted
+ DOTLINE_LIMIT))
{
return ENABLE_DEAL_DATA;
}
else
{
return DISABLE_DEAL_DATA;
}
}
}
/*
******************************************************
*
* 函数名:bspTSPrntCheckState
*
* 功 能:热敏已处理数据是否允许打印判断
*
* 输 入:g_uiprntDotLineDealed
* g_ucTSprntLinePrinted
*
* 输 出:无
*
* 返 回:DISABLE_PRNT_DATA 仅继续处理数据
* ENABLE_PRNT_DATA 处理数据同时执行打印操作
*
******************************************************
*/
INT1 bspTSPrntCheckState
(
UINT1 _ucLineSpace /* 热敏打印行间距 */
)
{
if (s_usprntDotLineDealed >= s_usTSprntLinePrinted)
{
if (s_usprntDotLineDealed >=(s_usTSprntLinePrinted + ENABLE_PRNT_LIMIT * _ucLineSpace))
{
return ENABLE_PRNT_DATA;
}
else
{
return DISABLE_PRNT_DATA;
}
}
else
{
if ((s_usTSprntLinePrinted + ENABLE_PRNT_LIMIT * _ucLineSpace)<= (s_usprntDotLineDealed
+ DOTLINE_LIMIT))
{
return ENABLE_PRNT_DATA;
}
else
{
return DISABLE_PRNT_DATA;
}
}
}
/*
******************************************************
*
* 函数名:bspTSPrntSetIntPos
*
* 功 能:热敏打印设置起始位置参数
*
* 输 入:无
*
* 输 出:s_uiprntHoriPosition
* s_ucprntHoriByte
*
* 返 回:SUCCESS----程序处理成功
*
*
******************************************************
*/
INT1 bspTSPrntSetIntPos
(
UINT1 _ucStartPos /* 热敏打印确定横向起始位置(精确mm) */
)
{
if (_ucStartPos >= TS_ONE_LINE_BYTE)
{
_ucStartPos = 0;
}
s_usprntHoriPosition = _ucStartPos * 8;
if (g_ucPrntOrderMode)
{
/* 阿拉伯字符右对齐打印 */
s_ucprntHoriByte = TS_ONE_LINE_BYTE - 1 - _ucStartPos;
s_ucprntBitInByte = 0x01;
}
else
{
s_ucprntHoriByte = _ucStartPos;
s_ucprntBitInByte = 0x80;
}
return SUCCESS;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -