6,6 → 6,9 |
|
#USE FAST_IO (C) // Brana C je ve FAST_IO modu, aby slo rychle cist z kamery |
|
#define CAMERA_adr 0xC0 |
#define SONAR_adr 0xE0 |
|
// A/D vstupy |
#define RMAX 4 // AN4/RA5 - leve cidlo na vyjeti z cary |
#define LMAX 3 // AN3/RA3 - prave cidlo na vyjeti z cary |
208,7 → 211,7 |
setup_comparator(NC_NC_NC_NC); |
setup_vref(FALSE); |
|
set_tris_c(0b11111001); // Nastaveni vstup/vystup pro branu C, protoze se nedela automaticky |
set_tris_c(0b11111001); // Nastaveni vstup/vystup pro branu C, protoze se to nedela automaticky |
|
set_pwm1_duty(0); // Zastav motory |
set_pwm2_duty(0); |
222,16 → 225,16 |
|
//... Nastaveni sonaru ... |
i2c_start(); |
i2c_write(0xE0); |
i2c_write(SONAR_adr); |
i2c_write(0x02); // dosah |
i2c_write(0x03); // n*43mm |
i2c_stop(); |
i2c_start(); |
i2c_write(0xE0); |
i2c_write(SONAR_adr); |
i2c_write(0x01); // zesileni |
i2c_write(0x01); // male, pro eliminaci echa z minuleho mereni |
i2c_stop(); |
|
|
// pro ladeni sonaru |
/* |
while(true) |
256,13 → 259,13 |
|
//... Nastaveni kamery ... |
i2c_start(); // Soft RESET kamery |
i2c_write(0xC0); // Pro single slave musi mit vsechny zapisy adresu C0h |
i2c_write(CAMERA_adr); // Pro single slave musi mit vsechny zapisy adresu C0h |
i2c_write(0x12); // Adresa registru COMH |
i2c_write(0x80 | 0x24); // Zapis ridiciho slova |
i2c_stop(); |
|
i2c_start(); // BW |
i2c_write(0xC0); |
i2c_write(CAMERA_adr); |
i2c_write(0x28); |
i2c_write(0b01000001); |
i2c_stop(); |
282,19 → 285,19 |
*/ |
|
i2c_start(); // Fame Rate |
i2c_write(0xC0); |
i2c_write(CAMERA_adr); |
i2c_write(0x2B); |
i2c_write(0x00); // cca 17ms (puvodni hodnota 5Eh = 20ms) |
i2c_stop(); |
|
i2c_start(); // VSTRT |
i2c_write(0xC0); |
i2c_write(CAMERA_adr); |
i2c_write(0x19); |
i2c_write(118); // prostredni radka |
i2c_stop(); |
|
i2c_start(); // VEND |
i2c_write(0xC0); |
i2c_write(CAMERA_adr); |
i2c_write(0x1A); |
i2c_write(118); |
i2c_stop(); |
305,7 → 308,7 |
int8 t1,t2; |
|
i2c_start(); // Brightness, zacni od uplne tmy |
i2c_write(0xC0); |
i2c_write(CAMERA_adr); |
i2c_write(0x06); |
i2c_write(0); // 80h default |
i2c_stop(); |
314,7 → 317,7 |
for(offset=0x04;offset<(255-0x04);offset+=0x04) // Zacni od jasu 10h |
{ |
i2c_start(); // Brightness |
i2c_write(0xC0); |
i2c_write(CAMERA_adr); |
i2c_write(0x06); |
i2c_write(offset); // 80h default |
i2c_stop(); |
348,7 → 351,7 |
// offset += 0x70; // Jas nebude nikdy nizsi |
disp(offset); |
i2c_start(); // Brightness |
i2c_write(0xC0); |
i2c_write(CAMERA_adr); |
i2c_write(0x06); |
i2c_write(offset); // 80h default |
i2c_stop(); |