int main (void) { // unsigned int i,data[2]; // unsigned char count = 0,flag = FALSE; Init(); /* for (i = 0; i < 0x1FFF; i++) { OdometrieData(data); if ((data[0] < 200) && (flag == TRUE)) { count ++; flag = FALSE; } if (data[0] >= 600) flag = TRUE; } if (count > 10) Demo(); */ while (1) { if (PollSwitch()) { while (PollSwitch()); Demo(); } SelfTest(); } return 0; }
void Demo (void) { unsigned char sw; Init(); for (;;) { sw = PollSwitch(); if (sw == 0x01) LineDemo(); if (sw == 0x02) RechteckDemo(); if (sw == 0x04) PCDemo(); if (sw == 0x08) IRDemo(); } }
void check_buttons() { char i; uint8_t switch_new = PollSwitch(); for (i=0; i<6; i++) { char b_new = (switch_new & (1<<i)); char b_old = (switch_old & (1<<i)); if (b_new != b_old) { on_switch(i, b_new>0); } } switch_old = switch_new; }
void Kollision(void){ char switches = '0'; char zero = '0'; char one = '0'; char two = '0'; char three = '0'; char four = '0'; char five = '0'; switches = PollSwitch() & PollSwitch() & 0b00111111; zero = switches & SWITCH(1); one = switches & SWITCH(2); two = switches & SWITCH(1); three = switches & SWITCH(2); four = switches & SWITCH(1); five = switches & SWITCH(2); if(zero || one || two || three || four || five){ MotorSpeed(0,0); StereoSound(duck_melody,duck_melody); Lichtorgel(); } }
bool has_hit_wall() { uint8_t t1, t2; t1 = PollSwitch(); Msleep(10); t2 = PollSwitch(); // Ignore K6 while driving. return t1 && t1 == t2 && t1 & ~K6 && t1 < 64; }