Basic fading in and out of leds with light sensor.

Dependencies:   mbed

Committer:
mturner5
Date:
Mon Sep 19 03:24:58 2016 +0000
Revision:
0:cf7af2656659
Basic v1

Who changed what in which revision?

UserRevisionLine numberNew contents of line
mturner5 0:cf7af2656659 1 /* mbed Microcontroller Library
mturner5 0:cf7af2656659 2 * Copyright (c) 2006-2013 ARM Limited
mturner5 0:cf7af2656659 3 *
mturner5 0:cf7af2656659 4 * Licensed under the Apache License, Version 2.0 (the "License");
mturner5 0:cf7af2656659 5 * you may not use this file except in compliance with the License.
mturner5 0:cf7af2656659 6 * You may obtain a copy of the License at
mturner5 0:cf7af2656659 7 *
mturner5 0:cf7af2656659 8 * http://www.apache.org/licenses/LICENSE-2.0
mturner5 0:cf7af2656659 9 *
mturner5 0:cf7af2656659 10 * Unless required by applicable law or agreed to in writing, software
mturner5 0:cf7af2656659 11 * distributed under the License is distributed on an "AS IS" BASIS,
mturner5 0:cf7af2656659 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
mturner5 0:cf7af2656659 13 * See the License for the specific language governing permissions and
mturner5 0:cf7af2656659 14 * limitations under the License.
mturner5 0:cf7af2656659 15 */
mturner5 0:cf7af2656659 16 #ifndef MBED_FILESYSTEMLIKE_H
mturner5 0:cf7af2656659 17 #define MBED_FILESYSTEMLIKE_H
mturner5 0:cf7af2656659 18
mturner5 0:cf7af2656659 19 #include "platform.h"
mturner5 0:cf7af2656659 20
mturner5 0:cf7af2656659 21 #include "FileBase.h"
mturner5 0:cf7af2656659 22 #include "FileHandle.h"
mturner5 0:cf7af2656659 23 #include "DirHandle.h"
mturner5 0:cf7af2656659 24
mturner5 0:cf7af2656659 25 namespace mbed {
mturner5 0:cf7af2656659 26
mturner5 0:cf7af2656659 27 /** A filesystem-like object is one that can be used to open files
mturner5 0:cf7af2656659 28 * though it by fopen("/name/filename", mode)
mturner5 0:cf7af2656659 29 *
mturner5 0:cf7af2656659 30 * Implementations must define at least open (the default definitions
mturner5 0:cf7af2656659 31 * of the rest of the functions just return error values).
mturner5 0:cf7af2656659 32 */
mturner5 0:cf7af2656659 33 class FileSystemLike : public FileBase {
mturner5 0:cf7af2656659 34
mturner5 0:cf7af2656659 35 public:
mturner5 0:cf7af2656659 36 /** FileSystemLike constructor
mturner5 0:cf7af2656659 37 *
mturner5 0:cf7af2656659 38 * @param name The name to use for the filesystem.
mturner5 0:cf7af2656659 39 */
mturner5 0:cf7af2656659 40 FileSystemLike(const char *name);
mturner5 0:cf7af2656659 41
mturner5 0:cf7af2656659 42 virtual ~FileSystemLike();
mturner5 0:cf7af2656659 43
mturner5 0:cf7af2656659 44 static DirHandle *opendir();
mturner5 0:cf7af2656659 45 friend class BaseDirHandle;
mturner5 0:cf7af2656659 46
mturner5 0:cf7af2656659 47 /** Opens a file from the filesystem
mturner5 0:cf7af2656659 48 *
mturner5 0:cf7af2656659 49 * @param filename The name of the file to open.
mturner5 0:cf7af2656659 50 * @param flags One of O_RDONLY, O_WRONLY, or O_RDWR, OR'd with
mturner5 0:cf7af2656659 51 * zero or more of O_CREAT, O_TRUNC, or O_APPEND.
mturner5 0:cf7af2656659 52 *
mturner5 0:cf7af2656659 53 * @returns
mturner5 0:cf7af2656659 54 * A pointer to a FileHandle object representing the
mturner5 0:cf7af2656659 55 * file on success, or NULL on failure.
mturner5 0:cf7af2656659 56 */
mturner5 0:cf7af2656659 57 virtual FileHandle *open(const char *filename, int flags) = 0;
mturner5 0:cf7af2656659 58
mturner5 0:cf7af2656659 59 /** Remove a file from the filesystem.
mturner5 0:cf7af2656659 60 *
mturner5 0:cf7af2656659 61 * @param filename the name of the file to remove.
mturner5 0:cf7af2656659 62 * @param returns 0 on success, -1 on failure.
mturner5 0:cf7af2656659 63 */
mturner5 0:cf7af2656659 64 virtual int remove(const char *filename) { return -1; };
mturner5 0:cf7af2656659 65
mturner5 0:cf7af2656659 66 /** Rename a file in the filesystem.
mturner5 0:cf7af2656659 67 *
mturner5 0:cf7af2656659 68 * @param oldname the name of the file to rename.
mturner5 0:cf7af2656659 69 * @param newname the name to rename it to.
mturner5 0:cf7af2656659 70 *
mturner5 0:cf7af2656659 71 * @returns
mturner5 0:cf7af2656659 72 * 0 on success,
mturner5 0:cf7af2656659 73 * -1 on failure.
mturner5 0:cf7af2656659 74 */
mturner5 0:cf7af2656659 75 virtual int rename(const char *oldname, const char *newname) { return -1; };
mturner5 0:cf7af2656659 76
mturner5 0:cf7af2656659 77 /** Opens a directory in the filesystem and returns a DirHandle
mturner5 0:cf7af2656659 78 * representing the directory stream.
mturner5 0:cf7af2656659 79 *
mturner5 0:cf7af2656659 80 * @param name The name of the directory to open.
mturner5 0:cf7af2656659 81 *
mturner5 0:cf7af2656659 82 * @returns
mturner5 0:cf7af2656659 83 * A DirHandle representing the directory stream, or
mturner5 0:cf7af2656659 84 * NULL on failure.
mturner5 0:cf7af2656659 85 */
mturner5 0:cf7af2656659 86 virtual DirHandle *opendir(const char *name) { return NULL; };
mturner5 0:cf7af2656659 87
mturner5 0:cf7af2656659 88 /** Creates a directory in the filesystem.
mturner5 0:cf7af2656659 89 *
mturner5 0:cf7af2656659 90 * @param name The name of the directory to create.
mturner5 0:cf7af2656659 91 * @param mode The permissions to create the directory with.
mturner5 0:cf7af2656659 92 *
mturner5 0:cf7af2656659 93 * @returns
mturner5 0:cf7af2656659 94 * 0 on success,
mturner5 0:cf7af2656659 95 * -1 on failure.
mturner5 0:cf7af2656659 96 */
mturner5 0:cf7af2656659 97 virtual int mkdir(const char *name, mode_t mode) { return -1; }
mturner5 0:cf7af2656659 98
mturner5 0:cf7af2656659 99 // TODO other filesystem functions (mkdir, rm, rn, ls etc)
mturner5 0:cf7af2656659 100 };
mturner5 0:cf7af2656659 101
mturner5 0:cf7af2656659 102 } // namespace mbed
mturner5 0:cf7af2656659 103
mturner5 0:cf7af2656659 104 #endif