From 167b2f520e648327e267cb49a70b628198b790e0 Mon Sep 17 00:00:00 2001 From: cuu Date: Sat, 21 May 2022 05:57:03 +0000 Subject: [PATCH] test thermal code --- .../thermal_printer/devterm_thermal_printer.c | 38 +++++++++---------- Code/thermal_printer/printer.c | 36 +++++++++++++----- Code/thermal_printer/printer.h | 4 +- 3 files changed, 48 insertions(+), 30 deletions(-) diff --git a/Code/thermal_printer/devterm_thermal_printer.c b/Code/thermal_printer/devterm_thermal_printer.c index a7fa540..201e30f 100644 --- a/Code/thermal_printer/devterm_thermal_printer.c +++ b/Code/thermal_printer/devterm_thermal_printer.c @@ -259,7 +259,7 @@ NULL cfg->img->revert_bits = 0; cfg->align = ALIGN_LEFT; - feed_pitch1(15, cfg->orient); + print_lines8(NULL,15, cfg->orient); cfg->align = ALIGN_CENTER; /* //selftest1 @@ -285,7 +285,7 @@ NULL } cfg->align = ALIGN_LEFT; - feed_pitch1(32, cfg->orient); + print_lines8(NULL,32, cfg->orient); //--------------------------------------------- @@ -308,7 +308,7 @@ NULL } parse_serial_stream(cfg, 10); // Serial.println(); - feed_pitch1(48, cfg->orient); + print_lines8(NULL,48, cfg->orient); } printer_set_font_mode(cfg, FONT_MODE_0); @@ -328,7 +328,7 @@ NULL } parse_serial_stream(cfg, 10); // Serial.println(); - feed_pitch1(48, cfg->orient); + print_lines8(NULL,48, cfg->orient); printer_set_font_mode(cfg, FONT_MODE_0); printer_set_font(cfg, 0); @@ -347,7 +347,7 @@ NULL } parse_serial_stream(cfg, 10); // Serial.println(); - feed_pitch1(28, cfg->orient); + print_lines8(NULL,28, cfg->orient); //------------------------------------------- @@ -368,7 +368,7 @@ NULL //------------------------------------------ label_print_f(cfg, "Firmware version:", 0.1, ""); - feed_pitch1(cfg->font->height, cfg->orient); + print_lines8(NULL,cfg->font->height, cfg->orient); //-------------------------------------------------------------- printer_set_font_mode(cfg, FONT_MODE_0); printer_set_font(cfg, 0); @@ -383,7 +383,7 @@ NULL //----------------------------------- // grid - /* + ENABLE_VH; for(ch = 0;ch <16;ch++){ if(ch%2==0) j = 0xff; @@ -401,9 +401,9 @@ NULL print_dots_8bit_split(cfg,(uint8_t*)buf,48); } } - */ + DISABLE_VH; //-------------------------------------------------------- - feed_pitch1(cfg->font->height * 2, cfg->orient); + print_lines8(NULL,cfg->font->height * 2, cfg->orient); } void printer_set_font_mode(CONFIG *cfg, int mode) { @@ -499,16 +499,16 @@ void parse_cmd(CONFIG *cfg, uint8_t *cmd, uint8_t cmdidx) { // ESC j n if (cmd[0] == ASCII_ESC && cmd[1] == 0x4a) { - if (print_lines8(cfg) == 0) { - feed_pitch1(cmd[2], cfg->orient); + if (print_lines8(cfg,0,0) == 0) { + print_lines8(NULL,cmd[2], cfg->orient); } reset_cmd(); } // ESC d n if (cmd[0] == ASCII_ESC && cmd[1] == 0x64) { - if (print_lines8(cfg) == 0) { - feed_pitch1(cmd[2] * cfg->font->height, cfg->orient); + if (print_lines8(cfg,0,0) == 0) { + print_lines8(NULL,cmd[2] * cfg->font->height, cfg->orient); } reset_cmd(); } @@ -712,14 +712,14 @@ void parse_serial_stream(CONFIG *cfg, uint8_t input_ch) { switch (input_ch) { case ASCII_LF: if (ser_cache.idx == 0) { - feed_pitch1(cfg->font->height, cfg->orient); + print_lines8(NULL,cfg->font->height, cfg->orient); } - print_lines8(cfg); + print_lines8(cfg,0,0); reset_cmd(); break; case ASCII_FF: - print_lines8(cfg); + print_lines8(cfg,0,0); reset_cmd(); break; case ASCII_DC2: @@ -777,9 +777,9 @@ void parse_serial_stream(CONFIG *cfg, uint8_t input_ch) { if (a >= MAX_DOTS) // got enough points to print { if (cfg->font->mode == FONT_MODE_1 && cfg->face != NULL ) { - print_lines_ft(cfg); + print_lines_ft(cfg,0,0); } else { - print_lines8(cfg); + print_lines8(cfg,0,0); } reset_cmd(); } @@ -840,7 +840,7 @@ void print_lowpower(CONFIG *cfg) { parse_serial_stream(cfg, 10); reset_cmd(); - feed_pitch1(128, cfg->orient); + print_lines8(NULL,128, cfg->orient); printer_set_font(cfg, 0); PRINTF("%s\n", msg); diff --git a/Code/thermal_printer/printer.c b/Code/thermal_printer/printer.c index dd2ca8a..75be66c 100644 --- a/Code/thermal_printer/printer.c +++ b/Code/thermal_printer/printer.c @@ -200,9 +200,11 @@ uint8_t feed_pitch1(uint64_t lines, uint8_t forward_backward) { restor &= 0x01; if (lines > 0) { + /* MOTOR_ENABLE1; MOTOR_ENABLE2; ENABLE_VH; + */ while (lines > 0) { motor_stepper_pos2(pos); /* 0.0625mm */ @@ -213,10 +215,11 @@ uint8_t feed_pitch1(uint64_t lines, uint8_t forward_backward) { lines--; } + /* MOTOR_DISABLE1; MOTOR_DISABLE2; DISABLE_VH; - + */ } else { return ERROR_FEED_PITCH; } @@ -268,7 +271,6 @@ void print_dots_8bit(CONFIG *cfg, uint8_t *Array, uint8_t characters, uint8_t i = 0, y = 0, MAX = MAXPIXELS; uint8_t blank; - ENABLE_VH; if (cfg->align == 0) { while ((i < characters) && (i < MAX)) { @@ -325,7 +327,6 @@ void print_dots_8bit(CONFIG *cfg, uint8_t *Array, uint8_t characters, feed_pitch1(feed_num, cfg->orient); - DISABLE_VH; return; } @@ -414,7 +415,8 @@ uint16_t get_serial_cache_font_width(CONFIG *cfg) { } // print with freetype font dots glyph -uint8_t print_lines_ft(CONFIG *cfg) { +uint8_t print_lines_ft(CONFIG *cfg,int lines,int bf) { + uint8_t i, j, k; int8_t w; uint8_t dot_line_data[MAXPIXELS]; @@ -427,7 +429,13 @@ uint8_t print_lines_ft(CONFIG *cfg) { int8_t left = ser_cache.idx; uint8_t rv; - + + if(cfg == NULL && lines > 0) { + ENABLE_VH; + feed_pitch1(lines,bf); + DISABLE_VH; + return 0; + } line_bits = cfg->margin.width; dot_line_idx = line_bits / 8; dot_line_bitsidx = line_bits % 8; @@ -587,10 +595,18 @@ uint8_t print_lines_ft(CONFIG *cfg) { } } -uint8_t print_lines8(CONFIG *cfg) { +uint8_t print_lines8(CONFIG *cfg,int lines,int backforward) { + + + if(lines > 0 && cfg == NULL ){ + ENABLE_VH; + feed_pitch1(lines,backforward); + DISABLE_VH; + return 0; + } if (cfg->font->mode == FONT_MODE_1 && cfg->face!=NULL) { - return print_lines_ft(cfg); + return print_lines_ft(cfg,0,0); } uint8_t i, j, k; int8_t w; @@ -635,6 +651,7 @@ uint8_t print_lines8(CONFIG *cfg) { lastj = 0; // DEBUG("left",left); + ENABLE_VH; while (left > 0) { i = lastidx; while (row < current_font.height) { @@ -737,7 +754,7 @@ uint8_t print_lines8(CONFIG *cfg) { // Serial.println("print ever"); free(data); - + DISABLE_VH; return rv; } @@ -755,7 +772,7 @@ uint8_t print_image8(CONFIG *cfg) { addr = 0; rv = IsPaper(); - + ENABLE_VH; while (y < height) { x = 0; while (x < cfg->img->width) { @@ -782,6 +799,7 @@ uint8_t print_image8(CONFIG *cfg) { cfg->img->num = 0; cfg->img->idx = 0; cfg->img->width = 0; + DISABLE_VH; return rv; } diff --git a/Code/thermal_printer/printer.h b/Code/thermal_printer/printer.h index b3c1269..7cc9344 100644 --- a/Code/thermal_printer/printer.h +++ b/Code/thermal_printer/printer.h @@ -31,8 +31,8 @@ uint16_t read_adc(char *); uint16_t temperature(); int glob_file(char *); uint16_t get_serial_cache_font_width(CONFIG *); -uint8_t print_lines_ft(CONFIG *); -uint8_t print_lines8(CONFIG *); +uint8_t print_lines_ft(CONFIG *,int ,int); +uint8_t print_lines8(CONFIG *,int,int); uint8_t invert_bit(uint8_t a);