Make log output slightly more readable
This commit is contained in:
@@ -144,8 +144,6 @@ int I2C_SetChannel(int channel)
|
||||
{
|
||||
unsigned char crb;
|
||||
|
||||
Info("Switching I2C channel to %d...", channel);
|
||||
|
||||
// Excerpts taken from the PCA9546A datasheet:
|
||||
// https://www.ti.com/lit/ds/symlink/pca9546a.pdf
|
||||
|
||||
|
||||
@@ -24,28 +24,34 @@ int PWM_Init(void)
|
||||
|
||||
// The 328P would allow us to use OCR2A as top but with
|
||||
// 8-bit this gives us a really low duty step size of 2.5%.
|
||||
// Ideal would be two 16-bit timers with two outputs each.
|
||||
|
||||
// Timer2: Fast mode, non-inverting, top=0xFF, prescale /8
|
||||
// Top set to 8000000 (f_cpu) / 8 (prescale) / 25000 (f_pwm) - 1
|
||||
// TCCR2 = BIT(WGM20) | BIT(WGM21) | BIT(COM21) | BIT(CS21);
|
||||
// OCR2 = 40 - 1; // XXX: OCR2A=top OCR2B=duty
|
||||
|
||||
TCCR2 = 0;
|
||||
OCR2 = 0;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Port must be PD4, PD5 or PD7 and the value is
|
||||
// expected to be in the range between 0 and 100
|
||||
// Value in range 0-100 is expected
|
||||
void PWM_SetValue(int port, int value)
|
||||
{
|
||||
int n;
|
||||
|
||||
if (port != PD4 && port != PD5 && port != PD7)
|
||||
if (port != FAN01 && port != FAN02 && port != FAN03)
|
||||
return; // Invalid port
|
||||
|
||||
n = CLAMP(value, 100, 0) * (PWM_CYCLE_TOP / 100.0f);
|
||||
Info("Setting PWM value to %d...", n);
|
||||
|
||||
Info("Setting duty cycle for %s to %d/%d...",
|
||||
(port == FAN01) ? "FAN01" :
|
||||
(port == FAN02) ? "FAN02" :
|
||||
(port == FAN03) ? "FAN03" :
|
||||
"UNKNOWN", n, PWM_CYCLE_TOP);
|
||||
|
||||
switch (port) {
|
||||
case PD4: OCR1B = n; break;
|
||||
|
||||
16
src/main.c
16
src/main.c
@@ -77,26 +77,28 @@ int Init(void)
|
||||
|
||||
void Update(void)
|
||||
{
|
||||
float temp, rhum;
|
||||
float temp[3], rhum[3];
|
||||
short raw[4];
|
||||
|
||||
Info("Reading sensor values...");
|
||||
|
||||
I2C_SetChannel(AHT01);
|
||||
if (I2C_AHT20_Read(&temp, &rhum) == 0)
|
||||
Info("TEMP=%.2fC, RHUM=%.2f%", temp, rhum);
|
||||
I2C_AHT20_Read(&temp[0], &rhum[0]);
|
||||
|
||||
I2C_SetChannel(AHT02);
|
||||
if (I2C_AHT20_Read(&temp, &rhum) == 0)
|
||||
Info("TEMP=%.2fC, RHUM=%.2f%", temp, rhum);
|
||||
I2C_AHT20_Read(&temp[1], &rhum[1]);
|
||||
|
||||
I2C_SetChannel(AHT03);
|
||||
if (I2C_AHT20_Read(&temp, &rhum) == 0)
|
||||
Info("TEMP=%.2fC, RHUM=%.2f%", temp, rhum);
|
||||
I2C_AHT20_Read(&temp[2], &rhum[2]);
|
||||
|
||||
raw[0] = I2C_ADS1115_Read(0);
|
||||
raw[1] = I2C_ADS1115_Read(1);
|
||||
raw[2] = I2C_ADS1115_Read(2);
|
||||
raw[3] = I2C_ADS1115_Read(3);
|
||||
|
||||
Info("TEM0=%.2fC, RH0=%.2f%%", temp[0], rhum[0]);
|
||||
Info("TEM1=%.2fC, RH1=%.2f%%", temp[1], rhum[1]);
|
||||
Info("TEM2=%.2fC, RH2=%.2f%%", temp[2], rhum[2]);
|
||||
Info("ADC0=%04X, ADC1=%04X, ADC2=%04X, ADC3=%04X",
|
||||
raw[0], raw[1], raw[2], raw[3]);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user