示例#1
0
void update( hwlib::port_out_from_pins & leds, hwlib::pin_in & knopmeer, hwlib::pin_in & knopminder, hwlib::hc595(&ledc)){
    unsigned int counter = 0;
        while(1){
            if (!knopmeer.get()&& counter < 8){
                counter++;
                leds.set((0x01<<counter)-1);
                ledc.set((0x01<<counter)-1);
                hwlib::wait_ms(500);
            }
            if (!knopminder.get()&& counter > 0){
                counter --;
                leds.set((0x01<<counter)-1);
                ledc.set((0x01<<counter)-1);
                hwlib::wait_ms( 500 );
            }
        }
}
void input(hwlib::port_out& leds, hwlib::pin_in& min, hwlib::pin_in& plus)
{
    unsigned int n = 0;
    while (1)
    {
        if (min.get() == 1 && n > 0) {
            n--;
        } else if (plus.get() == 1 && n < leds.number_of_pins()) {
            n++;
        }

        switch (n)
        {
            case 0: leds.set(0x0); break;
            case 1: leds.set(0x1); break;
            case 2: leds.set(0x3); break;
            case 4: leds.set(0x7); break;
            default: leds.set(0xF); break;
        }

        hwlib::wait_ms(250);
    }
}
示例#3
0
 bool get() {
     return !p1->get2() && !p2->get();
 }