googlearchive / science-journal

Use the sensors in your mobile devices to perform science experiments. Science doesn’t just happen in the classroom or lab—tools like Science Journal let you see how the world works with just your phone.
https://sciencejournal.withgoogle.com/
Apache License 2.0
508 stars 131 forks source link

Changing dimensions when configuring external devices #5

Closed berndporr closed 7 years ago

berndporr commented 7 years ago

The two ADC channels can be configured to measure V, mV (multiplied by 1000 for mV signals) and Ohm. For channel one I have: V and mV depending on the application. For biosignals (or small differential one) I set the PGA of the ADC to a higher value (x6) and I multiply the result by 1000 (see also my ECG). adc_config For channel 2 I have Volt or Ohm (essentially I switch on a 22uA bias current via the config menu and then one can measure resistance): adc2config I've got the impression that the dimensions are only read once and then stored in sciencejournal. Would it be possible to have these checked dynamically or perhaps move these to the observer and/or able to modify them after an config intent has happened?

dsaff commented 7 years ago

Yes, we should reload after configuration.

whatsthebeef commented 7 years ago

@dsaff Any ideas when this might be implemented? I could look into it if you are accepting pull requests and haven't started working on it yet.

dsaff commented 7 years ago

@whatsthebeef, I expect a fix by Friday, if not sooner. I would consider pull requests, but I'd recommend holding off; this particular area of the code is seeing a lot of churn right now.

dsaff commented 7 years ago

This should be, at last, fixed in master. Please verify!

berndporr commented 7 years ago

Yes. Works! Thanks, @dsaff!

berndporr commented 7 years ago

Sorry guys. As you know in the sensor menu I can switch to mV, V or uV. That worked really well but now it's back to the problem that the first onSensorFound dimension stays. Here've switched in the sensor menu from V to uV but the plot still shows V: volt

I've added this debug output to my code:
                    c.onSensorFound("" + i, // sensorAddress = ch index number
                            channelDescr, // name
                            behaviour[i],
                            sensorAppearanceResources[i]);
                    if (Log.isLoggable(TAG, Log.DEBUG)) {
                        Log.d(TAG,String.format("onSensorFound:%s:%s",
                                sensorAppearanceResources[i].shortDescription,
                                sensorAppearanceResources[i].units));
                    }
                                    }

11-15 18:40:16.992 16532-16545/tech.glasgowneuro.attysplot D/Attys2ScienceJournal: onSensorFound:Acceleration X:m/s^2 11-15 18:40:16.993 16532-16545/tech.glasgowneuro.attysplot D/Attys2ScienceJournal: onSensorFound:Acceleration Y:m/s^2 11-15 18:40:16.993 16532-16545/tech.glasgowneuro.attysplot D/Attys2ScienceJournal: onSensorFound:Acceleration Z:m/s^2 11-15 18:40:16.994 16532-16545/tech.glasgowneuro.attysplot D/Attys2ScienceJournal: onSensorFound:Magnetic field X:µT 11-15 18:40:16.995 16532-16545/tech.glasgowneuro.attysplot D/Attys2ScienceJournal: onSensorFound:Magnetic field Y:µT 11-15 18:40:16.995 16532-16545/tech.glasgowneuro.attysplot D/Attys2ScienceJournal: onSensorFound:Magnetic field Z:µT 11-15 18:40:16.996 16532-16545/tech.glasgowneuro.attysplot D/Attys2ScienceJournal: onSensorFound:Analogue channel 1:µV 11-15 18:40:16.997 16532-16545/tech.glasgowneuro.attysplot D/Attys2ScienceJournal: onSensorFound:Analogue channel 2:V Perhaps it needs to be updated via another call? I'm pretty sure it worked last week.

berndporr commented 7 years ago

P.S.: you see the same problem in my cropping example.

dsaff commented 7 years ago

Bernd,

Quick question; does the behavior change even when the appearance does not, or do they both get stuck? Thanks,

David

berndporr commented 7 years ago

It's recording V, mV or uV actually so the settings are correctly propagated to the onData call (I scale the data up there by x1,x1000,x1,000,000. It's just the appearance which won't change. It always shows as dimension (V).

dsaff commented 7 years ago

Thanks for the report; we're tracking the bug, and hope to have a fix posted very shortly.