]> git.earman.xyz Git - sensor-watch.git/commitdiff
remove uses of deprecated watch_gpio functions
authorjoeycastillo <joeycastillo@utexas.edu>
Mon, 7 Oct 2024 13:01:21 +0000 (09:01 -0400)
committerjoeycastillo <joeycastillo@utexas.edu>
Mon, 7 Oct 2024 13:01:21 +0000 (09:01 -0400)
14 files changed:
movement/watch_faces/complication/day_one_face.c
movement/watch_faces/complication/deadline_face.c
movement/watch_faces/complication/endless_runner_face.c
movement/watch_faces/complication/flashlight_face.c
movement/watch_faces/complication/periodic_face.c
movement/watch_faces/complication/tally_face.c
movement/watch_faces/complication/time_left_face.c
movement/watch_faces/complication/timer_face.c
movement/watch_faces/complication/wareki_face.c
movement/watch_faces/complication/wordle_face.c
movement/watch_faces/demo/lis2dw_logging_face.c
movement/watch_faces/sensor/accelerometer_data_acquisition_face.c
watch-library/shared/driver/spiflash.c
watch-library/shared/driver/thermistor_driver.c

index 0810b9aaf3d12c369b5900d4951d87081460f52d..cdb6fc79d9b41cca37501897680c6e46ab41d075 100644 (file)
@@ -117,7 +117,7 @@ bool day_one_face_loop(movement_event_t event, void *context) {
         case EVENT_LOW_ENERGY_UPDATE:
         case EVENT_TICK:
             if (state->quick_cycle) {
-                if (watch_get_pin_level(BTN_ALARM)) {
+                if (HAL_GPIO_BTN_ALARM_read()) {
                     _day_one_face_increment(state);
                 } else {
                     _day_one_face_abort_quick_cycle(state);
index ed4b5a0605bf2d3d8279acd5c68322b4d0450c0f..113d118a6ff2c9308be8340b77e9ed84ea0797f9 100644 (file)
@@ -502,7 +502,7 @@ static bool _setting_loop(movement_event_t event, void *context)
     switch (event.event_type) {
         case EVENT_TICK:
             if (state->tick_freq == 8) {
-                if (watch_get_pin_level(BTN_ALARM)) {
+                if (HAL_GPIO_BTN_ALARM_read()) {
                     _increment_date(state, date_time);
                     _setting_display(event, state, date_time);
                 } else {
index f305ac4fe0883d75497a1b53cea168fd773f0525..1a17329365fcb6273013c426395c8a46a75e4276 100644 (file)
@@ -520,7 +520,7 @@ static void update_game(endless_runner_state_t *state, uint8_t subsecond) {
                 game_state.jump_state = JUMPING_FINAL_FRAME;
             else
                 game_state.fuel--;
-            if (!watch_get_pin_level(BTN_ALARM) && !watch_get_pin_level(BTN_LIGHT)) stop_jumping(state);
+            if (!HAL_GPIO_BTN_ALARM_read() && !HAL_GPIO_BTN_LIGHT_read()) stop_jumping(state);
         }
         else {
             curr_jump_frame = game_state.jump_state - NOT_JUMPING;
index 0c4facd0e1207bd72a4824fcb220206fd105ef59..10794de4f1cb70160fa1d7bfbc13749694030d4a 100644 (file)
@@ -39,8 +39,8 @@ void flashlight_face_setup(uint8_t watch_face_index, void ** context_ptr) {
 void flashlight_face_activate(void *context) {
     (void) context;
 
-    watch_enable_digital_output(A2);
-    watch_set_pin_level(A2, false);
+    HAL_GPIO_A2_out();
+    HAL_GPIO_A2_clr();
 }
 
 bool flashlight_face_loop(movement_event_t event, void *context) {
@@ -53,11 +53,7 @@ bool flashlight_face_loop(movement_event_t event, void *context) {
         case EVENT_LIGHT_BUTTON_DOWN:
             break;
         case EVENT_LIGHT_BUTTON_UP:
-            if (watch_get_pin_level(A2)) {
-                watch_set_pin_level(A2, false);
-            } else {
-                watch_set_pin_level(A2, true);
-            }
+            HAL_GPIO_A2_toggle();
             break;
         case EVENT_TIMEOUT:
             movement_move_to_face(0);
@@ -72,7 +68,6 @@ bool flashlight_face_loop(movement_event_t event, void *context) {
 void flashlight_face_resign(void *context) {
     (void) context;
 
-    watch_set_pin_level(A2, false);
-    watch_disable_digital_output(A2);
+    HAL_GPIO_A2_clr();
+    HAL_GPIO_A2_off();
 }
-
index 82a3442808d315329e9ccc7cf4b6a79b24c727a8..f6647e96c62cd870f17bf4f88993e54bc31e965d 100644 (file)
@@ -364,7 +364,7 @@ static void _handle_backward(periodic_state_t *state, bool should_sound){
 
 static void _handle_mode_still_pressed(periodic_state_t *state, bool should_sound) {
     if (_ts_ticks != 0){
-        if (!watch_get_pin_level(BTN_MODE)) {
+        if (!HAL_GPIO_BTN_MODE_read()) {
             _ts_ticks = 0;
             return;
         }
@@ -401,8 +401,8 @@ bool periodic_face_loop(movement_event_t event, void *context)
         if (state->mode == SCREEN_TITLE) _text_pos = _loop_text(_text_looping, _text_pos, 5);
         else if (state->mode == SCREEN_FULL_NAME) _text_pos = _loop_text(_text_looping, _text_pos, 6);
         if (_quick_ticks_running) {
-            if (watch_get_pin_level(BTN_LIGHT)) _handle_backward(state, false);
-            else if (watch_get_pin_level(BTN_ALARM)) _handle_forward(state, false);
+            if (HAL_GPIO_BTN_LIGHT_read()) _handle_backward(state, false);
+            else if (HAL_GPIO_BTN_ALARM_read()) _handle_forward(state, false);
             else stop_quick_cyc();
         }
 
index 75d59c86a14fcdd3e327f3015c7b64ded01f8804..128e84a600aaf55a93ea2ec3c99992ed1fe282ad 100644 (file)
@@ -113,7 +113,7 @@ bool tally_face_loop(movement_event_t event, void *context) {
     static bool using_led = false;
 
     if (using_led) {
-        if(!watch_get_pin_level(BTN_MODE) && !watch_get_pin_level(BTN_LIGHT) && !watch_get_pin_level(BTN_ALARM))
+        if(!HAL_GPIO_BTN_MODE_read() && !HAL_GPIO_BTN_LIGHT_read() && !HAL_GPIO_BTN_ALARM_read())
             using_led = false;
         else {
             if (event.event_type == EVENT_LIGHT_BUTTON_DOWN || event.event_type == EVENT_ALARM_BUTTON_DOWN)
@@ -125,8 +125,8 @@ bool tally_face_loop(movement_event_t event, void *context) {
     switch (event.event_type) {
         case EVENT_TICK:
             if (_quick_ticks_running) {
-                bool light_pressed = watch_get_pin_level(BTN_LIGHT);
-                bool alarm_pressed = watch_get_pin_level(BTN_ALARM);
+                bool light_pressed = HAL_GPIO_BTN_LIGHT_read();
+                bool alarm_pressed = HAL_GPIO_BTN_ALARM_read();
                 if (light_pressed && alarm_pressed) stop_quick_cyc();
                 else if (light_pressed) tally_face_increment(state, movement_button_should_sound());
                 else if (alarm_pressed) tally_face_decrement(state, movement_button_should_sound());
@@ -160,7 +160,7 @@ bool tally_face_loop(movement_event_t event, void *context) {
             break;
         case EVENT_LIGHT_BUTTON_DOWN:
         case EVENT_ALARM_BUTTON_DOWN:
-            if (watch_get_pin_level(BTN_MODE)) {
+            if (HAL_GPIO_BTN_MODE_read()) {
                 movement_illuminate_led();
                 using_led = true;
             }
index b91db201b3c17f87f2f42a05cf3c5cf8562222ef..2780d472b15a936cc5c14794ac7df4ea6754779c 100644 (file)
@@ -253,7 +253,7 @@ bool time_left_face_loop(movement_event_t event, void *context) {
         case EVENT_TICK: {
             uint8_t subsecond = event.subsecond;
             if (_quick_ticks_running) {
-                if (watch_get_pin_level(BTN_ALARM)) {
+                if (HAL_GPIO_BTN_ALARM_read()) {
                     _handle_alarm_button(state);
                     subsecond = 0;
                 } else _abort_quick_ticks();
index 338269a306ae4afc7fbde9eee9b61d5c7e9b5a44..de48e3562d7374d73dbac0b88e4fd2257cd2d20e 100644 (file)
@@ -224,7 +224,7 @@ bool timer_face_loop(movement_event_t event, void *context) {
             if (state->mode == running) state->now_ts++;
             else if (state->mode == pausing) state->pausing_seconds++;
             else if (state->quick_cycle) {
-                if (watch_get_pin_level(BTN_ALARM)) {
+                if (HAL_GPIO_BTN_ALARM_read()) {
                     _settings_increment(state);
                     subsecond = 0;
                 } else _abort_quick_cycle(state);
index 79d8f63758c042d8e763af95434569df87bf0299..ec87659c5bb79385d98366450a096e30bea4ad80 100644 (file)
@@ -123,7 +123,7 @@ bool wareki_loop(movement_event_t event, void *context) {
 
             //printf("tick %d\n",state->disp_year );
 
-            if (_alarm_button_press && watch_get_pin_level(BTN_ALARM)){
+            if (_alarm_button_press && HAL_GPIO_BTN_ALARM_read()){
                 //printf("ALARM ON\n");
             }
             else{
@@ -131,7 +131,7 @@ bool wareki_loop(movement_event_t event, void *context) {
                 _alarm_button_press = false;
             }
 
-            if (_light_button_press && watch_get_pin_level(BTN_LIGHT)){
+            if (_light_button_press && HAL_GPIO_BTN_LIGHT_read()){
                 //printf("LIGHT ON\n");
             }
             else{
index e7ab39f9f61402a2b7d7a0cc5c494f49d8b39928..a93a0e0e1b207e3de8fc7c77eea83c1f996eba2d 100644 (file)
@@ -556,7 +556,7 @@ bool wordle_face_loop(movement_event_t event, void *context) {
             display_letter(state, true);
             if (state->word_elements[state->position] == WORDLE_NUM_VALID_LETTERS) break;
 #if (WORDLE_USE_RANDOM_GUESS != 0)
-            if (watch_get_pin_level(BTN_LIGHT) &&
+            if (HAL_GPIO_BTN_LIGHT_read() &&
             (state->using_random_guess || (state->attempt == 0 && state->position == 0))) {
                 insert_random_guess(state);
                 break;
index 76108a0b6e4750b026cd4432566485e52c6882a5..467a99f5e4a5548d1055fb671f8124543a95b8f2 100644 (file)
@@ -131,7 +131,7 @@ void lis2dh_logging_face_activate(void *context) {
     lis2dh_logger_state_t *logger_state = (lis2dh_logger_state_t *)context;
     logger_state->display_index = 0;
     logger_state->log_ticks = 0;
-    watch_enable_digital_input(A4);
+    HAL_GPIO_A4_in();
 }
 
 bool lis2dw_logging_face_loop(movement_event_t event, void *context) {
@@ -184,7 +184,7 @@ bool lis2dw_logging_face_loop(movement_event_t event, void *context) {
 
 void lis2dw_logging_face_resign(void *context) {
     (void) context;
-    watch_disable_digital_input(A4);
+    HAL_GPIO_A4_off();
 }
 
 movement_watch_face_advisory_t lis2dw_logging_face_advise(void *context) {
index 5784bd2c978cf2d408b6bf19062529b33ca97ba4..725847497b05e8842b9853b5a13c5fb5ed9fd61b 100644 (file)
@@ -83,7 +83,7 @@ void accelerometer_data_acquisition_face_setup(uint8_t watch_face_index, void **
         // mark first four pages as used
         buf[0] = 0x0F;
         wait_for_flash_ready();
-        watch_set_pin_level(A3, false);
+        HAL_GPIO_A3_clr();
         spi_flash_command(CMD_ENABLE_WRITE);
         wait_for_flash_ready();
         spi_flash_write_data(0, buf, 256);
@@ -351,15 +351,15 @@ static void write_buffer_to_page(uint8_t *buf, uint16_t page) {
     uint32_t address = 256 * page;
 
     wait_for_flash_ready();
-    watch_set_pin_level(A3, false);
+    HAL_GPIO_A3_clr();
     spi_flash_command(CMD_ENABLE_WRITE);
     wait_for_flash_ready();
-    watch_set_pin_level(A3, false);
+    HAL_GPIO_A3_clr();
     spi_flash_write_data(address, buf, 256);
     wait_for_flash_ready();
 
     uint8_t buf2[256];
-    watch_set_pin_level(A3, false);
+    HAL_GPIO_A3_clr();
     spi_flash_read_data(address, buf2, 256);
     wait_for_flash_ready();
 
@@ -376,26 +376,26 @@ static void write_buffer_to_page(uint8_t *buf, uint16_t page) {
         }
     }
 
-    watch_set_pin_level(A3, false);
+    HAL_GPIO_A3_clr();
     spi_flash_read_data(header_page * 256, used_pages, 256);
     used_pages[offset_in_buf] = used_byte;
-    watch_set_pin_level(A3, false);
+    HAL_GPIO_A3_clr();
     spi_flash_command(CMD_ENABLE_WRITE);
     wait_for_flash_ready();
-    watch_set_pin_level(A3, false);
+    HAL_GPIO_A3_clr();
     spi_flash_write_data(header_page * 256, used_pages, 256);
     wait_for_flash_ready();
 }
 
 static bool wait_for_flash_ready(void) {
-    watch_set_pin_level(A3, false);
+    HAL_GPIO_A3_clr();
     bool ok = true;
     uint8_t read_status_response[1] = {0x00};
     do {
         ok = spi_flash_read_command(CMD_READ_STATUS, read_status_response, 1);
     } while ((read_status_response[0] & 0x3) != 0);
     delay_ms(1); // why do i need this?
-    watch_set_pin_level(A3, true);
+    HAL_GPIO_A3_set();
     return ok;
 }
 
index da6b2630b3ce9fc5a3a868ef5707ba3873462bb0..d5bdcd5e7f25efc970c4c31c7e1e231eb3113de4 100644 (file)
 #define SPI_FLASH_FAST_READ false
 
 static void flash_enable(void) {
-    watch_set_pin_level(A3, false);
+    HAL_GPIO_A3_clr();
 }
 
 static void flash_disable(void) {
-    watch_set_pin_level(A3, true);
+    HAL_GPIO_A3_set();
 }
 
 static bool transfer(uint8_t *command, uint32_t command_length, uint8_t *data_in, uint8_t *data_out, uint32_t data_length) {
index 8ce5934544d1b5f3c2d35ba0537a07eb8769576d..d9f1ae0f9ac626086465e2c3eb8605de4ca812f0 100644 (file)
@@ -30,20 +30,22 @@ void thermistor_driver_enable(void) {
     // Enable the ADC peripheral, which we'll use to read the thermistor value.
     watch_enable_adc();
     // Enable analog circuitry on the sense pin, which is tied to the thermistor resistor divider.
-    watch_enable_analog_input(THERMISTOR_SENSE_PIN);
+    HAL_GPIO_TEMPSENSE_in();
+    HAL_GPIO_TEMPSENSE_pmuxen(HAL_GPIO_PMUX_ADC);
     // Enable digital output on the enable pin, which is the power to the thermistor circuit.
-    watch_enable_digital_output(THERMISTOR_ENABLE_PIN);
+    HAL_GPIO_TS_ENABLE_out();
     // and make sure it's off.
-    watch_set_pin_level(THERMISTOR_ENABLE_PIN, !THERMISTOR_ENABLE_VALUE);
+    HAL_GPIO_TS_ENABLE_write(!THERMISTOR_ENABLE_VALUE);
 }
 
 void thermistor_driver_disable(void) {
     // Disable the ADC peripheral.
     watch_disable_adc();
     // Disable analog circuitry on the sense pin to save power.
-    watch_disable_analog_input(THERMISTOR_SENSE_PIN);
+    HAL_GPIO_TEMPSENSE_pmuxdis();
+    HAL_GPIO_TEMPSENSE_off();
     // Disable the enable pin's output circuitry.
-    watch_disable_digital_output(THERMISTOR_ENABLE_PIN);
+    HAL_GPIO_TS_ENABLE_off();
 }
 #if __EMSCRIPTEN__
 #include <emscripten.h>
@@ -56,11 +58,11 @@ float thermistor_driver_get_temperature(void)
 #else
 float thermistor_driver_get_temperature(void) {
     // set the enable pin to the level that powers the thermistor circuit.
-    watch_set_pin_level(THERMISTOR_ENABLE_PIN, THERMISTOR_ENABLE_VALUE);
+    HAL_GPIO_TS_ENABLE_write(THERMISTOR_ENABLE_VALUE);
     // get the sense pin level
-    uint16_t value = watch_get_analog_pin_level(THERMISTOR_SENSE_PIN);
+    uint16_t value = watch_get_analog_pin_level(HAL_GPIO_TEMPSENSE_pin());
     // and then set the enable pin to the opposite value to power down the thermistor circuit.
-    watch_set_pin_level(THERMISTOR_ENABLE_PIN, !THERMISTOR_ENABLE_VALUE);
+    HAL_GPIO_TS_ENABLE_write(!THERMISTOR_ENABLE_VALUE);
 
     return watch_utility_thermistor_temperature(value, THERMISTOR_HIGH_SIDE, THERMISTOR_B_COEFFICIENT, THERMISTOR_NOMINAL_TEMPERATURE, THERMISTOR_NOMINAL_RESISTANCE, THERMISTOR_SERIES_RESISTANCE);
 }