优化字符打印框架,实现字符累计追加和换行功能
This commit is contained in:
parent
6ffa8a56ef
commit
12dbd4e5d1
@ -122,6 +122,12 @@ void BSP_GPIO_Init(void)
|
|||||||
gpio_set_level(VH_EN.pin_num,VH_EN.state);
|
gpio_set_level(VH_EN.pin_num,VH_EN.state);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Set_gpio_state(gpio_state_t* GPIO,uint32_t level)
|
||||||
|
{
|
||||||
|
GPIO->state = level;
|
||||||
|
gpio_set_level(GPIO->pin_num,GPIO->state);
|
||||||
|
}
|
||||||
|
|
||||||
//步进电机驱动部分
|
//步进电机驱动部分
|
||||||
uint8_t motorTable[8][4] =
|
uint8_t motorTable[8][4] =
|
||||||
{
|
{
|
||||||
|
|||||||
@ -14,7 +14,6 @@ EXT_RAM_BSS_ATTR uint8_t uheap_1[1024*512];
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Receive_data_t Rev_USB_data = {
|
Receive_data_t Rev_USB_data = {
|
||||||
.type = USB,
|
.type = USB,
|
||||||
.read = 0,
|
.read = 0,
|
||||||
@ -23,10 +22,20 @@ Receive_data_t Rev_USB_data = {
|
|||||||
.max_size = 1024*512,
|
.max_size = 1024*512,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
typedef struct _Heat_block
|
||||||
|
{
|
||||||
|
uint16_t hight;
|
||||||
|
uint8_t PosX;
|
||||||
|
uint16_t PosY;
|
||||||
|
char* Heat_block_buff;
|
||||||
|
}Heat_block_t;
|
||||||
|
|
||||||
|
|
||||||
typedef struct _Heat_page_t{
|
typedef struct _Heat_page_t{
|
||||||
|
|
||||||
char* Heat_Page_buff;
|
char* Heat_Page_buff;
|
||||||
char* Heat_block_buff;
|
char* Heat_block_buff;
|
||||||
|
Heat_block_t Heat_block;
|
||||||
uint8_t Heat_line_buf[TH_WIDTH];
|
uint8_t Heat_line_buf[TH_WIDTH];
|
||||||
uint32_t Heat_Read;
|
uint32_t Heat_Read;
|
||||||
uint32_t Heat_Write;
|
uint32_t Heat_Write;
|
||||||
@ -40,9 +49,31 @@ Heat_page_t Heat58MM = {
|
|||||||
.Heat_Initial_time = 300,
|
.Heat_Initial_time = 300,
|
||||||
.Heat_Read = 0,
|
.Heat_Read = 0,
|
||||||
.Heat_Write = 0,
|
.Heat_Write = 0,
|
||||||
|
.Heat_block.PosX=0,
|
||||||
|
.Heat_block.PosY=0,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
typedef struct _fonttype
|
||||||
|
{
|
||||||
|
uint8_t font_id;
|
||||||
|
uint8_t width;
|
||||||
|
uint8_t hight;
|
||||||
|
uint16_t char_size;
|
||||||
|
uint32_t file_size;
|
||||||
|
char* file_buff;
|
||||||
|
}FontType_t;
|
||||||
|
|
||||||
|
|
||||||
|
FontType_t FontASCII_24x24 = {
|
||||||
|
.font_id = 3,
|
||||||
|
.width = 24,
|
||||||
|
.hight = 24,
|
||||||
|
.char_size = 72,
|
||||||
|
.file_size = 9144,
|
||||||
|
.file_buff = Font24x24ASCII,
|
||||||
|
};
|
||||||
|
|
||||||
/********************************* 定义系统全局变量 *****************************/
|
/********************************* 定义系统全局变量 *****************************/
|
||||||
|
|
||||||
|
|
||||||
@ -59,7 +90,7 @@ EventGroupHandle_t Printer_group;
|
|||||||
SemaphoreHandle_t Spi_send_end;
|
SemaphoreHandle_t Spi_send_end;
|
||||||
SemaphoreHandle_t Motor_is_Running;
|
SemaphoreHandle_t Motor_is_Running;
|
||||||
|
|
||||||
extern const char Font24x24ASCII[];
|
|
||||||
|
|
||||||
void Sys_heap_Init(void)
|
void Sys_heap_Init(void)
|
||||||
{
|
{
|
||||||
@ -78,25 +109,58 @@ void Fill_block2Page_Buff(uint16_t SetPosY,uint16_t hight,uint8_t* block_buff)
|
|||||||
Heat58MM.Max_hight = Total_height;
|
Heat58MM.Max_hight = Total_height;
|
||||||
}
|
}
|
||||||
Heat58MM.Heat_Write = Heat58MM.Max_hight;
|
Heat58MM.Heat_Write = Heat58MM.Max_hight;
|
||||||
|
Heat58MM.Heat_block.PosX = 0;
|
||||||
|
Heat58MM.Heat_block.PosY = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Fill_char2block_Buff(char ch,uint8_t SetPosX,uint16_t SetPosY,FontType_t font)
|
||||||
|
{
|
||||||
|
int i=0;
|
||||||
|
uint8_t* Rebuff;
|
||||||
|
Rebuff = malloc(font.char_size+12);
|
||||||
|
memcpy(&Rebuff[0],&font.file_buff[ch*font.char_size],font.char_size);
|
||||||
|
for(i=0;i<font.hight;i++)
|
||||||
|
{
|
||||||
|
memcpy(&Heat58MM.Heat_block_buff[(SetPosY+i)*TH_ACTUAL_WIDTH+SetPosX],&Rebuff[i*(font.width/8)],(font.width/8));
|
||||||
|
}
|
||||||
|
|
||||||
|
free(Rebuff);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Addchar2PrintArea(char ch)
|
||||||
|
{
|
||||||
|
Fill_char2block_Buff(ch,Heat58MM.Heat_block.PosX,Heat58MM.Heat_block.PosY,FontASCII_24x24);
|
||||||
|
Heat58MM.Heat_block.PosX += FontASCII_24x24.width/8;
|
||||||
|
if(Heat58MM.Heat_block.PosX >= TH_ACTUAL_WIDTH ||ch == '\n')
|
||||||
|
{
|
||||||
|
Heat58MM.Heat_block.PosX = 0;
|
||||||
|
Heat58MM.Heat_block.PosY += FontASCII_24x24.hight;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Fill_Page_Buff(char ch)
|
void Fill_Page_Buff(char ch)
|
||||||
{
|
{
|
||||||
int i=0,j=0;
|
// int i=0,j=0;
|
||||||
uint8_t Rebuff[72];
|
// uint8_t Rebuff[72];
|
||||||
memcpy(&Rebuff[0],&Font24x24ASCII[ch*72],72);
|
// memcpy(&Rebuff[0],&Font24x24ASCII[ch*72],72);
|
||||||
memset(&Heat58MM.Heat_block_buff[0],0x00,TH_ACTUAL_WIDTH*24);
|
// memset(&Heat58MM.Heat_block_buff[0],0x00,TH_ACTUAL_WIDTH*24);
|
||||||
// ESP_LOGI(TAG, "Font24x24ASCII[%d]: %X %X %X",0x41,)
|
// // ESP_LOGI(TAG, "Font24x24ASCII[%d]: %X %X %X",0x41,)
|
||||||
for(i=0;i<24;i++)
|
// for(i=0;i<24;i++)
|
||||||
{
|
// {
|
||||||
for(j=0;j<16;j++)
|
// for(j=0;j<16;j++)
|
||||||
{
|
// {
|
||||||
memcpy(&Rebuff[0],&Font24x24ASCII[(ch+j)*72],72);
|
// memcpy(&Rebuff[0],&Font24x24ASCII[(ch+j)*72],72);
|
||||||
memcpy(&Heat58MM.Heat_block_buff[i*TH_ACTUAL_WIDTH+j*3],&Rebuff[i*3],3);
|
// memcpy(&Heat58MM.Heat_block_buff[i*TH_ACTUAL_WIDTH+j*3],&Rebuff[i*3],3);
|
||||||
}
|
// }
|
||||||
|
|
||||||
|
// }
|
||||||
|
// Fill_char2block_Buff(ch,3,FontASCII_24x24);
|
||||||
|
for(int i=0;i<30;i++)
|
||||||
|
{
|
||||||
|
Addchar2PrintArea('A'+i);
|
||||||
|
// Addchar2PrintArea('\n');
|
||||||
}
|
}
|
||||||
Fill_block2Page_Buff(50,24*50,(uint8_t*)&Heat58MM.Heat_block_buff[0]);
|
Fill_block2Page_Buff(10,Heat58MM.Heat_block.PosY+24*3,(uint8_t*)&Heat58MM.Heat_block_buff[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -261,12 +325,9 @@ void Printer_Heat_task(void *pvParameter)
|
|||||||
break;
|
break;
|
||||||
case EVENT_Heat_Begin:
|
case EVENT_Heat_Begin:
|
||||||
//开始加热
|
//开始加热
|
||||||
STB.state = 1;
|
Set_gpio_state(&STB,1);
|
||||||
gpio_set_level(STB.pin_num,STB.state);
|
|
||||||
Set_heat_timer_value(400*1);
|
Set_heat_timer_value(400*1);
|
||||||
// Motor_GO(1);
|
|
||||||
// //ESP_LOGI(TAG,"Heat_EVENT:%d",PrnDotRd);
|
|
||||||
// xSemaphoreGive(Spi_send_end);
|
|
||||||
xEventGroupClearBits(Printer_group,EVENT_Heat_Begin);
|
xEventGroupClearBits(Printer_group,EVENT_Heat_Begin);
|
||||||
break;
|
break;
|
||||||
case EVENT_SPI_SEND_Begin:
|
case EVENT_SPI_SEND_Begin:
|
||||||
@ -283,8 +344,7 @@ void Printer_Heat_task(void *pvParameter)
|
|||||||
break;
|
break;
|
||||||
case EVENT_Heat_Done:
|
case EVENT_Heat_Done:
|
||||||
// ESP_LOGI(TAG,"Event Heat_Done");
|
// ESP_LOGI(TAG,"Event Heat_Done");
|
||||||
STB.state = 0;
|
Set_gpio_state(&STB,0);
|
||||||
gpio_set_level(STB.pin_num,STB.state);
|
|
||||||
Motor_GO(1);
|
Motor_GO(1);
|
||||||
Heat_Step+=1;
|
Heat_Step+=1;
|
||||||
if(Heat_Step>3)
|
if(Heat_Step>3)
|
||||||
@ -313,6 +373,7 @@ void Printer_Heat_task(void *pvParameter)
|
|||||||
case EVENT_Motor_Sleep:
|
case EVENT_Motor_Sleep:
|
||||||
ESP_LOGI(TAG,"EVENT_Motor_Sleep");
|
ESP_LOGI(TAG,"EVENT_Motor_Sleep");
|
||||||
Motor_GO(0xff);
|
Motor_GO(0xff);
|
||||||
|
Set_gpio_state(&STB,0);
|
||||||
xEventGroupClearBits(Printer_group,EVENT_Motor_Sleep);
|
xEventGroupClearBits(Printer_group,EVENT_Motor_Sleep);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
|||||||
@ -81,7 +81,10 @@ extern EventGroupHandle_t Printer_group;
|
|||||||
extern spi_device_handle_t Printer_spi;
|
extern spi_device_handle_t Printer_spi;
|
||||||
extern SemaphoreHandle_t SysTick_queue;
|
extern SemaphoreHandle_t SysTick_queue;
|
||||||
|
|
||||||
|
extern const char Font24x24ASCII[];
|
||||||
|
|
||||||
extern void BSP_GPIO_Init(void);
|
extern void BSP_GPIO_Init(void);
|
||||||
|
extern void Set_gpio_state(gpio_state_t* GPIO,uint32_t level);
|
||||||
extern uint8_t Motor_GO(uint8_t DIR);
|
extern uint8_t Motor_GO(uint8_t DIR);
|
||||||
extern void Printer_run_init();
|
extern void Printer_run_init();
|
||||||
extern void Printer_Bsp_Init(void);
|
extern void Printer_Bsp_Init(void);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user