Early commits of my project

Dependencies:   mbed Gamepad N5110

main.cpp

Committer:
el17arm
Date:
2019-03-12
Revision:
4:e7215819c9bc
Parent:
3:140cad440684
Child:
5:f09602591ad3

File content as of revision 4:e7215819c9bc:

#include "main.h"
#include "N5110.h"
#include "Gamepad.h"

Gamepad pad;
N5110 lcd(PTC9,PTC0,PTC7,PTD2,PTD1,PTC11); 
AnalogIn pot0(PTB2);

int x = 0;
int y = 0;


int main()
{
    init();

    while (1) {
      
        contrast();
        minerbitmap();
    }
    
}

void init()
{
    lcd.init();
    lcd.normalMode();      // normal colour mode
    lcd.setBrightness(0.5); // put LED backlight on 50%
    lcd.refresh();
    Gamepad gamepad;
    gamepad.leds_off();
}

void contrast()
{   
    lcd.refresh();
    float con = pot0.read();
    lcd.setContrast(con);
    
    
}

void minerbitmap()
{
    const int miner[13][5] =   {
        0,0,0,1,1,
        0,1,1,1,1,
        0,1,0,1,0,
        0,1,1,1,1,
        0,1,1,1,0,
        0,0,1,0,0,
        1,1,1,1,1,
        1,1,1,1,1,
        1,1,1,1,1,
        0,1,1,1,0,
        0,1,0,1,0,
        0,1,1,1,1,
    };
    
    lcd.clear();
    
        Gamepad gamepad;
        Direction d = gamepad.get_direction();
        printf("Direction = %i\n",d);
        
    
    
    
        if (d==1){   
            lcd.clear();
            x = x+1;
            lcd.drawSprite(WIDTH/2 + x,HEIGHT/2 + y,13,5,(int *)miner);
            lcd.refresh();
            wait(0.25);
        
        }
    
        if (d == 7){   
        
            lcd.clear();
            x = x-1;
            lcd.drawSprite(WIDTH/2 + x,HEIGHT/2 + y,13,5,(int *)miner);
            lcd.refresh();
            wait(0.25);
            }
            lcd.drawSprite(WIDTH/2 + x,HEIGHT/2 + y,13,5,(int *)miner);
            lcd.refresh();
        }