From abd9645df02028417d4043a27fb4662f5da66416 Mon Sep 17 00:00:00 2001 From: Samuel Date: Sat, 6 May 2023 15:40:21 +0200 Subject: [PATCH] =?UTF-8?q?petites=20am=C3=A9liorations?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .vscode/settings.json | 4 +++- Tests.c | 17 ++++++++++++++++- VL53L1X_Fonctions.c | 4 ++-- main.c | 1 + 4 files changed, 22 insertions(+), 4 deletions(-) diff --git a/.vscode/settings.json b/.vscode/settings.json index c9cf880..d7bf0d6 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -2,6 +2,8 @@ "files.associations": { "vl53l1x_calibration.h": "c", "vl53l1x_api.h": "c", - "i2c.h": "c" + "i2c.h": "c", + "vl53l1_platform.h": "c", + "vl53l1_types.h": "c" } } \ No newline at end of file diff --git a/Tests.c b/Tests.c index 102c33c..410c2f4 100644 --- a/Tests.c +++ b/Tests.c @@ -1,4 +1,5 @@ #include "pico/stdlib.h" +#include "pico/multicore.h" #include #include "ws2812.h" #include "VL53L1X_Fonctions.h" @@ -8,6 +9,19 @@ void test_couleur_led(); #define TEST_TIMEOUT_US 10000000 + +void blink_test(void){ + const uint LED_PIN = PICO_DEFAULT_LED_PIN; + while(1){ + for(uint8_t capteur=0; capteur<12; capteur++){ + printf(">distance%x:%d\n", capteur, distance_capteur_cm[capteur]); + } + sleep_ms(50); + + } + +} + void Tests(void){ int answer_at_least_once=0; uint8_t VL53L1X_device = 0x31; @@ -49,6 +63,7 @@ void Tests(void){ case 'j': case 'J': printf("Lecture continue des capteurs inutilisés.\nAppuyer sur une touche pour quitter"); + multicore_launch_core1(blink_test); do{ keycode = getchar_timeout_us(0); continuous_multiple_reading(); @@ -60,7 +75,7 @@ void Tests(void){ break; case 'l': case 'L': - while(continuous_reading(0x31)); + while(continuous_reading(0x38)); break; case 'o': case 'O': diff --git a/VL53L1X_Fonctions.c b/VL53L1X_Fonctions.c index e35c369..c427abb 100644 --- a/VL53L1X_Fonctions.c +++ b/VL53L1X_Fonctions.c @@ -9,7 +9,7 @@ #define DISTANCE_TROP_LOIN_CM 200 /* Distance de saturation */ #define DISTANCE_TRES_LOIN_CM 120 /* Seuil min. pour la couleur bleu*/ #define DISTANCE_LOIN_CM 80 /* Seuil min. pour la couleur verte*/ -#define DISTANCE_PROCHE_CM 14 /* Seuil entre violet et jaune*/ +#define DISTANCE_PROCHE_CM 15 /* Seuil entre violet et jaune*/ #define NB_CAPTEURS 12 @@ -121,7 +121,7 @@ int continuous_multiple_reading(){ printf("GetDistance KO, error %d, capteur:%x\n", status, device); return 0; }else{ - if(distance_mm < DISTANCE_TROP_LOIN_CM * 10){ + if(distance_mm/10 < (uint16_t) DISTANCE_TROP_LOIN_CM){ distance_capteur_cm[device-0x31] = distance_mm / 10; }else{ distance_capteur_cm[device-0x31] = DISTANCE_TROP_LOIN_CM; diff --git a/main.c b/main.c index dd01fa4..ac05333 100644 --- a/main.c +++ b/main.c @@ -181,6 +181,7 @@ void main(void) affiche_couleur_sur_led(couleur, led); } } + ws2812_affiche_buffer(); } } }