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.
MenuClasses/Settings/Settings.cpp
- Committer:
- AhmedPlaymaker
- Date:
- 2019-04-26
- Revision:
- 49:441c32f6603e
- Parent:
- 43:233f93860d08
- Child:
- 55:df0825049171
File content as of revision 49:441c32f6603e:
#include "Settings.h"
Settings::Settings()
{
}
Settings::~Settings()
{
}
int naviL[13][8] = {
{0,0,0,0,0,0,1,1},
{0,0,0,0,0,1,1,0},
{0,0,0,0,1,1,0,0},
{0,0,0,1,1,0,0,0},
{0,0,1,1,0,0,0,0},
{0,1,1,0,0,0,0,0},
{1,1,0,0,0,0,0,0},
{0,1,1,0,0,0,0,0},
{0,0,1,1,0,0,0,0},
{0,0,0,1,1,0,0,0},
{0,0,0,0,1,1,0,0},
{0,0,0,0,0,1,1,0},
{0,0,0,0,0,0,1,1},
};
int naviR[13][8] = {
{1,1,0,0,0,0,0,0},
{0,1,1,0,0,0,0,0},
{0,0,1,1,0,0,0,0},
{0,0,0,1,1,0,0,0},
{0,0,0,0,1,1,0,0},
{0,0,0,0,0,1,1,0},
{0,0,0,0,0,0,1,1},
{0,0,0,0,0,1,1,0},
{0,0,0,0,1,1,0,0},
{0,0,0,1,1,0,0,0},
{0,0,1,1,0,0,0,0},
{0,1,1,0,0,0,0,0},
{1,1,0,0,0,0,0,0},
};
float * Settings::Implement(N5110 &lcd, Gamepad &pad, float cs)
{
Settings::info(lcd, pad);
int st = 1;
pad.init();
while (pad.check_event(Gamepad::BACK_PRESSED) == false) { //if button pressed.
Direction d = pad.get_direction();
wait(1/cs);
lcd.clear();
if((d==E)&&(st==5)) {
st=1;
}
else if((d==W)&&(st==1)) {
st=5;
}
else if((d==E)&&(1<=st<=4)) {
st=st+1;
}
else if((d==W)&&(2<=st<=5)) {
st=st-1;
}
lcd.drawSprite(5,22,13,8,(int *)naviL); //Function used to draw the sprite.
lcd.drawSprite(71,22,13,8,(int *)naviR); //Function used to draw the sprite.
if(st==1) {
Settings::controlSensitivity(lcd, pad);
}
if(st==2) {
Settings::brigntness(lcd, pad);
}
if(st==3) {
Settings::contrast(lcd, pad);
}
if(st==4) {
Settings::volume(lcd, pad);
}
if(st==5) {
Settings::showCredits(lcd, pad);
}
lcd.refresh();
}
return cs_sc;
}
void Settings::info(N5110 &lcd, Gamepad &pad)
{
lcd.clear();
pad.leds_on();
lcd.printString("For selecting",0,0);//Function used to promt the user to how to use settings.
lcd.printString("from settings",0,1);
lcd.printString("available, use",0,2);
lcd.printString("Joystick in <>",0,3);
lcd.printString("directions",0,4);
lcd.refresh();
wait(2);
lcd.clear();
lcd.printString("For adjusting",0,0);
lcd.printString("the parameters,",0,1);
lcd.printString("use the pot",0,2);
lcd.printString("by rotating",0,3);
lcd.printString("Press Back",0,4);
lcd.printString("to confirm",0,5);
lcd.refresh();
wait(2);
pad.leds_off();
lcd.clear();
}
void Settings::controlSensitivity(N5110 &lcd, Gamepad &pad)
{
lcd.printString("Control Speeds",0,0);
cs_sc[0] = pad.read_pot()*5+1;
lcd.drawRect(15,22,54,13,FILL_TRANSPARENT);
lcd.drawRect(15,22,pad.read_pot()*54,13,FILL_BLACK);
pad.leds_on();
}
void Settings::brigntness(N5110 &lcd, Gamepad &pad)
{
lcd.printString("Brigntness",9,0);
float pot;
pot = pad.read_pot();
lcd.drawRect(15,22,54,13,FILL_TRANSPARENT);
lcd.drawRect(15,22,pad.read_pot()*54,13,FILL_BLACK);
lcd.setBrightness(pot);
pad.leds_on();
}
void Settings::contrast(N5110 &lcd, Gamepad &pad)
{
lcd.printString("Contrast",16,0);
float pot;
pot = ((pad.read_pot()+3.8)/8);
lcd.drawRect(15,22,54,13,FILL_TRANSPARENT);
lcd.drawRect(15,22,pad.read_pot()*54,13,FILL_BLACK);
lcd.setContrast(pot);
pad.leds_on();
}
void Settings::volume(N5110 &lcd, Gamepad &pad)
{
lcd.printString("Volume",20,0);
float pot;
pot = pad.read_pot();
lcd.drawRect(15,22,54,13,FILL_TRANSPARENT);
lcd.drawRect(15,22,pot*54,13,FILL_BLACK);
pad.leds_on();
}
void Settings::showCredits(N5110 &lcd, Gamepad &pad)
{
lcd.printString("Show Credits?",5,0);
float pot;
pot = pad.read_pot();
if(((0.1<=pot)&&(pot<=0.2))||((0.3<=pot)&&(pot<=0.4))||((0.5<=pot)&&(pot<=0.6))||((0.7<=pot)&&(pot<=0.8))||((0.9<=pot)&&(pot<=1))) {
lcd.printString("NO",36,3);
cs_sc[1] = 0;
}
else {
lcd.printString("YES",33,3);
cs_sc[1] = 1;
}
pad.leds_on();
}