Unfinished v0.7, added bearing detection
Fork of Pi_Swarm_Library_v06_alpha by
Diff: piswarm.h
- Revision:
- 1:b067a08ff54e
- Parent:
- 0:9ffe8ebd1c40
- Child:
- 3:4c0f2f3de33e
--- a/piswarm.h Fri Jan 31 22:59:25 2014 +0000 +++ b/piswarm.h Sun Feb 02 18:05:58 2014 +0000 @@ -17,7 +17,6 @@ #include "alpha433.h" #include "main.h" - #ifdef MBED_RPC #include "rpc.h" #endif @@ -50,41 +49,18 @@ // Public functions public: - /** Create the m3pi object connected to the default pins - * Pin 05 : Alpha Transceiver SDI - * Pin 06 : Alpha Transceiver SDO - * Pin 07 : Alpha Transceiver CLK - * Pin 08 : Alpha Transceiver FSS - * Pin 09 : Serial (3pi) transmit - * Pin 10 : Serial (3pi) receive - * Pin 11 : Alpha Transceiver NIRQ - * Pin 12 : IR Pulse Output for IR1,2,7,8 - * Pin 13 : IR Pulse Output for IR3,4,5,6 - * Pin 14 : Echo Pin for Sonar - * Pin 15 : Light Sensor Analogue Input - * Pin 16 : Gyrometer Analogue Input - * Pin 17 : Accelerometer Z Analogue Input - * Pin 18 : Accelerometer Y Analogue Input - * Pin 19 : Accelerometer X Analogue Input - * Pin 20 : Temperature Sensor Analogue Input - * Pin 21 : Center LED Blue PWM Output - * Pin 22 : Center LED Green PWM Output - * Pin 23 : Center LED Red PWM Output - * Pin 24 : Outer LED Blue PWM Output - * Pin 25 : Outer LED Green PWM Output - * Pin 26 : Outer LED Red PWM Output - * Pin 27 : I2C SCL - * Pin 28 : I2C SDA - * Pin 29 : GPIO Expander Interrupt - * Pin 30 : Trigger Pin for Sonar - * Pin 31 : USB D+ Connector - * Pin 32 : USB D- Connector - */ + // Create the Pi Swarm object connected to the default pins [see end of file] PiSwarm(); // Returns the RGB Colour of the Outer LED as an int (r<<16 g<<8 b) int get_oled_colour(void); + // Returns the enable state of an single outer led + char get_oled_state(char oled); + + // Returns the enable state of the center LED + char get_cled_state(void); + // Returns the RGB Colour of the Center LED as an int (r<<16 g<<8 b) int get_cled_colour(void); @@ -223,28 +199,10 @@ void read_raw_sensors ( int * raw_ls_array ); - /** Play a tune on the 3pi buzzer - * @ param tune Pointer to a character sequence of the tune - * @ param length Length of characters in sequence - * ‘A’ – ‘G’: used to specify the notes that will be played - * ‘R’: used to specify a rest (no sound for the duration of the note) - * ‘<’ ‘>’ plays the next note one octave lower or higher - * ‘+’ or ‘#’ after a note raises any note one half-step, ‘-’ after a note lowers any note one half-step - * ‘.’ after a note “dots” it, increasing the length by 50%. Each additional dot adds half as much as the previous dot, so that “A..” is 1.75 times the length of “A”. - * ‘O’ followed by a number sets the octave (default: O4). - * ‘T’ followed by a number sets the tempo in beats/min (default: T120). - * ‘L’ followed by a number sets the default note duration to the type specified by the number: 4 for quarter notes, 8 for eighth notes, 16 for sixteenth notes, etc. (default: L4). - * ‘V’ followed by a number from 0-15 sets the music volume (default: V15). - * ‘MS’ sets all subsequent notes to play play staccato – each note is played for 1/2 of its allotted time, followed by an equal period of silence. - * ‘ML’ sets all subsequent notes to play legato – each note is played for full length. This is the default setting. - * ‘!’ resets the octave, tempo, duration, volume, and staccato setting to their default values. These settings persist from one play() to the next, which allows you to more conveniently break up your music into reusable sections. - * 1-2000: when immediately following a note, a number determines the duration of the note. For example, C16 specifies C played as a sixteenth note (1/16th the length of a whole note). - * EG Blue Danube Waltz (badly): s3pi.play_tune("MSCEGGR>F>FR>D>DRCCEGGR>G>GR>E>ER<B<BDAAR>A>AR>F>F",51); - */ + // Play a tune on the 3-pi buzzer (see end of file for more details) void play_tune (char * tune, int length); - /** Force a hardware reset of the 3pi - */ + // Force a hardware reset of the 3-pi void reset (void); float get_left_motor (void); @@ -389,8 +347,97 @@ #endif +/******************************************************************************** + * MBED Pin connection layout * + * * + * * Pin 05 : Alpha Transceiver SDI * + * * Pin 06 : Alpha Transceiver SDO * + * * Pin 07 : Alpha Transceiver CLK * + * * Pin 08 : Alpha Transceiver FSS * + * * Pin 09 : Serial (3pi) transmit * + * * Pin 10 : Serial (3pi) receive * + * * Pin 11 : Alpha Transceiver NIRQ * + * * Pin 12 : IR Pulse Output for IR1,2,7,8 * + * * Pin 13 : IR Pulse Output for IR3,4,5,6 * + * * Pin 14 : Echo Pin for Sonar * + * * Pin 15 : Light Sensor Analogue Input * + * * Pin 16 : Gyrometer Analogue Input * + * * Pin 17 : Accelerometer Z Analogue Input * + * * Pin 18 : Accelerometer Y Analogue Input * + * * Pin 19 : Accelerometer X Analogue Input * + * * Pin 20 : Temperature Sensor Analogue Input * + * * Pin 21 : Center LED Blue PWM Output * + * * Pin 22 : Center LED Green PWM Output * + * * Pin 23 : Center LED Red PWM Output * + * * Pin 24 : Outer LED Blue PWM Output * + * * Pin 25 : Outer LED Green PWM Output * + * * Pin 26 : Outer LED Red PWM Output * + * * Pin 27 : I2C SCL * + * * Pin 28 : I2C SDA * + * * Pin 29 : GPIO Expander Interrupt * + * * Pin 30 : Trigger Pin for Sonar * + * * Pin 31 : USB D+ Connector * + * * Pin 32 : USB D- Connector * + * * + *******************************************************************************/ /******************************************************************************** + * Using the 3-Pi Buzzer * + * * + * play_tune (char * tune, int length) * + * * + * tune - Pointer to a character sequence of the tune * + * length - Length of characters in sequence * + * * + * The character sequence recognises the following characters: * + * * + * A – G : used to specify the notes that will be played * + * * + * R : used to specify a rest (no sound for the duration of the note) * + * * + * < or > : plays the next note one octave lower or higher * + * * + * + or # : raises the previous notes pitch by one semitone * + * * + * - : lowers the previous note pitch by one semitone * + * * + * . : extend length of previous by 50% (each additional dot adds half as * + * much as the previous dot, so that A.. is 1.75 times the length of A * + * * + * O followed by a number : sets the octave (default : O4) * + * * + * T followed by a number : sets the tempo in beats/min (default : T120) * + * * + * L followed by a number : sets the default note duration specified by the* + * number - 4 for quarter notes, 8 for eighth, 16 * + * for sixteenth notes, etc. (default : L4) * + * * + * V followed by a number : sets the volume (range 0 - 15, default : V15) * + * * + * MS : sets all subsequent notes to play staccato (each note is played for* + * 1/2 of its allotted time followed by an equal period of silence) * + * * + * ML : sets all subsequent notes to play legato (each note is played for * + * full length. This is the default setting. * + * * + * ! : resets the octave, tempo, duration, volume, and staccato setting to * + * their default values. These settings persist from one play_tune() to* + * the next, which allows you to more conveniently break up your music * + * into reusable sections. * + * * + * 1 - 2000 : when immediately following a note, a number determines the * + * duration of the note. For example, C16 specifies C played as * + * a sixteenth note (1/16th the length of a whole note). * + * * + * * + * Some examples: * + * * + * Blue Danube Waltz (played badly!) * + * play_tune("MSCEGGR>F>FR>D>DRCCEGGR>G>GR>E>ER<B<BDAAR>A>AR>F>F",51); * + * * + *******************************************************************************/ + +/******************************************************************************** * COPYRIGHT NOTICE * * * * Permission is hereby granted, free of charge, to any person obtaining a copy *