Le code d'initialisation (i) et le code de lecture (j) semble marcher à tous les coups. A confirmer + faire README
This commit is contained in:
parent
e655b48835
commit
75443c2d22
@ -43,5 +43,5 @@ void Selection_capteur_init_pin_low(uint pin){
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Selection_capteur_deselect(){
|
void Selection_capteur_deselect(){
|
||||||
Selection_capteur_select(15);
|
Selection_capteur_select(16);
|
||||||
}
|
}
|
33
main.c
33
main.c
@ -24,6 +24,7 @@ void init_sensors(void);
|
|||||||
void display_menu();
|
void display_menu();
|
||||||
|
|
||||||
|
|
||||||
|
uint8_t statu_capteurs[13];
|
||||||
|
|
||||||
void main(void)
|
void main(void)
|
||||||
{
|
{
|
||||||
@ -92,11 +93,13 @@ void main(void)
|
|||||||
void initialise_adresses(void){
|
void initialise_adresses(void){
|
||||||
const uint8_t tmp_i2c_adresse = 0x28;
|
const uint8_t tmp_i2c_adresse = 0x28;
|
||||||
const uint8_t default_i2c_adresse = 0x29;
|
const uint8_t default_i2c_adresse = 0x29;
|
||||||
uint8_t VL53L1X_device = 0x29;
|
uint8_t adresse = default_i2c_adresse;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// On change l'adresse de tous les capteurs
|
// On change l'adresse de tous les capteurs
|
||||||
Selection_capteur_deselect();
|
Selection_capteur_deselect();
|
||||||
change_address(&VL53L1X_device, tmp_i2c_adresse);
|
change_address(&adresse, tmp_i2c_adresse);
|
||||||
|
|
||||||
// Pour chaque capteur
|
// Pour chaque capteur
|
||||||
for(uint capteur=1; capteur<=12; capteur++){
|
for(uint capteur=1; capteur<=12; capteur++){
|
||||||
@ -105,21 +108,21 @@ void initialise_adresses(void){
|
|||||||
sleep_ms(1);
|
sleep_ms(1);
|
||||||
Selection_capteur_deselect();
|
Selection_capteur_deselect();
|
||||||
sleep_ms(1);
|
sleep_ms(1);
|
||||||
VL53L1X_device = 0x29;
|
uint8_t VL53L1X_device = 0x29;
|
||||||
|
|
||||||
if(change_address(&VL53L1X_device, 0x30 + capteur)){
|
if(change_address(&VL53L1X_device, 0x30 + capteur)){
|
||||||
printf("Erreur change adresse : %x => %x, capteur : %d\n", VL53L1X_device, 0x30 + capteur, capteur);
|
printf("Erreur change adresse : %x => %x, capteur : %d\n", VL53L1X_device, 0x30 + capteur, capteur);
|
||||||
ws2812_set_buffer_rgb(0x4, 0, 0, capteur-1);
|
ws2812_set_buffer_rgb(0x4, 0, 0, capteur-1);
|
||||||
|
statu_capteurs[capteur]=0;
|
||||||
}else{
|
}else{
|
||||||
if(VL53L1X_SensorInit(VL53L1X_device)){
|
if(VL53L1X_SensorInit(VL53L1X_device)){
|
||||||
// bad init
|
// bad init
|
||||||
ws2812_set_buffer_rgb(0x4, 0, 0, capteur-1);
|
ws2812_set_buffer_rgb(0x4, 0, 0, capteur-1);
|
||||||
|
statu_capteurs[capteur]=0;
|
||||||
}else{
|
}else{
|
||||||
// good init
|
// good init
|
||||||
|
statu_capteurs[capteur]=1;
|
||||||
int status;
|
int status;
|
||||||
ws2812_set_buffer_rgb(0, 0x4, 0, capteur-1);
|
|
||||||
|
|
||||||
// Custom configuration
|
|
||||||
status = VL53L1X_SetDistanceMode (VL53L1X_device, 1); // Short mode
|
status = VL53L1X_SetDistanceMode (VL53L1X_device, 1); // Short mode
|
||||||
status |= VL53L1X_SetInterMeasurementInMs(VL53L1X_device, 200);
|
status |= VL53L1X_SetInterMeasurementInMs(VL53L1X_device, 200);
|
||||||
status |= VL53L1X_SetTimingBudgetInMs(VL53L1X_device, 200);
|
status |= VL53L1X_SetTimingBudgetInMs(VL53L1X_device, 200);
|
||||||
@ -131,15 +134,28 @@ void initialise_adresses(void){
|
|||||||
}
|
}
|
||||||
|
|
||||||
status=VL53L1X_StartRanging(VL53L1X_device);
|
status=VL53L1X_StartRanging(VL53L1X_device);
|
||||||
|
if(!status){
|
||||||
|
ws2812_set_buffer_rgb(0, 0x4, 0, capteur-1);
|
||||||
|
}else{
|
||||||
|
ws2812_set_buffer_rgb(0x2, 0x2, 0, capteur-1);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ws2812_affiche_buffer();
|
ws2812_affiche_buffer();
|
||||||
|
|
||||||
|
ws2812_affiche_buffer();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int continuous_multiple_reading(){
|
int continuous_multiple_reading(){
|
||||||
for(uint8_t device=0x31; device<0x34; device++){
|
for(uint8_t device=0x31; device<0x31+12; device++){
|
||||||
|
if(statu_capteurs[device-0x31+1]==0){
|
||||||
|
continue;
|
||||||
|
}
|
||||||
int status;
|
int status;
|
||||||
uint8_t data_ready = 0;
|
uint8_t data_ready = 0;
|
||||||
uint16_t distance;
|
uint16_t distance;
|
||||||
@ -147,7 +163,6 @@ int continuous_multiple_reading(){
|
|||||||
status=VL53L1X_CheckForDataReady(device, &data_ready);
|
status=VL53L1X_CheckForDataReady(device, &data_ready);
|
||||||
if(status){
|
if(status){
|
||||||
printf("CheckForDataReady KO, error %d, capteur:%x\n", status, device);
|
printf("CheckForDataReady KO, error %d, capteur:%x\n", status, device);
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -167,7 +182,7 @@ int continuous_multiple_reading(){
|
|||||||
|
|
||||||
int lettre = getchar_timeout_us(0);
|
int lettre = getchar_timeout_us(0);
|
||||||
if(lettre != PICO_ERROR_TIMEOUT && lettre != 0){
|
if(lettre != PICO_ERROR_TIMEOUT && lettre != 0){
|
||||||
return 0;
|
//return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return 1;
|
return 1;
|
||||||
|
Loading…
Reference in New Issue
Block a user