From c47485371ac69797b487f9549368fab62859de78 Mon Sep 17 00:00:00 2001 From: Clyne Sullivan Date: Tue, 24 Apr 2018 14:11:01 -0400 Subject: file cleanup, better text, documentation --- include/display_text.h | 58 +++++++++++++++++++++++++++++++++++++ include/fat32.h | 38 ++++++++++++++++++++++-- include/initrd.h | 57 ------------------------------------ include/lcd.h | 78 -------------------------------------------------- include/sdcard.h | 2 +- 5 files changed, 94 insertions(+), 139 deletions(-) delete mode 100644 include/initrd.h delete mode 100644 include/lcd.h (limited to 'include') diff --git a/include/display_text.h b/include/display_text.h index de7ebce..65b0703 100644 --- a/include/display_text.h +++ b/include/display_text.h @@ -1,13 +1,71 @@ +/* + * @file display_text.h + * A text-rendering/managing library to work with the display + * + * Copyright (C) 2018 Clyne Sullivan + * + * This program 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 3 of the License, or + * (at your option) any later version. + * + * This program 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. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + #ifndef DISPLAY_TEXT_H_ #define DISPLAY_TEXT_H_ +/** + * The number of existing buffers. + */ +#define TTY_COUNT 2 + +/** + * Initializes text buffers and starts the blinking cursor. + * Must call before using other functions in this file. + */ void text_init(void); + +/** + * Switches to the i'th buffer. + * The display shows text from a buffer that has data and a position. By + * switching buffers, current text (and position in the text) can be preserved + * and switched back to later. + * @param i the buffer to switch to + */ void text_switch(unsigned int i); + +/** + * Puts a string of text to the display/current buffer. + * The cursor advances, and the buffer scrolls if the end of it is reached. + * @param s the string to put + */ void text_puts(const char *s); +/** + * Clears the display/current buffer. + */ void text_clear(void); +/** + * Sets the cursor's position. + * @param x the x position to move to + * @param y the y position to move to + */ void text_setpos(uint8_t x, uint8_t y); + +/** + * Moves the cursor relative to its current position. + * Can move in both positive and negative directions. + * @param x how many characters to move in the x direction + * @param y how many characters to move in the y direction + */ void text_relpos(int8_t x, int8_t y); #endif // DISPLAY_TEXT_H_ diff --git a/include/fat32.h b/include/fat32.h index 39d22f6..279b652 100644 --- a/include/fat32.h +++ b/include/fat32.h @@ -1,11 +1,36 @@ +/** + * @file fat32.h + * A very basic FAT32 reading implementation + * This only supports reading files in the root directory. Currently, the files + * must also have a name under eight characters, with no extension. + * + * Copyright (C) 2018 Clyne Sullivan + * + * This program 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 3 of the License, or + * (at your option) any later version. + * + * This program 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. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + #ifndef FAT32_H_ #define FAT32_H_ #include +/** + * A structure to store important information for loading a file. + */ typedef struct { - uint32_t size; - uint32_t start; + uint32_t size; /**< The file's size in bytes */ + uint32_t start; /**< The file's first data cluster */ } file_t; /** @@ -22,10 +47,17 @@ int fat_find(void); file_t *fat_findfile(const char *name); /** - * + * Reads given file into an allocated buffer. + * @param file the file's data structure from fat_findfile() + * @return a malloc'd buffer containing the file's data */ char *fat_readfile(file_t *file); +/** + * Gets the name of the nth file in the root directory. + * @param index n, the index of the file + * @return the file's name, in a malloc'd buffer + */ char *fat_getname(uint32_t index); #endif // FAT32_H_ diff --git a/include/initrd.h b/include/initrd.h deleted file mode 100644 index 47f81c4..0000000 --- a/include/initrd.h +++ /dev/null @@ -1,57 +0,0 @@ -/** - * @file initrd.h - * Initrd image support - * An archive file (made with ar) can be linked into the final executable to - * allow files to be loaded in memory on boot. See mkinitrd.sh or the Makefile - * for more info. - * - * Copyright (C) 2018 Clyne Sullivan - * - * This program 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 3 of the License, or - * (at your option) any later version. - * - * This program 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. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#ifndef INITRD_H_ -#define INITRD_H_ - -#include - -/** - * Confirms the initrd image is loaded and valid. - * @return non-zero if valid image found - */ -uint8_t initrd_validate(void); - -/** - * Gets the file name of the index'th file in the archive. - * @param index the index of the file - * @return the file's name, or zero if not found - */ -char *initrd_getfile(uint32_t index); -char *initrd_getname(uint32_t index); - -/** - * Gets contents of the given file. - * @param name the file's name - * @return pointer to file data, null if not found - */ -char *initrd_readfile(const char *name); - -/** - * Gets the size of the given file. - * @param name the file's name - * @return the file's size, in bytes - */ -uint32_t initrd_filesize(const char *name); - -#endif // INITRD_H_ diff --git a/include/lcd.h b/include/lcd.h deleted file mode 100644 index c13ff97..0000000 --- a/include/lcd.h +++ /dev/null @@ -1,78 +0,0 @@ -/** - * @file lcd.h - * A basic library for writing a 16x2 text LCD. - * - * Copyright (C) 2018 Clyne Sullivan - * - * This program 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 3 of the License, or - * (at your option) any later version. - * - * This program 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. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#ifndef LCD_H_ -#define LCD_H_ - -#include - -/** - * A handler/task to manage asyncronous LCD writes. - */ -void lcd_handler(void); - -/** - * Writes a string asyncronously to the LCD. - * The lcd_handler task must be running for the string to actually be printed. - * @param s the string to write - */ -void lcd_put(const char *s); - -// -// The following functions do not support asyncronous calls. -// - -/** - * Initializes the LCD. - */ -void lcd_init(void); - -/** - * Writes a string to the LCD. - * A cursor position is kept internally. When the end of the screen is reached, - * writing resumes at the first position. - * @param s the string to write - */ -void lcd_puts(const char *s); - -/** - * Writes a base 10 integer to the screen. - * @param i the integer to print - */ -void lcd_puti(int i); - -/** - * Writes a base 16 integer to the screen. - * @param h the integer to print - */ -void lcd_puth(int h); - -/** - * Writes a byte in binary to the screen. - * @param b the byte to print - */ -void lcd_putb(uint8_t b); - -/** - * Clears the LCD. - */ -void lcd_clear(void); - -#endif // LCD_H_ diff --git a/include/sdcard.h b/include/sdcard.h index 8cdef58..3722afc 100644 --- a/include/sdcard.h +++ b/include/sdcard.h @@ -1,5 +1,5 @@ /** - * @file sdcard.c + * @file sdcard.h * Provides a basic library for accessing an SD card * * Copyright (C) 2018 Clyne Sullivan -- cgit v1.2.3