James Heavey / 3875_Individualproject

Dependents:   3875_DISSERTATION

m3pi.h

Committer:
eencae
Date:
2017-04-04
Revision:
0:56320ef879a6
Child:
1:5523d6d1feec

File content as of revision 0:56320ef879a6:

#ifndef M3PI_H
#define M3PI_H

#include "mbed.h"

/** m3pi Class
@brief Library to control m3pi robot from Polulu running the serial slave code
@brief Revision 1.0
@author Craig A. Evans <C.A.Evans@leeds.ac.uk> 
@date   April 2017

*/
class m3pi
{

public:

    /** m3pi constructor
    */
    m3pi();
    /** m3pi destructor
    */
    ~m3pi();

    /** Write value to LEDs
    * @param val - value to display in binary on LEDs (0 to 255)
    */
    void write_leds(int val);

    /** Initialisation function
    * @details should be called at the start of the program
    */
    void init();

    /** Get signature of slave firmware
    * @param signature - array of size 7 to store signature
    */
    void get_signature(char *signature);
    
    /** Read raw sensor values from IR sensors (0 - 2000)
    * @param values - array of size 5 to store values
    */
    void get_raw_values(unsigned int *values);      

    /** Read calibrated sensor values from IR sensors (0 - 1000)
    * @param values - array of size 5 to store values
    */
    void get_calibrated_values(unsigned int *values);
    
    /** Read user potentiometer values
    * @returns float in range  0.0 to 1.0
    */
    float get_trimpot_value();

    /** Read battery voltage
    * @returns battery voltage in volts
    */
    float get_battery_voltage();
    
    /** Play music
    * @param notes - const array containing Pololu notes
    */
    void play_music(const char notes[],int length);
    
    void calibrate();

    void reset_calibration();

    int get_line_position();
    
    float get_normalised_line_position();

    void lcd_clear();
    
    void lcd_print(char text[],int length);
    
    void lcd_goto_xy(int x, int y);
    
    void auto_calibrate();
    
    void left_motor(float speed);
    
    void right_motor(float speed);
    
    //////
    
    void motors(float left_speed,float right_speed);
    
    void stop();
    
    void forward(float speed);
    
    void reverse(float speed);
    
    void spin_right(float speed);
    
    void spin_left(float speed);
    
    int read_button();
    
    void display_battery_voltage(int x,int y);
    
    void display_signature(int x,int y);


private:

    Serial* _serial;
    DigitalOut* _reset;
    DigitalIn* _button;
    BusOut* _leds;

    void reset();

};



#endif