diff --git a/cmdline/read-temp.c b/cmdline/read-temp.c index fffcd8b..59f1702 100644 --- a/cmdline/read-temp.c +++ b/cmdline/read-temp.c @@ -166,7 +166,7 @@ int cnt, vid, pid; fprintf(stderr, "%c", rxIndex); } } - usleep(1000); + usleep(100); } } else { usage(); diff --git a/firmware/masterchip/spi_config.h b/firmware/masterchip/spi_config.h index 6cb5a59..adc910d 100644 --- a/firmware/masterchip/spi_config.h +++ b/firmware/masterchip/spi_config.h @@ -1,5 +1,5 @@ -#define SPI_BAUDRATE 10000 +#define SPI_BAUDRATE 30000 #define SPI_MASTER #define SPI_SS_PORT D #define SPI_SS_PIN 7 diff --git a/firmware/slavechip/main.c b/firmware/slavechip/main.c index f0e48d8..ae317b3 100644 --- a/firmware/slavechip/main.c +++ b/firmware/slavechip/main.c @@ -11,6 +11,9 @@ uint16_t bar; uint16_t timertmp; uint16_t temperatures[4]; +int32_t temp_avg_cumul; +int16_t temp_avg_count; + void baz() { foo++; @@ -77,9 +80,21 @@ int __attribute__((noreturn)) main(void) { if(mcpadc_has_new_data()) { temperatures[0] = mcpadc_get_data(); temperatures[2]++; + int16_t temp = temperatures[0]; + temp_avg_cumul += temp; + temp_avg_count += 1; } temperatures[1] = 22; } + SOFTTIMER(2,500){ + int32_t temp = temp_avg_cumul; + temp /= temp_avg_count; + temp_avg_count = 0; temp_avg_cumul = 0; + int32_t nV = (temp * 625); + int32_t mK = nV/39; + + dbgLog("temp: %6li (%li µV, %li mK)\n",temp,nV/1000, mK); + } } }