Yuheng Huo / Mbed 2 deprecated hyh_copy

Dependencies:   mbed FXOS8700CQ

Committer:
Neowless
Date:
Fri May 15 12:32:47 2020 +0000
Revision:
1:48b0bf0bcda8
test;

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Neowless 1:48b0bf0bcda8 1 #include "plane.h"
Neowless 1:48b0bf0bcda8 2
Neowless 1:48b0bf0bcda8 3 void plane::init(){
Neowless 1:48b0bf0bcda8 4 _width = 7;
Neowless 1:48b0bf0bcda8 5 _height = 8;
Neowless 1:48b0bf0bcda8 6 int d[56] = {
Neowless 1:48b0bf0bcda8 7 0,0,1,1,1,0,0,
Neowless 1:48b0bf0bcda8 8 0,0,1,0,1,0,0,
Neowless 1:48b0bf0bcda8 9 0,0,1,1,1,0,0,
Neowless 1:48b0bf0bcda8 10 1,1,0,1,0,0,0,
Neowless 1:48b0bf0bcda8 11 1,0,1,1,1,1,0,
Neowless 1:48b0bf0bcda8 12 1,0,1,1,0,0,0,
Neowless 1:48b0bf0bcda8 13 1,1,0,0,1,0,0,
Neowless 1:48b0bf0bcda8 14 0,0,0,0,1,0,0
Neowless 1:48b0bf0bcda8 15 };
Neowless 1:48b0bf0bcda8 16 for(int i = 0; i<56;i++){
Neowless 1:48b0bf0bcda8 17 data[i] = d[i];
Neowless 1:48b0bf0bcda8 18 }
Neowless 1:48b0bf0bcda8 19 _xy.x = 0;
Neowless 1:48b0bf0bcda8 20 _xy.y = 25;
Neowless 1:48b0bf0bcda8 21 }
Neowless 1:48b0bf0bcda8 22
Neowless 1:48b0bf0bcda8 23 void plane::update(Gamepad &pad, FXOS8700CQ &device){
Neowless 1:48b0bf0bcda8 24 Data values = device.get_values();
Neowless 1:48b0bf0bcda8 25
Neowless 1:48b0bf0bcda8 26 printf("ax = %f ay = %f az = %f | mx = %f my = %f mz = %f\n"
Neowless 1:48b0bf0bcda8 27 ,values.ax, values.ay, values.az
Neowless 1:48b0bf0bcda8 28 ,values.mx, values.my, values.mz);
Neowless 1:48b0bf0bcda8 29
Neowless 1:48b0bf0bcda8 30 if(pad.get_direction() == N){
Neowless 1:48b0bf0bcda8 31 _xy.y = _xy.y -4;
Neowless 1:48b0bf0bcda8 32 }else{
Neowless 1:48b0bf0bcda8 33 _xy.y = _xy.y + 3;
Neowless 1:48b0bf0bcda8 34 }
Neowless 1:48b0bf0bcda8 35
Neowless 1:48b0bf0bcda8 36 if(values.ay>=0){
Neowless 1:48b0bf0bcda8 37 _xy.x = _xy.x - int(values.ay*10);
Neowless 1:48b0bf0bcda8 38 }else if(values.ay<=0){
Neowless 1:48b0bf0bcda8 39 _xy.x = _xy.x - int(values.ay*10);
Neowless 1:48b0bf0bcda8 40 }
Neowless 1:48b0bf0bcda8 41
Neowless 1:48b0bf0bcda8 42 if(_xy.x>=77){
Neowless 1:48b0bf0bcda8 43 _xy.x = 77;
Neowless 1:48b0bf0bcda8 44 }else if(_xy.x<=0){
Neowless 1:48b0bf0bcda8 45 _xy.x=0;
Neowless 1:48b0bf0bcda8 46 }
Neowless 1:48b0bf0bcda8 47 if(_xy.y>=41){
Neowless 1:48b0bf0bcda8 48 _xy.y = 41 ;
Neowless 1:48b0bf0bcda8 49 }else if(_xy.y<=7){
Neowless 1:48b0bf0bcda8 50 _xy.y=7;
Neowless 1:48b0bf0bcda8 51 }
Neowless 1:48b0bf0bcda8 52 }
Neowless 1:48b0bf0bcda8 53
Neowless 1:48b0bf0bcda8 54 void plane::display(N5110 &lcd){
Neowless 1:48b0bf0bcda8 55 unsigned int width = _width;
Neowless 1:48b0bf0bcda8 56 unsigned int height = _height;
Neowless 1:48b0bf0bcda8 57 Bitmap p(data, height, width);
Neowless 1:48b0bf0bcda8 58 p.render(lcd, _xy.x, _xy.y);
Neowless 1:48b0bf0bcda8 59 }
Neowless 1:48b0bf0bcda8 60
Neowless 1:48b0bf0bcda8 61 xy plane::getxy(){return _xy;}
Neowless 1:48b0bf0bcda8 62
Neowless 1:48b0bf0bcda8 63 int plane::getwidth(){return _width;}
Neowless 1:48b0bf0bcda8 64 int plane::getheight(){return _height;}
Neowless 1:48b0bf0bcda8 65