?? print.c.bak
字號:
#include <api.h>
#include <console.h>
#include "string.h"
#include "stdio.h"
#include "Ppos.h"
////************打印機的初始化*************************/
//unsigned char InitPrinter[2] = {0x1B, 0x40};//初始化打印機,清除緩沖區
//unsigned char LeftPrinterHead[2] = {0x1B, 0x3C};//打印頭置左
//unsigned char PrintNoFeed[1] = {0x0D};//打印緩沖區并送紙
//unsigned char PrintAndFeed[1] = {0x0A};//打印緩沖區并送紙
//unsigned char SetPrinterModeEN[3] = {0x1B, 0x21, 0x00};//設置英文打印模式
//unsigned char SetPrinterTitle[3] = {0x1C, 0x21, 0x08};//設置中文標題打印模式
//unsigned char SetPrinterModeHZ[3] = {0x1C, 0x21, 0x00};//設置中文打印模式
//unsigned char MoveToNextHori[1] = {0x09};//移動到下一個表格位置
//unsigned char SetHoriPosition[35] = {0x1B, 0x44, 0x00, 0x00, 0x00};//設置表格
//unsigned char SetEmphasized[3] = {0x1B, 0x44, 0x00};//設置粗體,0為關閉,1為打開
//unsigned char PrintAndFeedL[3] = {0x1B, 0x4A, 0x00};//打印并進紙6+24*line
//unsigned char PrintAndRFeedL[3] = {0x1B, 0x4B, 0x00};//打印并退紙6+24*line
//unsigned char SetPanelButton[4] = {0x1b, 0x63, 0x35, 0x00};//面板按鈕是否有效,0為有效,1為無效
//unsigned char PrintAndFeedN[3] = {0x1B, 0x64, 0x00};//打印并進紙N行
//unsigned char PrintAndRFeedN[3] = {0x1B, 0x65, 0x00};//打印并退紙N行
//unsigned char CutPaper1[2] = {0x1B, 0x69};//部分切紙1
//unsigned char CutPaper2[2] = {0x1B, 0x6d};//部分切紙2
//unsigned char GetPrintStatus[2] = {0x1B, 0x76};//獲取打印機狀態
//unsigned char SetPrintDir[3] = {0x1B, 0x7B, 0x00};//設置進紙方向,0為向下,1為向上
//unsigned char EnableSelectHZ[2] = {0x1C, 0x26};//選擇漢字打印
//unsigned char DisableSelectHZ[2] = {0x1C, 0x2E};//取消漢字打印
//unsigned char SetHZMode[3] = {0x1C, 0x43, 0x01};//設置漢字編碼方式
//unsigned char SetHZSpace[4] = {0x1C, 0x53, 0x04, 0x04};//選擇漢字間距
//unsigned char SetQuadrupleHZ[3] = {0x1C, 0x57, 0x00};//設置四倍體積漢字,0為關閉,1為打開
//unsigned char SetPrinterColor[3] = {0x1B, 0x72, 0x00};//設置打印色彩,0為黑色,1為紅色
//************打印機的初始化************************
unsigned char InitPrinter[2] = {0x1B, 0x40};//初始化打印機,清除緩沖區
//unsigned char LeftPrinterHead[2] = {0x1B, 0x3C};//打印頭置左
//unsigned char PrintNoFeed[1] = {0x0D};//打印緩沖區并送紙
unsigned char PrintAndFeed[1] = {0x0A};//打印緩沖區并送紙
unsigned char SetPrinterModeEN[3] = {0x1B, 0x21, 0x00};//設置英文打印模式
unsigned char SetPrinterTitle[3] = {0x1B, 0x21, 0x10};//設置中文標題打印模式
unsigned char SetPrinterModeHZ[3] = {0x1B, 0x21, 0x00};//設置中文打印模式
//unsigned char MoveToNextHori[1] = {0x09};//移動到下一個表格位置
//unsigned char SetHoriPosition[35] = {0x1B, 0x44, 0x00, 0x00, 0x00};//設置表格
//unsigned char SetEmphasized[3] = {0x1B, 0x44, 0x00};//設置粗體,0為關閉,1為打開
unsigned char PrintAndFeedL[3] = {0x1B, 0x4A, 0x00};//打印并進紙6+24*line
//unsigned char PrintAndRFeedL[3] = {0x1B, 0x4B, 0x00};//打印并退紙6+24*line
//unsigned char SetPanelButton[4] = {0x1b, 0x63, 0x35, 0x00};//面板按鈕是否有效,0為有效,1為無效
//unsigned char PrintAndFeedN[3] = {0x1B, 0x64, 0x00};//打印并進紙N行
//unsigned char PrintAndRFeedN[3] = {0x1B, 0x65, 0x00};//打印并退紙N行
unsigned char CutPaper1[2] = {0x1B, 0x69};//部分切紙1
unsigned char CutPaper2[2] = {0x1B, 0x6d};//部分切紙2
unsigned char GetPrintStatus[2] = {0x1B, 0x76};//獲取打印機狀態
//unsigned char SetPrintDir[3] = {0x1B, 0x7B, 0x00};//設置進紙方向,0為向下,1為向上
//unsigned char EnableSelectHZ[2] = {0x1C, 0x26};//選擇漢字打印
//unsigned char DisableSelectHZ[2] = {0x1C, 0x2E};//取消漢字打印
//unsigned char SetHZMode[3] = {0x1C, 0x43, 0x01};//設置漢字編碼方式
//unsigned char SetHZSpace[4] = {0x1C, 0x53, 0x04, 0x04};//選擇漢字間距
//unsigned char SetQuadrupleHZ[3] = {0x1C, 0x57, 0x00};//設置四倍體積漢字,0為關閉,1為打開
//unsigned char SetPrinterColor[3] = {0x1B, 0x72, 0x00};//設置打印色彩,0為黑色,1為紅色
extern struct sttMenu stPrintReport;
void OpenPrinter()
{
typ_msg_word msg_buffer;
typ_UART_stat_word Ustat;
unsigned char recBuf[1024];
unsigned char sendBuf[6];
unsigned short checksum=0,recLen=0;
SPT_set(64);
UART_disconnect();
msg_buffer.s_word = sys_msg(SM_STAY_AWAKE);
UART_init(UART_ON | UART_232_ON | UART_8_DATA_BITS | UART_BAUD_9600);
UART_fcntl(UART_fcntl(UART_F_INQ) | UART_F_NO_CTS);
delay_n_ms(3);
SPT_set(64);
}
void ClosePrinter()
{
typ_UART_stat_word Ustat;
Ustat.l_word = UART_stat();
if (Ustat.bits.UART_on)
{
UART_init(UART_OFF);
sys_msg(SM_GOTO_SLEEP);
}
}
void InitlizePrinter(void)
{
unsigned int status;
unsigned char i;
UART_puts(InitPrinter, 2);
UART_puts(SetPrinterModeEN, 3);
UART_puts(SetPrinterModeHZ, 3);
//UART_puts(SetHZMode, 2);
//UART_puts(SetHZSpace, 4);
//UART_puts(EnableSelectHZ, 2);
// for(i=0;i<2;i++)
// UART_send_char(*(InitPrinter+i));
//
// for(i=0;i<3;i++)
// UART_send_char(*(SetPrinterModeEN+i));
//
// for(i=0;i<3;i++)
// UART_send_char(*(SetPrinterModeHZ+i));
//
// for(i=0;i<2;i++)
// UART_send_char(*(SetHZMode+i));
//
// for(i=0;i<4;i++)
// UART_send_char(*(SetHZSpace+i));
//
// for(i=0;i<2;i++)
// UART_send_char(*(EnableSelectHZ+i));
}
void Print_Cut(unsigned char mode)
{
unsigned int status;
unsigned char i;
if(mode==0)
UART_puts(CutPaper1, 2);
else
UART_puts(CutPaper2, 2);
// for(i=0;i<2;i++)
// {
// if(mode==0)
// UART_send_char(*(CutPaper1+i));
// else
// UART_send_char(*(CutPaper2+i));
// }
}
//void Printer_CreateTable(unsigned char TableNum, unsigned char *TableWidth)
//{
// unsigned int status;
// unsigned char i;
// unsigned char buf[35];
//
// buf[0] = SetHoriPosition[0];
// buf[1] = SetHoriPosition[1];
// memcpy(buf+2, TableWidth, TableNum);
// buf[2+TableNum] = 0x00;
//
// UART_puts(buf, 3+TableNum);
//// for(i=0;i<3+TableNum;i++)
//// UART_send_char(*(buf+i));
//
//}
//
//void Printer_MoveTable(unsigned char n)
//{
// unsigned int status;
// unsigned char i;
//
// for(i=0;i<n;i++)
// UART_send_char(*(MoveToNextHori));
//}
void Print_Line(unsigned char *ptr,unsigned char size) //在一行中打印
{
unsigned int status;
unsigned char i;
// if((mode>>1)&0x01 == 1)
// {
// UART_puts(EnableSelectHZ, 2);
//// for(i=0;i<2;i++)
//// UART_send_char(*(EnableSelectHZ+i));
// }
// else
// {
// UART_puts(DisableSelectHZ, 2);
//// for(i=0;i<2;i++)
//// UART_send_char(*(DisableSelectHZ+i));
// }
UART_puts(ptr, size);
// for(i=0;i<size;i++)
// {
// UART_send_char(*(ptr+i)); //發送要打印數據處理
// }
// if(mode&0x01 == 1)
UART_send_char(*(PrintAndFeed));
// else
// UART_send_char(*(PrintNoFeed));
}
void Print_Title(unsigned char *title, unsigned char size)
{
unsigned int status;
unsigned char i;
UART_puts(SetPrinterTitle, 3);
// for(i=0;i<3;i++)
// {
// UART_send_char(*(SetPrinterTitle+i));
// }
// Print_SetColor(1);
Print_Line(title, size);
// Print_SetColor(0);
UART_puts(SetPrinterModeHZ, 3);
// for(i=0;i<3;i++)
// {
// UART_send_char(*(SetPrinterModeHZ+i));
// }
}
//void Print_SetColor(unsigned char color)
//{
// unsigned int status;
// unsigned char i;
//
// if(color==0)
// SetPrinterColor[2] = 0;
// else
// SetPrinterColor[2] = 1;
// UART_puts(SetPrinterColor, 3);
//// for(i=0;i<3;i++)
//// {
//// UART_send_char(*(SetPrinterColor+i));
//// }
//}
void PrintTable()
{
unsigned char buf[40],i;
OpenPrinter();
InitlizePrinter();
Print_Line(stPrintReport.pTitle, 17);
for(i=0;i<stPrintReport.cItemNum;i++)
{
Print_Line(stPrintReport.ppItem[i], 17);
}
ClosePrinter();
// if(mode==0)
// {
// buf[0] = 1;
// buf[1] = 7;
// Printer_CreateTable(2, buf);
// Printer_MoveTable(2);
// Print_Title((unsigned char*)"", 22);
//
// Print_SetColor(1);
// Print_Line((unsigned char*)"=================================", 33, 1);
// Print_SetColor(0);
//
// buf[0] = 1;
// buf[1] = 7;
// Printer_CreateTable(2, buf);
// Printer_MoveTable(1);
// Print_Line((unsigned char*)"客戶卡號", 8, 2);
// Printer_MoveTable(2);
// memset(buf, 0 ,40);
// sprintf(buf, ": %012ld", CardInfo.CardNo);
// Print_Line(buf, 14, 1);
//
// buf[0] = 1;
// buf[1] = 7;
// buf[2] = 18;
// buf[3] = 22;
// Printer_CreateTable(4, buf);
// Printer_MoveTable(1);
// Print_Line((unsigned char*)"充值機號", 8, 2);
// Printer_MoveTable(2);
// memset(buf, 0 ,40);
// buf[20] = DeviceNo[3];
// buf[21] = DeviceNo[2];
// buf[22] = DeviceNo[1];
// buf[23] = DeviceNo[0];
// sprintf(buf, ": %8s", BCD2ASC(buf+20,4));
// Print_Line(buf, 10, 0);
// Printer_MoveTable(3);
// Print_Line((unsigned char*)"流水號", 6, 2);
// Printer_MoveTable(4);
// memset(buf, 0 ,40);
// sprintf(buf, ": %08ld", TradeCounter);
// Print_Line(buf, 10, 1);
//
// buf[0] = 1;
// buf[1] = 7;
// buf[2] = 17;
// Printer_CreateTable(3, buf);
// Printer_MoveTable(1);
// Print_Line((unsigned char*)"交易原額", 8, 2);
// Printer_MoveTable(2);
// memset(buf, 0 ,40);
// if(ChargeMode2 ==MODE_CHARGE_INC)
// {
// sprintf(buf, ": %7.2f", ((float)(CardInfo.Money-CardInfo.hChargeMoney))/100);
// }
// else
// {
// sprintf(buf, ": %7.2f", ((float)(CardInfo.Money+CardInfo.hChargeMoney))/100);
// }
// for(i=10;i>1;i--)
// {
// if(buf[i]==' ')
// {
// buf[i] = '*';
// break;
// }
// }
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -