Psi Swarm robot library version 0.9

Dependents:   PsiSwarm_V9_Blank

Fork of PsiSwarmV9 by James Hilder

Committer:
richardredpath
Date:
Mon Jul 08 10:50:40 2019 +0000
Revision:
20:2b6ebe60929d
Parent:
16:50686c07ad07
Fixed deprecated warnings for callbacks throughout the library

Who changed what in which revision?

UserRevisionLine numberNew contents of line
jah128 0:d6269d17c8cf 1 /* University of York Robotics Laboratory PsiSwarm Library: LED Functions Header File
jah128 9:dde9e21030eb 2 *
jah128 16:50686c07ad07 3 * Copyright 2017 University of York
jah128 6:b340a527add9 4 *
jah128 9:dde9e21030eb 5 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License.
jah128 6:b340a527add9 6 * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
jah128 6:b340a527add9 7 * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS
jah128 9:dde9e21030eb 8 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
jah128 6:b340a527add9 9 * See the License for the specific language governing permissions and limitations under the License.
jah128 6:b340a527add9 10 *
jah128 0:d6269d17c8cf 11 * File: led.h
jah128 0:d6269d17c8cf 12 *
jah128 0:d6269d17c8cf 13 * (C) Dept. Electronics & Computer Science, University of York
jah128 0:d6269d17c8cf 14 * James Hilder, Alan Millard, Alexander Horsfield, Homero Elizondo, Jon Timmis
jah128 0:d6269d17c8cf 15 *
jah128 16:50686c07ad07 16 * PsiSwarm Library Version: 0.9
jah128 0:d6269d17c8cf 17 *
jah128 16:50686c07ad07 18 * June 2017
jah128 0:d6269d17c8cf 19 *
jah128 0:d6269d17c8cf 20 *
jah128 9:dde9e21030eb 21 */
jah128 0:d6269d17c8cf 22
jah128 0:d6269d17c8cf 23
jah128 0:d6269d17c8cf 24 #ifndef LED_H
jah128 0:d6269d17c8cf 25 #define LED_H
jah128 0:d6269d17c8cf 26
jah128 9:dde9e21030eb 27 /**
jah128 9:dde9e21030eb 28 * Led class
jah128 9:dde9e21030eb 29 * Functions to control the various LEDs on the robot
jah128 9:dde9e21030eb 30 *
jah128 9:dde9e21030eb 31 * Example:
jah128 9:dde9e21030eb 32 * @code
jah128 9:dde9e21030eb 33 * #include "psiswarm.h"
jah128 9:dde9e21030eb 34 *
jah128 9:dde9e21030eb 35 * int main() {
jah128 9:dde9e21030eb 36 * init();
jah128 9:dde9e21030eb 37 * led.set_led(0,1); //Set the outer LED number 0 (North) to red
jah128 9:dde9e21030eb 38 * led.set_led(4,3); //Set the outer LED number 4 (South) to orange (red+green)
jah128 9:dde9e21030eb 39 * }
jah128 9:dde9e21030eb 40 * @endcode
jah128 9:dde9e21030eb 41 */
jah128 9:dde9e21030eb 42 class Led
jah128 9:dde9e21030eb 43 {
jah128 9:dde9e21030eb 44
jah128 9:dde9e21030eb 45 public:
jah128 9:dde9e21030eb 46
jah128 9:dde9e21030eb 47 /** Set all 8 outer LEDs to the defined colour sequence
jah128 9:dde9e21030eb 48 * @param green - An 8-bit description of the green leds eg(0b00000001) means that LED 7 green is on, rest are off
jah128 9:dde9e21030eb 49 * @param red - An 8-bit description of the red leds eg(0b11111110) means that LED 7 red is off, rest are on
jah128 9:dde9e21030eb 50 */
jah128 9:dde9e21030eb 51 void set_leds(char green, char red);
jah128 9:dde9e21030eb 52
jah128 9:dde9e21030eb 53 /** Set the green component of all 8 outer LEDs to the defined colour sequence
jah128 9:dde9e21030eb 54 * @param green - An 8-bit description of the green leds eg(0b00000001) means that LED 7 green is on, rest are off
jah128 9:dde9e21030eb 55 */
jah128 9:dde9e21030eb 56 void set_green_leds(char green);
jah128 9:dde9e21030eb 57
jah128 9:dde9e21030eb 58 /** Set the red component of all 8 outer LEDs to the defined colour sequence
jah128 9:dde9e21030eb 59 * @param red - An 8-bit description of the red leds eg(0b11111110) means that LED 7 red is off, rest are on
jah128 9:dde9e21030eb 60 */
jah128 9:dde9e21030eb 61 void set_red_leds(char red);
jah128 9:dde9e21030eb 62
jah128 9:dde9e21030eb 63 /** Set the state of an invididual outer LED without affecting other LEDs
jah128 9:dde9e21030eb 64 * @param led - The LED to change state of (range 0 to 7)
jah128 9:dde9e21030eb 65 * @param state - 0 for off, 1 for red, 2 for green, 3 for orange
jah128 9:dde9e21030eb 66 */
jah128 9:dde9e21030eb 67 void set_led(char led, char state);
jah128 0:d6269d17c8cf 68
jah128 9:dde9e21030eb 69 /** Set the state of the base LEDs [if fitted]
jah128 9:dde9e21030eb 70 * @param state - 0 for off, 1 for on
jah128 9:dde9e21030eb 71 */
jah128 9:dde9e21030eb 72 void set_base_led(char state);
jah128 9:dde9e21030eb 73
jah128 9:dde9e21030eb 74 /** Turns on all outer LEDs for a period of time defined by timeout then restore their previous state
jah128 9:dde9e21030eb 75 * @param timeout - The time (in seconds) to keep LEDs on
jah128 9:dde9e21030eb 76 */
jah128 9:dde9e21030eb 77 void blink_leds(float timeout);
jah128 9:dde9e21030eb 78
jah128 9:dde9e21030eb 79 /** Set the state the center LED
jah128 9:dde9e21030eb 80 * @param state - 0 for off, 1 for red, 2 for green, 3 for orange
jah128 9:dde9e21030eb 81 */
jah128 9:dde9e21030eb 82 void set_center_led(char state);
jah128 9:dde9e21030eb 83
jah128 9:dde9e21030eb 84 /** Set the state the center LED with brightness control
jah128 9:dde9e21030eb 85 * @param state - 0 for off, 1 for red, 2 for green, 3 for orange
jah128 9:dde9e21030eb 86 * @param brightness - brightness of LED [PWM duty cycle] - range 0.0 to 1.0
jah128 9:dde9e21030eb 87 */
jah128 9:dde9e21030eb 88 void set_center_led(char state, float brightness);
jah128 9:dde9e21030eb 89
jah128 9:dde9e21030eb 90 /** Set the brightness of center LED without changing state
jah128 9:dde9e21030eb 91 * @param brightness - brightness of LED [PWM duty cycle] - range 0.0 to 1.0
jah128 9:dde9e21030eb 92 */
jah128 9:dde9e21030eb 93 void set_center_led_brightness(float brightness);
jah128 9:dde9e21030eb 94
jah128 9:dde9e21030eb 95 /** Returns the current state of the outer LEDs
jah128 9:dde9e21030eb 96 * @return A 16-bit value when MSB represent the green states and LSB the red states of the 8 LEDs
jah128 9:dde9e21030eb 97 */
jah128 9:dde9e21030eb 98 unsigned short get_led_states(void);
jah128 9:dde9e21030eb 99
jah128 9:dde9e21030eb 100 /** Store the current LED states for use with restore_led_states()
jah128 9:dde9e21030eb 101 */
jah128 9:dde9e21030eb 102 void save_led_states(void);
jah128 9:dde9e21030eb 103
jah128 9:dde9e21030eb 104 /** Restore the LED states to those set usign store_led_states()
jah128 9:dde9e21030eb 105 */
jah128 9:dde9e21030eb 106 void restore_led_states(void);
jah128 9:dde9e21030eb 107
jah128 9:dde9e21030eb 108 void IF_init_leds(void);
jah128 9:dde9e21030eb 109 void IF_update_leds(void);
jah128 9:dde9e21030eb 110
jah128 9:dde9e21030eb 111 };
jah128 0:d6269d17c8cf 112 #endif