14,7 → 14,8 |
#define ODODO2 0x5E |
|
// Adresy IIC periferii |
#define CAMERA_ADR 0xC0 |
#define COMPAS_ADR 0xC0 |
#define CAMERA_ADR 0xDC |
#define SONAR_ADR 0xE0 |
|
// A/D vstupy |
212,6 → 213,8 |
#int_EXT |
EXT_isr() // Preruseni od prekazky |
{ |
int8 bearing, bearing_offset, delta_bearing; |
|
set_pwm1_duty(0); // zabrzdi levym kolem, prave vypni |
set_pwm2_duty(0); |
output_high(MOT_L); |
226,7 → 229,17 |
return; |
}; |
output_low(IRTX); // Zapni LED na detekci prekazky |
delay_ms(10); |
|
i2c_start(); // Cteni kompasu |
i2c_write(COMPAS_ADR); |
i2c_write(0x1); |
i2c_stop(); |
i2c_start(); |
i2c_write(COMPAS_ADR+1); |
bearing_offset=i2c_read(0); |
i2c_stop(); |
|
delay_ms(9); |
if (!IRRX) // stale nas signal? |
{ |
output_low(MOT_L); // neni odraz -> vpred |
243,7 → 256,6 |
bb_f[log]=0xFF; // Cihla |
if(log<MAXLOG) log++; // Ukazatel na dalsi zaznam |
}; |
//!!! Vyzkouset, ze nepreteka LOG |
|
//!!! if(stav==cihla) while(true); // Zastav na furt, konec drahy |
// if(stav==cihla) return; // Po druhe nic neobjizdej |
281,6 → 293,26 |
output_low(MOT_L); // Nastav smer vpred |
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; |
291,12 → 323,20 |
SaveLog(0); // Zapis do EEPROM pocet zaznamu 0, tedy jeden zaznam |
while(true) |
{ |
if(!IRRX) |
{ |
disp(0x55); // Blikni pro potvrzeni |
delay_ms(200); |
disp(0xAA); |
delay_ms(200); |
} |
else |
{ |
disp(0x81); // Diagnostika celniho IR senzoru na prekazku |
delay_ms(200); |
} |
} |
} |
|
output_low(IRTX); // Zapni LED na detekci prekazky |
|
339,7 → 379,7 |
|
//... Nastaveni kamery ... |
i2c_start(); // Soft RESET kamery |
i2c_write(CAMERA_ADR); // Pro single slave musi mit vsechny zapisy adresu C0h |
i2c_write(CAMERA_ADR); // Adresa kamery |
i2c_write(0x12); // Adresa registru COMH |
i2c_write(0x80 | 0x24); // Zapis ridiciho slova |
i2c_stop(); |
352,13 → 392,13 |
|
/* |
i2c_start(); // Contrast (nema podstatny vliv na obraz) |
i2c_write(0xC0); |
i2c_write(CAMERA_ADR); |
i2c_write(0x05); |
i2c_write(0xA0); // 48h |
i2c_stop(); |
|
i2c_start(); // Band Filter (pokud by byl problem se zarivkama 50Hz) |
i2c_write(0xC0); |
i2c_write(CAMERA_ADR); |
i2c_write(0x2D); |
i2c_write(0x04 | 0x03); |
i2c_stop(); |