Skip to content

Commit

Permalink
Merge branch 'next' - new faces before the freeze
Browse files Browse the repository at this point in the history
Merge the next branch containing numerous new sensor watch faces
as well as some new features. Not all of them made it in the end
and we even had to revert improvements merged in last next due to
issues that weren't found during testing. Still, I am very proud
to be merging in and closing over 20 pull requests.

I believe the project is in the best possible shape it can be
before the movement 2.0 refactor.

Reviewed-by: Matheus Afonso Martins Moreira <[email protected]>
Tested-on-hardware-by: David Volovskiy <[email protected]>
Tested-on-hardware-by: CarpeNoctem <[email protected]>
GitHub-Pull-Request: #469
  • Loading branch information
matheusmoreira committed Sep 17, 2024
2 parents 035fff5 + fe9a0a6 commit bf4d461
Show file tree
Hide file tree
Showing 56 changed files with 7,843 additions and 145 deletions.
14 changes: 14 additions & 0 deletions make.mk
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,20 @@ SRCS += \

endif

ifeq ($(LED), BLUE)
CFLAGS += -DWATCH_IS_BLUE_BOARD
endif

ifndef COLOR
$(error Set the COLOR variable to RED, BLUE, or GREEN depending on what board you have.)
endif

COLOR_VALID := $(filter $(COLOR),RED BLUE GREEN)

ifeq ($(COLOR_VALID),)
$(error COLOR must be RED, BLUE, or GREEN)
endif

ifeq ($(COLOR), BLUE)
CFLAGS += -DWATCH_IS_BLUE_BOARD
endif
Expand Down
12 changes: 12 additions & 0 deletions movement/make/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ SRCS += \
../shell.c \
../shell_cmd_list.c \
../watch_faces/clock/simple_clock_face.c \
../watch_faces/clock/close_enough_clock_face.c \
../watch_faces/clock/clock_face.c \
../watch_faces/clock/world_clock_face.c \
../watch_faces/clock/beats_face.c \
Expand Down Expand Up @@ -129,6 +130,17 @@ SRCS += \
../watch_faces/clock/minute_repeater_decimal_face.c \
../watch_faces/complication/tuning_tones_face.c \
../watch_faces/complication/kitchen_conversions_face.c \
../watch_faces/complication/wordle_face.c \
../watch_faces/complication/endless_runner_face.c \
../watch_faces/complication/periodic_face.c \
../watch_faces/complication/deadline_face.c \
../watch_faces/complication/higher_lower_game_face.c \
../watch_faces/clock/french_revolutionary_face.c \
../watch_faces/clock/minimal_clock_face.c \
../watch_faces/complication/simon_face.c \
../watch_faces/complication/simple_calculator_face.c \
../watch_faces/sensor/alarm_thermometer_face.c \
../watch_faces/demo/beeps_face.c \
# New watch faces go above this line.

# Leave this line at the bottom of the file; it has all the targets for making your project.
Expand Down
69 changes: 30 additions & 39 deletions movement/movement.c
Original file line number Diff line number Diff line change
Expand Up @@ -95,31 +95,6 @@
#define MOVEMENT_DEFAULT_LED_DURATION 1
#endif

// Default to no set location latitude
#ifndef MOVEMENT_DEFAULT_LATITUDE
#define MOVEMENT_DEFAULT_LATITUDE 0
#endif

// Default to no set location longitude
#ifndef MOVEMENT_DEFAULT_LONGITUDE
#define MOVEMENT_DEFAULT_LONGITUDE 0
#endif

// Default to no set birthdate year
#ifndef MOVEMENT_DEFAULT_BIRTHDATE_YEAR
#define MOVEMENT_DEFAULT_BIRTHDATE_YEAR 0
#endif

// Default to no set birthdate month
#ifndef MOVEMENT_DEFAULT_BIRTHDATE_MONTH
#define MOVEMENT_DEFAULT_BIRTHDATE_MONTH 0
#endif

// Default to no set birthdate day
#ifndef MOVEMENT_DEFAULT_BIRTHDATE_DAY
#define MOVEMENT_DEFAULT_BIRTHDATE_DAY 0
#endif

#if __EMSCRIPTEN__
#include <emscripten.h>
#endif
Expand Down Expand Up @@ -264,14 +239,24 @@ void movement_request_tick_frequency(uint8_t freq) {
}

void movement_illuminate_led(void) {
if (movement_state.settings.bit.led_duration) {
if (movement_state.settings.bit.led_duration != 0b111) {
watch_set_led_color(movement_state.settings.bit.led_red_color ? (0xF | movement_state.settings.bit.led_red_color << 4) : 0,
movement_state.settings.bit.led_green_color ? (0xF | movement_state.settings.bit.led_green_color << 4) : 0);
movement_state.light_ticks = (movement_state.settings.bit.led_duration * 2 - 1) * 128;
if (movement_state.settings.bit.led_duration == 0) {
movement_state.light_ticks = 1;
} else {
movement_state.light_ticks = (movement_state.settings.bit.led_duration * 2 - 1) * 128;
}
_movement_enable_fast_tick_if_needed();
}
}

static void _movement_led_off(void) {
watch_set_led_off();
movement_state.light_ticks = -1;
_movement_disable_fast_tick_if_possible();
}

bool movement_default_loop_handler(movement_event_t event, movement_settings_t *settings) {
(void)settings;

Expand All @@ -282,6 +267,11 @@ bool movement_default_loop_handler(movement_event_t event, movement_settings_t *
case EVENT_LIGHT_BUTTON_DOWN:
movement_illuminate_led();
break;
case EVENT_LIGHT_BUTTON_UP:
if (movement_state.settings.bit.led_duration == 0) {
_movement_led_off();
}
break;
case EVENT_MODE_LONG_PRESS:
if (MOVEMENT_SECONDARY_FACE_INDEX && movement_state.current_face_idx == 0) {
movement_move_to_face(MOVEMENT_SECONDARY_FACE_INDEX);
Expand Down Expand Up @@ -416,11 +406,7 @@ void app_init(void) {
movement_state.settings.bit.to_interval = MOVEMENT_DEFAULT_TIMEOUT_INTERVAL;
movement_state.settings.bit.le_interval = MOVEMENT_DEFAULT_LOW_ENERGY_INTERVAL;
movement_state.settings.bit.led_duration = MOVEMENT_DEFAULT_LED_DURATION;
movement_state.location.bit.latitude = MOVEMENT_DEFAULT_LATITUDE;
movement_state.location.bit.longitude = MOVEMENT_DEFAULT_LONGITUDE;
movement_state.birthdate.bit.year = MOVEMENT_DEFAULT_BIRTHDATE_YEAR;
movement_state.birthdate.bit.month = MOVEMENT_DEFAULT_BIRTHDATE_MONTH;
movement_state.birthdate.bit.day = MOVEMENT_DEFAULT_BIRTHDATE_DAY;

movement_state.light_ticks = -1;
movement_state.alarm_ticks = -1;
movement_state.next_available_backup_register = 4;
Expand All @@ -443,14 +429,10 @@ void app_init(void) {

void app_wake_from_backup(void) {
movement_state.settings.reg = watch_get_backup_data(0);
movement_state.location.reg = watch_get_backup_data(1);
movement_state.birthdate.reg = watch_get_backup_data(2);
}

void app_setup(void) {
watch_store_backup_data(movement_state.settings.reg, 0);
watch_store_backup_data(movement_state.location.reg, 1);
watch_store_backup_data(movement_state.birthdate.reg, 2);

static bool is_first_launch = true;

Expand Down Expand Up @@ -544,9 +526,7 @@ bool app_loop(void) {
if (watch_get_pin_level(BTN_LIGHT)) {
movement_state.light_ticks = 1;
} else {
watch_set_led_off();
movement_state.light_ticks = -1;
_movement_disable_fast_tick_if_possible();
_movement_led_off();
}
}

Expand Down Expand Up @@ -584,6 +564,17 @@ bool app_loop(void) {
event.subsecond = movement_state.subsecond;
// the first trip through the loop overrides the can_sleep state
can_sleep = wf->loop(event, &movement_state.settings, watch_face_contexts[movement_state.current_face_idx]);

// Keep light on if user is still interacting with the watch.
if (movement_state.light_ticks > 0) {
switch (event.event_type) {
case EVENT_LIGHT_BUTTON_DOWN:
case EVENT_MODE_BUTTON_DOWN:
case EVENT_ALARM_BUTTON_DOWN:
movement_illuminate_led();
}
}

event.event_type = EVENT_NONE;
}

Expand Down
7 changes: 3 additions & 4 deletions movement/movement.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ typedef union {
uint8_t to_interval : 2; // an inactivity interval for asking the active face to resign.
bool to_always : 1; // if true, always time out from the active face to face 0. otherwise only faces that time out will resign (the default).
uint8_t le_interval : 3; // 0 to disable low energy mode, or an inactivity interval for going into low energy mode.
uint8_t led_duration : 2; // how many seconds to shine the LED for (x2), or 0 to disable it.
uint8_t led_duration : 3; // how many seconds to shine the LED for (x2), 0 to shine only while the button is depressed, or all bits set to disable the LED altogether.
uint8_t led_red_color : 4; // for general purpose illumination, the red LED value (0-15)
uint8_t led_green_color : 4; // for general purpose illumination, the green LED value (0-15)
uint8_t time_zone : 6; // an integer representing an index in the time zone table.
Expand All @@ -60,9 +60,10 @@ typedef union {
// time-oriented complication like a sunrise/sunset timer, and a simple locale preference could tell an
// altimeter to display feet or meters as easily as it tells a thermometer to display degrees in F or C.
bool clock_mode_24h : 1; // indicates whether clock should use 12 or 24 hour mode.
bool clock_24h_leading_zero : 1; // indicates whether clock should leading zero to indicate 24 hour mode.
bool use_imperial_units : 1; // indicates whether to use metric units (the default) or imperial.
bool alarm_enabled : 1; // indicates whether there is at least one alarm enabled.
uint8_t reserved : 6; // room for more preferences if needed.
uint8_t reserved : 5; // room for more preferences if needed.
} bit;
uint32_t reg;
} movement_settings_t;
Expand Down Expand Up @@ -242,8 +243,6 @@ typedef struct {
typedef struct {
// properties stored in BACKUP register
movement_settings_t settings;
movement_location_t location;
movement_birthdate_t birthdate;

// transient properties
int16_t current_face_idx;
Expand Down
30 changes: 7 additions & 23 deletions movement/movement_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,15 +76,15 @@ const watch_face_t watch_faces[] = {
/* Set the timeout before switching to low energy mode
* Valid values are:
* 0: Never
* 1: 10 mins
* 2: 1 hour
* 3: 2 hours
* 4: 6 hours
* 5: 12 hours
* 6: 1 day
* 1: 1 hour
* 2: 2 hours
* 3: 6 hours
* 4: 12 hours
* 5: 1 day
* 6: 2 days
* 7: 7 days
*/
#define MOVEMENT_DEFAULT_LOW_ENERGY_INTERVAL 2
#define MOVEMENT_DEFAULT_LOW_ENERGY_INTERVAL 1

/* Set the led duration
* Valid values are:
Expand All @@ -95,20 +95,4 @@ const watch_face_t watch_faces[] = {
*/
#define MOVEMENT_DEFAULT_LED_DURATION 1

/* The latitude and longitude used for the wearers location
* Set signed values in 1/100ths of a degree
*/
#define MOVEMENT_DEFAULT_LATITUDE 0
#define MOVEMENT_DEFAULT_LONGITUDE 0

/* The wearers birthdate
* Valid values:
* Year: 1 - 4095
* Month: 1 - 12
* Day: 1 - 31
*/
#define MOVEMENT_DEFAULT_BIRTHDATE_YEAR 0
#define MOVEMENT_DEFAULT_BIRTHDATE_MONTH 0
#define MOVEMENT_DEFAULT_BIRTHDATE_DAY 0

#endif // MOVEMENT_CONFIG_H_
83 changes: 83 additions & 0 deletions movement/movement_custom_signal_tunes.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,33 @@ int8_t signal_tune[] = {
};
#endif // SIGNAL_TUNE_MARIO_THEME

#ifdef SIGNAL_TUNE_MGS_CODEC
int8_t signal_tune[] = {
BUZZER_NOTE_G5SHARP_A5FLAT, 1,
BUZZER_NOTE_C6, 1,
BUZZER_NOTE_G5SHARP_A5FLAT, 1,
BUZZER_NOTE_C6, 1,
BUZZER_NOTE_G5SHARP_A5FLAT, 1,
BUZZER_NOTE_C6, 1,
BUZZER_NOTE_G5SHARP_A5FLAT, 1,
BUZZER_NOTE_C6, 1,
BUZZER_NOTE_G5SHARP_A5FLAT, 1,
BUZZER_NOTE_C6, 1,
BUZZER_NOTE_REST, 6,
BUZZER_NOTE_G5SHARP_A5FLAT, 1,
BUZZER_NOTE_C6, 1,
BUZZER_NOTE_G5SHARP_A5FLAT, 1,
BUZZER_NOTE_C6, 1,
BUZZER_NOTE_G5SHARP_A5FLAT, 1,
BUZZER_NOTE_C6, 1,
BUZZER_NOTE_G5SHARP_A5FLAT, 1,
BUZZER_NOTE_C6, 1,
BUZZER_NOTE_G5SHARP_A5FLAT, 1,
BUZZER_NOTE_C6, 1,
0
};
#endif // SIGNAL_TUNE_MGS_CODEC

#ifdef SIGNAL_TUNE_KIM_POSSIBLE
int8_t signal_tune[] = {
BUZZER_NOTE_G7, 6,
Expand Down Expand Up @@ -119,4 +146,60 @@ int8_t signal_tune[] = {
};
#endif // SIGNAL_TUNE_LAYLA

#ifdef SIGNAL_TUNE_HARRY_POTTER_SHORT
int8_t signal_tune[] = {
BUZZER_NOTE_B5, 12,
BUZZER_NOTE_REST, 1,
BUZZER_NOTE_E6, 12,
BUZZER_NOTE_REST, 1,
BUZZER_NOTE_G6, 6,
BUZZER_NOTE_REST, 1,
BUZZER_NOTE_F6SHARP_G6FLAT, 6,
BUZZER_NOTE_REST, 1,
BUZZER_NOTE_E6, 16,
BUZZER_NOTE_REST, 1,
BUZZER_NOTE_B6, 8,
BUZZER_NOTE_REST, 1,
BUZZER_NOTE_A6, 24,
BUZZER_NOTE_REST, 1,
BUZZER_NOTE_F6SHARP_G6FLAT, 24,
0
};
#endif // SIGNAL_TUNE_HARRY_POTTER_SHORT

#ifdef SIGNAL_TUNE_HARRY_POTTER_LONG
int8_t signal_tune[] = {
BUZZER_NOTE_B5, 12,
BUZZER_NOTE_REST, 1,
BUZZER_NOTE_E6, 12,
BUZZER_NOTE_REST, 1,
BUZZER_NOTE_G6, 6,
BUZZER_NOTE_REST, 1,
BUZZER_NOTE_F6SHARP_G6FLAT, 6,
BUZZER_NOTE_REST, 1,
BUZZER_NOTE_E6, 16,
BUZZER_NOTE_REST, 1,
BUZZER_NOTE_B6, 8,
BUZZER_NOTE_REST, 1,
BUZZER_NOTE_A6, 24,
BUZZER_NOTE_REST, 1,
BUZZER_NOTE_F6SHARP_G6FLAT, 24,
BUZZER_NOTE_REST, 1,

BUZZER_NOTE_E6, 12,
BUZZER_NOTE_REST, 1,
BUZZER_NOTE_G6, 6,
BUZZER_NOTE_REST, 1,
BUZZER_NOTE_F6SHARP_G6FLAT, 6,
BUZZER_NOTE_REST, 1,
BUZZER_NOTE_D6SHARP_E6FLAT, 16,
BUZZER_NOTE_REST, 1,
BUZZER_NOTE_F6, 8,
BUZZER_NOTE_REST, 1,
BUZZER_NOTE_B5, 24,

0
};
#endif // SIGNAL_TUNE_HARRY_POTTER_LONG

#endif // MOVEMENT_CUSTOM_SIGNAL_TUNES_H_
12 changes: 12 additions & 0 deletions movement/movement_faces.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
#define MOVEMENT_FACES_H_

#include "simple_clock_face.h"
#include "close_enough_clock_face.h"
#include "clock_face.h"
#include "world_clock_face.h"
#include "preferences_face.h"
Expand Down Expand Up @@ -104,6 +105,17 @@
#include "minute_repeater_decimal_face.h"
#include "tuning_tones_face.h"
#include "kitchen_conversions_face.h"
#include "wordle_face.h"
#include "endless_runner_face.h"
#include "periodic_face.h"
#include "deadline_face.h"
#include "higher_lower_game_face.h"
#include "french_revolutionary_face.h"
#include "minimal_clock_face.h"
#include "simon_face.h"
#include "simple_calculator_face.h"
#include "alarm_thermometer_face.h"
#include "beeps_face.h"
// New includes go above this line.

#endif // MOVEMENT_FACES_H_
Loading

0 comments on commit bf4d461

Please sign in to comment.