Skip to content

Commit

Permalink
updated flutter
Browse files Browse the repository at this point in the history
  • Loading branch information
pseudoincorrect committed Mar 18, 2021
1 parent 95cbc22 commit 2e59bcf
Show file tree
Hide file tree
Showing 46 changed files with 403 additions and 279 deletions.
5 changes: 1 addition & 4 deletions Embedded_system/smart_mask/src/ble/services/ble_sms.c
Original file line number Diff line number Diff line change
Expand Up @@ -117,10 +117,7 @@ static uint32_t add_sensor_ctrl_char(ble_sms_t * p_sms, uint8_t uuid,
static uint32_t ble_sms_event_on_write(
ble_sms_t * p_sms, ble_evt_t const * p_ble_evt)
{

NRF_LOG_INFO("ble_sms_event_on_write: got a write event");

ble_gatts_evt_write_t const * p_evt_write =
ble_gatts_evt_write_t const * p_evt_write =
&p_ble_evt->evt.gatts_evt.params.write;

if (p_evt_write->len != sizeof(sensor_ctrl_t))
Expand Down
13 changes: 7 additions & 6 deletions Embedded_system/smart_mask/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -109,13 +109,14 @@ static void led_write_handler(
* @param[in] sensor selected sensor
* @param[in] sensor_ctrl sensor control handler with new value
*/
static void sensor_ctrl_update(sensor_t sensor, sensor_ctrl_t * sensor_ctrl)
static void sensor_ctrl_update(sensor_t sensor, sensor_ctrl_t * ctrl)
{
sensor_handle_set_control(sensor, sensor_ctrl);
NRF_LOG_INFO("sensor %d", sensor + 1);
sensor_ctrl_t * ctrl = sensor_handle_get_control(sensor);
NRF_LOG_INFO("sample period ms %d, gain %d, enable %d",
ctrl->sample_period_ms, ctrl->gain, ctrl->enable);
ret_code_t err;
NRF_LOG_INFO("sensor %d sample period ms %d, gain %d, enable %d",
sensor + 1, ctrl->sample_period_ms, ctrl->gain, ctrl->enable);
err = sensor_sampling_update_sensor_control(sensor, ctrl);
if (err == NRF_ERROR_INVALID_DATA)
NRF_LOG_INFO("invalid sensor_ctrl_t data");
}


Expand Down
4 changes: 2 additions & 2 deletions Embedded_system/smart_mask/src/sensors/sensor_handle.c
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ void sensor_handles_init(void)
ctrl = sensor_handle_get_control(s_i);
ctrl->gain = SAADC_CH_CONFIG_GAIN_Gain1_6;
ctrl->enable = true;
ctrl->sample_period_ms = 100; // ms
ctrl->sample_period_ms = 1000; // ms
}

s_h_1.hardware.pwr_pin = SENSOR_1_PWR_PIN;
Expand Down Expand Up @@ -253,7 +253,7 @@ ret_code_t sensor_handle_get_values(
*/
bool is_sensor_ctrl_valid(sensor_ctrl_t * ctrl)
{
if (ctrl->sample_period_ms < 50 || ctrl->sample_period_ms > 1000)
if (ctrl->sample_period_ms < 500 || ctrl->sample_period_ms > 2000)
return false;
if (ctrl->gain < SAADC_CH_CONFIG_GAIN_Gain1_6 ||
ctrl->gain > SAADC_CH_CONFIG_GAIN_Gain4)
Expand Down
125 changes: 88 additions & 37 deletions Embedded_system/smart_mask/src/sensors/sensor_sampling.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/**
/**
* @file
* @brief sensor_sampling: Module that takes care of the sampling
* of the sensors through ADC with a periodic interupts. it can
Expand Down Expand Up @@ -45,8 +45,8 @@ static int mock_adc;

/**
* @brief Unsued but mandatory callback function for the ADC
*
* @param[in] p_event pointer to a ADC event
*
* @param[in] p_event pointer to a ADC event
*/
static void saadc_callback(nrfx_saadc_evt_t const * p_event)
{
Expand All @@ -56,11 +56,11 @@ static void saadc_callback(nrfx_saadc_evt_t const * p_event)
/**ef
* @brief configure an ADC channel (gain, reference, polarity, etc..) for
* a particular sensor
*
*
* @param[in] sensor Selected sensor
* @param[in] ctrl Pointer to a sensor control handle
*
* @retval NRF_SUCCESS on success, otherwise an error code is returned
* @retval NRF_SUCCESS on success, otherwise an error code is returned
*/
ret_code_t saadc_config_channel(sensor_t sensor)
{
Expand All @@ -78,7 +78,7 @@ ret_code_t saadc_config_channel(sensor_t sensor)
/**
* @brief initialize the ADC module and ADC channel for each sensor
*
* @retval NRF_SUCCESS on success, otherwise an error code is returned
* @retval NRF_SUCCESS on success, otherwise an error code is returned
*/
static ret_code_t saadc_init(void)
{
Expand All @@ -99,7 +99,6 @@ static ret_code_t saadc_init(void)
hardware = sensor_handle_get_hardware(s_i);
err = saadc_config_channel(s_i);
APP_ERROR_CHECK(err);
NRF_LOG_INFO("sensor %d pwr_pin %d", s_i + 1, hardware->pwr_pin);
nrf_gpio_cfg_output(hardware->pwr_pin);
}

Expand All @@ -108,10 +107,10 @@ static ret_code_t saadc_init(void)

/**
* @brief Sample the ADC channel for one sensor
*
* @param[in] sensor Selected sensor
*
* @retval NRF_SUCCESS on success, otherwise an error code is returned
*
* @param[in] sensor Selected sensor
*
* @retval NRF_SUCCESS on success, otherwise an error code is returned
*/
static ret_code_t sample_one_sensor(sensor_t sensor)
{
Expand All @@ -130,36 +129,51 @@ static ret_code_t sample_one_sensor(sensor_t sensor)
}

/**
* @brief Sample the ADC channels for all sensors
*
* @retval NRF_SUCCESS on success, otherwise an error code is returned
* @brief Sample the ADC channels for all sensors
*
* @retval NRF_SUCCESS on success, otherwise an error code is returned
*/
static ret_code_t sample_all_sensors(void)
{
ret_code_t err;
sensor_ctrl_t * ctrl;

sample_one_sensor(SENSOR_1);
ctrl = sensor_handle_get_control(SENSOR_1);
if (ctrl->enable)
sample_one_sensor(SENSOR_1);

// err = nrfx_saadc_sample_convert(SENSOR_2_ADC_CHANNEL, &adc_val);
err = sensor_handle_add_value(SENSOR_2, mock_adc++);
APP_ERROR_CHECK(err);
ctrl = sensor_handle_get_control(SENSOR_2);
if (ctrl->enable)
{
// err = nrfx_saadc_sample_convert(SENSOR_2_ADC_CHANNEL, &adc_val);
err = sensor_handle_add_value(SENSOR_2, mock_adc++);
APP_ERROR_CHECK(err);
}

// err = nrfx_saadc_sample_convert(SENSOR_3_ADC_CHANNEL, &adc_val);
err = sensor_handle_add_value(SENSOR_3, 0);
APP_ERROR_CHECK(err);
ctrl = sensor_handle_get_control(SENSOR_3);
if (ctrl->enable)
{
// err = nrfx_saadc_sample_convert(SENSOR_3_ADC_CHANNEL, &adc_val);
err = sensor_handle_add_value(SENSOR_3, 0);
APP_ERROR_CHECK(err);
}

// err = nrfx_saadc_sample_convert(SENSOR_4_ADC_CHANNEL, &adc_val);
err = sensor_handle_add_value(SENSOR_4, 0);
APP_ERROR_CHECK(err);
ctrl = sensor_handle_get_control(SENSOR_4);
if (ctrl->enable)
{
// err = nrfx_saadc_sample_convert(SENSOR_4_ADC_CHANNEL, &adc_val);
err = sensor_handle_add_value(SENSOR_4, 0);
APP_ERROR_CHECK(err);
}

return err;
}

/**
* @brief Timer handler for time event (periodic) for the ADC
*
*
* @param[in] event_type Timer event (compare)
* @param[in] p_context Can be used to pass extra arguments to the handler
* @param[in] p_context Can be used to pass extra arguments to the handler
*/
static void saadc_timer_handler(nrf_timer_event_t event_type, void * p_context)
{
Expand All @@ -176,8 +190,8 @@ static void saadc_timer_handler(nrf_timer_event_t event_type, void * p_context)

/**
* @brief Initialize the timer for the periodic ADC sampling
*
* @retval NRF_SUCCESS on success, otherwise an error code is returned
*
* @retval NRF_SUCCESS on success, otherwise an error code is returned
*/
static ret_code_t saadc_timer_init(void)
{
Expand All @@ -197,15 +211,45 @@ static ret_code_t saadc_timer_init(void)
nrfx_timer_enable(&saadc_timer_instance);
}

/**
* @brief Update the time for the ADC sampling, especially the frequency
*
* @param[in] sensor Selected sensor
*
* @retval NRF_SUCCESS on success, otherwise an error code is returned
*/
static ret_code_t update_saadc_timer(sensor_t sensor)
{
ret_code_t err;

nrfx_timer_uninit(&saadc_timer_instance);

nrfx_timer_config_t timer_conf = NRFX_TIMER_DEFAULT_CONFIG;
timer_conf.bit_width = NRF_TIMER_BIT_WIDTH_32;
err = nrfx_timer_init(
&saadc_timer_instance, &timer_conf, saadc_timer_handler);
APP_ERROR_CHECK(err);

sensor_ctrl_t* ctrl = sensor_handle_get_control(sensor);
uint32_t time_ticks =
nrfx_timer_ms_to_ticks(&saadc_timer_instance, ctrl->sample_period_ms);

nrfx_timer_extended_compare(&saadc_timer_instance, NRF_TIMER_CC_CHANNEL0,
time_ticks, NRF_TIMER_SHORT_COMPARE0_CLEAR_MASK, true);

nrfx_timer_enable(&saadc_timer_instance);

return NRF_SUCCESS;
}

#if (MOCK_ADC)
/**
* @brief Generate a vector/array of random number
*
*
* @param[in] p_buff Pointer to a buffer where random number will be copied
* @param[in] size Amount of random number to be generated
*
* @retval Amount of random numbers that have been generated
* @retval Amount of random numbers that have been generated
*/
static uint8_t random_vector_generate(uint8_t * p_buff, uint8_t size)
{
Expand All @@ -219,7 +263,7 @@ static uint8_t random_vector_generate(uint8_t * p_buff, uint8_t size)
}

/**
* @brief initialize the random number module
* @brief initialize the random number module
*/
static void random_vector_generate_init(void)
{
Expand All @@ -230,8 +274,8 @@ static void random_vector_generate_init(void)

/**
* @brief generate random values for each sensors
*
* @param[in] sensors Array of sensors
*
* @param[in] sensors Array of sensors
*/
static void mock_sensor_values(sensors_t * sensors)
{
Expand All @@ -248,8 +292,8 @@ static void mock_sensor_values(sensors_t * sensors)

/**
* @brief Initialize the sensor sampling module: ADC, timer, sensor handles
*
* @retval NRF_SUCCESS on success, otherwise an error code is returned
*
* @retval NRF_SUCCESS on success, otherwise an error code is returned
*/
ret_code_t sensor_sampling_init(void)
{
Expand All @@ -268,24 +312,31 @@ ret_code_t sensor_sampling_init(void)

/**
* @brief update the ADC configuration/control for particuliar sensor
*
*
* @param[in] sensor Selected sensor
* @param[in] ctrl Pointer to a sensor control handle with new values
*
* @retval NRF_SUCCESS on success, otherwise an error code is returned
* @retval NRF_SUCCESS on success, otherwise an error code is returned
*/
ret_code_t sensor_sampling_update_sensor_control(
sensor_t sensor, sensor_ctrl_t * new_sensor_ctrl)
{
ret_code_t err;
if (!is_sensor_ctrl_valid(new_sensor_ctrl))
return NRF_ERROR_INVALID_DATA;

sensor_hardware_t * hardware = sensor_handle_get_hardware(sensor);
err = nrfx_saadc_channel_uninit(hardware->adc_chanel);
APP_ERROR_CHECK(err);

err = sensor_handle_set_control(sensor, new_sensor_ctrl);
APP_ERROR_CHECK(err);

err = saadc_config_channel(sensor);
APP_ERROR_CHECK(err);

err = update_saadc_timer(sensor);
APP_ERROR_CHECK(err);

return NRF_SUCCESS;
}
2 changes: 1 addition & 1 deletion Mobile_app/mask/.flutter-plugins-dependencies
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"info":"This is a generated file; do not edit or check into version control.","plugins":{"ios":[{"name":"flutter_blue","path":"C:\\\\Users\\\\maxim\\\\Programming\\\\SDKs\\\\Flutter\\\\Flutter_1_12_13\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\flutter_blue-0.7.2\\\\","dependencies":[]},{"name":"path_provider","path":"C:\\\\Users\\\\maxim\\\\Programming\\\\SDKs\\\\Flutter\\\\Flutter_1_12_13\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\path_provider-1.6.8\\\\","dependencies":[]},{"name":"sqflite","path":"C:\\\\Users\\\\maxim\\\\Programming\\\\SDKs\\\\Flutter\\\\Flutter_1_12_13\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\sqflite-1.3.0+1\\\\","dependencies":[]}],"android":[{"name":"flutter_blue","path":"C:\\\\Users\\\\maxim\\\\Programming\\\\SDKs\\\\Flutter\\\\Flutter_1_12_13\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\flutter_blue-0.7.2\\\\","dependencies":[]},{"name":"path_provider","path":"C:\\\\Users\\\\maxim\\\\Programming\\\\SDKs\\\\Flutter\\\\Flutter_1_12_13\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\path_provider-1.6.8\\\\","dependencies":[]},{"name":"sqflite","path":"C:\\\\Users\\\\maxim\\\\Programming\\\\SDKs\\\\Flutter\\\\Flutter_1_12_13\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\sqflite-1.3.0+1\\\\","dependencies":[]}],"macos":[{"name":"path_provider_macos","path":"C:\\\\Users\\\\maxim\\\\Programming\\\\SDKs\\\\Flutter\\\\Flutter_1_12_13\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\path_provider_macos-0.0.4+2\\\\","dependencies":[]},{"name":"sqflite","path":"C:\\\\Users\\\\maxim\\\\Programming\\\\SDKs\\\\Flutter\\\\Flutter_1_12_13\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\sqflite-1.3.0+1\\\\","dependencies":[]}],"linux":[],"windows":[],"web":[]},"dependencyGraph":[{"name":"flutter_blue","dependencies":[]},{"name":"path_provider","dependencies":["path_provider_macos"]},{"name":"path_provider_macos","dependencies":[]},{"name":"sqflite","dependencies":[]}],"date_created":"2021-02-28 17:27:00.403874","version":"1.22.6"}
{"info":"This is a generated file; do not edit or check into version control.","plugins":{"ios":[{"name":"flutter_blue","path":"C:\\\\Users\\\\maxim\\\\Programming\\\\SDKs\\\\Flutter\\\\Flutter_1_12_13\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\flutter_blue-0.7.2\\\\","dependencies":[]},{"name":"path_provider","path":"C:\\\\Users\\\\maxim\\\\Programming\\\\SDKs\\\\Flutter\\\\Flutter_1_12_13\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\path_provider-1.6.28\\\\","dependencies":[]},{"name":"sqflite","path":"C:\\\\Users\\\\maxim\\\\Programming\\\\SDKs\\\\Flutter\\\\Flutter_1_12_13\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\sqflite-1.3.2+4\\\\","dependencies":[]}],"android":[{"name":"flutter_blue","path":"C:\\\\Users\\\\maxim\\\\Programming\\\\SDKs\\\\Flutter\\\\Flutter_1_12_13\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\flutter_blue-0.7.2\\\\","dependencies":[]},{"name":"path_provider","path":"C:\\\\Users\\\\maxim\\\\Programming\\\\SDKs\\\\Flutter\\\\Flutter_1_12_13\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\path_provider-1.6.28\\\\","dependencies":[]},{"name":"sqflite","path":"C:\\\\Users\\\\maxim\\\\Programming\\\\SDKs\\\\Flutter\\\\Flutter_1_12_13\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\sqflite-1.3.2+4\\\\","dependencies":[]}],"macos":[{"name":"path_provider_macos","path":"C:\\\\Users\\\\maxim\\\\Programming\\\\SDKs\\\\Flutter\\\\Flutter_1_12_13\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\path_provider_macos-0.0.4+8\\\\","dependencies":[]},{"name":"sqflite","path":"C:\\\\Users\\\\maxim\\\\Programming\\\\SDKs\\\\Flutter\\\\Flutter_1_12_13\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\sqflite-1.3.2+4\\\\","dependencies":[]}],"linux":[{"name":"path_provider_linux","path":"C:\\\\Users\\\\maxim\\\\Programming\\\\SDKs\\\\Flutter\\\\Flutter_1_12_13\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\path_provider_linux-0.0.1+2\\\\","dependencies":[]}],"windows":[{"name":"path_provider_windows","path":"C:\\\\Users\\\\maxim\\\\Programming\\\\SDKs\\\\Flutter\\\\Flutter_1_12_13\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\path_provider_windows-0.0.4+3\\\\","dependencies":[]}],"web":[]},"dependencyGraph":[{"name":"flutter_blue","dependencies":[]},{"name":"path_provider","dependencies":["path_provider_macos","path_provider_linux","path_provider_windows"]},{"name":"path_provider_linux","dependencies":[]},{"name":"path_provider_macos","dependencies":[]},{"name":"path_provider_windows","dependencies":[]},{"name":"sqflite","dependencies":[]}],"date_created":"2021-03-18 13:39:53.775359","version":"1.22.6"}
48 changes: 8 additions & 40 deletions Mobile_app/mask/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,52 +22,20 @@

# Flutter/Dart/Pub related
**/doc/api/
**/ios/Flutter/.last_build_id
.dart_tool/
.flutter-plugins
.flutter-plugins-dependencies
.packages
.pub-cache/
.pub/
/build/

# Android related
**/android/**/gradle-wrapper.jar
**/android/.gradle
**/android/captures/
**/android/gradlew
**/android/gradlew.bat
**/android/local.properties
**/android/**/GeneratedPluginRegistrant.java
# Web related
lib/generated_plugin_registrant.dart

# iOS/XCode related
**/ios/**/*.mode1v3
**/ios/**/*.mode2v3
**/ios/**/*.moved-aside
**/ios/**/*.pbxuser
**/ios/**/*.perspectivev3
**/ios/**/*sync/
**/ios/**/.sconsign.dblite
**/ios/**/.tags*
**/ios/**/.vagrant/
**/ios/**/DerivedData/
**/ios/**/Icon?
**/ios/**/Pods/
**/ios/**/.symlinks/
**/ios/**/profile
**/ios/**/xcuserdata
**/ios/.generated/
**/ios/Flutter/App.framework
**/ios/Flutter/Flutter.framework
**/ios/Flutter/Generated.xcconfig
**/ios/Flutter/app.flx
**/ios/Flutter/app.zip
**/ios/Flutter/flutter_assets/
**/ios/Flutter/flutter_export_environment.sh
**/ios/ServiceDefinitions.json
**/ios/Runner/GeneratedPluginRegistrant.*
# Symbolication related
app.*.symbols

# Exceptions to above rules.
!**/ios/**/default.mode1v3
!**/ios/**/default.mode2v3
!**/ios/**/default.pbxuser
!**/ios/**/default.perspectivev3
!/packages/flutter_tools/test/data/dart_dependencies_test/**/.packages
# Obfuscation related
app.*.map.json
2 changes: 1 addition & 1 deletion Mobile_app/mask/.metadata
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# This file should be version controlled and should not be manually edited.

version:
revision: cc949a8e8b9cf394b9290a8e80f87af3e207dce5
revision: 9b2d32b605630f28625709ebd9d78ab3016b2bf6
channel: stable

project_type: app
13 changes: 0 additions & 13 deletions Mobile_app/mask/.vscode/launch.json

This file was deleted.

Loading

0 comments on commit 2e59bcf

Please sign in to comment.