From 9c0e674f78b8c10047d43dfa02443656a3522a6e Mon Sep 17 00:00:00 2001 From: cuu Date: Thu, 27 May 2021 13:47:34 +0800 Subject: [PATCH] tested the read_adc with thermal_printer --- Code/thermal_printer/config.h | 2 +- Code/thermal_printer/printer.c | 22 +++++++++++++++++----- 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/Code/thermal_printer/config.h b/Code/thermal_printer/config.h index aa91b11..a801f5c 100644 --- a/Code/thermal_printer/config.h +++ b/Code/thermal_printer/config.h @@ -114,7 +114,7 @@ #define TempNominal 25 #define ADCResolution 1024 #define SeriesResistor 30000 -#define NumSamples 10 +#define NumSamples 1 #define KELVIN 1 #define CELSIUS 0 diff --git a/Code/thermal_printer/printer.c b/Code/thermal_printer/printer.c index ca9fff8..2075b9c 100644 --- a/Code/thermal_printer/printer.c +++ b/Code/thermal_printer/printer.c @@ -22,6 +22,7 @@ uint8_t as; static unsigned int printer_vps_time; static uint8_t printer_vps_last_status; +static uint8_t printer_temp_check; void printer_send_data8(uint8_t w) { @@ -62,15 +63,25 @@ uint8_t IsPaper() else {status = NO_PAPER; PRINTF("Error:NO PAPER\n"); } DISABLE_PEM; + + if(printer_temp_check > 20) { + tmp = temperature(); + + if (tmp >= HOT){ + PRINTF("Printer too Hot\n"); + status |= HOT_PRINTER; + } + + printer_temp_check = 0; + + }else { + printer_temp_check++; + } + }else { status = printer_vps_last_status; } - tmp = temperature(); - if (tmp >= HOT){ - PRINTF("Printer too Hot\n"); - status |= HOT_PRINTER; - } printer_vps_last_status = status; printer_vps_time = millis(); @@ -123,6 +134,7 @@ uint8_t header_init() { printer_vps_time = 0; printer_vps_last_status = IS_PAPER; + printer_temp_check= 0; }