예제 #1
0
  private static void populateAndPlotFuelMap(final String data) {

    mapOffset += 16;

    String[] mapmap = data.trim().split(" ");
    for (int x = 3; x < 35; x++) {
      mapData.append(mapmap[x]);
      mapData.append(" ");
    }

    if (mapOffset < 512) {
      sendRequest(mapOffset);
      return;
    }

    String[] map = mapData.toString().trim().split(" ");
    short cnt = 0;

    chart.setAutoRepaint(false);
    ser.clear();

    for (int x = 0; x < 32; x++) {
      for (int y = 0; y < 16; y++) {
        double val =
            Double.parseDouble(
                String.format("%.0f", Integer.parseInt(map[cnt] + map[cnt + 1], 16) / 128f));
        val = val - 95;
        ser.add(x, val, y);
        if (DEBUG_MODE) Log.d(TAG, String.format("%d:%d = %.0f", x, y, val));
        cnt = (short) (cnt + 2);
      }
    }

    for (int x = 0; x < chart.getAxes().getCount(); x++) {
      chart.getAxes().getAxis(x).getLabels().getItems().clear();
    }

    for (double x = 0; x < 32; x++) {
      AxisLabelItem itm = chart.getAxes().getBottom().getLabels().getItems().add(x);
      itm.getFont().setSize(10);
      itm.getFont().setColor(com.steema.teechart.drawing.Color.white);
      itm.setText(String.format("%.0f", 300 * x));
    }

    for (double x = 0; x < 16; x++) {
      AxisLabelItem itm =
          chart
              .getAxes()
              .getDepth()
              .getLabels()
              .getItems()
              .add(x, x == 0 ? " " : String.format("%.0f", 13 * x));
      itm.getFont().setSize(10);
      itm.getFont().setColor(com.steema.teechart.drawing.Color.white);
    }

    chart.getAxes().getBottom().getTitle().setText("Engine RPM");
    chart
        .getAxes()
        .getBottom()
        .getTitle()
        .getFont()
        .setColor(com.steema.teechart.drawing.Color.white);
    chart.getAxes().getBottom().getTitle().getFont().setSize(14);

    chart.getAxes().getDepth().getTitle().setText("MAP (kPa)");
    chart
        .getAxes()
        .getDepth()
        .getTitle()
        .getFont()
        .setColor(com.steema.teechart.drawing.Color.white);
    chart.getAxes().getDepth().getTitle().getFont().setSize(14);

    chart.refreshControl();
    chart.setAutoRepaint(true);

    if (progress != null && progress.isShowing()) progress.dismiss();

    lastRegister = REGISTER_4096_PLUS_SEVEN;
    mapMode = false;
  }
예제 #2
0
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setContentView(R.layout.activity_main);

    ctx = this;
    prefs = PreferenceManager.getDefaultSharedPreferences(ctx);

    adaptiveFragment = getFragmentManager().findFragmentById(R.id.frag_adaptive);
    gaugesFragment = getFragmentManager().findFragmentById(R.id.frag_gauges);
    fuelFragment = getFragmentManager().findFragmentById(R.id.frag_fuel);

    ActionBar bar = getActionBar();

    bar.addTab(bar.newTab().setText(R.string.tab_adaptive).setTabListener(this), false);
    bar.addTab(bar.newTab().setText(R.string.tab_gauges).setTabListener(this), false);
    bar.addTab(bar.newTab().setText("Fuel Map").setTabListener(this), false);

    mActionBarView = getLayoutInflater().inflate(R.layout.action_bar_custom, null);

    bar.setCustomView(mActionBarView);
    bar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM | ActionBar.DISPLAY_USE_LOGO);
    bar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
    bar.setDisplayShowHomeEnabled(true);

    txtData = (TextView) findViewById(R.id.txtData);
    lvDevices = (ListView) findViewById(R.id.lvDevices);
    layoutDevices = (RelativeLayout) findViewById(R.id.layoutDevices);
    imgStatus = (ImageView) findViewById(R.id.imgStatus);

    txtFuelLearn = (TextView) findViewById(R.id.fuellearn);

    imgIWait = (ImageView) findViewById(R.id.imgIWait);
    imgIRpm = (ImageView) findViewById(R.id.imgIRpm);
    imgILoad = (ImageView) findViewById(R.id.imgILoad);

    imgFWait = (ImageView) findViewById(R.id.imgFWait);
    imgFRpm = (ImageView) findViewById(R.id.imgFRpm);
    imgFLoad = (ImageView) findViewById(R.id.imgFLoad);

    imgIat = (ImageView) findViewById(R.id.iat);

    gridData = (GridView) findViewById(R.id.gridData);

    dataArray = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1);
    dataArray.add("RPM\n ----");
    dataArray.add("MAP\n ---");
    dataArray.add("MAT\n ---\u00B0");
    dataArray.add("AFR\n --.-");
    dataArray.add("TAFR\n --.-");
    dataArray.add("WAT\n ---\u00B0");

    gridData.setAdapter(dataArray);

    lvDevices.setOnItemClickListener(DevicesClickListener);

    waterNeedle = (GaugeNeedle) findViewById(R.id.waterneedle);
    iatNeedle = (GaugeNeedle) findViewById(R.id.iatneedle);
    mapNeedle = (GaugeNeedle) findViewById(R.id.mapneedle);
    afrNeedle = (GaugeNeedle) findViewById(R.id.afrneedle);
    targetAfrNeedle = (GaugeNeedle) findViewById(R.id.targetafrneedle);
    rpmNeedle = (GaugeNeedle) findViewById(R.id.rpmneedle);

    waterNeedle.setPivotPoint(.65f);
    waterNeedle.setMinValue(100);
    waterNeedle.setMaxValue(240);
    waterNeedle.setMinDegrees(-50);
    waterNeedle.setMaxDegrees(55);

    afrNeedle.setPivotPoint(.5f);
    afrNeedle.setMinValue(AFR_MIN);
    afrNeedle.setMaxValue(AFR_MAX);
    afrNeedle.setMinDegrees(-180);
    afrNeedle.setMaxDegrees(90);

    targetAfrNeedle.setPivotPoint(.5f);
    targetAfrNeedle.setMinValue(AFR_MIN);
    targetAfrNeedle.setMaxValue(AFR_MAX);
    targetAfrNeedle.setMinDegrees(-180);
    targetAfrNeedle.setMaxDegrees(90);

    mapNeedle.setPivotPoint(.5f);
    mapNeedle.setMinValue(0);
    mapNeedle.setMaxValue(200);
    mapNeedle.setMinDegrees(-150);
    mapNeedle.setMaxDegrees(140);

    rpmNeedle.setPivotPoint(.5f);
    rpmNeedle.setMinValue(0);
    rpmNeedle.setMaxValue(9000);
    rpmNeedle.setMinDegrees(-130);
    rpmNeedle.setMaxDegrees(157);

    ChangeLog cl = new ChangeLog(this);
    if (cl.firstRun()) {
      cl.getLogDialog().show();
    }

    LinearLayout group = (LinearLayout) findViewById(R.id.linearLayoutTchart);
    chart = new TChart(this);
    chart.setAutoRepaint(false);

    group.addView(chart);

    ThemesList.applyTheme(chart.getChart(), 1);

    chart.removeAllSeries();
    ser = new Surface(chart.getChart());

    chart.getAspect().setView3D(true);
    ser.setIrregularGrid(true);

    ser.setUseColorRange(false);
    ser.setUsePalette(true);
    ser.setPaletteStyle(PaletteStyle.RAINBOW);

    chart.getPanel().setBorderRound(7);

    chart.getAspect().setView3D(true);
    chart.getAspect().setChart3DPercent(100);
    chart.getAspect().setOrthogonal(false);
    chart.getAspect().setZoom(75);
    chart.getAspect().setRotation(350);
    chart.getAspect().setElevation(350);
    chart.getAspect().setPerspective(37);

    chart.getAxes().getDepth().setVisible(true);
    chart.getLegend().setVisible(false);
    chart.getHeader().setText("Fuel Map #1 (VE)");
    chart.getHeader().getFont().setSize(18);
    chart.getHeader().getFont().setBold(true);

    ser.setColor(com.steema.teechart.drawing.Color.darkGray);
    new Rotate(chart.getChart());

    // EVAN
    mUsbDetachedFilter.addAction(UsbManager.ACTION_USB_DEVICE_DETACHED);
    registerReceiver(mUsbReceiver, mUsbDetachedFilter);
    // END EVAN

  }