![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
ft. button press reset
Fork of BeaconDemo_RobotCode by
PsiSwarm/psiswarm.h@8:00558287a4ef, 2015-10-22 (annotated)
- Committer:
- jah128
- Date:
- Thu Oct 22 15:36:16 2015 +0000
- Revision:
- 8:00558287a4ef
- Parent:
- 6:ff3c66f7372b
- Child:
- 10:1b09d4bb847b
Added time_based_turn_degrees
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
jah128 | 0:8a5497a2e366 | 1 | /* University of York Robotics Laboratory PsiSwarm Library: PsiSwarm Core Header File |
jah128 | 0:8a5497a2e366 | 2 | * |
jah128 | 0:8a5497a2e366 | 3 | * File: psiswarm.h |
jah128 | 0:8a5497a2e366 | 4 | * |
jah128 | 6:ff3c66f7372b | 5 | * (C) Dept. Electronics & Computer Science, University of York |
jah128 | 6:ff3c66f7372b | 6 | * James Hilder, Alan Millard, Homero Elizondo, Jon Timmis |
jah128 | 0:8a5497a2e366 | 7 | * |
jah128 | 6:ff3c66f7372b | 8 | * PsiSwarm Library Version: 0.3 |
jah128 | 0:8a5497a2e366 | 9 | * |
jah128 | 6:ff3c66f7372b | 10 | * October 2015 |
jah128 | 0:8a5497a2e366 | 11 | * |
jah128 | 0:8a5497a2e366 | 12 | */ |
jah128 | 0:8a5497a2e366 | 13 | |
jah128 | 0:8a5497a2e366 | 14 | #ifndef PSISWARM_H |
jah128 | 0:8a5497a2e366 | 15 | #define PSISWARM_H |
jah128 | 0:8a5497a2e366 | 16 | |
jah128 | 0:8a5497a2e366 | 17 | #define SOFTWARE_VERSION_CODE 0.20 |
jah128 | 0:8a5497a2e366 | 18 | |
jah128 | 4:25039ea5eb09 | 19 | #define PIC_ADDRESS 0x30 |
jah128 | 0:8a5497a2e366 | 20 | #define LCD_ADDRESS 0x7C |
jah128 | 0:8a5497a2e366 | 21 | #define LED_IC_ADDRESS 0x42 |
jah128 | 0:8a5497a2e366 | 22 | #define GPIO_IC_ADDRESS 0x40 |
jah128 | 0:8a5497a2e366 | 23 | #define AUX_IC_ADDRESS 0x4E |
jah128 | 0:8a5497a2e366 | 24 | #define ADC1_ADDRESS 0x46 |
jah128 | 0:8a5497a2e366 | 25 | #define ADC2_ADDRESS 0x48 |
jah128 | 0:8a5497a2e366 | 26 | #define EEPROM_ADDRESS 0XA0 |
jah128 | 0:8a5497a2e366 | 27 | #define TEMPERATURE_ADDRESS 0X30 |
jah128 | 0:8a5497a2e366 | 28 | #define BASE_COLOUR_ADDRESS 0X52 |
jah128 | 0:8a5497a2e366 | 29 | #define TOP_COLOUR_ADDRESS 0X72 |
jah128 | 0:8a5497a2e366 | 30 | #define ULTRASONIC_ADDRESS 0XE0 |
jah128 | 0:8a5497a2e366 | 31 | #define COMMAND_MESSAGE_BYTE 0X1D |
jah128 | 0:8a5497a2e366 | 32 | #define ACKNOWLEDGE_MESSAGE_BYTE 0X1E |
jah128 | 0:8a5497a2e366 | 33 | #define RESPONSE_MESSAGE_BYTE 0X1F |
jah128 | 0:8a5497a2e366 | 34 | #define PSI_BYTE 0X1D |
jah128 | 0:8a5497a2e366 | 35 | |
jah128 | 0:8a5497a2e366 | 36 | //Set temperature sensor warnings: 60C critical, 50C high, 0C low |
jah128 | 0:8a5497a2e366 | 37 | #define TEMPERATURE_CRITICAL_HI 0X03 |
jah128 | 0:8a5497a2e366 | 38 | #define TEMPEARTURE_CRITICAL_LO 0XC0 |
jah128 | 0:8a5497a2e366 | 39 | #define TEMPERATURE_HIGH_HI 0X03 |
jah128 | 0:8a5497a2e366 | 40 | #define TEMPEARTURE_HIGH_LO 0X20 |
jah128 | 0:8a5497a2e366 | 41 | #define TEMPERATURE_LOW_HI 0X00 |
jah128 | 0:8a5497a2e366 | 42 | #define TEMPEARTURE_LOW_LO 0X00 |
jah128 | 0:8a5497a2e366 | 43 | |
jah128 | 0:8a5497a2e366 | 44 | #define DEFAULT_IR_PULSE_DELAY 400 |
jah128 | 0:8a5497a2e366 | 45 | #define DEFAULT_BASE_IR_PULSE_DELAY 50 |
jah128 | 0:8a5497a2e366 | 46 | |
jah128 | 0:8a5497a2e366 | 47 | #include <stdio.h> |
jah128 | 0:8a5497a2e366 | 48 | #include <stdarg.h> |
jah128 | 0:8a5497a2e366 | 49 | |
jah128 | 0:8a5497a2e366 | 50 | #include "settings.h" |
jah128 | 0:8a5497a2e366 | 51 | #include "serial.h" |
jah128 | 0:8a5497a2e366 | 52 | #include "mbed.h" |
jah128 | 0:8a5497a2e366 | 53 | #include "display.h" |
jah128 | 0:8a5497a2e366 | 54 | #include "led.h" |
jah128 | 0:8a5497a2e366 | 55 | #include "i2c.h" |
jah128 | 0:8a5497a2e366 | 56 | #include "motors.h" |
jah128 | 0:8a5497a2e366 | 57 | #include "sensors.h" |
jah128 | 0:8a5497a2e366 | 58 | #include "eprom.h" |
jah128 | 0:8a5497a2e366 | 59 | #include "colour.h" |
jah128 | 4:25039ea5eb09 | 60 | #include "pic.h" |
jah128 | 0:8a5497a2e366 | 61 | #include "demo.h" |
jah128 | 0:8a5497a2e366 | 62 | |
jah128 | 0:8a5497a2e366 | 63 | |
jah128 | 0:8a5497a2e366 | 64 | //NB The user needs to have a main.cpp with a main() function and a handle_switch_event(char) function |
jah128 | 0:8a5497a2e366 | 65 | #include "main.h" |
jah128 | 0:8a5497a2e366 | 66 | |
jah128 | 0:8a5497a2e366 | 67 | |
jah128 | 0:8a5497a2e366 | 68 | void init(void); |
jah128 | 0:8a5497a2e366 | 69 | float get_uptime(void); |
jah128 | 0:8a5497a2e366 | 70 | void pause_user_code(float period); |
jah128 | 0:8a5497a2e366 | 71 | void reset_encoders(void); |
jah128 | 0:8a5497a2e366 | 72 | void debug(const char* format, ...) ; |
jah128 | 0:8a5497a2e366 | 73 | |
jah128 | 0:8a5497a2e366 | 74 | void IF_end_pause_user_code(void); |
jah128 | 0:8a5497a2e366 | 75 | void IF_handle_events(void); |
jah128 | 0:8a5497a2e366 | 76 | void IF_update_encoders(void); |
jah128 | 0:8a5497a2e366 | 77 | void IF_update_user_id(void); |
jah128 | 0:8a5497a2e366 | 78 | void IF_update_switch(void); |
jah128 | 0:8a5497a2e366 | 79 | void IF_update_minutes(void); |
jah128 | 0:8a5497a2e366 | 80 | |
jah128 | 0:8a5497a2e366 | 81 | extern char * program_name; |
jah128 | 0:8a5497a2e366 | 82 | extern char * author_name; |
jah128 | 1:f6356cf1cefc | 83 | extern char * version_name; |
jah128 | 0:8a5497a2e366 | 84 | |
jah128 | 0:8a5497a2e366 | 85 | extern Serial pc; |
jah128 | 0:8a5497a2e366 | 86 | extern Serial bt; |
jah128 | 0:8a5497a2e366 | 87 | extern Display display; |
jah128 | 0:8a5497a2e366 | 88 | extern I2C primary_i2c; |
jah128 | 0:8a5497a2e366 | 89 | extern InterruptIn gpio_interrupt; |
jah128 | 0:8a5497a2e366 | 90 | |
jah128 | 0:8a5497a2e366 | 91 | extern AnalogIn vin_current; |
jah128 | 0:8a5497a2e366 | 92 | extern AnalogIn vin_battery; |
jah128 | 0:8a5497a2e366 | 93 | extern AnalogIn vin_dc; |
jah128 | 0:8a5497a2e366 | 94 | |
jah128 | 0:8a5497a2e366 | 95 | extern DigitalOut mbed_led1; |
jah128 | 0:8a5497a2e366 | 96 | extern DigitalOut mbed_led2; |
jah128 | 0:8a5497a2e366 | 97 | extern DigitalOut mbed_led3; |
jah128 | 0:8a5497a2e366 | 98 | extern DigitalOut mbed_led4; |
jah128 | 0:8a5497a2e366 | 99 | extern PwmOut center_led_red; |
jah128 | 0:8a5497a2e366 | 100 | extern PwmOut center_led_green; |
jah128 | 0:8a5497a2e366 | 101 | extern PwmOut motor_left_f; |
jah128 | 0:8a5497a2e366 | 102 | extern PwmOut motor_left_r; |
jah128 | 0:8a5497a2e366 | 103 | extern PwmOut motor_right_f; |
jah128 | 0:8a5497a2e366 | 104 | extern PwmOut motor_right_r; |
jah128 | 0:8a5497a2e366 | 105 | |
jah128 | 8:00558287a4ef | 106 | extern char time_based_motor_action; |
jah128 | 8:00558287a4ef | 107 | |
jah128 | 0:8a5497a2e366 | 108 | extern int base_colour_sensor_raw_values []; |
jah128 | 0:8a5497a2e366 | 109 | extern int top_colour_sensor_raw_values []; |
jah128 | 0:8a5497a2e366 | 110 | |
jah128 | 0:8a5497a2e366 | 111 | extern char waiting_for_ultrasonic; |
jah128 | 0:8a5497a2e366 | 112 | extern int ultrasonic_distance; |
jah128 | 0:8a5497a2e366 | 113 | extern char ultrasonic_distance_updated; |
jah128 | 0:8a5497a2e366 | 114 | extern Timeout ultrasonic_timeout; |
jah128 | 0:8a5497a2e366 | 115 | extern Ticker ultrasonic_ticker; |
jah128 | 0:8a5497a2e366 | 116 | |
jah128 | 0:8a5497a2e366 | 117 | extern unsigned short background_ir_values []; |
jah128 | 0:8a5497a2e366 | 118 | extern unsigned short illuminated_ir_values []; |
jah128 | 0:8a5497a2e366 | 119 | extern float reflected_ir_distances []; |
jah128 | 0:8a5497a2e366 | 120 | extern char ir_values_stored; |
jah128 | 0:8a5497a2e366 | 121 | |
jah128 | 0:8a5497a2e366 | 122 | extern char firmware_bytes[]; |
jah128 | 0:8a5497a2e366 | 123 | |
jah128 | 5:598298aa4900 | 124 | extern char testing_voltage_regulators_flag; |
jah128 | 5:598298aa4900 | 125 | extern char power_good_motor_left; |
jah128 | 5:598298aa4900 | 126 | extern char power_good_motor_right; |
jah128 | 5:598298aa4900 | 127 | extern char power_good_infrared; |
jah128 | 5:598298aa4900 | 128 | extern char status_dc_in; |
jah128 | 5:598298aa4900 | 129 | extern char status_charging; |
jah128 | 5:598298aa4900 | 130 | |
jah128 | 0:8a5497a2e366 | 131 | extern unsigned short background_base_ir_values []; |
jah128 | 0:8a5497a2e366 | 132 | extern unsigned short illuminated_base_ir_values []; |
jah128 | 0:8a5497a2e366 | 133 | extern char base_ir_values_stored; |
jah128 | 3:cd048f6e544e | 134 | extern float line_position; |
jah128 | 3:cd048f6e544e | 135 | extern char line_found; |
jah128 | 0:8a5497a2e366 | 136 | |
jah128 | 0:8a5497a2e366 | 137 | extern float motor_left_speed; |
jah128 | 0:8a5497a2e366 | 138 | extern float motor_right_speed; |
jah128 | 0:8a5497a2e366 | 139 | extern char motor_left_brake; |
jah128 | 0:8a5497a2e366 | 140 | extern char motor_right_brake; |
jah128 | 0:8a5497a2e366 | 141 | |
jah128 | 0:8a5497a2e366 | 142 | extern float center_led_brightness; |
jah128 | 0:8a5497a2e366 | 143 | extern float backlight_brightness; |
jah128 | 0:8a5497a2e366 | 144 | |
jah128 | 0:8a5497a2e366 | 145 | extern float firmware_version; |
jah128 | 0:8a5497a2e366 | 146 | |
jah128 | 0:8a5497a2e366 | 147 | extern int ir_pulse_delay; |
jah128 | 0:8a5497a2e366 | 148 | extern int base_ir_pulse_delay; |
jah128 | 0:8a5497a2e366 | 149 | |
jah128 | 0:8a5497a2e366 | 150 | extern char robot_id; |
jah128 | 0:8a5497a2e366 | 151 | extern char previous_robot_id; |
jah128 | 0:8a5497a2e366 | 152 | |
jah128 | 0:8a5497a2e366 | 153 | extern char wheel_encoder_byte; |
jah128 | 0:8a5497a2e366 | 154 | extern char previous_wheel_encoder_byte; |
jah128 | 0:8a5497a2e366 | 155 | extern signed int left_encoder; |
jah128 | 0:8a5497a2e366 | 156 | extern signed int right_encoder; |
jah128 | 0:8a5497a2e366 | 157 | |
jah128 | 0:8a5497a2e366 | 158 | extern char switch_byte; |
jah128 | 0:8a5497a2e366 | 159 | extern char previous_switch_byte; |
jah128 | 0:8a5497a2e366 | 160 | |
jah128 | 0:8a5497a2e366 | 161 | extern char user_code_running; |
jah128 | 0:8a5497a2e366 | 162 | extern char user_code_restore_mode; |
jah128 | 0:8a5497a2e366 | 163 | extern char demo_on; |
jah128 | 0:8a5497a2e366 | 164 | extern char event; |
jah128 | 0:8a5497a2e366 | 165 | extern char change_id_event; |
jah128 | 0:8a5497a2e366 | 166 | extern char encoder_event; |
jah128 | 0:8a5497a2e366 | 167 | extern char switch_event; |
jah128 | 0:8a5497a2e366 | 168 | extern char system_warnings; |
jah128 | 0:8a5497a2e366 | 169 | |
jah128 | 0:8a5497a2e366 | 170 | extern char debug_mode; |
jah128 | 0:8a5497a2e366 | 171 | extern char debug_output; |
jah128 | 0:8a5497a2e366 | 172 | #endif |