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.
Dependencies: mbed
main.cpp
- Committer:
- MYY
- Date:
- 2019-04-20
- Revision:
- 4:b52a0d2925df
- Parent:
- 1:7a3eed610fea
- Child:
- 5:fe1f5b231446
File content as of revision 4:b52a0d2925df:
#include "mbed.h"
#include "Image.h"
#include "Rotate.h"
#include "Release.h"
#include "Gamepad.h"
#define PI 3.1415
Image Image;
N5110 lcd(PTC9,PTC0,PTC7,PTD2,PTD1,PTC11);
Rotate Rotate;
Release Release;
Detect detect;
InterruptIn A(PTB9);
InterruptIn B(PTD0);
void A_isr();
void B_isr();
void init_K64F();
volatile int g_A_flag = 0;
volatile int g_B_flag = 0;
int main()
{
// first need to initialise display
lcd.init();
// change set contrast in range 0.0 to 1.0
// 0.4 appears to be a good starting point
lcd.setContrast(0.5);
A.mode(PullDown);
A.rise(&A_isr);
B.mode(PullDown);
B.rise(&B_isr);
// since SW2 has an external pull-up, we should disable to internal pull-down
// resistor that is enabled by default using InterruptIn
Rotate.return_flag=1;
Rotate.return_angle=PI;
while(1) {
int detector=A.read();
// these are default settings so not strictly needed
lcd.normalMode(); // normal colour mode
lcd.setBrightness(0.4); // put LED backlight on 50%
// x origin, y origin, rows, cols, sprite
if(g_A_flag) {
detector=1;
}
if(g_B_flag) {
g_A_flag=0;
detector=2;
}
switch(detector) {
case 0 :
lcd.clear();
lcd.printString("Misery Miner!",0,0);
lcd.refresh();
wait(0.1);
break;
case 1 :
Rotate.rotate(lcd,Image, Rotate.return_angle, PI, Rotate.return_flag);
//printf("f%", Rotate.return_angle);
// int i=0;
// i=i+1
//int catched(i)=(n,n)
// int ii
//for (ii=0; ii<i; ii=ii+1)
// draw blank(i)
// end
break;
case 2 :
Release.release(detect, lcd,Image, Rotate.return_angle);
//printf("f%", Rotate.return_angle);
g_A_flag = 1;
g_B_flag = 0;
break;
}
}
}
void A_isr()
{
g_A_flag = 1;
}
void B_isr()
{
g_B_flag = 1;
}