Make log output slightly more readable

This commit is contained in:
2024-09-04 23:17:21 +02:00
parent 1602aa4297
commit 14e12cdd03
3 changed files with 19 additions and 13 deletions

View File

@@ -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

View File

@@ -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;