MCPcopy Create free account
hub / github.com/BlueAndi/Pixelix / load

Method load

src/Hal/SensorDataProvider.cpp:280–326  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

278}
279
280bool SensorDataProvider::load()
281{
282 bool status = false;
283 JsonFile jsonFile(FILESYSTEM);
284 const size_t JSON_DOC_SIZE = 512U;
285 DynamicJsonDocument jsonDoc(JSON_DOC_SIZE);
286
287 if (true == jsonFile.load(SENSOR_CALIB_FILE_NAME, jsonDoc))
288 {
289 uint8_t sensorIdx = 0U;
290 const uint8_t SENSOR_CNT = m_impl->getNumSensors();
291
292 while (SENSOR_CNT > sensorIdx)
293 {
294 ISensor* sensor = m_impl->getSensor(sensorIdx);
295
296 if (nullptr != sensor)
297 {
298 JsonArrayConst jsonArray = jsonDoc[sensor->getName()];
299
300 if (false == jsonArray.isNull())
301 {
302 uint8_t channelIdx = 0U;
303 const uint8_t CHANNEL_CNT = sensor->getNumChannels();
304
305 while (CHANNEL_CNT > channelIdx)
306 {
307 ISensorChannel* channel = sensor->getChannel(channelIdx);
308
309 if (nullptr != channel)
310 {
311 channelOffsetFromJson(*channel, jsonArray[channelIdx]);
312 }
313
314 ++channelIdx;
315 }
316 }
317 }
318
319 ++sensorIdx;
320 }
321
322 status = true;
323 }
324
325 return status;
326}
327
328bool SensorDataProvider::save()
329{

Callers

nothing calls this directly

Calls 5

getNumSensorsMethod · 0.45
getSensorMethod · 0.45
getNameMethod · 0.45
getNumChannelsMethod · 0.45
getChannelMethod · 0.45

Tested by

no test coverage detected