A simple 128x32 graphical LCD program to quickstart with LCD on ARM mbed IoT Starter Kit. This requires mbed Applciation Shield with FRDM-K64F platform.
mbed/DirHandle.h@1:eb68c94a8ee5, 2015-04-12 (annotated)
- Committer:
- tushki7
- Date:
- Sun Apr 12 15:45:52 2015 +0000
- Revision:
- 1:eb68c94a8ee5
- Parent:
- 0:60d829a0353a
A simple 128x32 LCD program with ARM mbed IoT Starter Kit;
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
tushki7 | 0:60d829a0353a | 1 | /* mbed Microcontroller Library |
tushki7 | 0:60d829a0353a | 2 | * Copyright (c) 2006-2013 ARM Limited |
tushki7 | 0:60d829a0353a | 3 | * |
tushki7 | 0:60d829a0353a | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
tushki7 | 0:60d829a0353a | 5 | * you may not use this file except in compliance with the License. |
tushki7 | 0:60d829a0353a | 6 | * You may obtain a copy of the License at |
tushki7 | 0:60d829a0353a | 7 | * |
tushki7 | 0:60d829a0353a | 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
tushki7 | 0:60d829a0353a | 9 | * |
tushki7 | 0:60d829a0353a | 10 | * Unless required by applicable law or agreed to in writing, software |
tushki7 | 0:60d829a0353a | 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
tushki7 | 0:60d829a0353a | 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
tushki7 | 0:60d829a0353a | 13 | * See the License for the specific language governing permissions and |
tushki7 | 0:60d829a0353a | 14 | * limitations under the License. |
tushki7 | 0:60d829a0353a | 15 | */ |
tushki7 | 0:60d829a0353a | 16 | #ifndef MBED_DIRHANDLE_H |
tushki7 | 0:60d829a0353a | 17 | #define MBED_DIRHANDLE_H |
tushki7 | 0:60d829a0353a | 18 | |
tushki7 | 0:60d829a0353a | 19 | #if defined(__ARMCC_VERSION) || defined(__ICCARM__) |
tushki7 | 0:60d829a0353a | 20 | # define NAME_MAX 255 |
tushki7 | 0:60d829a0353a | 21 | typedef int mode_t; |
tushki7 | 0:60d829a0353a | 22 | |
tushki7 | 0:60d829a0353a | 23 | #else |
tushki7 | 0:60d829a0353a | 24 | # include <sys/syslimits.h> |
tushki7 | 0:60d829a0353a | 25 | #endif |
tushki7 | 0:60d829a0353a | 26 | |
tushki7 | 0:60d829a0353a | 27 | #include "FileHandle.h" |
tushki7 | 0:60d829a0353a | 28 | |
tushki7 | 0:60d829a0353a | 29 | struct dirent { |
tushki7 | 0:60d829a0353a | 30 | char d_name[NAME_MAX+1]; |
tushki7 | 0:60d829a0353a | 31 | }; |
tushki7 | 0:60d829a0353a | 32 | |
tushki7 | 0:60d829a0353a | 33 | namespace mbed { |
tushki7 | 0:60d829a0353a | 34 | |
tushki7 | 0:60d829a0353a | 35 | /** Represents a directory stream. Objects of this type are returned |
tushki7 | 0:60d829a0353a | 36 | * by a FileSystemLike's opendir method. Implementations must define |
tushki7 | 0:60d829a0353a | 37 | * at least closedir, readdir and rewinddir. |
tushki7 | 0:60d829a0353a | 38 | * |
tushki7 | 0:60d829a0353a | 39 | * If a FileSystemLike class defines the opendir method, then the |
tushki7 | 0:60d829a0353a | 40 | * directories of an object of that type can be accessed by |
tushki7 | 0:60d829a0353a | 41 | * DIR *d = opendir("/example/directory") (or opendir("/example") |
tushki7 | 0:60d829a0353a | 42 | * to open the root of the filesystem), and then using readdir(d) etc. |
tushki7 | 0:60d829a0353a | 43 | * |
tushki7 | 0:60d829a0353a | 44 | * The root directory is considered to contain all FileLike and |
tushki7 | 0:60d829a0353a | 45 | * FileSystemLike objects, so the DIR* returned by opendir("/") will |
tushki7 | 0:60d829a0353a | 46 | * reflect this. |
tushki7 | 0:60d829a0353a | 47 | */ |
tushki7 | 0:60d829a0353a | 48 | class DirHandle { |
tushki7 | 0:60d829a0353a | 49 | |
tushki7 | 0:60d829a0353a | 50 | public: |
tushki7 | 0:60d829a0353a | 51 | /** Closes the directory. |
tushki7 | 0:60d829a0353a | 52 | * |
tushki7 | 0:60d829a0353a | 53 | * @returns |
tushki7 | 0:60d829a0353a | 54 | * 0 on success, |
tushki7 | 0:60d829a0353a | 55 | * -1 on error. |
tushki7 | 0:60d829a0353a | 56 | */ |
tushki7 | 0:60d829a0353a | 57 | virtual int closedir()=0; |
tushki7 | 0:60d829a0353a | 58 | |
tushki7 | 0:60d829a0353a | 59 | /** Return the directory entry at the current position, and |
tushki7 | 0:60d829a0353a | 60 | * advances the position to the next entry. |
tushki7 | 0:60d829a0353a | 61 | * |
tushki7 | 0:60d829a0353a | 62 | * @returns |
tushki7 | 0:60d829a0353a | 63 | * A pointer to a dirent structure representing the |
tushki7 | 0:60d829a0353a | 64 | * directory entry at the current position, or NULL on reaching |
tushki7 | 0:60d829a0353a | 65 | * end of directory or error. |
tushki7 | 0:60d829a0353a | 66 | */ |
tushki7 | 0:60d829a0353a | 67 | virtual struct dirent *readdir()=0; |
tushki7 | 0:60d829a0353a | 68 | |
tushki7 | 0:60d829a0353a | 69 | /** Resets the position to the beginning of the directory. |
tushki7 | 0:60d829a0353a | 70 | */ |
tushki7 | 0:60d829a0353a | 71 | virtual void rewinddir()=0; |
tushki7 | 0:60d829a0353a | 72 | |
tushki7 | 0:60d829a0353a | 73 | /** Returns the current position of the DirHandle. |
tushki7 | 0:60d829a0353a | 74 | * |
tushki7 | 0:60d829a0353a | 75 | * @returns |
tushki7 | 0:60d829a0353a | 76 | * the current position, |
tushki7 | 0:60d829a0353a | 77 | * -1 on error. |
tushki7 | 0:60d829a0353a | 78 | */ |
tushki7 | 0:60d829a0353a | 79 | virtual off_t telldir() { return -1; } |
tushki7 | 0:60d829a0353a | 80 | |
tushki7 | 0:60d829a0353a | 81 | /** Sets the position of the DirHandle. |
tushki7 | 0:60d829a0353a | 82 | * |
tushki7 | 0:60d829a0353a | 83 | * @param location The location to seek to. Must be a value returned by telldir. |
tushki7 | 0:60d829a0353a | 84 | */ |
tushki7 | 0:60d829a0353a | 85 | virtual void seekdir(off_t location) { } |
tushki7 | 0:60d829a0353a | 86 | |
tushki7 | 0:60d829a0353a | 87 | virtual ~DirHandle() {} |
tushki7 | 0:60d829a0353a | 88 | }; |
tushki7 | 0:60d829a0353a | 89 | |
tushki7 | 0:60d829a0353a | 90 | } // namespace mbed |
tushki7 | 0:60d829a0353a | 91 | |
tushki7 | 0:60d829a0353a | 92 | typedef mbed::DirHandle DIR; |
tushki7 | 0:60d829a0353a | 93 | |
tushki7 | 0:60d829a0353a | 94 | extern "C" { |
tushki7 | 0:60d829a0353a | 95 | DIR *opendir(const char*); |
tushki7 | 0:60d829a0353a | 96 | struct dirent *readdir(DIR *); |
tushki7 | 0:60d829a0353a | 97 | int closedir(DIR*); |
tushki7 | 0:60d829a0353a | 98 | void rewinddir(DIR*); |
tushki7 | 0:60d829a0353a | 99 | long telldir(DIR*); |
tushki7 | 0:60d829a0353a | 100 | void seekdir(DIR*, long); |
tushki7 | 0:60d829a0353a | 101 | int mkdir(const char *name, mode_t n); |
tushki7 | 0:60d829a0353a | 102 | }; |
tushki7 | 0:60d829a0353a | 103 | |
tushki7 | 0:60d829a0353a | 104 | #endif /* MBED_DIRHANDLE_H */ |