Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: Rocky.js Support #113

Draft
wants to merge 12 commits into
base: master
Choose a base branch
from
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@
#Kate
.kate-swp

#Visual Studio Code
.vscode

*~

build/*
Expand Down
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,6 @@
[submodule "lib/libpebble2"]
path = lib/libpebble2
url = ../../pebble-dev/libpebble2
[submodule "lib/jerryscript"]
path = lib/jerryscript
url = https://github.com/UDXS/jerryscript.git
1 change: 1 addition & 0 deletions AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@ The RebbleOS Authors are:
Barry Carter <[email protected]>
Joshua Wise <[email protected]>
NiVZ <[email protected]>
Davit Markarian (UDXS) <[email protected]>

If you contribute code to RebbleOS, please add your name to this file.
2 changes: 2 additions & 0 deletions config.mk
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ CFLAGS_all += -Irwatch/ui/animation
CFLAGS_all += -Irwatch/input
CFLAGS_all += -Irwatch/graphics
CFLAGS_all += -Irwatch/event
CFLAGS_all += -Irwatch/js
CFLAGS_all += -Ihw/platform/qemu
CFLAGS_all += -DNGFX_IS_CORE -DREBBLEOS

Expand Down Expand Up @@ -155,6 +156,7 @@ SRCS_all += rwatch/ui/notifications/notification_window.c
SRCS_all += rwatch/ui/notifications/battery_overlay.c
SRCS_all += rwatch/ui/notifications/mini_message.c
SRCS_all += rwatch/ui/vibes.c
SRCS_all += rwatch/js/rocky_js.c

SRCS_all += Watchfaces/simple.c
SRCS_all += Watchfaces/nivz.c
Expand Down
145 changes: 145 additions & 0 deletions hw/platform/snowy_family/config.mk
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,23 @@ CFLAGS_snowy_family += $(CFLAGS_driver_stm32_rtc)
CFLAGS_snowy_family += $(CFLAGS_driver_stm32_backlight)
CFLAGS_snowy_family += -Ihw/platform/snowy_family

CFLAGS_snowy_family += -Irwatch/js
CFLAGS_snowy_family += -Ilib/jerryscript/jerry-core
CFLAGS_snowy_family += -Ilib/jerryscript/jerry-core/ecma
CFLAGS_snowy_family += -Ilib/jerryscript/jerry-core/debugger
CFLAGS_snowy_family += -Ilib/jerryscript/jerry-core/ecma/base
CFLAGS_snowy_family += -Ilib/jerryscript/jerry-core/ecma/builtin-objects
CFLAGS_snowy_family += -Ilib/jerryscript/jerry-core/ecma/operations
CFLAGS_snowy_family += -Ilib/jerryscript/jerry-core/jcontext
CFLAGS_snowy_family += -Ilib/jerryscript/jerry-core/jmem
CFLAGS_snowy_family += -Ilib/jerryscript/jerry-core/jrt
CFLAGS_snowy_family += -Ilib/jerryscript/jerry-core/lit
CFLAGS_snowy_family += -Ilib/jerryscript/jerry-core/parser/js
CFLAGS_snowy_family += -Ilib/jerryscript/jerry-core/parser/regexp
CFLAGS_snowy_family += -Ilib/jerryscript/jerry-core/vm
CFLAGS_snowy_family += -Ilib/jerryscript/jerry-libm
CFLAGS_snowy_family += -Ilib/jerryscript/jerry-libm/include

SRCS_snowy_family = $(SRCS_stm32f4xx)
SRCS_snowy_family += $(SRCS_driver_stm32_usart)
SRCS_snowy_family += $(SRCS_driver_stm32_dma)
Expand All @@ -26,6 +43,134 @@ SRCS_snowy_family += hw/platform/snowy_family/snowy_ambient.c
SRCS_snowy_family += hw/platform/snowy_family/snowy_ext_flash.c
SRCS_snowy_family += hw/platform/snowy_family/snowy_common.c

# Note: rocky_js.c is added to all platforms.
SRCS_snowy_family += rwatch/js/rocky_setjmp.c
SRCS_snowy_family += rwatch/js/rocky_port.c
SRCS_snowy_family += rwatch/js/rocky_canvas.c
SRCS_snowy_family += rwatch/js/rocky_lib.c
SRCS_snowy_family += rwatch/js/rocky_event.c

SRCS_snowy_family += lib/jerryscript/jerry-core/ecma/base/ecma-alloc.c
SRCS_snowy_family += lib/jerryscript/jerry-core/ecma/base/ecma-gc.c
SRCS_snowy_family += lib/jerryscript/jerry-core/ecma/base/ecma-helpers-conversion.c
SRCS_snowy_family += lib/jerryscript/jerry-core/ecma/base/ecma-helpers-errol.c
SRCS_snowy_family += lib/jerryscript/jerry-core/ecma/base/ecma-helpers-external-pointers.c
SRCS_snowy_family += lib/jerryscript/jerry-core/ecma/base/ecma-helpers-number.c
SRCS_snowy_family += lib/jerryscript/jerry-core/ecma/base/ecma-helpers-string.c
SRCS_snowy_family += lib/jerryscript/jerry-core/ecma/base/ecma-helpers-value.c
SRCS_snowy_family += lib/jerryscript/jerry-core/ecma/base/ecma-helpers-values-collection.c
SRCS_snowy_family += lib/jerryscript/jerry-core/ecma/base/ecma-helpers.c
SRCS_snowy_family += lib/jerryscript/jerry-core/ecma/base/ecma-init-finalize.c
SRCS_snowy_family += lib/jerryscript/jerry-core/ecma/base/ecma-lcache.c
SRCS_snowy_family += lib/jerryscript/jerry-core/ecma/base/ecma-literal-storage.c
SRCS_snowy_family += lib/jerryscript/jerry-core/ecma/base/ecma-property-hashmap.c
SRCS_snowy_family += lib/jerryscript/jerry-core/ecma/builtin-objects/ecma-builtin-array-prototype.c
SRCS_snowy_family += lib/jerryscript/jerry-core/ecma/builtin-objects/ecma-builtin-array.c
SRCS_snowy_family += lib/jerryscript/jerry-core/ecma/builtin-objects/ecma-builtin-boolean-prototype.c
SRCS_snowy_family += lib/jerryscript/jerry-core/ecma/builtin-objects/ecma-builtin-boolean.c
SRCS_snowy_family += lib/jerryscript/jerry-core/ecma/builtin-objects/ecma-builtin-date-prototype.c
SRCS_snowy_family += lib/jerryscript/jerry-core/ecma/builtin-objects/ecma-builtin-date.c
SRCS_snowy_family += lib/jerryscript/jerry-core/ecma/builtin-objects/ecma-builtin-error-prototype.c
SRCS_snowy_family += lib/jerryscript/jerry-core/ecma/builtin-objects/ecma-builtin-error.c
SRCS_snowy_family += lib/jerryscript/jerry-core/ecma/builtin-objects/ecma-builtin-evalerror-prototype.c
SRCS_snowy_family += lib/jerryscript/jerry-core/ecma/builtin-objects/ecma-builtin-evalerror.c
SRCS_snowy_family += lib/jerryscript/jerry-core/ecma/builtin-objects/ecma-builtin-function-prototype.c
SRCS_snowy_family += lib/jerryscript/jerry-core/ecma/builtin-objects/ecma-builtin-function.c
SRCS_snowy_family += lib/jerryscript/jerry-core/ecma/builtin-objects/ecma-builtin-global.c
SRCS_snowy_family += lib/jerryscript/jerry-core/ecma/builtin-objects/ecma-builtin-helpers-date.c
SRCS_snowy_family += lib/jerryscript/jerry-core/ecma/builtin-objects/ecma-builtin-helpers-error.c
SRCS_snowy_family += lib/jerryscript/jerry-core/ecma/builtin-objects/ecma-builtin-helpers-json.c
SRCS_snowy_family += lib/jerryscript/jerry-core/ecma/builtin-objects/ecma-builtin-helpers.c
SRCS_snowy_family += lib/jerryscript/jerry-core/ecma/builtin-objects/ecma-builtin-json.c
SRCS_snowy_family += lib/jerryscript/jerry-core/ecma/builtin-objects/ecma-builtin-math.c
SRCS_snowy_family += lib/jerryscript/jerry-core/ecma/builtin-objects/ecma-builtin-number-prototype.c
SRCS_snowy_family += lib/jerryscript/jerry-core/ecma/builtin-objects/ecma-builtin-number.c
SRCS_snowy_family += lib/jerryscript/jerry-core/ecma/builtin-objects/ecma-builtin-object-prototype.c
SRCS_snowy_family += lib/jerryscript/jerry-core/ecma/builtin-objects/ecma-builtin-object.c
SRCS_snowy_family += lib/jerryscript/jerry-core/ecma/builtin-objects/ecma-builtin-rangeerror-prototype.c
SRCS_snowy_family += lib/jerryscript/jerry-core/ecma/builtin-objects/ecma-builtin-rangeerror.c
SRCS_snowy_family += lib/jerryscript/jerry-core/ecma/builtin-objects/ecma-builtin-referenceerror-prototype.c
SRCS_snowy_family += lib/jerryscript/jerry-core/ecma/builtin-objects/ecma-builtin-referenceerror.c
SRCS_snowy_family += lib/jerryscript/jerry-core/ecma/builtin-objects/ecma-builtin-regexp-prototype.c
SRCS_snowy_family += lib/jerryscript/jerry-core/ecma/builtin-objects/ecma-builtin-regexp.c
SRCS_snowy_family += lib/jerryscript/jerry-core/ecma/builtin-objects/ecma-builtin-string-prototype.c
SRCS_snowy_family += lib/jerryscript/jerry-core/ecma/builtin-objects/ecma-builtin-string.c
SRCS_snowy_family += lib/jerryscript/jerry-core/ecma/builtin-objects/ecma-builtin-syntaxerror-prototype.c
SRCS_snowy_family += lib/jerryscript/jerry-core/ecma/builtin-objects/ecma-builtin-syntaxerror.c
SRCS_snowy_family += lib/jerryscript/jerry-core/ecma/builtin-objects/ecma-builtin-type-error-thrower.c
SRCS_snowy_family += lib/jerryscript/jerry-core/ecma/builtin-objects/ecma-builtin-typeerror-prototype.c
SRCS_snowy_family += lib/jerryscript/jerry-core/ecma/builtin-objects/ecma-builtin-typeerror.c
SRCS_snowy_family += lib/jerryscript/jerry-core/ecma/builtin-objects/ecma-builtin-urierror-prototype.c
SRCS_snowy_family += lib/jerryscript/jerry-core/ecma/builtin-objects/ecma-builtin-urierror.c
SRCS_snowy_family += lib/jerryscript/jerry-core/ecma/builtin-objects/ecma-builtins.c
SRCS_snowy_family += lib/jerryscript/jerry-core/ecma/operations/ecma-array-object.c
SRCS_snowy_family += lib/jerryscript/jerry-core/ecma/operations/ecma-boolean-object.c
SRCS_snowy_family += lib/jerryscript/jerry-core/ecma/operations/ecma-comparison.c
SRCS_snowy_family += lib/jerryscript/jerry-core/ecma/operations/ecma-conversion.c
SRCS_snowy_family += lib/jerryscript/jerry-core/ecma/operations/ecma-eval.c
SRCS_snowy_family += lib/jerryscript/jerry-core/ecma/operations/ecma-exceptions.c
SRCS_snowy_family += lib/jerryscript/jerry-core/ecma/operations/ecma-function-object.c
SRCS_snowy_family += lib/jerryscript/jerry-core/ecma/operations/ecma-get-put-value.c
SRCS_snowy_family += lib/jerryscript/jerry-core/ecma/operations/ecma-lex-env.c
SRCS_snowy_family += lib/jerryscript/jerry-core/ecma/operations/ecma-number-arithmetic.c
SRCS_snowy_family += lib/jerryscript/jerry-core/ecma/operations/ecma-number-object.c
SRCS_snowy_family += lib/jerryscript/jerry-core/ecma/operations/ecma-objects-arguments.c
SRCS_snowy_family += lib/jerryscript/jerry-core/ecma/operations/ecma-objects-general.c
SRCS_snowy_family += lib/jerryscript/jerry-core/ecma/operations/ecma-objects.c
SRCS_snowy_family += lib/jerryscript/jerry-core/ecma/operations/ecma-reference.c
SRCS_snowy_family += lib/jerryscript/jerry-core/ecma/operations/ecma-regexp-object.c
SRCS_snowy_family += lib/jerryscript/jerry-core/ecma/operations/ecma-string-object.c
SRCS_snowy_family += lib/jerryscript/jerry-core/jcontext/jcontext.c
SRCS_snowy_family += lib/jerryscript/jerry-core/jerry.c
SRCS_snowy_family += lib/jerryscript/jerry-core/jmem/jmem-allocator.c
SRCS_snowy_family += lib/jerryscript/jerry-core/jmem/jmem-heap.c
SRCS_snowy_family += lib/jerryscript/jerry-core/jmem/jmem-poolman.c
SRCS_snowy_family += lib/jerryscript/jerry-core/jrt/jrt-fatals.c
SRCS_snowy_family += lib/jerryscript/jerry-core/lit/lit-char-helpers.c
SRCS_snowy_family += lib/jerryscript/jerry-core/lit/lit-magic-strings.c
SRCS_snowy_family += lib/jerryscript/jerry-core/lit/lit-strings.c
SRCS_snowy_family += lib/jerryscript/jerry-core/parser/js/byte-code.c
SRCS_snowy_family += lib/jerryscript/jerry-core/parser/js/common.c
SRCS_snowy_family += lib/jerryscript/jerry-core/parser/js/js-lexer.c
SRCS_snowy_family += lib/jerryscript/jerry-core/parser/js/js-parser-expr.c
SRCS_snowy_family += lib/jerryscript/jerry-core/parser/js/js-parser-mem.c
SRCS_snowy_family += lib/jerryscript/jerry-core/parser/js/js-parser-scanner.c
SRCS_snowy_family += lib/jerryscript/jerry-core/parser/js/js-parser-statm.c
SRCS_snowy_family += lib/jerryscript/jerry-core/parser/js/js-parser-util.c
SRCS_snowy_family += lib/jerryscript/jerry-core/parser/js/js-parser.c
SRCS_snowy_family += lib/jerryscript/jerry-core/parser/regexp/re-bytecode.c
SRCS_snowy_family += lib/jerryscript/jerry-core/parser/regexp/re-compiler.c
SRCS_snowy_family += lib/jerryscript/jerry-core/parser/regexp/re-parser.c
SRCS_snowy_family += lib/jerryscript/jerry-core/vm/opcodes-ecma-arithmetics.c
SRCS_snowy_family += lib/jerryscript/jerry-core/vm/opcodes-ecma-bitwise.c
SRCS_snowy_family += lib/jerryscript/jerry-core/vm/opcodes-ecma-equality.c
SRCS_snowy_family += lib/jerryscript/jerry-core/vm/opcodes-ecma-relational.c
SRCS_snowy_family += lib/jerryscript/jerry-core/vm/opcodes.c
SRCS_snowy_family += lib/jerryscript/jerry-core/vm/vm-stack.c
SRCS_snowy_family += lib/jerryscript/jerry-core/vm/vm.c

SRCS_snowy_family += lib/jerryscript/jerry-libm/acos.c
SRCS_snowy_family += lib/jerryscript/jerry-libm/asin.c
SRCS_snowy_family += lib/jerryscript/jerry-libm/atan.c
SRCS_snowy_family += lib/jerryscript/jerry-libm/atan2.c
SRCS_snowy_family += lib/jerryscript/jerry-libm/ceil.c
SRCS_snowy_family += lib/jerryscript/jerry-libm/copysign.c
SRCS_snowy_family += lib/jerryscript/jerry-libm/exp.c
SRCS_snowy_family += lib/jerryscript/jerry-libm/fabs.c
SRCS_snowy_family += lib/jerryscript/jerry-libm/finite.c
SRCS_snowy_family += lib/jerryscript/jerry-libm/floor.c
SRCS_snowy_family += lib/jerryscript/jerry-libm/fmod.c
SRCS_snowy_family += lib/jerryscript/jerry-libm/isnan.c
SRCS_snowy_family += lib/jerryscript/jerry-libm/log.c
SRCS_snowy_family += lib/jerryscript/jerry-libm/nextafter.c
SRCS_snowy_family += lib/jerryscript/jerry-libm/pow.c
SRCS_snowy_family += lib/jerryscript/jerry-libm/scalbn.c
SRCS_snowy_family += lib/jerryscript/jerry-libm/sqrt.c
SRCS_snowy_family += lib/jerryscript/jerry-libm/trig.c




LDFLAGS_snowy_family = $(LDFLAGS_stm32f4xx)
LIBS_snowy_family = $(LIBS_stm32f4xx)

1 change: 1 addition & 0 deletions lib/jerryscript
Submodule jerryscript added at 9bef6b
2 changes: 1 addition & 1 deletion lib/neographics
1 change: 1 addition & 0 deletions rcore/api_func_symbols.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include "librebble.h"
#include "graphics_wrapper.h"
#include "battery_state_service.h"
#include "rocky_js.h"

GBitmap *gbitmap_create_with_resource_proxy(uint32_t resource_id);
bool persist_exists(void);
Expand Down
4 changes: 2 additions & 2 deletions rcore/appmanager.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#include "node_list.h"
#include <stdbool.h>
#include "uuid.h"
#include "rocky_js.h"

// TODO Make this dynamic. hacky
#define NUM_APPS 3
Expand Down Expand Up @@ -148,6 +149,7 @@ typedef struct app_running_thread_t {
struct CoreTimer *timer_head;
qarena_t *arena;
struct n_GContext *graphics_context;
rocky_thread_state rocky_state;
} app_running_thread;

/* in appmanager.c */
Expand Down Expand Up @@ -187,6 +189,4 @@ TickType_t appmanager_timer_get_next_expiry(app_running_thread *thread);
App *appmanager_get_app(char *app_name);
void appmanager_app_loader_init(void);

void rocky_event_loop_with_resource(uint16_t resource_id);

void timer_init(void);
5 changes: 0 additions & 5 deletions rcore/appmanager_app_runloop.c
Original file line number Diff line number Diff line change
Expand Up @@ -86,11 +86,6 @@ bool appmanager_is_app_shutting_down(void)
return _this_thread->status == AppThreadUnloading;
}

void rocky_event_loop_with_resource(uint16_t resource_id)
{
app_event_loop();
}

static void _draw(uint8_t force_draw)
{
/* Request a draw. This is mostly from an app invalidating something */
Expand Down
2 changes: 1 addition & 1 deletion rcore/log.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ void log_printf_to_ar(const char *layer, const char *module, uint8_t level, cons

// NOTE Probably shouldn't use from an ISR or it'll likely lock

#define PRBUFSIZ 160
#define PRBUFSIZ 256
void log_printf(const char *layer, const char *module, uint8_t level, const char *filename, uint32_t line_no, const char *fmt, va_list ar)
{
uint8_t interrupt_set = 0;
Expand Down
2 changes: 1 addition & 1 deletion res
Submodule res updated 1 files
+1 −4 chalk.json
4 changes: 4 additions & 0 deletions rwatch/js/rocky_canvas.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#include <ctype.h>
#include "rocky_canvas.h"

bool rocky_font_parse(char* fontStr, RockyCanvasFont* outFont);
98 changes: 98 additions & 0 deletions rwatch/js/rocky_canvas.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
#pragma once
/* rockyjs.h
*
* Rocky.js (On-watch JavaScript) Implementation
* Rocky/JavaScript Canvas Library
*
* RebbleOS
*
* Author: Davit Markarian <[email protected]>
*/

#include "rebbleos.h"
#include "node_list.h"

typedef uint8_t RockyCanvasFontSize;

typedef enum
{
RockyCanvasFontVariant_Normal,
RockyCanvasFontVariant_Light,
RockyCanvasFontVariant_Bold,
RockyCanvasFontVariant_Bolder
} RockyCanvasFontWeight;

typedef enum
{
RockyCanvasFontVariant_Default,
RockyCanvasFontVariant_Numbers
} RockyCanvasFontVariant;

typedef enum
{
RockyCanvasFontFamily_Gothic,
RockyCanvasFontFamily_Bitham,
RockyCanvasFontFamily_Bitham_numeric,
RockyCanvasFontFamily_Roboto,
RockyCanvasFontFamily_Roboto_subset,
RockyCanvasFontFamily_Droid_serif,
RockyCanvasFontFamily_Leco_numbers,
RockyCanvasFontFamily_Leco_numbers_am_pm,
} RockyCanvasFontFamily;

// <Size>px [Weight] [Variant] <Family>
typedef struct
{
RockyCanvasFontSize size;
RockyCanvasFontVariant weight;
RockyCanvasFontVariant variant;
RockyCanvasFontFamily family;
} RockyCanvasFont;

bool rocky_font_parse(char *fontStr, RockyCanvasFont *outFont);

typedef enum
{
RockyCanvasPathPartType_Arc
} RockyCanvasPathPartType;

typedef struct
{
RockyCanvasPathPartType type;
int32_t x;
int32_t y;
union {
struct
{ // Arc
int32_t radius;
float startAngle;
float endAngle;
};
struct
{ // Rectangle
int32_t width;
int32_t height;
};
struct // Point (moveTo/lineTo)
{
};
};
} RockyCanvasPathPart;

typedef struct
{
int32_t currentX;
int32_t currentY;
list_head parts;
} RockyCanvasPath;

typedef struct
{
RockyCanvasPath path;
list_node node;
} RockyCanvasState;

typedef struct
{
RockyCanvasState state;
} RockyCanvas;
Loading