Sun Jul 12, 2015 11:21 am
Sun Jul 12, 2015 12:56 pm
char your_digit = '5';
int number = your_digit - 48;
// OR you can do it like this
int number = your_digit - '0'; //because '0' = 48
char number[] = "1234";
int final_number = 0;
int i = 0; //(position in the string)
while (number[i] != '\0') //while we aren't at the end of the string ('\0' is the end of string character)
{
final_number *= 10; //shift all the digits in the number by one rank
final_number += number[i]-'0'; // Add the current digit
i ++;
}
Sun Jul 12, 2015 2:33 pm
Sun Jul 12, 2015 3:04 pm
#include <SPI.h>
#include <Gamebuino.h>
Gamebuino gb;
void setup(){
gb.begin();
gb.titleScreen(F("TEST"));
}
void loop(){
if(gb.update()){
char number[] = "01234";
long final_number = 0;
long i = 0; //(position in the string)
while (number[i] != '\0') //while we aren't at the end of the string ('\0' is the end of string character)
{
final_number *= 10; //shift all the digits in the number by one rank
final_number += ((int) number[i] ) - 48; // Add the current digit
i ++;
}
gb.display.print(final_number);
}
}
Sun Jul 12, 2015 3:43 pm
Sun Jul 12, 2015 7:41 pm
void setup{
... Setup things
}
//Select the right variable to change/the calculator button
void loop{The Menu thing copied of the reference page.
case 0:
number();
break;
....
case 7:
calculate();
break;
}
//Open the keyboard and get the number to calculate with
void number(){
gb.Keyboard(Var., Number);
}
void calculate(){
while(Some things)
//Some operations done 1 time
......
while(1){
if(gb.update()){
Display the result
}
}
}
Thu Jul 16, 2015 3:02 pm
#include <SPI.h>
#include <Gamebuino.h>
Gamebuino gb;
char aSt[10] = "Anzahl S";
int aS = 0;
char Eingabe[10] = "Write";
int x[10];
int y[10];
int z[10];
int i = 0;
int final_number = 0;
void setup(){
gb.begin();
gb.titleScreen(F("WOOW"));
AnzahlSP();
SpwnC();
}
void loop(){
if(gb.update()){
gb.display.print(x[0]);
}
}
void AnzahlSP(){ //Get Anzahl Spawner
gb.keyboard(aSt, 10); //aS = Anzahl Spawner
//aSt umrechnen
while (aSt[i] != '\0') //while we aren't at the end of the string ('\0' is the end of string character)
{
final_number *= 10; //shift all the digits in the number by one rank
final_number += ((int) aSt[i] ) - 48; // Add the current digit
i ++;
}
aS = final_number;
i = 0;
final_number = 0;
}
void SpwnC(){
for(int abar = 0; abar < aS; abar ++){
for(int xyz = 0; xyz < 3; xyz ++){
gb.keyboard(Eingabe, 10);
while(Eingabe[i] != '\0'){
final_number *= 10;
final_number += ((int) Eingabe[i] ) - 48;
i ++;
}
if(xyz = 0){
x[abar] = final_number;
}
if(xyz = 1){
y[abar] = final_number;
}
if(xyz = 2){
z[abar] = final_number;
}
final_number = 0;
i = 0;
}
}
}
for(int abar; abar < aS; abar ++){
if(x[abar] < 10){
?????
}
}