CDEBUG = -g$(DEBUG)
CWARN = -Wall -Wstrict-prototypes
-CTUNING = -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums -Wl,--relax
+CTUNING = -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums -Wl,--relax -Wl,-u,vfprintf -lprintf_flt -lm
#CEXTRA = -Wa,-adhlns=$(<:.c=.lst)
CFLAGS = $(CDEBUG) $(CDEFS) $(CINCS) -O$(OPT) $(CWARN) $(CSTANDARD) $(CEXTRA) $(CTUNING)
#include <avr/io.h>
#include <avr/eeprom.h>
#include <string.h>
+#include <stdio.h>
#include <usb_serial.h>
#define FIRMWARE_VERSION 0x011
uint8_t rxcnt = 0;
uint8_t rxbuf[7];
-uint8_t txbuf[16];
+uint8_t txbuf[32];
uint8_t conversion_active = 0;
uint8_t channel = 0;
return h-0x61+10;
}
-void send_answer_hex(uint8_t chan, uint16_t v) {
- txbuf[0]='A';//ADC
- txbuf[1]=nib_to_hex(chan,0);
- txbuf[2]='-';//temperature or modi
- txbuf[3]=nib_to_hex(v,3);
- txbuf[4]=nib_to_hex(v,2);
- txbuf[5]=nib_to_hex(v,1);
- txbuf[6]=nib_to_hex(v,0);
- txbuf[7]='\n';
- txbuf[8] = 0;
- usb_serial_write(txbuf,8);
+void send_answer(uint8_t chan, float v) {
+ int nbytes = sprintf(txbuf, "A%1d %.3f\n", chan, v);
+ usb_serial_write(txbuf, nbytes);
usb_serial_flush_output();
}
-
ISR(TIMER0_OVF_vect) {
time++;
asm volatile("wdr");
}
void original_value(uint8_t channel, uint8_t get_value_1, uint8_t get_value_2) {
- uint16_t result = (get_value_1 << 8) | get_value_2;
- send_answer_hex(channel+1,result);
+ uint16_t val = (get_value_1 << 8) | get_value_2;
+ float result = val;
+ result = result / 8.0 / 1000.;
+ send_answer(channel+1, result);
}
void update_eeprom(void) {