Psi Swarm Robot / PsiSwarmV8_CPP

Dependents:   PsiSwarm_V8_Blank_CPP Autonomia_RndmWlk

Fork of PsiSwarmV7_CPP by Psi Swarm Robot

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers led.h Source File

led.h

00001 /* University of York Robotics Laboratory PsiSwarm Library: LED Functions Header File
00002  *
00003  * Copyright 2016 University of York
00004  *
00005  * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License.
00006  * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
00007  * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS
00008  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00009  * See the License for the specific language governing permissions and limitations under the License.
00010  *
00011  * File: led.h
00012  *
00013  * (C) Dept. Electronics & Computer Science, University of York
00014  * James Hilder, Alan Millard, Alexander Horsfield, Homero Elizondo, Jon Timmis
00015  *
00016  * PsiSwarm Library Version: 0.8
00017  *
00018  * October 2016
00019  *
00020  *
00021  */
00022 
00023 
00024 #ifndef LED_H
00025 #define LED_H
00026 
00027 /**
00028  * Led class
00029  * Functions to control the various LEDs on the robot
00030  *
00031  * Example:
00032  * @code
00033  * #include "psiswarm.h"
00034  *
00035  * int main() {
00036  *     init();
00037  *     led.set_led(0,1);       //Set the outer LED number 0 (North) to red
00038  *     led.set_led(4,3);       //Set the outer LED number 4 (South) to orange (red+green)
00039  * }
00040  * @endcode
00041 */
00042 class Led
00043 {
00044 
00045 public:
00046 
00047     /** Set all 8 outer LEDs to the defined colour sequence
00048     * @param green - An 8-bit description of the green leds eg(0b00000001) means that LED 7 green is on, rest are off
00049     * @param red - An 8-bit description of the red   leds eg(0b11111110) means that LED 7 red is off, rest are on
00050     */
00051     void set_leds(char green, char red);
00052 
00053     /** Set the green component of all 8 outer LEDs to the defined colour sequence
00054     * @param green - An 8-bit description of the green leds eg(0b00000001) means that LED 7 green is on, rest are off
00055     */
00056     void set_green_leds(char green);
00057 
00058     /** Set the red component of all 8 outer LEDs to the defined colour sequence
00059     * @param red - An 8-bit description of the red   leds eg(0b11111110) means that LED 7 red is off, rest are on
00060     */
00061     void set_red_leds(char red);
00062 
00063     /** Set the state of an invididual outer LED without affecting other LEDs
00064     * @param led - The LED to change state of (range 0 to 7)
00065     * @param state - 0 for off, 1 for red, 2 for green, 3 for orange
00066     */
00067     void set_led(char led, char state);
00068 
00069     /** Set the state of the base LEDs [if fitted]
00070     * @param state - 0 for off, 1 for on
00071     */
00072     void set_base_led(char state);
00073 
00074     /** Turns on all outer LEDs for a period of time defined by timeout then restore their previous state
00075     * @param timeout - The time (in seconds) to keep LEDs on
00076     */
00077     void blink_leds(float timeout);
00078 
00079     /** Set the state the center LED
00080     * @param state - 0 for off, 1 for red, 2 for green, 3 for orange
00081     */
00082     void set_center_led(char state);
00083 
00084     /** Set the state the center LED with brightness control
00085     * @param state - 0 for off, 1 for red, 2 for green, 3 for orange
00086     * @param brightness - brightness of LED [PWM duty cycle] - range 0.0 to 1.0
00087     */
00088     void set_center_led(char state, float brightness);
00089 
00090     /** Set the brightness of center LED without changing state
00091     * @param brightness - brightness of LED [PWM duty cycle] - range 0.0 to 1.0
00092     */
00093     void set_center_led_brightness(float brightness);
00094 
00095     /** Returns the current state of the outer LEDs
00096     * @return A 16-bit value when MSB represent the green states and LSB the red states of the 8 LEDs
00097     */
00098     unsigned short get_led_states(void);
00099 
00100     /** Store the current LED states for use with restore_led_states()
00101     */
00102     void save_led_states(void);
00103 
00104     /** Restore the LED states to those set usign store_led_states()
00105     */
00106     void restore_led_states(void);
00107 
00108     void IF_init_leds(void);
00109     void IF_update_leds(void);
00110 
00111 };
00112 #endif