diff --git a/movement/watch_faces/complication/day_one_face.c b/movement/watch_faces/complication/day_one_face.c index 0810b9a..cdb6fc7 100644 --- a/movement/watch_faces/complication/day_one_face.c +++ b/movement/watch_faces/complication/day_one_face.c @@ -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); diff --git a/movement/watch_faces/complication/deadline_face.c b/movement/watch_faces/complication/deadline_face.c index ed4b5a0..113d118 100644 --- a/movement/watch_faces/complication/deadline_face.c +++ b/movement/watch_faces/complication/deadline_face.c @@ -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 { diff --git a/movement/watch_faces/complication/endless_runner_face.c b/movement/watch_faces/complication/endless_runner_face.c index f305ac4..1a17329 100644 --- a/movement/watch_faces/complication/endless_runner_face.c +++ b/movement/watch_faces/complication/endless_runner_face.c @@ -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; diff --git a/movement/watch_faces/complication/flashlight_face.c b/movement/watch_faces/complication/flashlight_face.c index 0c4facd..10794de 100644 --- a/movement/watch_faces/complication/flashlight_face.c +++ b/movement/watch_faces/complication/flashlight_face.c @@ -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(); } - diff --git a/movement/watch_faces/complication/periodic_face.c b/movement/watch_faces/complication/periodic_face.c index 82a3442..f6647e9 100644 --- a/movement/watch_faces/complication/periodic_face.c +++ b/movement/watch_faces/complication/periodic_face.c @@ -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(); } diff --git a/movement/watch_faces/complication/tally_face.c b/movement/watch_faces/complication/tally_face.c index 75d59c8..128e84a 100644 --- a/movement/watch_faces/complication/tally_face.c +++ b/movement/watch_faces/complication/tally_face.c @@ -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; } diff --git a/movement/watch_faces/complication/time_left_face.c b/movement/watch_faces/complication/time_left_face.c index b91db20..2780d47 100644 --- a/movement/watch_faces/complication/time_left_face.c +++ b/movement/watch_faces/complication/time_left_face.c @@ -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(); diff --git a/movement/watch_faces/complication/timer_face.c b/movement/watch_faces/complication/timer_face.c index 338269a..de48e35 100644 --- a/movement/watch_faces/complication/timer_face.c +++ b/movement/watch_faces/complication/timer_face.c @@ -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); diff --git a/movement/watch_faces/complication/wareki_face.c b/movement/watch_faces/complication/wareki_face.c index 79d8f63..ec87659 100644 --- a/movement/watch_faces/complication/wareki_face.c +++ b/movement/watch_faces/complication/wareki_face.c @@ -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{ diff --git a/movement/watch_faces/complication/wordle_face.c b/movement/watch_faces/complication/wordle_face.c index e7ab39f..a93a0e0 100644 --- a/movement/watch_faces/complication/wordle_face.c +++ b/movement/watch_faces/complication/wordle_face.c @@ -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; diff --git a/movement/watch_faces/demo/lis2dw_logging_face.c b/movement/watch_faces/demo/lis2dw_logging_face.c index 76108a0..467a99f 100644 --- a/movement/watch_faces/demo/lis2dw_logging_face.c +++ b/movement/watch_faces/demo/lis2dw_logging_face.c @@ -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) { diff --git a/movement/watch_faces/sensor/accelerometer_data_acquisition_face.c b/movement/watch_faces/sensor/accelerometer_data_acquisition_face.c index 5784bd2..7258474 100644 --- a/movement/watch_faces/sensor/accelerometer_data_acquisition_face.c +++ b/movement/watch_faces/sensor/accelerometer_data_acquisition_face.c @@ -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; } diff --git a/watch-library/shared/driver/spiflash.c b/watch-library/shared/driver/spiflash.c index da6b263..d5bdcd5 100644 --- a/watch-library/shared/driver/spiflash.c +++ b/watch-library/shared/driver/spiflash.c @@ -31,11 +31,11 @@ #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) { diff --git a/watch-library/shared/driver/thermistor_driver.c b/watch-library/shared/driver/thermistor_driver.c index 8ce5934..d9f1ae0 100644 --- a/watch-library/shared/driver/thermistor_driver.c +++ b/watch-library/shared/driver/thermistor_driver.c @@ -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 @@ -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); }