Psi Swarm robot library version 0.9

Fork of PsiSwarmV9 by Psi Swarm Robot

Committer:
jah128
Date:
Sun Oct 16 21:06:15 2016 +0000
Revision:
11:312663037b8c
Parent:
10:e58323951c08
Child:
12:878c6e9d9e60
Added more classes

Who changed what in which revision?

UserRevisionLine numberNew contents of line
jah128 0:d6269d17c8cf 1 /* University of York Robotics Laboratory PsiSwarm Library: PsiSwarm Core Header File
jah128 0:d6269d17c8cf 2 *
jah128 6:b340a527add9 3 * Copyright 2016 University of York
jah128 6:b340a527add9 4 *
jah128 6:b340a527add9 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 6:b340a527add9 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: psiswarm.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 11:312663037b8c 16 * PsiSwarm Library Version: 0.8
jah128 0:d6269d17c8cf 17 *
jah128 5:3cdd1a37cdd7 18 * October 2016
jah128 0:d6269d17c8cf 19 *
jah128 0:d6269d17c8cf 20 *
jah128 0:d6269d17c8cf 21 */
jah128 0:d6269d17c8cf 22
jah128 0:d6269d17c8cf 23 #ifndef PSISWARM_H
jah128 0:d6269d17c8cf 24 #define PSISWARM_H
jah128 0:d6269d17c8cf 25
jah128 11:312663037b8c 26 #define SOFTWARE_VERSION_CODE 0.80
jah128 0:d6269d17c8cf 27
jah128 0:d6269d17c8cf 28 #define PIC_ADDRESS 0x30
jah128 0:d6269d17c8cf 29 #define LCD_ADDRESS 0x7C
jah128 0:d6269d17c8cf 30 #define LED_IC_ADDRESS 0x42
jah128 0:d6269d17c8cf 31 #define GPIO_IC_ADDRESS 0x40
jah128 0:d6269d17c8cf 32 #define AUX_IC_ADDRESS 0x4E
jah128 0:d6269d17c8cf 33 #define ADC1_ADDRESS 0x46
jah128 0:d6269d17c8cf 34 #define ADC2_ADDRESS 0x48
jah128 0:d6269d17c8cf 35 #define EEPROM_ADDRESS 0XA0
jah128 0:d6269d17c8cf 36 #define TEMPERATURE_ADDRESS 0X30
jah128 0:d6269d17c8cf 37 #define BASE_COLOUR_ADDRESS 0X52
jah128 0:d6269d17c8cf 38 #define TOP_COLOUR_ADDRESS 0X72
jah128 0:d6269d17c8cf 39 #define ULTRASONIC_ADDRESS 0XE0
jah128 0:d6269d17c8cf 40 #define COMMAND_MESSAGE_BYTE 0X1D
jah128 0:d6269d17c8cf 41 #define ACKNOWLEDGE_MESSAGE_BYTE 0X1E
jah128 0:d6269d17c8cf 42 #define RESPONSE_MESSAGE_BYTE 0X1F
jah128 0:d6269d17c8cf 43 #define PSI_BYTE 0X1D
jah128 0:d6269d17c8cf 44
jah128 0:d6269d17c8cf 45 //Set temperature sensor warnings: 60C critical, 50C high, 0C low
jah128 0:d6269d17c8cf 46 #define TEMPERATURE_CRITICAL_HI 0X03
jah128 0:d6269d17c8cf 47 #define TEMPEARTURE_CRITICAL_LO 0XC0
jah128 0:d6269d17c8cf 48 #define TEMPERATURE_HIGH_HI 0X03
jah128 0:d6269d17c8cf 49 #define TEMPEARTURE_HIGH_LO 0X20
jah128 0:d6269d17c8cf 50 #define TEMPERATURE_LOW_HI 0X00
jah128 0:d6269d17c8cf 51 #define TEMPEARTURE_LOW_LO 0X00
jah128 0:d6269d17c8cf 52
jah128 0:d6269d17c8cf 53 #define DEFAULT_IR_PULSE_DELAY 400
jah128 0:d6269d17c8cf 54 #define DEFAULT_BASE_IR_PULSE_DELAY 50
jah128 0:d6269d17c8cf 55
jah128 0:d6269d17c8cf 56 #include <stdio.h>
jah128 0:d6269d17c8cf 57 #include <stdarg.h>
jah128 0:d6269d17c8cf 58 #include <string>
jah128 0:d6269d17c8cf 59 #include <vector>
jah128 0:d6269d17c8cf 60
jah128 0:d6269d17c8cf 61 #include "settings.h"
jah128 0:d6269d17c8cf 62 #include "serial.h"
jah128 0:d6269d17c8cf 63 #include "mbed.h"
jah128 0:d6269d17c8cf 64 #include "display.h"
jah128 0:d6269d17c8cf 65 #include "led.h"
jah128 11:312663037b8c 66 #include "i2c_setup.h"
jah128 0:d6269d17c8cf 67 #include "motors.h"
jah128 0:d6269d17c8cf 68 #include "sensors.h"
jah128 0:d6269d17c8cf 69 #include "eprom.h"
jah128 0:d6269d17c8cf 70 #include "colour.h"
jah128 11:312663037b8c 71 #include "sound.h"
jah128 0:d6269d17c8cf 72 #include "demo.h"
jah128 0:d6269d17c8cf 73 #include "dances.h"
jah128 0:d6269d17c8cf 74 #include "basic.h"
jah128 0:d6269d17c8cf 75
jah128 0:d6269d17c8cf 76 //NB The user needs to have a main.cpp with a main() function and a handle_switch_event(char) function
jah128 0:d6269d17c8cf 77 #include "main.h"
jah128 0:d6269d17c8cf 78
jah128 0:d6269d17c8cf 79
jah128 8:6c92789d5f87 80 extern Serial pc;
jah128 8:6c92789d5f87 81 extern Serial bt;
jah128 8:6c92789d5f87 82 extern Display display;
jah128 8:6c92789d5f87 83 extern Motors motors;
jah128 8:6c92789d5f87 84 extern Eprom eprom;
jah128 9:dde9e21030eb 85 extern Led led;
jah128 10:e58323951c08 86 extern Sensors sensors;
jah128 11:312663037b8c 87 extern SerialControl serial;
jah128 11:312663037b8c 88 extern Sound sound;
jah128 11:312663037b8c 89 extern Setup i2c_setup;
jah128 11:312663037b8c 90 extern Demo demo;
jah128 11:312663037b8c 91 extern Dances dances;
jah128 8:6c92789d5f87 92
jah128 0:d6269d17c8cf 93 void init(void);
jah128 0:d6269d17c8cf 94 float get_uptime(void);
jah128 0:d6269d17c8cf 95 void pause_user_code(float period);
jah128 0:d6269d17c8cf 96 void reset_encoders(void);
jah128 0:d6269d17c8cf 97 void debug(const char* format, ...) ;
jah128 0:d6269d17c8cf 98
jah128 0:d6269d17c8cf 99 void IF_end_pause_user_code(void);
jah128 0:d6269d17c8cf 100 void IF_handle_events(void);
jah128 0:d6269d17c8cf 101 void IF_update_encoders(void);
jah128 0:d6269d17c8cf 102 void IF_update_user_id(void);
jah128 0:d6269d17c8cf 103 void IF_update_switch(void);
jah128 0:d6269d17c8cf 104 void IF_update_minutes(void);
jah128 1:060690a934a9 105 void IF_get_hardware_description(void);
jah128 0:d6269d17c8cf 106
jah128 0:d6269d17c8cf 107 extern char * program_name;
jah128 0:d6269d17c8cf 108 extern char * author_name;
jah128 0:d6269d17c8cf 109 extern char * version_name;
jah128 0:d6269d17c8cf 110
jah128 0:d6269d17c8cf 111 extern I2C primary_i2c;
jah128 0:d6269d17c8cf 112 extern InterruptIn gpio_interrupt;
jah128 0:d6269d17c8cf 113
jah128 0:d6269d17c8cf 114 extern AnalogIn vin_current;
jah128 0:d6269d17c8cf 115 extern AnalogIn vin_battery;
jah128 0:d6269d17c8cf 116 extern AnalogIn vin_dc;
jah128 0:d6269d17c8cf 117
jah128 0:d6269d17c8cf 118 extern DigitalOut mbed_led1;
jah128 0:d6269d17c8cf 119 extern DigitalOut mbed_led2;
jah128 0:d6269d17c8cf 120 extern DigitalOut mbed_led3;
jah128 0:d6269d17c8cf 121 extern DigitalOut mbed_led4;
jah128 0:d6269d17c8cf 122 extern PwmOut center_led_red;
jah128 0:d6269d17c8cf 123 extern PwmOut center_led_green;
jah128 0:d6269d17c8cf 124 extern PwmOut motor_left_f;
jah128 0:d6269d17c8cf 125 extern PwmOut motor_left_r;
jah128 0:d6269d17c8cf 126 extern PwmOut motor_right_f;
jah128 0:d6269d17c8cf 127 extern PwmOut motor_right_r;
jah128 0:d6269d17c8cf 128
jah128 0:d6269d17c8cf 129 extern char time_based_motor_action;
jah128 0:d6269d17c8cf 130
jah128 0:d6269d17c8cf 131 extern int base_colour_sensor_raw_values [];
jah128 0:d6269d17c8cf 132 extern int top_colour_sensor_raw_values [];
jah128 0:d6269d17c8cf 133
jah128 0:d6269d17c8cf 134 extern char waiting_for_ultrasonic;
jah128 0:d6269d17c8cf 135 extern int ultrasonic_distance;
jah128 0:d6269d17c8cf 136 extern char ultrasonic_distance_updated;
jah128 0:d6269d17c8cf 137 extern Timeout ultrasonic_timeout;
jah128 0:d6269d17c8cf 138 extern Ticker ultrasonic_ticker;
jah128 0:d6269d17c8cf 139
jah128 0:d6269d17c8cf 140 extern unsigned short background_ir_values [];
jah128 0:d6269d17c8cf 141 extern unsigned short illuminated_ir_values [];
jah128 0:d6269d17c8cf 142 extern float reflected_ir_distances [];
jah128 0:d6269d17c8cf 143 extern char ir_values_stored;
jah128 0:d6269d17c8cf 144
jah128 0:d6269d17c8cf 145 extern char firmware_bytes[];
jah128 0:d6269d17c8cf 146
jah128 0:d6269d17c8cf 147 extern char testing_voltage_regulators_flag;
jah128 0:d6269d17c8cf 148 extern char power_good_motor_left;
jah128 0:d6269d17c8cf 149 extern char power_good_motor_right;
jah128 0:d6269d17c8cf 150 extern char power_good_infrared;
jah128 0:d6269d17c8cf 151 extern char status_dc_in;
jah128 0:d6269d17c8cf 152 extern char status_charging;
jah128 0:d6269d17c8cf 153
jah128 0:d6269d17c8cf 154 extern unsigned short background_base_ir_values [];
jah128 0:d6269d17c8cf 155 extern unsigned short illuminated_base_ir_values [];
jah128 0:d6269d17c8cf 156 extern char base_ir_values_stored;
jah128 0:d6269d17c8cf 157 extern float line_position;
jah128 0:d6269d17c8cf 158 extern char line_found;
jah128 0:d6269d17c8cf 159
jah128 0:d6269d17c8cf 160 extern float motor_left_speed;
jah128 0:d6269d17c8cf 161 extern float motor_right_speed;
jah128 0:d6269d17c8cf 162 extern char motor_left_brake;
jah128 0:d6269d17c8cf 163 extern char motor_right_brake;
jah128 0:d6269d17c8cf 164
jah128 0:d6269d17c8cf 165 extern float center_led_brightness;
jah128 0:d6269d17c8cf 166 extern float backlight_brightness;
jah128 0:d6269d17c8cf 167
jah128 4:1c621cb8cf0d 168 extern char use_motor_calibration;
jah128 4:1c621cb8cf0d 169 extern char motor_calibration_set;
jah128 4:1c621cb8cf0d 170 extern float left_motor_calibration_value;
jah128 4:1c621cb8cf0d 171 extern float right_motor_calibration_value;
jah128 4:1c621cb8cf0d 172
jah128 0:d6269d17c8cf 173 extern float firmware_version;
jah128 1:060690a934a9 174 extern float pcb_version;
jah128 1:060690a934a9 175 extern float serial_number;
jah128 1:060690a934a9 176
jah128 1:060690a934a9 177 extern char has_compass;
jah128 1:060690a934a9 178 extern char has_side_ir;
jah128 1:060690a934a9 179 extern char has_base_ir;
jah128 1:060690a934a9 180 extern char has_base_colour_sensor;
jah128 1:060690a934a9 181 extern char has_top_colour_sensor;
jah128 1:060690a934a9 182 extern char has_wheel_encoders;
jah128 1:060690a934a9 183 extern char has_audio_pic;
jah128 1:060690a934a9 184 extern char has_ultrasonic_sensor;
jah128 1:060690a934a9 185 extern char has_temperature_sensor;
jah128 1:060690a934a9 186 extern char has_recharging_circuit;
jah128 1:060690a934a9 187 extern char has_433_radio;
jah128 0:d6269d17c8cf 188
jah128 0:d6269d17c8cf 189 extern int ir_pulse_delay;
jah128 0:d6269d17c8cf 190 extern int base_ir_pulse_delay;
jah128 0:d6269d17c8cf 191
jah128 0:d6269d17c8cf 192 extern char robot_id;
jah128 0:d6269d17c8cf 193 extern char previous_robot_id;
jah128 0:d6269d17c8cf 194
jah128 0:d6269d17c8cf 195 extern char wheel_encoder_byte;
jah128 0:d6269d17c8cf 196 extern char previous_wheel_encoder_byte;
jah128 0:d6269d17c8cf 197 extern signed int left_encoder;
jah128 0:d6269d17c8cf 198 extern signed int right_encoder;
jah128 0:d6269d17c8cf 199
jah128 0:d6269d17c8cf 200 extern char switch_byte;
jah128 0:d6269d17c8cf 201 extern char previous_switch_byte;
jah128 0:d6269d17c8cf 202
jah128 0:d6269d17c8cf 203 extern char user_code_running;
jah128 0:d6269d17c8cf 204 extern char user_code_restore_mode;
jah128 0:d6269d17c8cf 205 extern char demo_on;
jah128 0:d6269d17c8cf 206 extern char event;
jah128 0:d6269d17c8cf 207 extern char change_id_event;
jah128 0:d6269d17c8cf 208 extern char encoder_event;
jah128 0:d6269d17c8cf 209 extern char switch_event;
jah128 0:d6269d17c8cf 210 extern char system_warnings;
jah128 0:d6269d17c8cf 211
jah128 0:d6269d17c8cf 212 extern char debug_mode;
jah128 0:d6269d17c8cf 213 extern char debug_output;
jah128 0:d6269d17c8cf 214
jah128 0:d6269d17c8cf 215 extern vector<string> basic_filenames;
jah128 0:d6269d17c8cf 216 extern char psi_basic_file_count;
jah128 0:d6269d17c8cf 217 extern char use_flash_basic;
jah128 0:d6269d17c8cf 218 extern char file_transfer_mode;
jah128 0:d6269d17c8cf 219 #endif