Skip to content

Commit

Permalink
Update local main (#5)
Browse files Browse the repository at this point in the history
* Fixed incorrect conversion from UNIX timestamp to watch_date_time.

* Print memory percentages

this gives better idea of memories used.

* new face: Tuning tones

Add a new face that plays out tones that can be used as a
reference when tuning musical instruments.

* Turn on the funky segment of pos 0 for char '@'

* add new COLOR flag

* update alternate firmware for new board color

* Add a volume slider in the simulator

* Save the selected skin of the simulator in local storage

* fix signal tunes not firing in background, and split out foreground/background chime functions

* move buzzer enabled detection logic into movement for movement_play_signal/tune

this way watch faces don't have to disable/enable the buzzer themselves
before calling movement_play_signal() and movement_play_tune()

* use movement_play_signal for default tune (fixes background signal)

* Don't allow building without setting board color.

Fixes: joeycastillo#288

* add compile-time options for all preferences to movement_config

* Set default board color for GH workflow.

I've chosen blue arbitrarily.

* Update timer_face.c

Corrects the data type of the standard values in order to be able to configure seconds as well.

* new standard firmware for october boards

* Add Couch-To-5k training face

* Add sound to pause/resume button

* Add minute repeater decimal face

* moon_phase_face: Make alarm long-press reset to current day.

* Add solstice_face.

* Add simple_coin_flip_face.

* Add day_night_percentage_face.

* day_night_percentage_face: Calculate rise/set/daylen only once per day.

* day_night_percentage_face: Use PM indicator instead of DA/NI.

This allows for use of the weekday digits for displaying the weekday.

* day_night_percentage_face: Clear seconds digits when entering LE mode.

* Add save_load_face.

* day_one_face: cleanup

* day_one_face: allow years until 2080

This is the same limit introduced in commit 7fd51ca

* day_one_face: enable quick cycle through settings

This allows the alarm button to be held down in the date settings and
quickly cycle through the dates instead of having to push for each
single increment like in other faces.

* day_one_face: show set date on short alarm button press

* Improve simulator page design

* Fix simulator and hardware divergence in callback handling (joeycastillo#252)

When using the simulator, I encountered cases where the light would become stuck on, and the watch
would be unresponsive. In particular, this would occur when pressing the light button on the
sunrise sunset watch face.

I appears that this is caused by a divergence in out the callback mask is interpreted by the
hardware interface, and in the simulator in the following function.

void watch_rtc_disable_matching_periodic_callbacks(uint8_t mask)

In particular, a mask of 0xFE is intended to disable all except the 128hz callback at index 0,
but instead disables all except the 1hz callback at index 7 in the simulator.

* sunrise_sunset_face: Fix use of uninitialized memory.

This was causing a crash in the simulator when setting the location.

Fixes: joeycastillo#198

* Fit naming conventions

* Resign when the entering LE

* Simulator: Allow typing a, l & m in console input

These keys are the shortcuts to "press" the alarm, light and mode
buttons. However, they prevent these letters from being input in the
debug console to send filesystem commands. Strangely, there was already
some code to allow typing these letters in the console output, but not
in the input.

* Simulator: Allow sending debug command with Enter

* Simulator: Add keyboard arrows as buttons shortcuts

* Fix missing documentation for many clock faces:

* Move from .c to .h as needed for consistency.
* When missing from both, copy from pull request or wiki.
* When missing entirely, infer functionality from source code.

* Kitchen Conversions Face

* fix undefined behavior found by clang's sanitize

* make the zero in wyoscan a little more visually appealing

* make it clear that the movement_state contains indexes

* use a pointer to the watch face in the app loop instead of indirecting through the index each time, and also recalculate can_sleep based on the timeout loop call.

* clean up trailing whitespace in movement.c

* make the watch-face a global in movement.c, actually

* work around silicon erratum in TRNG

* work around silicon erratum in SUPC/VREG

* fix simulator build by declaring Trng type as a void pointer

* address SysTick erratum, which can hard-fault the chip

* make the HAL sleep function obey the chip documentation

the sleep mode doesn't get set immediately, and needs to be waited upon.

* make any unknown interrupts/faults reset the microcontroller

* delete stray line of code that messed with correction profile while adjusting cadence

* USB Improvements

* Introduce shell module for basic serial shell with argument parsing
* Introduce shell_cmd_list module for basic compile-time command
  registration
* Harden USB handling to hang less and drop fewer inputs
  - Service tud_task() with periodic TC0 timer interrupt
  - Service cdc_task() with periodic TC1 timer interrupt
  - Handle shell servicing in main app loop
  - Add a circular buffering layer for reads/writes
* Change newline prints to also send carriage return
* Refactor filesystem commands for shell subsystem
* Introduce new shell commands:
  - 'help' command
  - 'flash' command to reset into bootloader
  - 'stress' command to stress CDC writes

Testing:
* Shell validated on Sensor Watch Blue w/ Linux host
* Shell validated in emscripten emulator
* Tuned by spamming inputs during `stress` cmd until stack didn't crash

* Handle visibility for tomato watchface

(cherry picked from commit 547e8248ba3538693ee8c587a92ffece7b40d1a2)

* Revert "Merge pull request joeycastillo#283 from neutralinsomniac/fix_hourly_chime_background"

This reverts commit 5c94111, reversing
changes made to bc9b4ce.

* Use legacy buzzer functions when playing default tune.

This allows the default tune to be played in LE mode.

Fixes: joeycastillo#275

* Enable custom signal tones in LE mode.

This makes movement_play_signal synchronous when in LE mode, despite
using the underlying asynchronous API. It's a bit of a hack, but it
should work well enough for now.

This also moves the enabling/disabling of the buzzer into the
movement_play_signal function, so that watch faces no longer have to do
it.

* buzzer: fix simulator build, refactor sequence_length.

* movement: Use LE mode code to keep buzzer awake, instead of sleeping.

* fix alternate firmware script

* template: fix compiler warning on watch_face_index as mentioned in PR 269

* Revert "make the watch-face a global in movement.c, actually"

This reverts commit 0e801ed.

* annotate TRNG erratum, address review comment

* annotate SysTick erratum

* annotate voltage regulation erratum

* annotate SLEEPCFG-register detail

* Change inactivity deadlines: add 10 minutes and remove 2 days. (joeycastillo#365)

I like to use the ten minute timeout on my watch and there are other
people who have similar interests in a lower deadline. The two day
deadline had to go to still accommodate the change within the three
bit index.

The default setting is still the one hour timeout.

* faces/totp: define TOTP data structure

Aggregates all the data necessary for TOTP generation.

* faces/totp: define TOTP struct initializer macro

Generates a compound initializer for the given TOTP parameters.
Lessens repetition and allows functional definitions of TOTP records.

* faces/totp: update example data to new structure

The data definitions are much shorter and easier to read now.

* faces/totp: define TOTP data array size function

Computes the size of the array of TOTP records.
The compiler will likely evaluate it at compile time.

* faces/totp: define current TOTP data function

Selects the appropriate TOTP data structure
given the TOTP watch face state.

* faces/totp: update watch face logic for new struct

Using the new structured TOTP record data structure
allows the TOTP watch face to statically and implicitly
compute the total number of defined TOTP records.

Users can now simply add new keys and records in the designated area
and the watch face will compile and automatically use them with no need
to maintain a separate array size variable. Less chance of mistakes.

* faces/totp: delete unused structure field

The TOTP watch face now keeps track of each key separately.
There is no need to compute offsets at runtime.

* faces/totp: update copyright and license data

Update the copyrights to include full name attribution
to all who contributed to this watch face, including myself.

Also add an SPDX license identifier header comment to the files.

https://spdx.org/licenses/MIT.html

* faces/pulsometer: implement advanced pulsometer

Implements an advanced pulsometer that can be recalibrated by the user.
The main clock face now displays the measured pulses per minute.
The day of month digits now display the pulsometer calibration.
The light button now cycles through integer graduations
which now range from 1 to 39 pulses per minute.
Long presses of the light button cycle by 10 instead of 1.

The watch face's responsiveness to input has been carefully optimized.
The code has been reorganized and generally improved.

* faces/pulsometer: document the advanced pulsometer

Thoroughly document the new advanced pulsometer watch face
by describing what it is and how it works.

* faces/pulsometer: update copyrights and credits

Update the copyrights to include full name attribution to all
who contributed to the pulsometer watch face, including myself.

Also add an SPDX license identifier header comment to the files.

* faces/pulsometer: move structure definition

Instances of the pulsometer state structure are only passed
to the pulsometer itself and only via the opaque context pointer.
No other code uses it. There is no need to expose it in a header file
so make it an implementation detail of the watch face.

* faces: rename simple_clock_face to clock_face

It's not actually so simple and will only gain features from now on.
Just "clock face" also feels more canonical.

* faces/clock: move structure definition

Instances of the clock state structure
are only passed to the clock face itself
and only via the opaque context pointer.
No other code uses it.

Thus there is no need to expose it in a header file.
So make it an implementation detail of the watch face
by localizing it inside the translation unit.

* faces/clock: define general indication function

Sets or clears the specified indicator based on some boolean value.

* faces/clock: simplify alarm indication function

Deduplicates state in the clock state and movement settings.
Makes the code simpler.

Also makes it use the correct indicator.
For some reason it had been switched
with the hourly chime indicator.

    WATCH_INDICATOR_BELL
        The small bell indicating that an alarm is set.

    WATCH_INDICATOR_SIGNAL
        The hourly signal indicator.
        Also useful for indicating that sensors are on.

* faces/clock: simplify signal indication function

Simplifies the code and makes it use the correct indicator.
For some reason it had been switched with the alarm indicator.

    WATCH_INDICATOR_BELL
        The small bell indicating that an alarm is set.

    WATCH_INDICATOR_SIGNAL
        The hourly signal indicator.
        Also useful for indicating that sensors are on.

* faces/clock: simplify 24h indication function

Simplifies the code by adding a dedicated function for this.

* faces/clock: simplify PM indication function

Simplifies the code by adding dedicated functions for this.

* faces/clock: refactor daily battery check

Move the code in question to a dedicated function. Better organized.
Add overridable preprocessor definition for the low battery threshold.

* faces/clock: simplify LAP indication function

Simplifies the code by adding a dedicated function for this.
Also documents the meaning of the LAP indicator: Low Available Power.

* faces/clock: refactor low power tick function

Simplifies the code by defining dedicated functions
and separating the case from the main ones.

Also use the snprintf function since the buffer size is known.

* faces/clock: refactor tick tock animation code

Simplifies the code by defining dedicated functions for this.

* faces/clock: refactor full time display code

Simplifies the code by defining dedicated functions for this.

* faces/clock: refactor partial time display code

Simplifies the code by defining dedicated functions for this.

* faces/clock: reorder periodic battery check

Check the battery after the time has been updated.
Place all the indication code next to each other.

* faces/clock: refactor clock display code

Simplifies the code by defining dedicated functions for this.

* faces/clock: refactor time signal toggling code

Simplifies the code by defining dedicated functions for this.

* faces/clock: indicate alarm only when necessary

The alarm state is not modified within the clock face.
Therefore, it only needs to be set when the face is activated.

* faces/clock: indicate low power only when needed

There is no need to set the indicator on every clock tick.
Indicate only when the battery is checked.

* faces/totp: decode secrets when setting up

This allows the user to easily copy the base32 encoded secrets
into the TOTP record initializers. They will be decoded once
at runtime when the face is being set up by the movement framework.

Also rename the array of TOTP records to credentials. Much better.

* faces/totp: improve TOTP initializer labeling

It now generates the string literal from the preprocessor token.
Even warns the user if the string is too long!

* faces/totp: rename initializer macro to credential

Shorter and far more expressive.

* faces/totp: delete leading underscores

Makes for cleaner symbols.

* faces/clock: update copyrights and credits

Update the copyrights to include full name attribution to all
who contributed to the clock watch face, including myself.

Also add an SPDX license identifier header comment to the files.

* faces/clock: add 24h only feature

The clock watch face can now be configured at build time
to only display the time in 24h mode. Also enabled in forced 24h mode.

This should result in smaller code size due to dead code elimination.

* faces/totp: allow moving backwards through codes

Adds the ability to cycle back to the previous credential with LIGHT.
Long pressing LIGHT activates the LED.

Co-authored-by: Matheus Afonso Martins Moreira <[email protected]>

* faces/totp: update copyrights

Update the copyrights to include full name attribution
to Max Zettlmeißl whose code I've incorporated and who
has explicitly licensed it as MIT.

Max Zettlmeißl (@maxz) commented on 2024-01-20:

> I provide all my changes under the MIT license

GitHub-Comment: joeycastillo#356 (comment)

* faces/pulsometer: remember pulsometer calibration

Avoid resetting it to default when the face is activated.
Set the default pulsometer calibration once,
only when the face is first set up.

This makes it remember the calibration set by the user.
It will no longer overwrite it.

* faces/pulsometer: remember pulsometer measurement

Avoid resetting it to zero when the face is activated.
Initialize the variables once when the face is first set up.

This makes it remember the last measurement taken by the user.
It will no longer be overwritten when the watch face activates.

* movement: convert can_sleep an automatic variable

It is a simple boolean value and its scope is limited to the function.
There is no reason that I can think of for it to be a static variable.

* movement: fix unintended timeout short circuiting

Currently, movement drops time out events in case the previous loop
indicates that sleep is not possible due to short circuiting behavior
of logical and in C: if the left-hand side is false, the right hand
side is not evaluated at all, which means the loop is not called.
This was not intended to happen.

Fix it by storing the result in a second boolean variable
and working out the logic after the fact.

* faces: restore simple_clock_face

Restore the original simple clock face as requested.

---------

Signed-off-by: Matheus Afonso Martins Moreira <[email protected]>
Co-authored-by: Konrad Rieck <[email protected]>
Co-authored-by: Per Waagø <[email protected]>
Co-authored-by: Hugo Chargois <[email protected]>
Co-authored-by: joeycastillo <[email protected]>
Co-authored-by: Jeremy O'Brien <[email protected]>
Co-authored-by: Wesley Aptekar-Cassels <[email protected]>
Co-authored-by: madhogs <[email protected]>
Co-authored-by: LtKeks <[email protected]>
Co-authored-by: Ekaitz Zarraga <[email protected]>
Co-authored-by: Brian Blakley <[email protected]>
Co-authored-by: Christian Buschau <[email protected]>
Co-authored-by: Victor Graf <[email protected]>
Co-authored-by: Alex Utter <[email protected]>
Co-authored-by: PrimmR <[email protected]>
Co-authored-by: Alex Maestas <[email protected]>
Co-authored-by: Edward Shin <[email protected]>
Co-authored-by: Pietro F. Maggi <[email protected]>
Co-authored-by: CarpeNoctem <[email protected]>
Co-authored-by: Wesley Ellis <[email protected]>
Co-authored-by: Max Zettlmeißl <[email protected]>
Co-authored-by: madhogs <[email protected]>
Co-authored-by: Matheus Afonso Martins Moreira <[email protected]>
  • Loading branch information
1 parent 50bf001 commit 3b3fa40
Show file tree
Hide file tree
Showing 169 changed files with 5,936 additions and 1,080 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ on:
branches-ignore:
- gh-pages

env:
COLOR: BLUE

jobs:
build:
container:
Expand Down
17 changes: 16 additions & 1 deletion make.mk
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ SRCS += \
$(TOP)/watch-library/hardware/watch/watch_storage.c \
$(TOP)/watch-library/hardware/watch/watch_deepsleep.c \
$(TOP)/watch-library/hardware/watch/watch_private.c \
$(TOP)/watch-library/hardware/watch/watch_private_cdc.c \
$(TOP)/watch-library/hardware/watch/watch.c \
$(TOP)/watch-library/hardware/hal/src/hal_atomic.c \
$(TOP)/watch-library/hardware/hal/src/hal_delay.c \
Expand Down Expand Up @@ -208,7 +209,15 @@ ifeq ($(LED), BLUE)
CFLAGS += -DWATCH_IS_BLUE_BOARD
endif

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

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

ifeq ($(COLOR), RED)
CFLAGS += -DWATCH_INVERT_LED_POLARITY
CFLAGS += -DNO_FREQCORR
endif
Expand All @@ -221,3 +230,9 @@ endif
ifeq ($(BOARD), OSO-FEAL-A1-00)
CFLAGS += -DCRYSTALLESS
endif

# Build options to customize movement and faces

ifdef CLOCK_FACE_24H_ONLY
CFLAGS += -DCLOCK_FACE_24H_ONLY
endif
2 changes: 2 additions & 0 deletions movement/alt_fw/alt_time.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,6 @@ const watch_face_t watch_faces[] = {

#define MOVEMENT_NUM_FACES (sizeof(watch_faces) / sizeof(watch_face_t))

#define SIGNAL_TUNE_DEFAULT

#endif // MOVEMENT_CONFIG_H_
2 changes: 2 additions & 0 deletions movement/alt_fw/backer.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,6 @@ const watch_face_t watch_faces[] = {

#define MOVEMENT_NUM_FACES (sizeof(watch_faces) / sizeof(watch_face_t))

#define SIGNAL_TUNE_DEFAULT

#endif // MOVEMENT_CONFIG_H_
2 changes: 2 additions & 0 deletions movement/alt_fw/deep_space_now.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,6 @@ const watch_face_t watch_faces[] = {

#define MOVEMENT_NUM_FACES (sizeof(watch_faces) / sizeof(watch_face_t))

#define SIGNAL_TUNE_DEFAULT

#endif // MOVEMENT_CONFIG_H_
2 changes: 2 additions & 0 deletions movement/alt_fw/focus.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,6 @@ const watch_face_t watch_faces[] = {

#define MOVEMENT_NUM_FACES (sizeof(watch_faces) / sizeof(watch_face_t))

#define SIGNAL_TUNE_DEFAULT

#endif // MOVEMENT_CONFIG_H_
2 changes: 2 additions & 0 deletions movement/alt_fw/the_athlete.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,6 @@ const watch_face_t watch_faces[] = {

#define MOVEMENT_NUM_FACES (sizeof(watch_faces) / sizeof(watch_face_t))

#define SIGNAL_TUNE_DEFAULT

#endif // MOVEMENT_CONFIG_H_
2 changes: 2 additions & 0 deletions movement/alt_fw/the_backpacker.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,6 @@ const watch_face_t watch_faces[] = {

#define MOVEMENT_NUM_FACES (sizeof(watch_faces) / sizeof(watch_face_t))

#define SIGNAL_TUNE_DEFAULT

#endif // MOVEMENT_CONFIG_H_
2 changes: 2 additions & 0 deletions movement/alt_fw/the_stargazer.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,6 @@ const watch_face_t watch_faces[] = {

#define MOVEMENT_NUM_FACES (sizeof(watch_faces) / sizeof(watch_face_t))

#define SIGNAL_TUNE_DEFAULT

#endif // MOVEMENT_CONFIG_H_
2 changes: 2 additions & 0 deletions movement/alt_fw/timers.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,6 @@ const watch_face_t watch_faces[] = {

#define MOVEMENT_NUM_FACES (sizeof(watch_faces) / sizeof(watch_face_t))

#define SIGNAL_TUNE_DEFAULT

#endif // MOVEMENT_CONFIG_H_
121 changes: 61 additions & 60 deletions movement/filesystem.c
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ static int filesystem_ls(lfs_t *lfs, const char *path) {

printf("%4ld bytes ", info.size);

printf("%s\n", info.name);
printf("%s\r\n", info.name);
}

err = lfs_dir_close(lfs, &dir);
Expand All @@ -117,11 +117,11 @@ bool filesystem_init(void) {
// reformat if we can't mount the filesystem
// this should only happen on the first boot
if (err < 0) {
printf("Ignore that error! Formatting filesystem...\n");
printf("Ignore that error! Formatting filesystem...\r\n");
err = lfs_format(&lfs, &cfg);
if (err < 0) return false;
err = lfs_mount(&lfs, &cfg) == LFS_ERR_OK;
printf("Filesystem mounted with %ld bytes free.\n", filesystem_get_free_space());
printf("Filesystem mounted with %ld bytes free.\r\n", filesystem_get_free_space());
}

return err == LFS_ERR_OK;
Expand All @@ -139,7 +139,7 @@ bool filesystem_rm(char *filename) {
if (filesystem_file_exists(filename)) {
return lfs_remove(&lfs, filename) == LFS_ERR_OK;
} else {
printf("rm: %s: No such file\n", filename);
printf("rm: %s: No such file\r\n", filename);
return false;
}
}
Expand Down Expand Up @@ -197,13 +197,13 @@ static void filesystem_cat(char *filename) {
char *buf = malloc(info.size + 1);
filesystem_read_file(filename, buf, info.size);
buf[info.size] = '\0';
printf("%s\n", buf);
printf("%s\r\n", buf);
free(buf);
} else {
printf("\n");
printf("\r\n");
}
} else {
printf("cat: %s: No such file\n", filename);
printf("cat: %s: No such file\r\n", filename);
}
}

Expand All @@ -223,59 +223,60 @@ bool filesystem_append_file(char *filename, char *text, int32_t length) {
return lfs_file_close(&lfs, &file) == LFS_ERR_OK;
}

void filesystem_process_command(char *line) {
printf("$ %s", line);
char *command = strtok(line, " \n");

if (strcmp(command, "ls") == 0) {
char *directory = strtok(NULL, " \n");
if (directory == NULL) {
filesystem_ls(&lfs, "/");
} else {
printf("usage: ls\n");
}
} else if (strcmp(command, "cat") == 0) {
char *filename = strtok(NULL, " \n");
if (filename == NULL) {
printf("usage: cat file\n");
} else {
filesystem_cat(filename);
}
} else if (strcmp(command, "df") == 0) {
printf("free space: %ld bytes\n", filesystem_get_free_space());
} else if (strcmp(command, "rm") == 0) {
char *filename = strtok(NULL, " \n");
if (filename == NULL) {
printf("usage: rm file\n");
} else {
filesystem_rm(filename);
}
} else if (strcmp(command, "echo") == 0) {
char *text = malloc(248);
memset(text, 0, 248);
size_t pos = 0;
char *word = strtok(NULL, " \n");
while (strcmp(word, ">") && strcmp(word, ">>")) {
sprintf(text + pos, "%s ", word);
pos += strlen(word) + 1;
word = strtok(NULL, " \n");
if (word == NULL) break;
}
text[strlen(text) - 1] = 0;
char *filename = strtok(NULL, " \n");
if (filename == NULL) {
printf("usage: echo text > file\n");
} else if (strchr(filename, '/') || strchr(filename, '\\')) {
printf("subdirectories are not supported\n");
} else if (!strcmp(word, ">")) {
filesystem_write_file(filename, text, strlen(text));
filesystem_append_file(filename, "\n", 1);
} else if (!strcmp(word, ">>")) {
filesystem_append_file(filename, text, strlen(text));
filesystem_append_file(filename, "\n", 1);
}
free(text);
int filesystem_cmd_ls(int argc, char *argv[]) {
if (argc >= 2) {
filesystem_ls(&lfs, argv[1]);
} else {
printf("%s: command not found\n", command);
filesystem_ls(&lfs, "/");
}
return 0;
}

int filesystem_cmd_cat(int argc, char *argv[]) {
(void) argc;
filesystem_cat(argv[1]);
return 0;
}

int filesystem_cmd_df(int argc, char *argv[]) {
(void) argc;
(void) argv;
printf("free space: %ld bytes\r\n", filesystem_get_free_space());
return 0;
}

int filesystem_cmd_rm(int argc, char *argv[]) {
(void) argc;
filesystem_rm(argv[1]);
return 0;
}

int filesystem_cmd_echo(int argc, char *argv[]) {
(void) argc;

char *line = argv[1];
size_t line_len = strlen(line);
if (line[0] == '"' || line[0] == '\'') {
line++;
line_len -= 2;
line[line_len] = '\0';
}

if (strchr(argv[3], '/')) {
printf("subdirectories are not supported\r\n");
return -2;
}

if (!strcmp(argv[2], ">")) {
filesystem_write_file(argv[3], line, line_len);
filesystem_append_file(argv[3], "\n", 1);
} else if (!strcmp(argv[2], ">>")) {
filesystem_append_file(argv[3], line, line_len);
filesystem_append_file(argv[3], "\n", 1);
} else {
return -2;
}

return 0;
}

9 changes: 5 additions & 4 deletions movement/filesystem.h
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,10 @@ bool filesystem_write_file(char *filename, char *text, int32_t length);
*/
bool filesystem_append_file(char *filename, char *text, int32_t length);

/** @brief Handles the interactive file browser when Movement is plugged in to USB.
* @param line The command that the user typed into the serial console.
*/
void filesystem_process_command(char *line);
int filesystem_cmd_ls(int argc, char *argv[]);
int filesystem_cmd_cat(int argc, char *argv[]);
int filesystem_cmd_df(int argc, char *argv[]);
int filesystem_cmd_rm(int argc, char *argv[]);
int filesystem_cmd_echo(int argc, char *argv[]);

#endif // FILESYSTEM_H_
11 changes: 11 additions & 0 deletions movement/make/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,10 @@ SRCS += \
../../littlefs/lfs_util.c \
../movement.c \
../filesystem.c \
../shell.c \
../shell_cmd_list.c \
../watch_faces/clock/simple_clock_face.c \
../watch_faces/clock/clock_face.c \
../watch_faces/clock/world_clock_face.c \
../watch_faces/clock/beats_face.c \
../watch_faces/clock/weeknumber_clock_face.c \
Expand Down Expand Up @@ -122,6 +125,14 @@ SRCS += \
../watch_faces/complication/flashlight_face.c \
../watch_faces/clock/decimal_time_face.c \
../watch_faces/clock/wyoscan_face.c \
../watch_faces/settings/save_load_face.c \
../watch_faces/clock/day_night_percentage_face.c \
../watch_faces/complication/simple_coin_flip_face.c \
../watch_faces/complication/solstice_face.c \
../watch_faces/complication/couch_to_5k_face.c \
../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/milk_log_face.c \
../watch_faces/complication/panchang_face.c \
../watch_faces/complication/moonrise_moonset_face.c \
Expand Down
8 changes: 4 additions & 4 deletions movement/make/make_alternate_fw.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

fw_dir="firmware/download"
sim_dir="firmware/simulate"
colors=("green" "blue")
colors=("green" "blue" "red")
variants=("standard" "backer" "alt_time" "deep_space_now" "focus" "the_athlete" "the_backpacker" "the_stargazer")

if [ -d "$fw_dir" ] ; then
Expand All @@ -21,12 +21,12 @@ do
for color in "${colors[@]}"
do
COLOR=$(echo "$color" | tr '[:lower:]' '[:upper:]')
make clean
make LED=$COLOR FIRMWARE=$VARIANT
make COLOR=$COLOR clean
make COLOR=$COLOR FIRMWARE=$VARIANT
mv "build/watch.uf2" "$fw_dir/$variant-$color.uf2"
done
rm -rf ./build-sim
emmake make FIRMWARE=$VARIANT
emmake make COLOR=GREEN FIRMWARE=$VARIANT
mkdir "$sim_dir/$variant/"
mv "build-sim/watch.wasm" "$sim_dir/$variant/"
mv "build-sim/watch.js" "$sim_dir/$variant/"
Expand Down
Loading

0 comments on commit 3b3fa40

Please sign in to comment.