Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
main.h
- Committer:
 - el15yc
 - Date:
 - 2016-05-04
 - Revision:
 - 0:6acec66462d7
 - Child:
 - 1:412410b64834
 
File content as of revision 0:6acec66462d7:
//    VCC,SCE,RST,D/C,MOSI,SCLK,LED
N5110 lcd (PTE26 , PTA0 , PTC4 , PTD0, PTD2 , PTD1 , PTC3);
// Can also power (VCC) directly from VOUT (3.3 V) -
// Can give better performance due to current limitation from GPIO pin
/* Joystick
 
Example code of how to read a joystick
 
https://www.sparkfun.com/products/9032
 
Craig A. Evans
7 March 2015
*/
 
// change this to alter tolerance of joystick direction
#define DIRECTION_TOLERANCE 0.05
 
// connections for joystick
DigitalIn button(PTB18);
AnalogIn xPot(PTB2);
AnalogIn yPot(PTB3);
 
// timer to regularly read the joystick
Ticker pollJoystick;
// Serial for debug
Serial serial(USBTX,USBRX);
 
// create enumerated type (0,1,2,3 etc. for direction)
// could be extended for diagonals etc.
enum DirectionName {
    UP,
    DOWN,
    LEFT,
    RIGHT,
    CENTRE,
    UNKNOWN
};
 
// struct for Joystick
typedef struct JoyStick Joystick;
struct JoyStick {
    float x;    // current x value
    float x0;   // 'centred' x value
    float y;    // current y value
    float y0;   // 'centred' y value
    int button; // button state (assume pull-down used, so 1 = pressed, 0 = unpressed)
    DirectionName direction;  // current direction
};
// create struct variable
Joystick joystick;
 
// function prototypes
void calibrateJoystick();
void updateJoystick();
int printFlag = 0;
int x1=42;
int y1=19;
int x2=42;
int y2=29;
int x3=37;
int y3=24;
int x4=47;
int y4=24;
int x5=10;
int y5=20;
int x6=40;
int y6=30;
int x7=30;
int y7=10;
int x8=60;
int y8=15;
int opentimes=0;
int r2=2;
int colour=0;
int colour1=0;
int colour2=0;
int colour3=0;
int moves=0;