(config, sensors)
| 51 | ###################################################################### |
| 52 | |
| 53 | def plot_adc_resolution(config, sensors): |
| 54 | # Temperature list |
| 55 | all_temps = [float(i) for i in range(1, 351)] |
| 56 | temps = all_temps[:-1] |
| 57 | # Build plot |
| 58 | fig, (ax1, ax2) = matplotlib.pyplot.subplots(nrows=2, sharex=True) |
| 59 | pullup = config.getfloat('pullup_resistor', 0.) |
| 60 | adc_voltage = config.getfloat('adc_voltage', 0.) |
| 61 | ax1.set_title("Temperature Sensor (pullup=%.0f, adc_voltage=%.3f)" |
| 62 | % (pullup, adc_voltage)) |
| 63 | ax1.set_ylabel('ADC') |
| 64 | ax2.set_ylabel('ADC change per 1C') |
| 65 | for sensor in sensors: |
| 66 | sc = config.do_create_sensor(sensor) |
| 67 | adcs = [sc.calc_adc(t) for t in all_temps] |
| 68 | ax1.plot(temps, adcs[:-1], label=sensor, alpha=0.6) |
| 69 | adc_deltas = [abs(adcs[i+1] - adcs[i]) for i in range(len(temps))] |
| 70 | ax2.plot(temps, adc_deltas, alpha=0.6) |
| 71 | fontP = matplotlib.font_manager.FontProperties() |
| 72 | fontP.set_size('x-small') |
| 73 | ax1.legend(loc='best', prop=fontP) |
| 74 | ax2.set_xlabel('Temperature (C)') |
| 75 | ax1.grid(True) |
| 76 | ax2.grid(True) |
| 77 | fig.tight_layout() |
| 78 | return fig |
| 79 | |
| 80 | def plot_resistance(config, sensors): |
| 81 | # Temperature list |
no test coverage detected