here is my code
SensorDataProvider s;
Gauge g;
int value = 0;
final int Mainmenu = 0;
final int Car = 1;
void setup(){
fullScreen();
if (key == '1'){
s = new SensorDataProvider();
s.Initialize("car_status_BMW_323i.csv");
float radius = 23;
int fuelcapacity = 60;
//value = 1;
}
else if(key == '2'){
s = new SensorDataProvider();
s.Initialize("car_status_Truck_F150.csv");
float radius = 25.4;
int fuelcapacity = 80;
//value = 1;
}
}
void draw(){
g = new Gauge();
s = new SensorDataProvider();
switch(value){
case Mainmenu:
g.ShowMenu();
break;
}
switch(value){
case Car:
g.speedometer();
s.readNext();
break;
}
}
class Gauge{
SensorDataProvider s = new SensorDataProvider();
void ShowMenu(){
background(0);
text("Please select the following", 100, 100);
text("1. BMW", 100, 200);
text("2. Trcuk", 100, 300);
text("3. Quit", 100, 400);
if (key == '1'){
speedometer();
}
if (key == '2'){
speedometer();
}
if (key == '3'){
exit();
}
}
void speedometer(){
rpm();
}
void rpm(){
background(0);
stroke(255);
strokeWeight(6);
fill(0);
ellipse(500,230,240,240);
//textFont(font);
fill(255);
text("RPM", 480, 380);
//textFont(font);
fill(255);
textSize(55);
text(s.readRPM(), 460, 250);
}
}
class SensorDataProvider{
Table dataTable;
TableRow row1;
int currentvalue = 1;
String path;
SensorDataProvider() {
}
void Initialize(String path) {
if
dataTable = loadTable(path, "header");
}
void readNext() {
if (currentvalue < dataTable.getRowCount() - 1){
currentvalue++;
}
}
int readRPM() {
int RPM = dataTable.getRow(currentvalue).getInt("RPM");
return RPM;
}
float readFuelLevel() {
float FuelLevel = dataTable.getRow(currentvalue).getFloat("Fuel Level (liter)");
return FuelLevel;
}
float readRatio() {
float Ratio = dataTable.getRow(currentvalue).getFloat("Gear Ratio");
return Ratio;
}
float readX() {
float X = dataTable.getRow(currentvalue).getFloat("X");
return X;
}
float readY() {
float Y = dataTable.getRow(currentvalue).getFloat("Y");
return Y;
}
}
my code will start but it will freeze. I dont know how to fix this bug