PokittoLib with changes to lcd refresh etc.

Dependents:   Pokittris

Fork of Pokitto by Pokitto Community Team

This is a fork by user @Spinal, and is used in Pokittris for testing. Do not import this to your own program.

Committer:
spinal
Date:
Sun Oct 15 18:03:02 2017 +0000
Revision:
11:02ad9c807a21
Parent:
5:7e5c566b1760
fixed 4color refreshRegion code

Who changed what in which revision?

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