minor mod for trackball

add read_adc to read temperature for thermal_printer
This commit is contained in:
cuu
2021-05-27 13:28:13 +08:00
parent c626e1f797
commit 46944be3ce
5 changed files with 30 additions and 7 deletions

View File

@@ -333,6 +333,26 @@ void print_dots_8bit(CONFIG*cfg,uint8_t *Array, uint8_t characters,uint8_t feed_
return;
}
uint16_t read_adc() {
long ret;
char c[16];
FILE *fptr;
if ((fptr = fopen(ADC_FILE, "r")) == NULL) {
printf("Error! ADC File cannot be opened\n");
// Program exits if the file pointer returns NULL.
return 0;
}
fscanf(fptr, "%[^\n]", c);
//printf("Data from the file:\n%s", c);
fclose(fptr);
ret = strtol(c, NULL, 10);
//printf("the number ret %d\n",ret);
return (uint16_t)ret;
}
uint16_t temperature() {
@@ -344,7 +364,8 @@ uint16_t temperature() {
while(Sample<=NumSamples)
{
ADCSamples += analogRead(THERMISTORPIN);
//ADCSamples += analogRead(THERMISTORPIN); //stm32
ADCSamples += read_adc();
Sample++;
}
//Thermistor Resistance at x Kelvin