Skip to content

Commit

Permalink
Configure rgb led in device tree and add skeleton functionality for a…
Browse files Browse the repository at this point in the history
…lert processing

Signed-off-by: Brian Bradley <brian.bradley.p@gmail.com>
  • Loading branch information
bpbradley committed Jan 26, 2022
1 parent a41a123 commit d641f20
Show file tree
Hide file tree
Showing 7 changed files with 86 additions and 1 deletion.
3 changes: 2 additions & 1 deletion app/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
cmake_minimum_required(VERSION 3.20.0)
find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})

project(app LANGUAGES C VERSION 0.1.0)
project(app LANGUAGES C VERSION 0.2.0)

configure_file(app_version.h.in ${CMAKE_BINARY_DIR}/app/include/app_version.h)
target_include_directories(app PRIVATE ${CMAKE_BINARY_DIR}/app/include src)
Expand All @@ -22,6 +22,7 @@ set(PYRRHA_SOURCES
src/bluetooth.c
src/storage.c
src/timestamp.c
src/alerts.c
)
target_include_directories(app PRIVATE include src)
target_sources(app PRIVATE ${PYRRHA_SOURCES})
4 changes: 4 additions & 0 deletions app/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ module = PYRRHA
module-str = PYRRHA
source "subsys/logging/Kconfig.template.log_config"

module = ALERTS
module-str = ALERTS
source "subsys/logging/Kconfig.template.log_config"

menu "pyrrha threads"
menu "stacks"
config PYRRHA_COLLECTION_STACKSIZE
Expand Down
27 changes: 27 additions & 0 deletions app/boards/nrf52840dk_nrf52840.overlay
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,16 @@
};
};

&pwm0 {
status = "okay";
ch0-pin = <13>;
ch0-inverted;
ch1-pin = <14>;
ch1-inverted;
ch2-pin = <15>;
ch2-inverted;
};

/ {
gas_sensor: mics4514 {
label = "MICS4514";
Expand All @@ -35,4 +45,21 @@
rload-red-ohms = <47000>;
rload-ox-ohms = <22000>;
};
pwmleds {
compatible = "pwm-leds";
pwm_led0: pwm_led_0 {
pwms = <&pwm0 13>;
};
pwm_led1: pwm_led_1 {
pwms = <&pwm0 14>;
};
pwm_led2: pwm_led_2 {
pwms = <&pwm0 15>;
};
};
aliases {
red-pwm-led = &pwm_led0;
green-pwm-led = &pwm_led1;
blue-pwm-led = &pwm_led2;
};
};
1 change: 1 addition & 0 deletions app/configs/debug.conf
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ CONFIG_UART_CONSOLE=y
CONFIG_LOG=y
CONFIG_LOG_MODE_IMMEDIATE=y
CONFIG_PYRRHA_LOG_LEVEL_DBG=y
CONFIG_ALERTS_LOG_LEVEL_DBG=y
CONFIG_SENSOR_LOG_LEVEL_DBG=y
CONFIG_I2C_LOG_LEVEL_DBG=y

Expand Down
28 changes: 28 additions & 0 deletions app/include/alerts.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/**
* @file alerts.h
* @author Brian Bradley (brian.bradley.p@gmail.com)
* @date 2022-01-26
*
* @copyright Copyright (C) 2022 LION
*
* SPDX-License-Identifier: Apache-2.0
*
*/


#ifndef __PYRRHA_BLUETOOTH_H
#define __PYRRHA_BLUETOOTH_H

#include <collector.h>

/**
* @brief Check for and generate any alerts necessary based on
* sensor data
*
* @param data : sensor data used to match alert conditions
* @retval 0 on success
* @retval -errno otherwise
*/
int generate_alerts(struct pyrrha_data * data);

#endif
18 changes: 18 additions & 0 deletions app/src/alerts.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/**
* @file alerts.c
* @author Brian Bradley (brian.bradley.p@gmail.com)
* @brief
* @date 2022-01-26
*
* @copyright Copyright (C) 2022 LION
*
* SPDX-License-Identifier: Apache-2.0
*
*/

#include <alerts.h>
#include <logging/log.h>
LOG_MODULE_REGISTER(alerts, CONFIG_PYRRHA_LOG_LEVEL);
int generate_alerts(struct pyrrha_data * data){
return 0;
}
6 changes: 6 additions & 0 deletions app/src/collector.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#include <collector.h>
#include <messenger.h>
#include <timestamp.h>
#include <alerts.h>
LOG_MODULE_REGISTER(collector, CONFIG_PYRRHA_LOG_LEVEL);

void data_collection_process(void){
Expand All @@ -25,7 +26,12 @@ void data_collection_process(void){
data.err |= (capture_rht_data(&data.rht) != 0 ? ERR_RHT_SENSOR : 0);
data.timestamp = get_timestamp();
capture_rht_data(&data.rht);

/* Queue data for storage and / or notification to a host */
queue_sensor_data(&data);
/* Process any alerts based on current sample data */
generate_alerts(&data);

k_sleep(K_SECONDS(CONFIG_PYRRHA_SAMPLE_PERIOD));
}
}
Expand Down

0 comments on commit d641f20

Please sign in to comment.