/roboti/istrobot/camerus/SW/876/camerus.c |
---|
10,8 → 10,8 |
#define RR_CIHLA 30 // Rozumna rychlost pro objizdeni cihly |
#define RR_PRERUSENI 20 // Rozumna rychlost pro priblizeni se k preruseni |
#define BRZDNA_DRAHA 0x20 // Jak daleko pred problemem se zacne brzdit |
#define ODODO1 0x37 |
#define ODODO2 0x5E |
#define ODODO1 0xFFF |
#define ODODO2 0xFFF |
// Adresy IIC periferii |
#define COMPAS_ADR 0xC0 |
213,8 → 213,8 |
#int_EXT |
EXT_isr() // Preruseni od prekazky |
{ |
int8 bearing, bearing_offset, delta_bearing; |
unsigned int8 bearing, bearing_offset, delta_bearing; |
set_pwm1_duty(0); // zabrzdi levym kolem, prave vypni |
set_pwm2_duty(0); |
output_high(MOT_L); |
294,25 → 294,7 |
output_low(MOT_R); |
disp(0); // Zhasni LEDbar |
/*!!!! |
while(true) |
{ |
int8 ble; |
i2c_start(); // Cteni kompasu |
i2c_write(COMPAS_ADR); |
i2c_write(0x1); |
i2c_stop(); |
i2c_start(); |
i2c_write(COMPAS_ADR+1); |
ble=i2c_read(0); |
i2c_stop(); |
disp(ble); |
delay_ms(200); |
} |
//*/ |
if(BUMPER) // Kdyz nekdo na zacatku drzi naraznik, vymaz log |
{ |
int8 n; |
321,14 → 303,29 |
bb_l[0]=0; // Zapis na pozici 0 vzdalenost 0 |
bb_h[0]=0; |
SaveLog(0); // Zapis do EEPROM pocet zaznamu 0, tedy jeden zaznam |
for(n=0;n<=4;n++) |
{ |
disp(0x55); // Blikni pro potvrzeni |
delay_ms(200); |
disp(0xAA); |
delay_ms(200); |
}; |
while(true) |
{ |
if(!IRRX) |
{ |
disp(0x55); // Blikni pro potvrzeni |
int8 ble; |
i2c_start(); // Cteni kompasu |
i2c_write(COMPAS_ADR); |
i2c_write(0x1); |
i2c_stop(); |
i2c_start(); |
i2c_write(COMPAS_ADR+1); |
ble=i2c_read(0); |
i2c_stop(); |
disp(ble); |
delay_ms(200); |
disp(0xAA); |
delay_ms(200); |
} |
else |
{ |
638,8 → 635,8 |
{ |
bum(); |
SaveLog(log-1); // Zapis Black Boxu do EEPROM |
set_pwm1_duty(140); // pomalu vpred |
set_pwm2_duty(140); |
set_pwm1_duty(160); // pomalu vpred |
set_pwm2_duty(160); |
output_low(MOT_L); |
output_low(MOT_R); |
}; |
/roboti/istrobot/camerus/SW/876/objizdka_L.c |
---|
10,6 → 10,7 |
enum okolo_cihly {pred_carou,na_care,po_care}; |
okolo_cihly ridic; // V jakem jsme stavu objizdeni cihly |
int8 vzdalenost; |
int8 visualisation; |
stav=cihla; // Dalsi prekazku uz nezaznamenavej (je to s velkou pravdepodobnosti cil) |
touch=0; // Indikator detekce cary pri objizdeni |
53,6 → 54,7 |
cas=CASAVR-CASMIN; // rovne |
output_low(MOT_L); // vpred |
output_low(MOT_R); |
visualisation=0; |
while(true) |
{ |
if(BUMPER) // Narazili jsme do cihly, musime couvnout! |
59,20 → 61,21 |
{ |
bum(); |
SaveLog(log-1); // Zapis Black Boxu do EEPROM |
set_pwm1_duty(140); // vpred |
set_pwm2_duty(140); |
set_pwm1_duty(160); // vpred |
set_pwm2_duty(160); |
output_low(MOT_L); |
output_low(MOT_R); |
}; |
delta_bearing=bearing-bearing_offset; |
if(IRRX || ((delta_bearing>64)&&(delta_bearing<128))) // hrozi celni srazka s cihlou v prubehu objizdeni |
visualisation=(delta_bearing & 0xF0) | (visualisation & 0x0F); |
if(IRRX) // hrozi celni srazka s cihlou v prubehu objizdeni |
{ |
cas=CASMIN; |
} |
else |
{ |
if((vzdalenost!=0)||!input(PROXIMITY)) // Udrzovani konstantni vzdalenosti od cihly |
if((vzdalenost!=0)||!input(PROXIMITY)||((delta_bearing>60)&&(delta_bearing<128))) // Udrzovani konstantni vzdalenosti od cihly |
{ |
if(cas>(CASMIN+20)) cas-=20; |
} |
128,11 → 131,12 |
bearing=i2c_read(0); |
i2c_stop(); |
if(touch==L_TOUCH) disp(0xC0); |
if(touch==R_TOUCH) disp(0x03); |
if(touch==L_TOUCH) visualisation|=0x2; |
if(touch==R_TOUCH) visualisation|=0x1; |
if((touch==B_TOUCH)&&(ridic==pred_carou)) ridic=na_care; |
if((ridic==na_care)&&(touch==0)) break; |
if(ridic==na_care) touch=0; |
disp(visualisation); |
}; |
disp(0xC3); |