35 lines
719 B
C
35 lines
719 B
C
#include "creditos.h"
|
|
#include "led_driver.h"
|
|
#include "esp_random.h"
|
|
#include "esp_log.h"
|
|
#include "freertos/FreeRTOS.h"
|
|
#include "freertos/task.h"
|
|
#include "esp_random.h"
|
|
#include "esp_log.h"
|
|
|
|
|
|
volatile bool tem_creditos = false;
|
|
static const char *TAG = "CREDITOS";
|
|
|
|
void creditos_dar(void) {
|
|
tem_creditos = true;
|
|
ESP_LOGI(TAG, "💰 Crédito recebido");
|
|
}
|
|
|
|
void creditos_task(void *pv) {
|
|
while (1) {
|
|
|
|
if (tem_creditos) {
|
|
uint16_t pos = esp_random() % LED_COUNT;
|
|
|
|
ESP_LOGI(TAG, "🎯 SPIN -> posição %u", pos);
|
|
|
|
led_spin_to(pos, 2, 12, 80);
|
|
|
|
tem_creditos = false; // crédito consumido
|
|
}
|
|
|
|
vTaskDelay(pdMS_TO_TICKS(50));
|
|
}
|
|
}
|