1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87
|
/*
* Copyright (C) 2002,2003 Julien Danjou <julien@jdanjou.org>
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2, or (at your option) any
* later version.
*
* This is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*
*/
#include <stdio.h>
#include <unistd.h>
#include <sys/io.h>
#include <parportled.h>
/* Some code examples */
int led_on_right_to_left(int total_time)
{
int i;
for(i=1;i <= MAXLED;i++)
{
led_on(i);
usleep(total_time/MAXLED);
led_off(i);
}
}
int led_on_left_to_right(int total_time)
{
int i;
for(i=MAXLED;i > 0;i--)
{
led_on(i);
usleep(total_time/MAXLED);
led_off(i);
}
}
int led_on_center_to_border(int pause_time)
{
int i;
for(i=MAXLED/2;i>=0;i--){
led_on(i);
led_on(MAXLED-i+1);
usleep(pause_time);
if(i!=MAXLED/2) led_off(i+1);
if(i!=MAXLED/2) led_off(MAXLED-i);
usleep(pause_time);
}
}
int main()
{
/* led_setperm();
led_on_center_to_border(100000);
led_on_right_to_left(50000);
led_on_left_to_right(50000);
led_blink_on(4, 100000);
led_blink_on(5, 100000);
sleep(2);
led_blink_off(5);
sleep(1);
led_blink_off(4);
sleep(5);
led_on(1);
*/
led_setperm();
while(1) {
led_on_right_to_left(100000);
led_on_left_to_right(100000);
}
exit();
}
|