coffee/barista/test/test_led.c
2025-11-02 19:24:02 +01:00

43 lines
720 B
C

/* Copyright (c) 2025 Rodrigo Arias Mallo <rodarima@gmail.com>
* SPDX-License-Identifier: GPL-3.0-or-later */
#include <stdio.h>
#include "led.h"
#include "compat.h"
int main(void)
{
struct led led;
unsigned long t0 = millis();
unsigned long step = 1000UL;
led_pattern(&led, t0, step, "000123456789abcdefff");
int last_level = -1;
unsigned long last_t = millis();
while (1) {
unsigned long t = millis();
if (t - t0 >= 10000UL)
break;
if (t - last_t < 50UL)
continue;
int level = led_level(&led, millis());
printf("|");
for (int i = 0; i < 256; i+=4) {
if (i < level)
printf("=");
else
printf(" ");
}
printf("|\n");
last_level = level;
last_t = t;
}
return 0;
}