]> Devi Nivas Git - smartwatch.git/commitdiff
Add actual health app app_settings
authorGajula, Anish <agajula7@gatech.edu>
Tue, 25 Nov 2025 14:17:38 +0000 (09:17 -0500)
committerGajula, Anish <agajula7@gatech.edu>
Tue, 25 Nov 2025 14:17:38 +0000 (09:17 -0500)
* Add health app and implement viewing data
  via a queue
* Move txt_strw to goldeloxSerial and rename with
  gl_ prefix

main/app_health.c
main/goldeloxSerial.c
main/goldeloxSerial.h
main/task_imu.c
main/task_imu.h
main/task_lcd.c
main/task_lcd.h

index 88989ee79122a9ebedb6b2ecbcdbc1848b5e1afe..5d7ee3a0ca030dec94f723fb270b99dc8c9ef31c 100644 (file)
@@ -8,8 +8,12 @@
 
 #include "task_button.h"
 #include "task_imu.h"
+#include "task_lcd.h"
 #include "app_health.h"
 
+#define HEALTH_BANNER_HEIGHT 16
+#define HEALTH_PAD 5
+
 void app_health_data(gl_display_t *disp) {
     char data[64] = "watchdog test...";
     gl_gfx_Cls(disp);
@@ -39,27 +43,56 @@ void app_health_data(gl_display_t *disp) {
 }
 
 void app_health_data2(gl_display_t *disp) {
-    char data[64] = "watchdog test...";
+    char data[64] = "loading...";
+    char dat2[64] = "loading...";
+    const char *title = "Exercise";
+    const gl_word_t charht = gl_charheight(disp, 'x');
     gl_gfx_Cls(disp);
+
+
+    
+    uint16_t txtw = gl_txt_strw(disp, title);
+    gl_gfx_RectangleFilled(disp, 0, 0, LCD_WIDTH, HEALTH_BANNER_HEIGHT, ROSYBROWN);
+    gl_gfx_MoveTo(disp, LCD_WIDTH / 2 - txtw / 2, (HEALTH_BANNER_HEIGHT - charht) / 2);
+    gl_txt_BGcolour(disp, ROSYBROWN);
+    gl_txt_FGcolour(disp, WHITE);
+    gl_txt_Bold(disp, 1);
+    gl_putstr(disp, (uint8_t *) title);
+
+
     gl_txt_BGcolour(disp, BLACK);
     gl_txt_FGcolour(disp, WHITE);
+
     while (1) {
         // gl_txt_MoveCursor(disp, 0, 0);
         struct gt_btn_msg_t *btnmsg;
         struct gt_health_msg_t healthmsg;
-        snprintf(data, 64, "Steps: %d Cal: %.4f", gt_health_step, gt_health_cal);
-        printf(data);
-        // gl_putstr(disp, (uint8_t *) "Pedometer");
-        gl_txt_MoveCursor(disp, 5, 0);
-        for (char *x = &data[0]; *x == '\0' ; x++)
-            gl_putCH(disp, 'A');
+        
+        
         while (xQueueReceive(gt_btnq, (void *) &btnmsg, 0) == pdPASS) {
             if (btnmsg->btn == GT_BTN_WHITE
                     && btnmsg->evt == BUTTON_SINGLE_CLICK) {
                 return;
             }
         }
+
+        while (xQueueReceive(gt_healthq, (void *) &healthmsg, 0) == pdPASS) {
+            snprintf(data, 64, "Steps: %d", healthmsg.step);
+            snprintf(dat2, 64, "Calories: %d", (int) healthmsg.cal);
+        }
+
+        // printf(data);
+
         
+        // gl_txt_MoveCursor(disp, 5, 0);
+        txtw = gl_txt_strw(disp, data);
+        gl_gfx_MoveTo(disp, LCD_WIDTH / 2 - txtw / 2, LCD_HEIGHT / 2 - charht - HEALTH_PAD);
+        //for (char *x = &data[0]; *x == '\0' ; x++)
+        gl_putstr(disp, (unsigned char *) data);
+
+        txtw = gl_txt_strw(disp, dat2);
+        gl_gfx_MoveTo(disp, LCD_WIDTH / 2 - txtw / 2, LCD_HEIGHT / 2 + HEALTH_PAD);
+        gl_putstr(disp, (unsigned char *) dat2);
         vTaskDelay(pdMS_TO_TICKS(100));
     }
 }
\ No newline at end of file
index 7e39b94aab1975510dc9582d51a1fab35e37d98a..0e3fd7d10ba9b95a0fb43fa8face7b4d27b35954 100644 (file)
@@ -1329,3 +1329,13 @@ void gl_reset2(gl_display_t *disp) {
 
     disp->serif->flush_rx();
 }
+
+
+gl_word_t gl_txt_strw(gl_display_t *disp, char *str) {
+    gl_word_t pxlw = 0;
+    while (*str) {
+        pxlw += gl_charwidth(disp, (unsigned char) *str);
+        str++;
+    }
+    return pxlw;
+}
\ No newline at end of file
index 77b1b4c9b2ccd189091093059c95fd318d640964..0d7cf21b0531b137ece9eabe6f75c96cdd5d8276 100644 (file)
@@ -234,6 +234,9 @@ gl_word_t gl_peekW(gl_display_t *display, gl_word_t  Address) ;
 void gl_reset2(gl_display_t *);
 
 
+gl_word_t gl_txt_strw(gl_display_t *, char *);
+
+
 
 #ifdef __cplusplus
 }
index 0e2322ab7ec0e8865570d46ae03a1163c66e61a8..12c49a9c639db0a9e2bd48eeeda5d0f960162922 100644 (file)
@@ -18,9 +18,6 @@
 #define EVENT_Q_SIZE 1
 
 
-int gt_health_step;
-float gt_health_cal;
-
 /* i2c bus configuration */
 i2c_config_t conf = {
        .mode = I2C_MODE_MASTER,
@@ -169,8 +166,6 @@ void task_imu_all(void *)
                        msg.cal = calculate_calories_from_steps(step_count, 170.0f, 65.5f);
                        msg.step = step_count;
                        // ESP_LOGI(TAG, "Calories burned: %.2f kcal; Step Count: %d", msg.cal, step_count);
-                       gt_health_step = step_count;
-                       gt_health_cal = msg.cal;
                        xQueueSendToBackFromISR(gt_healthq, &msg, NULL);
                        
                } else {
index effc8a7a3338efcd9cc7b5b17ce5d54d627128f3..f0d6251a0ac1a1417cbea0558dd573c85a976c31 100644 (file)
@@ -10,8 +10,6 @@ struct gt_health_msg_t {
 };
 
 extern QueueHandle_t gt_healthq;
-extern int gt_health_step;
-extern float gt_health_cal;
 
 void task_imu_all(void *pvParams);
 
index 7bed529f036d145e77a9021f9db45c507deadb49..ce0e7c87046907fe886217b11b3f8e1de9321eae 100644 (file)
@@ -59,7 +59,7 @@ struct app_t applist[NUM_APPS] = {
 
 void lcd_clock_draw_face(gl_display_t *);
 void lcd_clock_draw_hand(gl_display_t *, uint16_t, uint16_t, uint8_t, gl_word_t);
-gl_word_t txt_strw(gl_display_t *, char *);
+
 int write_tx(const void*, size_t);
 int read_rx(void *, size_t, uint32_t);
 int flush_rx();
@@ -281,7 +281,7 @@ void lcd_clock_loop(gl_display_t *disp) {
                 tm / 60 % 60,
                 (tm / (60 * 60) % 24 > 12) ? "PM" : "AM");
         /*gl_txt_Italic(disp, 1);*/
-        uint16_t chw = txt_strw(disp, txt);
+        uint16_t chw = gl_txt_strw(disp, txt);
         gl_gfx_MoveTo(disp, (LCD_WIDTH / 2) - (chw / 2), (LCD_HEIGHT / 2)
                 + (CLOCKSCR_CIRCRAD / 2));
         gl_putstr(disp, (unsigned char *) txt);
@@ -395,7 +395,7 @@ void lcd_homepage_loop(gl_display_t *disp) {
             txt = applist[curr_idx].name;
             gl_gfx_RectangleFilled(disp, 0, LCD_HHEIGHT, LCD_WIDTH, LCD_HEIGHT,
                     BLACK);
-            chw = txt_strw(disp, txt);
+            chw = gl_txt_strw(disp, txt);
             gl_gfx_MoveTo(disp, LCD_WIDTH / 2 - chw / 2, LCD_HHEIGHT
                     + APPSCR_PAD);
             gl_txt_BGcolour(disp, BLACK);
@@ -457,11 +457,4 @@ void lcd_clock_draw_hand(gl_display_t *disp, uint16_t x, uint16_t n, uint8_t l,
 }
 
 
-gl_word_t txt_strw(gl_display_t *disp, char *str) {
-    gl_word_t pxlw = 0;
-    while (*str) {
-        pxlw += gl_charwidth(disp, (unsigned char) *str);
-        str++;
-    }
-    return pxlw;
-}
+
index 0f226c31ab2557c2aa0744bf9575b3ba2b381ec6..082b8611bfe50df6328fe60de77913b08b80632d 100644 (file)
@@ -81,4 +81,6 @@ void lcd_boot_flash_app(gl_display_t *);
 
 void lcd_task(void);
 
+
+
 #endif