4,7 → 4,7 |
#include "cholerik.h" |
|
// Konstanty |
#define TRESHOLD 0x250 // rozhodovaci uroven pro okraj areny |
#define TRESHOLD 0x90 // rozhodovaci uroven pro okraj areny |
//#define DEBUG1 1 // Diagnostika pohonu |
|
//motory //Napred vypnout potom zapnout! |
53,23 → 53,24 |
if (((FRONT && stav) || (!FRONT && !stav))) {if (f<255) f++;} else {f=0;}; |
majak++; |
stav = ((majak & 0b1) == 0b1); |
if (input(PIN_A3)) arena_r=TRUE; else arena_r=FALSE; |
if (input(PIN_A2)) arena_l=TRUE; else arena_l=FALSE; |
if (stav) |
{ |
if (read_adc(ADC_READ_ONLY) > TRESHOLD) arena_l=TRUE; else arena_l=FALSE; |
set_adc_channel(R); // prepnuti kanalu ADC, je treba min 10us na ustaleni |
delay_us(10); |
read_adc(ADC_START_ONLY); |
// if (read_adc(ADC_READ_ONLY) > TRESHOLD) arena_l=TRUE; else arena_l=FALSE; |
// set_adc_channel(R); // prepnuti kanalu ADC, je treba min 10us na ustaleni |
// delay_us(10); |
// read_adc(ADC_START_ONLY); |
set_pwm1_duty(27); // 1:1 |
} |
else |
{ |
if (read_adc(ADC_READ_ONLY) > TRESHOLD) arena_r=TRUE; else arena_r=FALSE; |
set_adc_channel(L); // prepnuti kanalu ADC, je treba min 10us na ustaleni |
delay_us(10); |
read_adc(ADC_START_ONLY); |
// if (read_adc(ADC_READ_ONLY) > TRESHOLD) arena_r=TRUE; else arena_r=FALSE; |
// set_adc_channel(L); // prepnuti kanalu ADC, je treba min 10us na ustaleni |
// delay_us(10); |
// read_adc(ADC_START_ONLY); |
set_pwm1_duty(55); // 1:0 |
}; |
|
if (GRAVITY) {if (g<255) g++;} else g=0; |
if (g>3 && !diag) {FL; FR; while(TRUE);}; // kdyz nas preklopi, nedej se |
} |
119,7 → 120,20 |
}; |
#endif |
|
if (GRAVITY) { |
//!!!!!!!!!!!!!!! |
/* |
while(true) |
{ |
set_adc_channel(R); // prepnuti kanalu ADC, je treba min 10us na ustaleni |
delay_us(10); |
read_adc(ADC_START_ONLY); |
delay_ms(1); |
delay_ms(read_adc(ADC_READ_ONLY)); |
beep(1000,200); |
} |
*/ |
if (GRAVITY) |
{ |
diag=TRUE; |
enable_interrupts(INT_TIMER0); |
enable_interrupts(GLOBAL); |
127,10 → 141,11 |
{ |
if (g>100) beep(800,100); |
Delay_ms(50); |
if (arena_l) beep(1000,200); |
if (arena_l) {beep(1000,200); delay_ms(10);beep(1000,200);}; |
Delay_ms(50); |
if (arena_r) beep(2000,300); |
if (arena_r) {beep(2000,300); delay_ms(10);beep(2000,300);}; |
Delay_ms(50); |
|
if (sr>10) beep(3000,400); |
Delay_ms(50); |
if (f>10) beep(4000,500); |
139,8 → 154,9 |
Delay_ms(50); |
if (b>10) beep(6000,600); |
Delay_ms(50); |
}}; |
} |
}; |
} |
|
void main() |
{ |
149,8 → 165,11 |
STOPL; STOPR; // zastavi motory |
|
setup_oscillator(OSC_8MHZ|OSC_INTRC); // CPU clock 8MHz |
setup_adc_ports(sAN2|sAN3|VSS_VDD); // prevodniky na cidla na okraj areny |
setup_adc(ADC_CLOCK_INTERNAL); |
// setup_adc_ports(sAN2|sAN3|VSS_VDD); // prevodniky na cidla na okraj areny |
// setup_adc(ADC_CLOCK_INTERNAL); |
//!!!!!!!!!!!!!!!!!! |
setup_adc_ports(NO_ANALOGS); // prevodniky na cidla na okraj areny |
setup_adc(ADC_OFF); |
setup_spi(FALSE); |
setup_timer_0(RTCC_INTERNAL|RTCC_DIV_4); // Casovac pro SW PWM a cteni cidel |
setup_timer_1(T1_DISABLED); |
170,12 → 189,11 |
enable_interrupts(INT_TIMER0); |
enable_interrupts(GLOBAL); |
/*---------------------------------------------------------------------------*/ |
for (n=1;n<=3;n++) // 5s do zacatku souboje |
for (n=1;n<=5;n++) // 5s do zacatku souboje |
{ |
Delay_ms(990); |
Delay_ms(720); |
Beep(1000,200); |
} |
Delay_ms(300); |
|
while(true) // hlavni smycka |
{ |