|
27 | 27 | import io.pslab.activity.BarometerActivity; |
28 | 28 | import io.pslab.activity.CompassActivity; |
29 | 29 | import io.pslab.activity.GyroscopeActivity; |
| 30 | +import io.pslab.activity.LogicalAnalyzerActivity; |
30 | 31 | import io.pslab.activity.LuxMeterActivity; |
31 | 32 | import io.pslab.activity.MapsActivity; |
32 | 33 | import io.pslab.activity.MultimeterActivity; |
|
39 | 40 | import io.pslab.models.BaroData; |
40 | 41 | import io.pslab.models.GyroData; |
41 | 42 | import io.pslab.models.CompassData; |
| 43 | +import io.pslab.models.LogicAnalyzerData; |
42 | 44 | import io.pslab.models.LuxData; |
43 | 45 | import io.pslab.models.MultimeterData; |
44 | 46 | import io.pslab.models.OscilloscopeData; |
@@ -125,6 +127,10 @@ public void onBindViewHolder(@NonNull final ViewHolder holder, int position) { |
125 | 127 | holder.sensor.setText(R.string.multimeter); |
126 | 128 | holder.tileIcon.setImageDrawable(context.getResources().getDrawable(R.drawable.tile_icon_multimeter)); |
127 | 129 | break; |
| 130 | + case PSLabSensor.LOGIC_ANALYZER: |
| 131 | + holder.sensor.setText(R.string.logical_analyzer); |
| 132 | + holder.tileIcon.setImageDrawable(context.getResources().getDrawable(R.drawable.tile_icon_logic_analyzer)); |
| 133 | + break; |
128 | 134 | default: |
129 | 135 | break; |
130 | 136 | } |
@@ -205,6 +211,11 @@ private void handleCardViewClick(SensorDataBlock block) { |
205 | 211 | multimeter.putExtra(KEY_LOG, true); |
206 | 212 | multimeter.putExtra(DATA_BLOCK, block.getBlock()); |
207 | 213 | context.startActivity(multimeter); |
| 214 | + } else if (block.getSensorType().equalsIgnoreCase(context.getResources().getString(R.string.logical_analyzer))) { |
| 215 | + Intent laIntent = new Intent(context, LogicalAnalyzerActivity.class); |
| 216 | + laIntent.putExtra(KEY_LOG, true); |
| 217 | + laIntent.putExtra(DATA_BLOCK, block.getBlock()); |
| 218 | + context.startActivity(laIntent); |
208 | 219 | } |
209 | 220 | } |
210 | 221 |
|
@@ -244,6 +255,8 @@ public void onClick(DialogInterface dialog, int whichButton) { |
244 | 255 | LocalDataLog.with().clearBlockOfPowerRecords(block.getBlock()); |
245 | 256 | } else if (block.getSensorType().equalsIgnoreCase(PSLabSensor.MULTIMETER)) { |
246 | 257 | LocalDataLog.with().clearBlockOfMultimeterRecords(block.getBlock()); |
| 258 | + } else if (block.getSensorType().equalsIgnoreCase(PSLabSensor.LOGIC_ANALYZER)) { |
| 259 | + LocalDataLog.with().clearBlockOfLARecords(block.getBlock()); |
247 | 260 | } |
248 | 261 | LocalDataLog.with().clearSensorBlock(block.getBlock()); |
249 | 262 | dialog.dismiss(); |
@@ -461,6 +474,25 @@ private void populateMapData(SensorDataBlock block) { |
461 | 474 | } |
462 | 475 | } |
463 | 476 | setMapDataToIntent(array); |
| 477 | + } else if (block.getSensorType().equalsIgnoreCase(PSLabSensor.LOGIC_ANALYZER)) { |
| 478 | + RealmResults<LogicAnalyzerData> data = LocalDataLog.with().getBlockOfLARecords(block.getBlock()); |
| 479 | + JSONArray array = new JSONArray(); |
| 480 | + for (LogicAnalyzerData d : data) { |
| 481 | + try { |
| 482 | + JSONObject i = new JSONObject(); |
| 483 | + i.put("date", CSVLogger.FILE_NAME_FORMAT.format(d.getTime())); |
| 484 | + i.put("channel", d.getChannel()); |
| 485 | + i.put("channel_mode", d.getChannelMode()); |
| 486 | + i.put("xaxis", d.getDataX()); |
| 487 | + i.put("yaxis", d.getDataY()); |
| 488 | + i.put("lat", d.getLat()); |
| 489 | + i.put("lon", d.getLon()); |
| 490 | + if (d.getLat() != 0.0 && d.getLon() != 0.0) array.put(i); |
| 491 | + } catch (JSONException e) { |
| 492 | + e.printStackTrace(); |
| 493 | + } |
| 494 | + } |
| 495 | + setMapDataToIntent(array); |
464 | 496 | } |
465 | 497 | } |
466 | 498 |
|
|
0 commit comments