Closed pelikhan closed 6 years ago
@pelikhan This is working already but the problem is in common package relying on the returned value from mbed. We can simply give you a driver that simply returns the temperature in Celsius, similar to what we did for the display. Or add a constant that defines the analog resolution. Your pick.
We've added CODAL_PIN and we are using BrainPadPin which scales the value correctly. Is it enough? https://github.com/ghi-electronics/codal-brainpad/blob/master/model/BrainPadPin.cpp
What kind of sensor is the temperature sensor? Does it fit the NonLinearAnalogSensor definition? https://github.com/lancaster-university/codal-core/blob/1f752584b7d6917c22007b0e9d35c10d8e7510bd/inc/drivers/NonLinearAnalogSensor.h
It is linear so that driver can't be used. We will go ahead per last phone call and implement a driver that simply returns the temperature. Do you want us to return float or int with temp scaled up x1000?
Per phone discussion with @pelikhan we changed the returned value from codal to Celsius. This is tested to work fine in codal but the value we are seeing from PXT are off. Maybe PXT is still scaling values from before? PXT can simply just take the value as is and use it.
This sample requires the display working and was run locally.
@pelikhan Note that the display only works locally till #91 is fixed.
This sample can now be tested since display is fixed. https://makecode.com/_1uaTitDjt4o0
I have added C++ macros in order to swap in your "LightSensor" in our light blocks. You can see the C++ sources here: https://github.com/Microsoft/pxt-common-packages/blob/master/libs/lightsensor/lightsensor.cpp
You would have to define CODAL_LIGHT_SENSOR_HEADER ("foo.h") and CODAL_LIGHT_SENSOR (myawesomelightsensor) in https://github.com/Microsoft/pxt-brainpad/blob/master/libs/core/platform.h#L32 with the proper file / class name. From there, make sure that your class supports the same constructor and file signatures.
Same idea for the temperature sensor.
Actually light defines go here: https://github.com/Microsoft/pxt-brainpad/blob/master/libs/core/platform.h#L59
Can we override int temperature(TemperatureUnit unit) or how can we get normalized values from temperature sensor? We need https://github.com/ghi-electronics/codal-brainpad/blob/master/source/BrainPadTemperatureSensor.cpp#L9
Right so your C++ implementation should be compatible with https://github.com/Microsoft/pxt-common-packages/blob/master/libs/thermometer/temperature.cpp . In particular, it should have "getValue()" replace readTemperatureCelsius
Should it be NonLinearAnalogSensor.h even if it is not nonlinear?
It can be any class you want as long as the signatures match.
From: VictorDuma notifications@github.com Sent: Thursday, June 7, 2018 12:04 PM To: Microsoft/pxt-brainpad Cc: Peli de Halleux; Mention Subject: Re: [Microsoft/pxt-brainpad] Temperature sensor (#21)
Should it be NonLinearAnalogSensor.h even if it is not nonlinear?
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2FMicrosoft%2Fpxt-brainpad%2Fissues%2F21%23issuecomment-395530470&data=02%7C01%7Cjhalleux%40microsoft.com%7Cba51bb309302486eb73108d5cca96cc2%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C636639950402759314&sdata=9yXsM7XbCCbTjR2rGDLLcXKV8ND44zwegVjV7snGsVE%3D&reserved=0, or mute the threadhttps://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FAD-4KVz8t1DmF-9WJP26W1GvENJ31tMXks5t6XkegaJpZM4R_RRx&data=02%7C01%7Cjhalleux%40microsoft.com%7Cba51bb309302486eb73108d5cca96cc2%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C636639950402769327&sdata=hvf%2BWiqutiNa1El1v5pJPO0%2BCQfufV0i%2BJJdLaruqRw%3D&reserved=0.
Our sensor is a linear sensor. So even when we define CODAL_TEMPERATURE_SENSOR_HEADER
and CODAL_TEMPERATURE_SENSOR
to our version and update our constructor to match the linear sensor, pxt-common-packages/libs/thermometer/temperature.cpp
is hard-coded to use the non-linear constructor signature, so we get compile errors.
This is done. Let's track status with new bugs.