Skip to content

Commit

Permalink
File renaming and organization.
Browse files Browse the repository at this point in the history
  • Loading branch information
jakkra committed Oct 17, 2023
1 parent a17b763 commit 68f5983
Show file tree
Hide file tree
Showing 44 changed files with 192 additions and 195 deletions.
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,7 @@
"${workspaceFolder}/app",
"${workspaceFolder}\\app"
],
"nrf-connect.debugging.bindings": {
"${workspaceFolder}/app/build": "Launch build"
},
}
23 changes: 12 additions & 11 deletions app/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,26 +26,27 @@ include_directories(src/)
include_directories(src/ui)
include_directories(src/applications)

target_sources(app PRIVATE src/display_control.c)
target_sources(app PRIVATE src/main.c)
target_sources(app PRIVATE src/ram_retention_storage.c)
target_sources(app PRIVATE src/zsw_vibration_motor.c)
target_sources(app PRIVATE src/zsw_clock.c)
target_sources(app PRIVATE src/zsw_cpu_freq.c)
target_sources(app PRIVATE src/zsw_gatt_sensor_server.c)
target_sources(app PRIVATE src/zsw_phone_app_publisher.c)

target_sources(app PRIVATE src/manager/application_manager.c)
target_sources(app PRIVATE src/manager/notification_manager.c)
target_sources(app PRIVATE src/manager/zsw_battery_manager.c)
target_sources(app PRIVATE src/manager/zsw_power_manager.c)
target_sources(app PRIVATE src/drivers/zsw_display_control.c)
target_sources(app PRIVATE src/drivers/zsw_vibration_motor.c)

target_sources(app PRIVATE src/managers/zsw_app_manager.c)
target_sources(app PRIVATE src/managers/zsw_notification_manager.c)
target_sources(app PRIVATE src/managers/zsw_battery_manager.c)
target_sources(app PRIVATE src/managers/zsw_power_manager.c)
target_sources(app PRIVATE src/managers/zsw_phone_app_publisher.c)

target_sources(app PRIVATE src/battery/battery.c)
target_sources(app PRIVATE src/battery/zsw_charger.c)

target_sources(app PRIVATE src/ble/ble_aoa.c)
target_sources(app PRIVATE src/ble/ble_comm.c)
target_sources(app PRIVATE src/ble/ble_transport.c)
target_sources(app PRIVATE src/ble/zsw_gatt_sensor_server.c)

target_sources(app PRIVATE src/sensors/zsw_imu.c)
target_sources(app PRIVATE src/sensors/zsw_pressure_sensor.c)
Expand All @@ -57,9 +58,9 @@ target_sources(app PRIVATE src/ui/notification/zsw_popup_notifcation.c)
target_sources(app PRIVATE src/ui/popup/zsw_popup_window.c)
target_sources(app PRIVATE src/ui/utils/zsw_ui_utils.c)

target_sources_ifdef(CONFIG_SPI_FLASH_LOADER app PRIVATE src/zsw_rtt_flash_loader.c)
target_sources_ifdef(CONFIG_FILE_SYSTEM_LITTLEFS app PRIVATE src/zsw_filesystem.c)
target_sources_ifdef(CONFIG_FILE_SYSTEM_LITTLEFS app PRIVATE src/zsw_lvgl_spi_decoder.c)
target_sources_ifdef(CONFIG_SPI_FLASH_LOADER app PRIVATE src/filesystem/zsw_rtt_flash_loader.c)
target_sources_ifdef(CONFIG_FILE_SYSTEM_LITTLEFS app PRIVATE src/filesystem/zsw_filesystem.c)
target_sources_ifdef(CONFIG_FILE_SYSTEM_LITTLEFS app PRIVATE src/filesystem/zsw_lvgl_spi_decoder.c)

if (DFU_BUILD)
target_sources(app PRIVATE src/dfu.c)
Expand Down
4 changes: 2 additions & 2 deletions app/src/applications/2048/game_2048_app.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#include <lv_100ask_2048.h>

#include "game_2048_ui.h"
#include "manager/application_manager.h"
#include "managers/zsw_app_manager.h"

// Functions needed for all applications
static void game_2048_app_start(lv_obj_t *root, lv_group_t *group);
Expand All @@ -30,7 +30,7 @@ static void game_2048_app_stop(void)

static int game_2048_app_add(void)
{
application_manager_add_application(&app);
zsw_app_manager_add_application(&app);

return 0;
}
Expand Down
6 changes: 3 additions & 3 deletions app/src/applications/accelerometer/accel_app.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#include "accel_ui.h"
#include "sensors/zsw_imu.h"
#include "events/zsw_periodic_event.h"
#include "manager/application_manager.h"
#include "managers/zsw_app_manager.h"

static void zbus_fetch_accel_data_callback(const struct zbus_channel *chan);
static void accel_app_start(lv_obj_t *root, lv_group_t *group);
Expand Down Expand Up @@ -49,12 +49,12 @@ static void zbus_fetch_accel_data_callback(const struct zbus_channel *chan)

static void on_close_accel(void)
{
application_manager_app_close_request(&app);
zsw_app_manager_app_close_request(&app);
}

static int accel_app_add(void)
{
application_manager_add_application(&app);
zsw_app_manager_add_application(&app);

return 0;
}
Expand Down
4 changes: 2 additions & 2 deletions app/src/applications/battery/battery_app.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#include "battery/battery.h"
#include "battery/battery_ui.h"
#include "events/battery_event.h"
#include "manager/application_manager.h"
#include "managers/zsw_app_manager.h"

LOG_MODULE_REGISTER(battery_app, LOG_LEVEL_WRN);

Expand Down Expand Up @@ -108,7 +108,7 @@ static int get_num_samples(void)

static int battery_app_add(void)
{
application_manager_add_application(&app);
zsw_app_manager_add_application(&app);
memset(battery_samples, 0, sizeof(battery_samples));
return 0;
}
Expand Down
4 changes: 2 additions & 2 deletions app/src/applications/compass/compass_app.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#include "compass_ui.h"
#include "ui/popup/zsw_popup_window.h"
#include "sensors/zsw_magnetometer.h"
#include "manager/application_manager.h"
#include "managers/zsw_app_manager.h"

LOG_MODULE_REGISTER(compass_app, LOG_LEVEL_DBG);

Expand Down Expand Up @@ -68,7 +68,7 @@ static void timer_callback(lv_timer_t *timer)

static int compass_app_add(void)
{
application_manager_add_application(&app);
zsw_app_manager_add_application(&app);
return 0;
}

Expand Down
6 changes: 3 additions & 3 deletions app/src/applications/info/info_app.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
#include <zephyr/bluetooth/hci.h>

#include "info_ui.h"
#include "manager/zsw_power_manager.h"
#include "manager/application_manager.h"
#include "managers/zsw_power_manager.h"
#include "managers/zsw_app_manager.h"

LOG_MODULE_REGISTER(info_app, LOG_LEVEL_DBG);

Expand Down Expand Up @@ -78,7 +78,7 @@ static void on_reset_pressed(void)

static int info_app_add(void)
{
application_manager_add_application(&app);
zsw_app_manager_add_application(&app);
return 0;
}

Expand Down
6 changes: 3 additions & 3 deletions app/src/applications/music_control/music_control_app.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#include "music_control_ui.h"
#include "ble/ble_comm.h"
#include "events/ble_data_event.h"
#include "manager/application_manager.h"
#include "managers/zsw_app_manager.h"

// Functions needed for all applications
static void music_control_app_start(lv_obj_t *root, lv_group_t *group);
Expand Down Expand Up @@ -60,7 +60,7 @@ static void on_music_ui_evt_music(music_control_ui_evt_type_t evt_type)

switch (evt_type) {
case MUSIC_CONTROL_UI_CLOSE:
application_manager_app_close_request(&app);
zsw_app_manager_app_close_request(&app);
break;
case MUSIC_CONTROL_UI_PLAY:
msg_len = snprintf(buf, sizeof(buf), "{\"t\":\"music\", \"n\": %s} \n", "play");
Expand Down Expand Up @@ -127,7 +127,7 @@ static void timer_callback(lv_timer_t *timer)

static int music_control_app_add(void)
{
application_manager_add_application(&app);
zsw_app_manager_add_application(&app);
running = false;

return 0;
Expand Down
12 changes: 6 additions & 6 deletions app/src/applications/notification/notification_app.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
#include <zephyr/init.h>

#include "notification_ui.h"
#include "manager/notification_manager.h"
#include "manager/application_manager.h"
#include "managers/zsw_notification_manager.h"
#include "managers/zsw_app_manager.h"

// Functions needed for all applications
static void notification_app_start(lv_obj_t *root, lv_group_t *group);
Expand All @@ -19,16 +19,16 @@ static application_t app = {
static void on_notification_page_notification_close(uint32_t not_id)
{
// TODO send to phone that the notification was read.
notification_manager_remove(not_id);
zsw_notification_manager_remove(not_id);
}


static void notification_app_start(lv_obj_t *root, lv_group_t *group)
{
int num_unread;
not_mngr_notification_t notifications[NOTIFICATION_MANAGER_MAX_STORED];
zsw_not_mngr_notification_t notifications[NOTIFICATION_MANAGER_MAX_STORED];

notification_manager_get_all(notifications, &num_unread);
zsw_notification_manager_get_all(notifications, &num_unread);
notifications_page_init(on_notification_page_notification_close);
notifications_page_create(notifications, num_unread, group);
}
Expand All @@ -40,7 +40,7 @@ static void notification_app_stop(void)

static int notification_app_add(void)
{
application_manager_add_application(&app);
zsw_app_manager_add_application(&app);

return 0;
}
Expand Down
6 changes: 3 additions & 3 deletions app/src/applications/notification/notification_ui.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

static void not_button_pressed(lv_event_t *e);
static void scroll_event_cb(lv_event_t *e);
static void build_notification_entry(lv_obj_t *parent, not_mngr_notification_t *not, lv_group_t *input_group);
static void build_notification_entry(lv_obj_t *parent, zsw_not_mngr_notification_t *not, lv_group_t *input_group);

static on_notification_remove_cb_t not_removed_callback;

Expand All @@ -15,7 +15,7 @@ void notifications_page_init(on_notification_remove_cb_t not_removed_cb)
not_removed_callback = not_removed_cb;
}

void notifications_page_create(not_mngr_notification_t *notifications, uint8_t num_notifications,
void notifications_page_create(zsw_not_mngr_notification_t *notifications, uint8_t num_notifications,
lv_group_t *input_group)
{
group = input_group;
Expand Down Expand Up @@ -49,7 +49,7 @@ void notifications_page_close(void)
lv_obj_del(main_page);
}

static void build_notification_entry(lv_obj_t *parent, not_mngr_notification_t *not, lv_group_t *input_group)
static void build_notification_entry(lv_obj_t *parent, zsw_not_mngr_notification_t *not, lv_group_t *input_group)
{
lv_obj_t *title;
lv_obj_t *cont;
Expand Down
4 changes: 2 additions & 2 deletions app/src/applications/notification/notification_ui.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@
#include <inttypes.h>
#include <lvgl.h>

#include "manager/notification_manager.h"
#include "managers/zsw_notification_manager.h"

typedef void(*on_notification_remove_cb_t)(uint32_t id);

void notifications_page_init(on_notification_remove_cb_t not_removed_cb);

void notifications_page_create(not_mngr_notification_t *notifications, uint8_t num_notifications,
void notifications_page_create(zsw_not_mngr_notification_t *notifications, uint8_t num_notifications,
lv_group_t *input_group);

void notifications_page_close(void);
Expand Down
12 changes: 6 additions & 6 deletions app/src/applications/qr_code/qr_code_app.c
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#include <zephyr/kernel.h>
#include <zephyr/init.h>
#include <display_control.h>
#include "drivers/zsw_display_control.h"

#include "qr_code_ui.h"
#include "manager/application_manager.h"
#include "managers/zsw_app_manager.h"

// Functions needed for all applications
static void qr_code_app_start(lv_obj_t *root, lv_group_t *group);
Expand All @@ -22,20 +22,20 @@ static uint8_t original_brightness;

static void qr_code_app_start(lv_obj_t *root, lv_group_t *group)
{
original_brightness = display_control_get_brightness();
display_control_set_brightness(100);
original_brightness = zsw_display_control_get_brightness();
zsw_display_control_set_brightness(100);
qr_code_ui_show(root);
}

static void qr_code_app_stop(void)
{
display_control_set_brightness(original_brightness);
zsw_display_control_set_brightness(original_brightness);
qr_code_ui_remove();
}

static int qr_code_app_add(void)
{
application_manager_add_application(&app);
zsw_app_manager_add_application(&app);

return 0;
}
Expand Down
6 changes: 3 additions & 3 deletions app/src/applications/sensors_summary/sensors_summary_app.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#include "sensors/zsw_env_sensor.h"
#include "sensors/zsw_light_sensor.h"
#include "sensors/zsw_pressure_sensor.h"
#include "manager/application_manager.h"
#include "managers/zsw_app_manager.h"

LOG_MODULE_REGISTER(sensors_summary_app, LOG_LEVEL_DBG);

Expand Down Expand Up @@ -85,7 +85,7 @@ static void timer_callback(lv_timer_t *timer)

static void on_close_sensors_summary(void)
{
application_manager_app_close_request(&app);
zsw_app_manager_app_close_request(&app);
}

static void on_ref_set(void)
Expand All @@ -95,7 +95,7 @@ static void on_ref_set(void)

static int sensors_summary_app_add(void)
{
application_manager_add_application(&app);
zsw_app_manager_add_application(&app);
return 0;
}

Expand Down
12 changes: 6 additions & 6 deletions app/src/applications/settings/settings_app.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#include <zephyr/kernel.h>
#include <zephyr/init.h>
#include <display_control.h>
#include <zephyr/bluetooth/gap.h>
#include <zephyr/bluetooth/bluetooth.h>
#include <zephyr/settings/settings.h>
Expand All @@ -9,7 +8,8 @@
#include "ble/ble_aoa.h"
#include "ble/ble_comm.h"
#include "sensors/zsw_imu.h"
#include "manager/application_manager.h"
#include "drivers/zsw_display_control.h"
#include "managers/zsw_app_manager.h"

static void settings_app_start(lv_obj_t *root, lv_group_t *group);
static void settings_app_stop(void);
Expand Down Expand Up @@ -155,13 +155,13 @@ static void settings_app_stop(void)
static void on_close_settings(void)
{
printk("on_close_settings\n");
application_manager_app_close_request(&app);
zsw_app_manager_app_close_request(&app);
}

static void on_brightness_changed(lv_setting_value_t value, bool final)
{
// Slider have values 0-10 hence multiply with 10 to get brightness in percent
display_control_set_brightness(value.item.slider * 10);
zsw_display_control_set_brightness(value.item.slider * 10);
value.item.slider *= 10;
settings_save_one("settings/brightness", &value.item.slider, sizeof(value.item.slider));
}
Expand Down Expand Up @@ -228,7 +228,7 @@ static int settings_load_cb(const char *name, size_t len,
rc = read_cb(cb_arg, &bri, sizeof(bri));
printk("Read br: %d\n", bri);
general_page_items[0].item.slider.inital_val = bri / 10;
display_control_set_brightness(bri);
zsw_display_control_set_brightness(bri);
if (rc >= 0) {
return 0;
}
Expand All @@ -242,7 +242,7 @@ static int settings_load_cb(const char *name, size_t len,

static int settings_app_add(void)
{
application_manager_add_application(&app);
zsw_app_manager_add_application(&app);

return 0;
}
Expand Down
4 changes: 2 additions & 2 deletions app/src/applications/template/template_app.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#include <zephyr/init.h>

#include "template_ui.h"
#include "manager/application_manager.h"
#include "managers/zsw_app_manager.h"

// Functions needed for all applications
static void template_app_start(lv_obj_t *root, lv_group_t *group);
Expand Down Expand Up @@ -51,7 +51,7 @@ static void on_incrementation(void)

static int template_app_add(void)
{
application_manager_add_application(&app);
zsw_app_manager_add_application(&app);

return 0;
}
Expand Down
Loading

0 comments on commit 68f5983

Please sign in to comment.