Created
September 27, 2013 14:41
-
-
Save ao-kenji/6729653 to your computer and use it in GitHub Desktop.
lcdcls.c - clear the LCD character display on OpenBSD/luna88k
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* | |
| * Copyright (c) 2013 Kenji Aoyama | |
| * | |
| * Permission to use, copy, modify, and distribute this software for any | |
| * purpose with or without fee is hereby granted, provided that the above | |
| * copyright notice and this permission notice appear in all copies. | |
| * | |
| * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES | |
| * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF | |
| * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR | |
| * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES | |
| * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN | |
| * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF | |
| * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | |
| */ | |
| #define LCD "/dev/lcd" | |
| #include <sys/ioctl.h> | |
| #include <machine/lcd.h> | |
| #include <fcntl.h> | |
| #include <stdio.h> | |
| /* Prototype */ | |
| void usage(void); | |
| /* | |
| * Clear the LCD on OpenBSD/luna88k. | |
| * Restore boot time message if -r flag is specified. | |
| */ | |
| int | |
| main(int argc, char *argv[]) | |
| { | |
| int fd, ret, rflag = 0, val; | |
| char ch; | |
| while ((ch = getopt(argc, argv, "hr")) != -1) | |
| switch (ch) { | |
| case 'h': | |
| usage(); | |
| break; | |
| case 'r': | |
| rflag = 1; | |
| break; | |
| } | |
| if ((fd = open(LCD, O_WRONLY)) == -1) { | |
| perror("open"); | |
| exit(1); | |
| } | |
| val = LCDCLS; | |
| if (rflag) val = LCDRESTORE; | |
| if ((ret =ioctl(fd, val)) == -1) { | |
| perror("ioctl"); | |
| exit(1); | |
| } | |
| close(fd); | |
| exit(0); | |
| } | |
| void | |
| usage(void) { | |
| extern char *__progname; | |
| fprintf(stderr, "usage: %s [-r]\n", __progname); | |
| exit(1); | |
| } |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
After clearing the LCD character display with this tool, you can put your favorite message on the LCD by: