Skip to content

Commit ea9ab09

Browse files
committed
reorganizing files to move include to src files and renaming src to lib
1 parent 34777a0 commit ea9ab09

23 files changed

+87
-19
lines changed

CMakeLists.txt

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,17 @@ project(picomotion VERSION 1.0
1212
pico_sdk_init()
1313
# rest of your project
1414
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
15-
set(LV_CONF_PATH "${CMAKE_SOURCE_DIR}/include/lv_config/lv_conf.h")
15+
set(LV_CONF_PATH "${CMAKE_SOURCE_DIR}/lib/gui/lv_conf.h")
1616

17-
add_subdirectory(src/gc9a01)
18-
add_subdirectory(src/qmi8658)
19-
add_subdirectory(src/hwconfig)
17+
add_subdirectory(lib/hwconfig)
18+
add_subdirectory(lib/gc9a01)
19+
add_subdirectory(lib/qmi8658)
2020
add_subdirectory(extern/lvgl)
21-
add_subdirectory(src/gui)
21+
add_subdirectory(lib/gui)
2222

2323
# lvgl stuff
2424
include_directories(
25-
${CMAKE_SOURCE_DIR}/include/lv_config
25+
${CMAKE_SOURCE_DIR}/lib/gui
2626
extern/lvgl
2727
extern/lvgl/src
2828
)
@@ -31,7 +31,7 @@ message(STATUS "Including lv_conf.h from ${LV_CONF_PATH} If there are compilatio
3131

3232
add_executable(picomotion
3333
app/picomotion.c
34-
src/sys_common.c
34+
lib/hwconfig/sys_common.c
3535
)
3636

3737
# Add pico_stdlib library which aggregates commonly used features

lib/calorie_estimator/CMakeLists.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
add_library(calorie_estimator calorie_estimator.c)
2+
target_include_directories(calorie_estimator PUBLIC ${CMAKE_SOURCE_DIR}/lib/calorie_estimator)
3+
target_link_libraries(calorie_estimator qmi8658 hardware_gpio hardware_spi)
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
#include "calorie_estimator.h"
2+
#include "qmi8658.h"
3+
#include "math.h"
4+
5+
// this should eventually become a struct tracking stuff
6+
static double calories = 0.f;
7+
8+
void initialize_calorie_estimator(ce_alg_state_t* alg_state);
9+
10+
double get_calorie_estimate() {
11+
12+
}
13+
14+
void reset_calorie_estimate() {
15+
16+
}
17+
18+
void stop_calorie_estimator() {
19+
20+
}
21+
22+
void push_imu_data(imu_pkt_t* accl, imu_pkt_t* gyro) {
23+
accl->x *= 9.81;
24+
accl->y *= 9.81;
25+
accl->z *= 9.81;
26+
accl->x *= accl->x;
27+
accl->y *= accl->y;
28+
accl->z *= accl->z;
29+
double amag = sqrt(accl->x + accl->y + accl->z)-9.81;
30+
double met = 1 + amag / 10.f;
31+
double calories_in_10ms = met * 80 * (0.010 / 3600) * 1.05;
32+
calories += 100*calories_in_10ms;
33+
if (calories > 4000)
34+
calories = 0.f;
35+
gprintf(DEBUG, "calories: %.3lf\r", calories);
36+
}
37+
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
#pragma once
2+
3+
#include <stdio.h>
4+
#include <stdbool.h>
5+
#include "pico/time.h"
6+
#include "qmi8658.h"
7+
8+
#define CC_QUEUE_SIZE 100
9+
10+
typedef bool(*ce_alg_callback)(repeating_timer_t*);
11+
12+
typedef struct _ce_alg_state_t_ {
13+
double calories;
14+
imu_pkt_t accel[CC_QUEUE_SIZE];
15+
imu_pkt_t gyro[CC_QUEUE_SIZE];
16+
double lpf_accel;
17+
double lpf_gyro;
18+
ce_alg_callback cb;
19+
} ce_alg_state_t;
20+
21+
bool update_arc_calories_cb(struct repeating_timer* t);
22+
void initialize_calorie_estimator(ce_alg_state_t* alg_state);
23+
double get_calorie_estimate();
24+
void reset_calorie_estimate();
25+
void stop_calorie_estimator();
26+
void push_imu_data(imu_pkt_t*, imu_pkt_t*);
27+
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
add_library(gc9a01 gc9a01.c)
2-
target_include_directories(gc9a01 PUBLIC ${CMAKE_SOURCE_DIR}/include/gc9a01)
2+
target_include_directories(gc9a01 PUBLIC ${CMAKE_SOURCE_DIR}/lib/gc9a01)
33
target_link_libraries(gc9a01 hwconfig hardware_gpio hardware_spi)
File renamed without changes.
File renamed without changes.

lib/gui/CMakeLists.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
add_library(gui gui.c)
2+
target_include_directories(gui PUBLIC ${CMAKE_SOURCE_DIR}/lib/gui ${CMAKE_SOURCE_DIR}/extern/lvgl)
3+
target_link_libraries(gui PUBLIC gc9a01 lvgl)

src/gui/gui.c renamed to lib/gui/gui.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,10 @@
1010
#include <src/lv_init.h>
1111
#include <src/misc/lv_color.h>
1212

13+
#define BUFSIZE DISP_HOR_RES* DISP_VER_RES / 10
14+
1315
static lv_display_t* display = NULL;
1416
static struct repeating_timer lvgl_timer;
15-
#define BUFSIZE DISP_HOR_RES* DISP_VER_RES / 10
1617
static uint16_t buf1[BUFSIZE]; /*Declare a buffer for 1/10 screen size*/
1718
static uint16_t buf2[BUFSIZE]; /*Declare a buffer for 1/10 screen size*/
1819

File renamed without changes.
File renamed without changes.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
add_library(hwconfig hw_configure.c interrupts.c)
22

33
target_include_directories(hwconfig PUBLIC
4-
${CMAKE_SOURCE_DIR}/include/hwconfig)
4+
${CMAKE_SOURCE_DIR}/lib/hwconfig)
55

66
target_link_libraries(hwconfig qmi8658 pico_stdlib hardware_spi hardware_i2c hardware_pwm hardware_adc hardware_dma)
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

lib/qmi8658/CMakeLists.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
add_library(qmi8658 qmi8658.c)
2+
target_include_directories(qmi8658 PUBLIC
3+
${CMAKE_SOURCE_DIR}/lib/qmi8658
4+
${CMAKE_SOURCE_DIR}/lib/common
5+
)
6+
target_link_libraries(qmi8658 hwconfig hardware_i2c hardware_gpio)
File renamed without changes.
File renamed without changes.

src/gui/CMakeLists.txt

Lines changed: 0 additions & 3 deletions
This file was deleted.

src/qmi8658/CMakeLists.txt

Lines changed: 0 additions & 6 deletions
This file was deleted.

0 commit comments

Comments
 (0)