Psi Swarm robot library version 0.9
Fork of PsiSwarmV8_CPP by
Diff: psiswarm.h
- Revision:
- 12:878c6e9d9e60
- Parent:
- 11:312663037b8c
- Child:
- 15:66be5ec52c3b
diff -r 312663037b8c -r 878c6e9d9e60 psiswarm.h --- a/psiswarm.h Sun Oct 16 21:06:15 2016 +0000 +++ b/psiswarm.h Mon Oct 17 13:09:10 2016 +0000 @@ -1,11 +1,11 @@ -/* University of York Robotics Laboratory PsiSwarm Library: PsiSwarm Core Header File - * +/* University of York Robotics Laboratory PsiSwarm Library: PsiSwarm C++ Core Header File + * * Copyright 2016 University of York * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and limitations under the License. * * File: psiswarm.h @@ -18,15 +18,15 @@ * October 2016 * * - */ + */ #ifndef PSISWARM_H #define PSISWARM_H - + #define SOFTWARE_VERSION_CODE 0.80 #define PIC_ADDRESS 0x30 -#define LCD_ADDRESS 0x7C +#define LCD_ADDRESS 0x7C #define LED_IC_ADDRESS 0x42 #define GPIO_IC_ADDRESS 0x40 #define AUX_IC_ADDRESS 0x4E @@ -70,13 +70,77 @@ #include "colour.h" #include "sound.h" #include "demo.h" -#include "dances.h" +#include "animations.h" #include "basic.h" //NB The user needs to have a main.cpp with a main() function and a handle_switch_event(char) function #include "main.h" +/** Psiswarm Class + * The main class to define a robot + * + * Example code for main.cpp: + * @code + * #include "psiswarm.h" + * Psiswarm psi; + * char * program_name = "Example"; + * char * author_name = "Name"; + * char * version_name = "0.8"; + * void handle_switch_event(char switch_state){} + * void handle_user_serial_message(char * message, char length, char interface) {} + * int main(){ + * psi.init(); + * while(1) { //Do something! + * } + * } + * @endcode + */ +class Psiswarm +{ +public: + /** + * Main initialisation routine for the PsiSwarm robot + * + * Set up the GPIO expansion ICs, launch demo mode if button is held + */ + void init(void); + + /** + * Get the uptime for the robot + * + * @return The amount of time in seconds that the MBED has been active since last reset + */ + float get_uptime(void); + + /** + * Pause the user code for a defined amount of time + * + * @param The amount of time in seconds to pause user code + */ + void pause_user_code(float period); + + /** + * Reset the wheel encoder counters + */ + void reset_encoders(void); + + /** + * Send a string (in printf format) to the preferred debug stream, specified in settings.h [of overridden programmatically] + * + * @param The string to send to output stream + */ + void debug(const char* format, ...) ; +private: + void IF_end_pause_user_code(void); + void IF_handle_events(void); + void IF_update_encoders(void); + void IF_update_user_id(void); + void IF_update_switch(void); + void IF_update_minutes(void); + void IF_get_hardware_description(void); +}; +extern Psiswarm psi; extern Serial pc; extern Serial bt; extern Display display; @@ -88,22 +152,8 @@ extern Sound sound; extern Setup i2c_setup; extern Demo demo; -extern Dances dances; - -void init(void); -float get_uptime(void); -void pause_user_code(float period); -void reset_encoders(void); -void debug(const char* format, ...) ; - -void IF_end_pause_user_code(void); -void IF_handle_events(void); -void IF_update_encoders(void); -void IF_update_user_id(void); -void IF_update_switch(void); -void IF_update_minutes(void); -void IF_get_hardware_description(void); - +extern Animations animations; +extern Basic basic; extern char * program_name; extern char * author_name; extern char * version_name; @@ -212,8 +262,9 @@ extern char debug_mode; extern char debug_output; -extern vector<string> basic_filenames; +extern vector<string> basic_filenames; extern char psi_basic_file_count; extern char use_flash_basic; extern char file_transfer_mode; + #endif