From 54279142179998cb958c30db18482c2d56610340 Mon Sep 17 00:00:00 2001 From: John Thomas Date: Sat, 28 Mar 2020 14:03:24 -0700 Subject: [PATCH] Fixed some includes --- Apps/System/menu.c | 1 - Apps/System/menu.h | 2 +- Apps/System/systemapp.c | 25 +++--- Apps/System/testapp.c | 2 +- Apps/System/tests/vibes_test.c | 2 +- Makefile | 8 +- hw/drivers/stm32_buttons/stm32_buttons.c | 1 - hw/drivers/stm32_usart/stm32_usart.h | 6 +- hw/platform/snowy/platform_config.h | 2 + lib/minilib/qalloc.c | 35 ++++---- lib/musl/time/mktime.c | 5 +- lib/png/png.c | 18 ++-- lib/png/png.h | 5 +- lib/png/upng.c | 8 +- lib/png/upng.h | 9 +- rcore/api_func_symbols.h | 1 + rcore/appmanager.c | 3 +- rcore/buttons.c | 103 ++++++++++++----------- rcore/buttons.h | 1 + rcore/overlay_manager.c | 40 ++++----- rcore/overlay_manager.h | 57 +++++++------ rcore/resource.c | 2 +- rwatch/event/battery_state_service.c | 1 + rwatch/event/connection_service.c | 7 +- rwatch/graphics/font_file.c | 15 ++-- rwatch/graphics/gbitmap.h | 2 + rwatch/input/click_config.c | 24 +++--- rwatch/input/click_config.h | 30 ------- rwatch/pebble.h | 12 +-- rwatch/pebble_defines.h | 2 - rwatch/ui/animation/animation.c | 1 + rwatch/ui/animation/animation.h | 2 +- rwatch/ui/layer/bitmap_layer.h | 15 ++-- rwatch/ui/layer/content_indicator.h | 28 ++++++ rwatch/ui/layer/layer.h | 6 +- rwatch/ui/layer/menu_layer.h | 4 + rwatch/ui/layer/scroll_layer.h | 3 +- rwatch/ui/notifications/mini_message.c | 1 + rwatch/ui/window.h | 12 ++- 39 files changed, 258 insertions(+), 243 deletions(-) create mode 100644 rwatch/ui/layer/content_indicator.h diff --git a/Apps/System/menu.c b/Apps/System/menu.c index b0e917db..ea7165ba 100644 --- a/Apps/System/menu.c +++ b/Apps/System/menu.c @@ -7,7 +7,6 @@ * Author: Barry Carter . */ -#include "rebbleos.h" #include "menu.h" static list_head _res_list_head = LIST_HEAD(_res_list_head); diff --git a/Apps/System/menu.h b/Apps/System/menu.h index 698ef6ab..3dbe4e01 100644 --- a/Apps/System/menu.h +++ b/Apps/System/menu.h @@ -8,7 +8,7 @@ * Author: Barry Carter . */ -#include "librebble.h" +#include #include "menu_layer.h" struct Menu; diff --git a/Apps/System/systemapp.c b/Apps/System/systemapp.c index 4628f06c..a90fc663 100644 --- a/Apps/System/systemapp.c +++ b/Apps/System/systemapp.c @@ -6,8 +6,6 @@ */ #include "rebbleos.h" -#include "systemapp.h" -#include "menu.h" #include "status_bar_layer.h" #include "platform_config.h" #include "platform_res.h" @@ -15,6 +13,9 @@ #include "protocol.h" #include "protocol_music.h" #include "event_service.h" +#include "graphics/system_font.h" +#include "menu.h" +#include "systemapp.h" /* Configure Logging */ #define MODULE_NAME "sysapp" @@ -145,7 +146,7 @@ static void _music_info(EventServiceProc command, void *data) LOG_INFO("Title: %s", amusic->title); LOG_INFO("Artist: %s", amusic->artist); LOG_INFO("Album: %s", amusic->album); - + items->items[2].sub_text = amusic->title; } @@ -182,7 +183,7 @@ static void systemapp_window_load(Window *window) #endif //tick_timer_service_subscribe(MINUTE_UNIT, prv_tick_handler); - + /* Music. Request the music track from the remote device */ protocol_music_get_current_track(); event_service_subscribe(EventServiceCommandMusic, _music_info); @@ -195,7 +196,7 @@ static void systemapp_window_unload(Window *window) static void window_exit_handler(ClickRecognizerRef recognizer, void *context) { - window_stack_pop(true); + window_stack_pop(true); } static void about_window_load(Window *window) @@ -215,7 +216,7 @@ static void about_window_load(Window *window) s_aboutCanvas_layer = layer_create(bounds); layer_set_update_proc(s_aboutCanvas_layer, about_update_proc); - scroll_layer_add_child(s_about_scroll, s_aboutCanvas_layer); + scroll_layer_add_child(s_about_scroll, s_aboutCanvas_layer); layer_mark_dirty(s_aboutCanvas_layer); layer_add_child(window_layer, scroll_layer_get_layer(s_about_scroll)); @@ -224,19 +225,19 @@ static void about_window_load(Window *window) #ifdef PBL_BW //TODO: Get black and white rocket bitmap for Classic logo_bitmap = gbitmap_create_with_resource(RESOURCE_ID_REBBLE_LOGO_BW); - rocket_bitmap = gbitmap_create_with_resource(RESOURCE_ID_TO_MOON_BW); + rocket_bitmap = gbitmap_create_with_resource(RESOURCE_ID_TO_MOON_BW); #else logo_bitmap = gbitmap_create_with_resource(RESOURCE_ID_REBBLE_LOGO_DARK); rocket_bitmap = gbitmap_create_with_resource(RESOURCE_ID_TO_MOON); #endif about_did_set_size = 0; - + /* XXX: Some day it would be cool to automatically scroll the credits after a short delay. */ } static void about_update_proc(Layer *layer, GContext *nGContext) -{ +{ GRect bounds = layer_get_unobstructed_bounds(layer); graphics_context_set_text_color(nGContext, GColorBlack); graphics_context_set_compositing_mode(nGContext, GCompOpSet); @@ -257,10 +258,10 @@ static void about_update_proc(Layer *layer, GContext *nGContext) graphics_draw_bitmap_in_rect(nGContext, logo_bitmap, GRect((bounds.size.w/2)-17, (bounds.size.h/2)-63, 34, 53)); graphics_draw_bitmap_in_rect(nGContext, rocket_bitmap, GRect((bounds.size.w/2)-8, (bounds.size.h/2)+60, 19, 19)); - + graphics_draw_text(nGContext, "Credits", fonts_get_system_font(FONT_KEY_GOTHIC_18_BOLD), GRect(10, bounds.size.h, bounds.size.w - 20, 20), n_GTextOverflowModeWordWrap, GTextAlignmentCenter, 0); - + const char **authorp = git_authors; int y = bounds.size.h + 30; for (authorp = git_authors; *authorp; authorp++) { @@ -269,7 +270,7 @@ static void about_update_proc(Layer *layer, GContext *nGContext) n_GTextOverflowModeWordWrap, GTextAlignmentCenter, 0); y += 16; } - + /* Set the size on the first render only, lest we interfere with actual scrolling. */ if (!about_did_set_size) { about_did_set_size = 1; diff --git a/Apps/System/testapp.c b/Apps/System/testapp.c index cc251a7f..1b9992da 100644 --- a/Apps/System/testapp.c +++ b/Apps/System/testapp.c @@ -6,7 +6,7 @@ * Author: Barry Carter */ -#include "rebbleos.h" +#include "librebble.h" #include "menu.h" #include "status_bar_layer.h" #include "test_defs.h" diff --git a/Apps/System/tests/vibes_test.c b/Apps/System/tests/vibes_test.c index dca97a08..7435337f 100644 --- a/Apps/System/tests/vibes_test.c +++ b/Apps/System/tests/vibes_test.c @@ -5,7 +5,7 @@ * Author: Author: Elliot Hawkins . */ -#include "rebbleos.h" +#include "librebble.h" #include "systemapp.h" #include "menu.h" #include "status_bar_layer.h" diff --git a/Makefile b/Makefile index 04d00072..825c0c08 100644 --- a/Makefile +++ b/Makefile @@ -135,18 +135,18 @@ $(BUILD)/$(1)/tintin_fw.elf: $(BUILD)/$(1)/res/platform_res.h $$(OBJS_$(1)) $(BUILD)/$(1)/%.o: %.c $(call SAY,[$(1)] CC $$<) @mkdir -p $$(dir $$@) - $(QUIET)$(CC) $$(CFLAGS_$(1)) -MMD -MP -MT $$@ -MF $$(addsuffix .d,$$(basename $$@)) -c -o $$@ $$< + $(QUIET)$(CC) $$(CFLAGS_$(1)) -MMD -MP -MT $$@ -MF $$(addsuffix .d,$$(basename $$@)) -c -o $$@ $$< $(BUILD)/$(1)/%.o: %.s $(call SAY,[$(1)] AS $$<) @mkdir -p $$(dir $$@) - $(QUIET)$(CC) $$(CFLAGS_$(1)) -c -o $$@ $$< + $(QUIET)$(CC) $$(CFLAGS_$(1)) -c -o $$@ $$< $(BUILD)/$(1)/%.o: %.S $(call SAY,[$(1)] AS $$<) @mkdir -p $$(dir $$@) - $(QUIET)$(CC) $$(CFLAGS_$(1)) -c -o $$@ $$< - + $(QUIET)$(CC) $$(CFLAGS_$(1)) -c -o $$@ $$< + $(BUILD)/$(1)/Resources/%_fpga.o: Resources/%_fpga.bin $(call SAY,[$(1)] FPGA $$<) @mkdir -p $$(dir $$@) diff --git a/hw/drivers/stm32_buttons/stm32_buttons.c b/hw/drivers/stm32_buttons/stm32_buttons.c index 89cce128..e6604572 100644 --- a/hw/drivers/stm32_buttons/stm32_buttons.c +++ b/hw/drivers/stm32_buttons/stm32_buttons.c @@ -32,7 +32,6 @@ #include "stm32_buttons.h" #include "stm32_power.h" #include "stm32_buttons_platform.h" -#include "buttons.h" #include "debug.h" static hw_button_isr_t _isr = NULL; diff --git a/hw/drivers/stm32_usart/stm32_usart.h b/hw/drivers/stm32_usart/stm32_usart.h index e132306c..ff4ee153 100644 --- a/hw/drivers/stm32_usart/stm32_usart.h +++ b/hw/drivers/stm32_usart/stm32_usart.h @@ -1,4 +1,4 @@ -/* +/* * stm32_usart.h * External-facing API for stm32 USART module * This is a simple wrapper around common USART defaults and functions @@ -45,7 +45,7 @@ typedef struct { const stm32_dma_t *dma; uint32_t baud; } stm32_usart_t; - + void stm32_usart_init_device(stm32_usart_t *usart); void stm32_usart_set_baud(stm32_usart_t *usart, uint32_t baud); size_t stm32_usart_write(stm32_usart_t *usart, const uint8_t *buf, size_t len); @@ -69,7 +69,7 @@ void _stm32_usart_rx_start_init_isr(stm32_usart_t *usart, uint16_t irqn, uint16_ static inline void _stm32_usart_tx_isr(void) { \ stm32_usart_tx_isr(usart, callback); \ } - + #define STM32_USART_MK_RX_IRQ_HANDLER(usart, dma_channel, stream, callback) \ STM32_DMA_MK_RX_IRQ_HANDLER( (usart) ->dma, dma_channel, stream, _stm32_usart_rx_isr ) \ \ diff --git a/hw/platform/snowy/platform_config.h b/hw/platform/snowy/platform_config.h index ac4d3a9e..1a0b3738 100644 --- a/hw/platform/snowy/platform_config.h +++ b/hw/platform/snowy/platform_config.h @@ -12,7 +12,9 @@ #define DISPLAY_COLS 144 //We are a square device +#ifndef PBL_RECT #define PBL_RECT +#endif extern unsigned char _binary_Resources_snowy_fpga_bin_size; extern unsigned char _binary_Resources_snowy_fpga_bin_start; diff --git a/lib/minilib/qalloc.c b/lib/minilib/qalloc.c index eb4b7729..3680d8e9 100644 --- a/lib/minilib/qalloc.c +++ b/lib/minilib/qalloc.c @@ -62,7 +62,7 @@ static void _qsplit(qarena_t *arena, qblock_t *blk, unsigned size); qarena_t *qinit(void *start, unsigned size) { qarena_t *arena = start; arena->size = size; - + qblock_t *blk = BLK(arena + 1); // start = &arena[1], so arena[0] is left alone. blk->szflag = size - sizeof(*arena); _cookie_unset(arena, blk); @@ -70,23 +70,22 @@ qarena_t *qinit(void *start, unsigned size) { memset(BLK_PAYLOAD(blk), 0xAA, BLK_SZ(blk) - sizeof(qblock_t)); #endif BLK_FREE(blk); - + return arena; } void *qalloc(qarena_t *arena, unsigned size) { qblock_t *blk = BLK(arena+1); qblock_t *end = BLK((char *)arena + arena->size); - void *n = NULL; - + if (size == 0) return NULL; size = BLK_ALSIZE(size); - + while (blk && blk < end) { qcheck(arena, blk); - + /* We need either exactly enough room for this block, or we * need enough room for this and one more block to be * constructed at the end. */ @@ -103,7 +102,7 @@ void *qalloc(qarena_t *arena, unsigned size) { _cookie_set(arena, blk); BLK_ALLOC(blk); - + return BLK_PAYLOAD(blk); } return NULL; @@ -121,14 +120,14 @@ static void _qsplit(qarena_t *arena, qblock_t *blk, unsigned size) { void *qrealloc(qarena_t *arena, void *ptr, unsigned size) { if (size == 0) return NULL; - + size = BLK_ALSIZE(size); - + if (!ptr) return qalloc(arena, size); - + qblock_t *blk = BLK_FROMPAYLOAD(ptr); - + /* is the new size smaller? */ if (size < BLK_SZ(blk)) { _qsplit(arena, blk, size); @@ -136,7 +135,7 @@ void *qrealloc(qarena_t *arena, void *ptr, unsigned size) { qjoin(arena); return BLK_PAYLOAD(blk); } - + /* is there room after */ qblock_t *nblk = BLK_NEXT(blk); uint32_t reqsize = size - BLK_SZ(blk); @@ -151,11 +150,11 @@ void *qrealloc(qarena_t *arena, void *ptr, unsigned size) { void *newm = qalloc(arena, size); if (!newm) return NULL; - + memcpy(newm, BLK_PAYLOAD(blk), BLK_SZ(blk)); qfree(arena, BLK_PAYLOAD(blk)); qjoin(arena); - + return newm; } @@ -163,7 +162,7 @@ uint32_t qusedbytes(qarena_t *arena) { qblock_t *blk = BLK(arena+1); qblock_t *end = BLK((char *)arena + arena->size); uint32_t cnt = 0; - + while (blk && blk < end) { if (!BLK_ISFREE(blk)) { cnt += BLK_SZ(blk); @@ -180,7 +179,7 @@ uint32_t qfreebytes(qarena_t *arena) { void qfree(qarena_t *arena, void *ptr) { if (!ptr) return; - + qblock_t *blk = BLK_FROMPAYLOAD(ptr); #ifdef HEAP_INTEGRITY @@ -200,7 +199,7 @@ void qfree(qarena_t *arena, void *ptr) { static void qjoin(qarena_t *arena) { qblock_t *blk = BLK(arena+1); qblock_t *end = (qblock_t *)((char *)arena + arena->size); - + while (blk && blk < end) { qcheck(arena, blk); if (BLK_NEXT(blk) < end && BLK_ISFREE(blk) && BLK_ISFREE(BLK_NEXT(blk))) { @@ -233,7 +232,7 @@ static void qcheck(qarena_t *arena, qblock_t *blk) { if (BLK_ISFREE(blk)) { unsigned i; uint8_t *p = BLK_PAYLOAD(blk); - + for (i = 0; i < BLK_SZ(blk) - sizeof(qblock_t); i++) if (p[i] != 0xAA) { printf("%08x %08x %08x %02x\n", p, i, &p[i], p[i]); diff --git a/lib/musl/time/mktime.c b/lib/musl/time/mktime.c index 73d37bbd..20d32150 100644 --- a/lib/musl/time/mktime.c +++ b/lib/musl/time/mktime.c @@ -3,11 +3,10 @@ time_t mktime(struct tm *tm) { - struct tm new; - long opp; long long t = __tm_to_secs(tm); + /*struct tm new; + long opp; - /* __secs_to_zone(t, 1, &new.tm_isdst, &new.__tm_gmtoff, &opp, &new.__tm_zone); if (tm->tm_isdst>=0 && new.tm_isdst!=tm->tm_isdst) diff --git a/lib/png/png.c b/lib/png/png.c index 4b609922..c360607e 100644 --- a/lib/png/png.c +++ b/lib/png/png.c @@ -1,8 +1,10 @@ +#include "rebble_memory.h" +#include "log.h" + #include "upng.h" #include "png.h" - -void png_to_gbitmap(GBitmap *bitmap, uint8_t *raw_buffer, size_t png_size) +void png_to_gbitmap(n_GBitmap *bitmap, uint8_t *raw_buffer, size_t png_size) { /* Set up the bitmap, assuming we will fail. */ bitmap->palette = NULL; @@ -14,7 +16,7 @@ void png_to_gbitmap(GBitmap *bitmap, uint8_t *raw_buffer, size_t png_size) bitmap->raw_bitmap_size.w = 0; bitmap->raw_bitmap_size.h = 0; bitmap->addr = NULL; - bitmap->format = GBitmapFormat8Bit; + bitmap->format = n_GBitmapFormat8Bit; bitmap->free_data_on_destroy = true; bitmap->free_palette_on_destroy = true; @@ -121,12 +123,12 @@ void png_to_gbitmap(GBitmap *bitmap, uint8_t *raw_buffer, size_t png_size) // set the resultant format if (bpp == 1 && (bitmap->palette_size > 0 || alen > 0)) { - bitmap->format = GBitmapFormat1BitPalette; + bitmap->format = n_GBitmapFormat1BitPalette; } else if (bpp == 1) { // easier to generate the black/white palette than to reverse every byte - bitmap->format = GBitmapFormat1BitPalette; + bitmap->format = n_GBitmapFormat1BitPalette; n_GColor* bw_palette = app_calloc(2, sizeof(n_GColor)); bw_palette[0] = n_GColorBlack; @@ -136,15 +138,15 @@ void png_to_gbitmap(GBitmap *bitmap, uint8_t *raw_buffer, size_t png_size) } else if (bpp == 2) { - bitmap->format = GBitmapFormat2BitPalette; + bitmap->format = n_GBitmapFormat2BitPalette; } else if (bpp == 4) { - bitmap->format = GBitmapFormat4BitPalette; + bitmap->format = n_GBitmapFormat4BitPalette; } else if (bpp == 8) { - bitmap->format = GBitmapFormat8Bit; + bitmap->format = n_GBitmapFormat8Bit; // Convert 8bit palette to just 8bit if (plen) diff --git a/lib/png/png.h b/lib/png/png.h index 7d479874..93d6ab08 100644 --- a/lib/png/png.h +++ b/lib/png/png.h @@ -2,8 +2,7 @@ #include #include -#include +#include "gbitmap/gbitmap.h" - -void png_to_gbitmap(GBitmap *bitmap, uint8_t *raw_buffer, size_t png_size); +void png_to_gbitmap(n_GBitmap *bitmap, uint8_t *raw_buffer, size_t png_size); diff --git a/lib/png/upng.c b/lib/png/upng.c index 3c34bc85..4f8cb544 100644 --- a/lib/png/upng.c +++ b/lib/png/upng.c @@ -27,15 +27,19 @@ freely, subject to the following restrictions: #include #include #include +#include #include +// TODO try to remove this. (Maybe do things on the stack, or let the caller do that allocation) +#include "rebble_memory.h" + #include "upng.h" //smaller decompressor //saves about 900 bytes, but still crashing watch //#include "tinfl.h" //#define TINFL 1 -#include +//#include "pebble.h" //Debug stack overflow //register uint32_t sp __asm("sp"); @@ -1422,7 +1426,7 @@ int upng_get_palette(const upng_t* upng, rgb **palette) return upng->palette_entries; } -int upng_get_alpha(const upng_t* upng, uint8_t **alpha) +int upng_get_alpha(const upng_t* upng, unsigned char **alpha) { *alpha = upng->alpha; return upng->alpha_entries; diff --git a/lib/png/upng.h b/lib/png/upng.h index 4aa8bdeb..81bcb149 100644 --- a/lib/png/upng.h +++ b/lib/png/upng.h @@ -24,9 +24,10 @@ freely, subject to the following restrictions: distribution. */ -#if !defined(UPNG_H) -#define UPNG_H -#include +#ifndef __UPNG_H +#define __UPNG_H + + typedef enum upng_error { UPNG_EOK = 0, /* success (no error) */ UPNG_ENOMEM = 1, /* memory allocation failed */ @@ -95,6 +96,6 @@ unsigned upng_get_size (const upng_t* upng); //returns keyword and text_out matching keyword char* upng_get_text(const upng_t* upng, char** text_out, unsigned int index); -int upng_get_alpha(const upng_t* upng, uint8_t **alpha); +int upng_get_alpha(const upng_t* upng, unsigned char **alpha); #endif /*defined(UPNG_H)*/ diff --git a/rcore/api_func_symbols.h b/rcore/api_func_symbols.h index 3c3723de..d8ed9d24 100644 --- a/rcore/api_func_symbols.h +++ b/rcore/api_func_symbols.h @@ -3,6 +3,7 @@ #include "librebble.h" #include "graphics_wrapper.h" #include "battery_state_service.h" +#include "librebble.h" GBitmap *gbitmap_create_with_resource_proxy(uint32_t resource_id); bool persist_exists(void); diff --git a/rcore/appmanager.c b/rcore/appmanager.c index aecb4c43..62dab5d1 100644 --- a/rcore/appmanager.c +++ b/rcore/appmanager.c @@ -10,7 +10,6 @@ #include #include "rebbleos.h" #include "librebble.h" -#include "appmanager.h" #include "systemapp.h" #include "test.h" #include "notification.h" @@ -18,6 +17,8 @@ #include "qalloc.h" #include "notification_manager.h" +#include "appmanager.h" + /* Configure Logging */ #define MODULE_NAME "appman" #define MODULE_TYPE "KERN" diff --git a/rcore/buttons.c b/rcore/buttons.c index c1f7c92d..c052dd2b 100644 --- a/rcore/buttons.c +++ b/rcore/buttons.c @@ -7,18 +7,21 @@ /* * MODULE TODO - * + * * Button Multi click support * buttonholder -> clickrecognizer convert / typedef * Theres a couple of bytes of ram to be shaved - * + * * review task priorities */ +#include #include "FreeRTOS.h" #include "task.h" #include "queue.h" #include "buttons.h" #include "overlay_manager.h" +#include "appmanager.h" +#include "rebble_memory.h" typedef struct ButtonHolder { uint8_t button_id; @@ -84,21 +87,21 @@ uint8_t rcore_buttons_init(void) { _button_init(i, (ClickConfig) {}); } - + _button_queue = xQueueCreateStatic(BUTTON_QUEUE_SIZE, sizeof(uint8_t), _button_queue_contents, &_button_queue_buf); - - _button_message_task = xTaskCreateStatic(_button_message_thread, - "Button", - STACK_SIZE_BUTTON_THREAD, - NULL, - tskIDLE_PRIORITY + 5UL, - _button_message_task_stack, + + _button_message_task = xTaskCreateStatic(_button_message_thread, + "Button", + STACK_SIZE_BUTTON_THREAD, + NULL, + tskIDLE_PRIORITY + 5UL, + _button_message_task_stack, &_button_message_task_buf); - + _button_debounce_task = xTaskCreateStatic(_button_debounce_thread, "Debounce", STACK_SIZE_BUTTON_DEBOUNCE, NULL, tskIDLE_PRIORITY + 6UL, _button_debounce_task_stack, &_button_debounce_task_buf); - + KERN_LOG("buttons", APP_LOG_LEVEL_INFO, "Button Task Created"); - + return 0; } @@ -108,7 +111,7 @@ uint8_t rcore_buttons_init(void) static void _button_isr(hw_button_t /* which is definitionally the same as a ButtonID */ button_id) { BaseType_t xHigherPriorityTaskWoken = pdFALSE; - + _last_press = button_id; vTaskNotifyGiveFromISR(_button_debounce_task, &xHigherPriorityTaskWoken); @@ -127,7 +130,7 @@ static ButtonHolder *_button_init(ButtonId button_id, ClickConfig click_config) { if (button_id >= NUM_BUTTONS) return NULL; - + ButtonHolder *button_holder = calloc(1, sizeof(ButtonHolder)); if (!button_holder) // could not malloc @@ -137,7 +140,7 @@ static ButtonHolder *_button_init(ButtonId button_id, ClickConfig click_config) button_holder->button_id = button_id; _button_holders[button_id] = button_holder; - + return button_holder; } @@ -147,13 +150,13 @@ static ButtonHolder *_button_init(ButtonId button_id, ClickConfig click_config) static void _button_update(ButtonId button_id, uint8_t press) { ButtonHolder *button = _button_holders[button_id]; - + // go through the buttons and find any that match if (press) { button->press_time = xTaskGetTickCount(); button->repeat_time = button->press_time; - + // send the raw keypress if (button->click_config.raw.down_handler) { @@ -178,11 +181,11 @@ static void _button_released(ButtonHolder *button) { uint32_t now = xTaskGetTickCount(); uint32_t delta_ms = portTICK_PERIOD_MS * (now - button->press_time); - + // we are releasing and it has a click handler // if we have long click, we are below the trigger threshold if (button->click_config.click.handler || - (button->click_config.click.handler && + (button->click_config.click.handler && button->click_config.long_click.handler && delta_ms < button->click_config.long_click.delay_ms)) { @@ -190,9 +193,9 @@ static void _button_released(ButtonHolder *button) NULL, // TODO button->click_config.context); } - + // long press release handler - if (button->click_config.long_click.release_handler && + if (button->click_config.long_click.release_handler && button->state == BUTTON_STATE_LONG) { // only trigger the release if we are over the repeat time @@ -200,7 +203,7 @@ static void _button_released(ButtonHolder *button) NULL, // TODO button->click_config.context); } - + // just send the raw if (button->click_config.raw.up_handler) { @@ -209,7 +212,7 @@ static void _button_released(ButtonHolder *button) NULL, // TODO button->click_config.context); } - + button->press_time = 0; button->repeat_time = 0; button->state = BUTTON_STATE_RELEASED; @@ -224,13 +227,13 @@ static uint8_t _button_check_time(void) { uint32_t now = xTaskGetTickCount(); ButtonHolder *button; - uint8_t pressed, any_pressed = 0; + uint8_t pressed, any_pressed = 0; for (uint8_t i = 0; i < NUM_BUTTONS; i++) { button = _button_holders[i]; pressed = _button_pressed(i); - + if (!pressed) { continue; @@ -242,7 +245,7 @@ static uint8_t _button_check_time(void) // button is still pressed // we have a click and a repeat - if (button->click_config.click.handler && button->repeat_time > 0 && + if (button->click_config.click.handler && button->repeat_time > 0 && button->click_config.click.repeat_interval_ms > 0) { // and the time of the last repeat was < now @@ -252,14 +255,14 @@ static uint8_t _button_check_time(void) button_send_app_click(button, BUTTON_CLICK_THREAD_S_C, button->click_config.click.handler, NULL, // TODO button->click_config.context); - + // reset the time button->repeat_time = now; } } - + // button pressed, and we just blasted past the long press time - if (button->click_config.long_click.handler && button->press_time > 0 && + if (button->click_config.long_click.handler && button->press_time > 0 && button->click_config.long_click.delay_ms > 0) { if (now > button->press_time + (button->click_config.long_click.delay_ms / portTICK_PERIOD_MS)) @@ -268,14 +271,14 @@ static uint8_t _button_check_time(void) button_send_app_click(button, BUTTON_CLICK_THREAD_L_C, button->click_config.long_click.handler, NULL, // TODO button->click_config.context); - + // stop further processing button->press_time = 0; button->repeat_time = 0; } } } - + return any_pressed; } @@ -288,13 +291,13 @@ static uint8_t _button_check_time(void) static void _button_message_thread(void *pvParameters) { uint8_t data; - + TickType_t time_increment = portMAX_DELAY; - + for( ;; ) { if (xQueueReceive(_button_queue, &data, time_increment)) - { + { _button_update(data, _button_pressed(data)); } @@ -304,7 +307,7 @@ static void _button_message_thread(void *pvParameters) time_increment = portMAX_DELAY; else time_increment = pdMS_TO_TICKS(10); - + } } @@ -323,9 +326,9 @@ static void _button_debounce_thread(void *pvParameters) // because we are using a notification on the task, any further triggers while // the buttons are bouncing are ignored while we are sleeping - // so lets go ahead and have a nap + // so lets go ahead and have a nap vTaskDelay(butDEBOUNCE_DELAY); - + // one last cleardown of our notification just to be sure ulTaskNotifyTake(pdTRUE, 0); @@ -337,7 +340,7 @@ static void _button_debounce_thread(void *pvParameters) * Convenience function to send a button click to the main application processor */ void button_send_app_click(ButtonHolder *button, uint8_t bit, void *callback, void *recognizer, void *context) -{ +{ _button_message.callback = callback; _button_message.clickref = recognizer; // TODO _button_message.context = context; @@ -355,7 +358,7 @@ void button_send_app_click(ButtonHolder *button, uint8_t bit, void *callback, vo * Check if a button is pressed */ static uint8_t _button_pressed(ButtonId button_id) -{ +{ return hw_button_pressed(button_id); } @@ -378,11 +381,11 @@ void button_single_click_subscribe(ButtonId button_id, ClickHandler handler) { if (button_id >= NUM_BUTTONS) return; - + ButtonHolder *holder = _button_holders[button_id]; // get the button holder->click_config.click.handler = handler; holder->click_config.click.repeat_interval_ms = 0; - + _button_set_is_app_thread_bit(holder, BUTTON_CLICK_THREAD_S_C); } @@ -390,11 +393,11 @@ void button_single_repeating_click_subscribe(ButtonId button_id, uint16_t repeat { if (button_id >= NUM_BUTTONS) return; - + ButtonHolder *holder = _button_holders[button_id]; // get the button holder->click_config.click.handler = handler; holder->click_config.click.repeat_interval_ms = repeat_interval_ms; - + _button_set_is_app_thread_bit(holder, BUTTON_CLICK_THREAD_R_C); } @@ -410,12 +413,12 @@ void button_long_click_subscribe(ButtonId button_id, uint16_t delay_ms, ClickHan { if (button_id >= NUM_BUTTONS) return; - + ButtonHolder *holder = _button_holders[button_id]; // get the button holder->click_config.long_click.handler = down_handler; holder->click_config.long_click.release_handler = up_handler; holder->click_config.long_click.delay_ms = delay_ms; - + _button_set_is_app_thread_bit(holder, BUTTON_CLICK_THREAD_L_C); } @@ -423,13 +426,13 @@ void button_raw_click_subscribe(ButtonId button_id, ClickHandler down_handler, C { if (button_id >= NUM_BUTTONS) return; - + ButtonHolder *holder = _button_holders[button_id]; // get the button holder->click_config.raw.up_handler = up_handler; holder->click_config.raw.down_handler = down_handler; if (context != NULL) holder->click_config.context = context; - + _button_set_is_app_thread_bit(holder, BUTTON_CLICK_THREAD_N_C); } @@ -455,8 +458,8 @@ uint8_t button_short_click_is_subscribed(ButtonId button_id) { if (button_id >= NUM_BUTTONS) return NULL; - + ButtonHolder *holder = _button_holders[button_id]; - + return holder->click_config.click.handler != NULL; } diff --git a/rcore/buttons.h b/rcore/buttons.h index 947915fd..6ef9474c 100644 --- a/rcore/buttons.h +++ b/rcore/buttons.h @@ -9,6 +9,7 @@ #include "FreeRTOS.h" #include "rebbleos.h" #include "librebble.h" +#include "click_config.h" #define butDEBOUNCE_DELAY ( pdMS_TO_TICKS(2) ) diff --git a/rcore/overlay_manager.c b/rcore/overlay_manager.c index d658c4e3..39b43ea2 100644 --- a/rcore/overlay_manager.c +++ b/rcore/overlay_manager.c @@ -1,17 +1,13 @@ /* overlay_manager.c * Routines for managing the overlay window and it's content * RebbleOS - * + * * Author: Barry Carter . */ +#include "overlay_manager.h" #include "rebbleos.h" #include "ngfxwrap.h" -#include "overlay_manager.h" -#include "protocol.h" -#include "protocol_music.h" -#include "event_service.h" #include "notification_manager.h" -#include "ngfxwrap.h" /* A message to talk to the overlay thread */ typedef struct OverlayMessage { @@ -42,21 +38,21 @@ static SemaphoreHandle_t _ovl_done_sem; static StaticSemaphore_t _ovl_done_sem_buf; uint8_t overlay_window_init(void) -{ +{ _ovl_done_sem = xSemaphoreCreateBinaryStatic(&_ovl_done_sem_buf); // XXX make static _overlay_queue = xQueueCreate(1, sizeof(struct OverlayMessage)); - + app_running_thread *thread = appmanager_get_thread(AppThreadOverlay); thread->status = AppThreadLoading; thread->thread_entry = &_overlay_thread; - /* start the thread + /* start the thread * We are only using the thread launcher in appmanager for this * not the full supervisory process. It's lightweight */ appmanager_execute_app(thread, 0); - + /* init must wait for us to complete */ return INIT_RESP_ASYNC_WAIT; } @@ -99,9 +95,9 @@ void overlay_window_draw(bool window_is_dirty) OverlayMessage om = (OverlayMessage) { .command = AppMessageOverlayDraw, .data = (void *)window_is_dirty, - }; + }; xQueueSendToBack(_overlay_queue, &om, 0); - + // xSemaphoreTake(_ovl_done_sem, portMAX_DELAY); } @@ -274,12 +270,12 @@ static void _overlay_window_destroy(OverlayWindow *overlay_window, bool animated window_dtor(&overlay_window->window); list_remove(&_overlay_window_list_head, &overlay_window->node); app_free(overlay_window); - + Window *top_window = overlay_window_get_next_window_with_click_config(); if (top_window == NULL) { - /* we are out of overlay windows, restore click + /* we are out of overlay windows, restore click * first get the top normal window. Grab it's click context * then restore it. Then configure it. */ /* next try and find any window */ @@ -293,7 +289,7 @@ static void _overlay_window_destroy(OverlayWindow *overlay_window, bool animated top_window = NULL; } } - + if (top_window == NULL) { top_window = window_stack_get_top_window(); @@ -313,7 +309,7 @@ static void _overlay_window_destroy(OverlayWindow *overlay_window, bool animated static void _overlay_window_draw(bool window_is_dirty) { app_running_thread *appthread = appmanager_get_thread(AppThreadMainApp); - + if (appmanager_get_thread_type() != AppThreadOverlay) { SYS_LOG("ov win", APP_LOG_LEVEL_ERROR, "Someone not overlay thread is trying to draw. Tsk."); @@ -328,9 +324,9 @@ static void _overlay_window_draw(bool window_is_dirty) * the main app has forced a redraw, then we have to do painting * regardless. So we paint. */ rbl_window_draw(window); - + window->is_render_scheduled = false; - + Window *w; list_foreach(w, &ow->head, Window, node) { @@ -347,22 +343,22 @@ static void _overlay_thread(void *pvParameters) { OverlayMessage data; app_running_thread *_this_thread = appmanager_get_current_thread(); - + SYS_LOG("overlay", APP_LOG_LEVEL_INFO, "Starting overlay thread..."); _this_thread->status = AppThreadLoaded; os_module_init_complete(0); - + event_service_subscribe(EventServiceCommandCall, notification_show_incoming_call); event_service_subscribe(EventServiceCommandAlert, notification_show_small_message); event_service_subscribe(EventServiceCommandNotification, notification_arrived); event_service_subscribe(EventServiceCommandProgress, notification_show_progress); - + while(1) { TickType_t next_timer = appmanager_timer_get_next_expiry(_this_thread); - if(next_timer == 0) + if(next_timer == 0) { appmanager_timer_expired(_this_thread); /* When we need to update draw, we post it to the main app. This way diff --git a/rcore/overlay_manager.h b/rcore/overlay_manager.h index 077a2434..ac96efb7 100644 --- a/rcore/overlay_manager.h +++ b/rcore/overlay_manager.h @@ -8,21 +8,22 @@ * An \ref OverlayWindow is a special window that is drawn above a running app. * The memory and runtime of the \ref OverlayWindow are controlled away from the application * If you invoke one of these windows, expect little heap to play with. - * + * * You can create as many \ref OverlayWindow objects as you like, they will get stacked * like a normal window. In fact you can treat an \ref OverlayWindow as transparent * once you create one. Just deal with the underlying \ref Window object. You will know * with an assert if you do something that isn't allowed. - * + * * The \ref OverlayWindow has a child of a \ref Window object in it. - * + * * The window is isolated away from normal window functions, but please don't * try and push one of these windows into a normal apps running stack. It will break. - * + * * Window creation happens in a callback so we can delegate the work to our thread * and constrain memory and runtime of the window */ #include "rebbleos.h" +#include "window.h" /* NOT USED YET */ typedef enum OverlayMode { @@ -46,7 +47,7 @@ typedef struct OverlayWindow { /** * @brief Prototype for the callback on window creation - * + * * @param overlay An \ref OverlayWindow pointer with the newly created window */ typedef void (*OverlayCreateCallback)(OverlayWindow *overlay, Window *window); @@ -62,7 +63,7 @@ void overlay_window_post_button_message(ButtonMessage *message); /** * @brief Creates a new managed \ref OverlayWindow. - * + * * The \ref OverlayWindow is provided in the callback \ref OverlayCreateCallback * @param creation_callback Is a provided function that will be called on the * creation of the window. @@ -72,25 +73,25 @@ void overlay_window_create(OverlayCreateCallback creation_callback); /** * @brief Creates a new managed \ref OverlayWindow but also sets a custom context * By default context is set to the \ref OverlayWindow - * + * * The \ref OverlayWindow is provided in the callback \ref OverlayCreateCallback * @param creation_callback Is a provided function that will be called on the * creation of the window. */ void overlay_window_create_with_context(OverlayCreateCallback creation_callback, void *context); -/** +/** * @brief Directly draw an \ref OverlayWindow. - * + * * This will also cause a full redraw of all \ref Window objects - * @param window_is_dirty When set the existing window we are overlaying + * @param window_is_dirty When set the existing window we are overlaying * is already dirty */ void overlay_window_draw(bool window_is_dirty); /** * @brief Clean up an \ref OverlayWindow. - * + * * This will also cause a full redraw of all \ref Window objects * @param overlay_window Pointer to the \ref OverlayWindow you wish to destroy */ @@ -104,44 +105,44 @@ uint8_t overlay_window_count(void); /** * @brief Push a new \ref OverlayWindow to the top of the stack above all others - * + * * @param overlay_window Pointer to the \ref OverlayWindow to be pushed to the top - * @param animated will enable any animated transistions on the window + * @param animated will enable any animated transistions on the window */ void overlay_window_stack_push(OverlayWindow *overlay_window, bool animated); /** * @brief Push a \ref OverlayWindow to the top of the stack. Push by \ref Window - * + * * @param window Pointer to the \ref Window to push to the top of the overlay - * @param animated will enable any animated transistions on the window - */ + * @param animated will enable any animated transistions on the window + */ void overlay_window_stack_push_window(Window *window, bool animated); /** * @brief Pop a \ref OverlayWindow from the stack, returning the \ref Window removed - * - * @param animated will enable any animated transistions on the window - */ + * + * @param animated will enable any animated transistions on the window + */ Window *overlay_window_stack_pop_window(bool animated); /** * @brief Return the top \ref Window in a stack of \ref OverlayWindow - * + * * @return \ref Window object of the found top window. NULL for no window. */ Window *overlay_window_stack_get_top_window(void); -/** +/** * @brief Given an \ref OverlayWindow, return the top \ref Window - * + * * @return \ref OverlayWindow that is very topmost */ OverlayWindow *overlay_stack_get_top_overlay_window(void); -/** +/** * @brief Given a \ref Window, check all \ref OverlayWindow objects for any match - * + * * @param window Pointer to the \ref Window to find the existance of * @return bool if window exists anywhere in an overlay */ @@ -149,23 +150,23 @@ bool overlay_window_stack_contains_window(Window *window); /** * @brief Destroy an \ref OverlayWindow by reference of it's \ref Window - * + * * @param window Pointer to the \ref Window to destroy */ void overlay_window_destroy_window(Window *window); /** * @brief Destroy an \ref OverlayWindow by reference of it's \ref OverlayWindow - * + * * @param animated If we should animate this overlay */ bool overlay_window_stack_remove(OverlayWindow *overlay_window, bool animated); /** * @brief Get the next \ref Window available that has a \ref ClickConfigProvider - * + * * @return the pointer to the \ref Window with a click provider - */ + */ Window *overlay_window_get_next_window_with_click_config(void); void overlay_window_post_event(uint8_t command, void *data, DestroyEventProc destroy_callback); diff --git a/rcore/resource.c b/rcore/resource.c index 0bcf1de5..55593614 100644 --- a/rcore/resource.c +++ b/rcore/resource.c @@ -8,7 +8,7 @@ #include "rebbleos.h" #include "platform.h" #include "flash.h" - +#include "rect.h" /* Configure Logging */ #define MODULE_NAME "res" diff --git a/rwatch/event/battery_state_service.c b/rwatch/event/battery_state_service.c index 5088bf56..61b72f85 100644 --- a/rwatch/event/battery_state_service.c +++ b/rwatch/event/battery_state_service.c @@ -8,6 +8,7 @@ #include "librebble.h" #include "ngfxwrap.h" #include "battery_state_service.h" +#include "power.h" static BatteryStateHandler _state_handler; diff --git a/rwatch/event/connection_service.c b/rwatch/event/connection_service.c index 7b3cf21e..8820d928 100644 --- a/rwatch/event/connection_service.c +++ b/rwatch/event/connection_service.c @@ -5,9 +5,8 @@ */ #include "librebble.h" +#include "rebble_util.h" #include "node_list.h" -#include "event_service.h" -#include "event_service.h" #include "connection_service.h" @@ -15,7 +14,7 @@ static void _connection_service_cb(EventServiceCommand command, void *data, void { /* context contains the handlers */ ConnectionHandlers *handlers = (ConnectionHandlers *)context; - + if (handlers->pebble_app_connection_handler) handlers->pebble_app_connection_handler((uint32_t)data); } @@ -41,7 +40,7 @@ void connection_service_subscribe(ConnectionHandlers conn_handlers) if (handlers->pebblekit_connection_handler) MK_THUMB_CB(handlers->pebblekit_connection_handler); - + event_service_subscribe_with_context(EventServiceCommandConnectionService, _connection_service_cb, handlers); } diff --git a/rwatch/graphics/font_file.c b/rwatch/graphics/font_file.c index ecb53b21..6099c085 100644 --- a/rwatch/graphics/font_file.c +++ b/rwatch/graphics/font_file.c @@ -5,7 +5,7 @@ uint8_t n_graphics_font_get_line_height(struct file *font) { struct fd fd; n_GFontInfo info; - + /* XXX: cache this */ fs_open(&fd, font); fs_read(&fd, &info, sizeof(info)); @@ -16,17 +16,16 @@ n_GGlyphInfo * n_graphics_font_get_glyph_info(struct file *font, uint32_t codepo struct fd fd; n_GFontInfo info; n_GGlyphInfo pglyph; - + n_GGlyphInfo *cglyph = fonts_glyphcache_get(font, codepoint); if (cglyph) { return cglyph; } - + /* XXX: cache this */ fs_open(&fd, font); fs_read(&fd, &info, sizeof(info)); - uint8_t * data; uint8_t hash_table_size = 255, codepoint_bytes = 4, features = 0; switch (info.version) { case 1: @@ -56,7 +55,7 @@ n_GGlyphInfo * n_graphics_font_get_glyph_info(struct file *font, uint32_t codepo /* Read the codepoint from the hash table ... */ fs_seek(&fd, (codepoint % hash_table_size) * sizeof(n_GFontHashTableEntry), FS_SEEK_CUR); - + n_GFontHashTableEntry hash_data; fs_read(&fd, &hash_data, sizeof(hash_data)); @@ -68,7 +67,7 @@ n_GGlyphInfo * n_graphics_font_get_glyph_info(struct file *font, uint32_t codepo fs_seek(&fd, offset_table_item_length * info.glyph_amount + 4, FS_SEEK_CUR); goto readglyph; } - + /* It exists, so we find it in the offset table. */ fs_seek(&fd, loc + hash_data.offset_table_offset, FS_SEEK_SET); uint8_t offset_entry[8]; /* 4 bytes max for codepoint, 4 bytes max for glyph offset */ @@ -102,11 +101,11 @@ n_GGlyphInfo * n_graphics_font_get_glyph_info(struct file *font, uint32_t codepo fs_read(&fd, &pglyph, sizeof(pglyph)); int gbits = pglyph.height * pglyph.width; int gbytes = (gbits + 7) / 8; - + n_GGlyphInfo *glyph = malloc(sizeof(pglyph) + gbytes); memcpy(glyph, &pglyph, sizeof(pglyph)); fs_read(&fd, glyph + 1, gbytes); - + fonts_glyphcache_put(font, codepoint, glyph); return glyph; diff --git a/rwatch/graphics/gbitmap.h b/rwatch/graphics/gbitmap.h index 71fef970..fa10c154 100644 --- a/rwatch/graphics/gbitmap.h +++ b/rwatch/graphics/gbitmap.h @@ -7,6 +7,8 @@ */ #include "types.h" +#include "context.h" +#include "text.h" #include "pebble_defines.h" #include "color.h" #include "upng.h" diff --git a/rwatch/input/click_config.c b/rwatch/input/click_config.c index 0e1ff649..5d5498e7 100644 --- a/rwatch/input/click_config.c +++ b/rwatch/input/click_config.c @@ -4,38 +4,38 @@ // * // * Author: Barry Carter // */ -// +// // #include "librebble.h" // #include "click_config.h" -// +// // typedef struct ButtonHolder { // ButtonId button_id; // ClickConfig click_config; // } ButtonHolder; -// +// // // we only have 4 buttons, so we can get away with a quick array lookup // static ButtonHolder click_config[NUM_BUTTONS]; -// +// // void window_single_click_subscribe(ButtonId button_id, ClickHandler handler) // { // click_config[button_id].click.handler = handler; // click_config[button_id].click.repeat_interval_ms = 0; // } -// +// // void window_single_repeating_click_subscribe(ButtonId button_id, uint16_t repeat_interval_ms, ClickHandler handler); // void window_multi_click_subscribe(ButtonId button_id, uint8_t min_clicks, uint8_t max_clicks, uint16_t timeout, bool last_click_only, ClickHandler handler); // void window_long_click_subscribe(ButtonId button_id, uint16_t delay_ms, ClickHandler down_handler, ClickHandler up_handler); // void window_raw_click_subscribe(ButtonId button_id, ClickHandler down_handler, ClickHandler up_handler, void * context); -// +// // /* // void window_invoke_single_click_cb(Window *window) // { // if (window == null || window->click_config_provider == null) // return; -// +// // window->click_config_provider(window); // } -// +// // // when a button is pressed, it proxies to here // void click_config_trigger(ButtonId button_id, bool up) // { @@ -43,13 +43,13 @@ // { // if (click_config[i].click.handler && up == false) // click_config[i].click.handler(context); -// +// // if (click_config[i].multi_click.handler) // } // } -// -// +// +// // void click_config_add(ButtonId button_id, ClickConfig click_config) // { -// +// // }*/ diff --git a/rwatch/input/click_config.h b/rwatch/input/click_config.h index 5172e990..3ac2bc9e 100644 --- a/rwatch/input/click_config.h +++ b/rwatch/input/click_config.h @@ -6,10 +6,8 @@ * Author: Barry Carter */ -#include "layer.h" #include "platform.h" #include "pebble_defines.h" -#include "gbitmap.h" /* XXX: move this to buttons.h so we don't have to depend on platform.h (ick) here */ typedef enum ButtonId @@ -22,9 +20,6 @@ typedef enum ButtonId } ButtonId; -struct Layer; -struct GRect; - typedef void *ClickRecognizerRef; typedef void (*ClickHandler)(ClickRecognizerRef recognizer, void *context); @@ -64,28 +59,3 @@ uint8_t click_number_of_clicks_counted(ClickRecognizerRef recognizer); ButtonId click_recognizer_get_button_id(ClickRecognizerRef recognizer); bool click_recognizer_is_repeating(ClickRecognizerRef recognizer); -// TODO move me - - -typedef struct GColourPair -{ - GColor foreground; - GColor background; -} GColourPair; - -typedef struct ContentIndicatorConfig -{ - Layer *layer; - bool times_out; - GAlign alignment; - GColourPair colors; -} ContentIndicatorConfig; - -typedef struct ContentIndicator ContentIndicator; - -typedef enum ContentIndicatorDirection -{ - ContentIndicatorDirectionUp, - ContentIndicatorDirectionDown, - NumContentIndicatorDirections -} ContentIndicatorDirection; diff --git a/rwatch/pebble.h b/rwatch/pebble.h index e655e65d..cc4f5543 100644 --- a/rwatch/pebble.h +++ b/rwatch/pebble.h @@ -6,17 +6,17 @@ * Author: Barry Carter */ -#include "FreeRTOS.h" +#include #include #include #include #include #include #include +#include "FreeRTOS.h" #include "rebble_memory.h" #include "log.h" #include "resource.h" -#include #include "platform_config.h" // tell neographics we are using it as our core @@ -28,18 +28,14 @@ #define TRIG_MAX_RATIO 0xffff #define TRIG_MAX_ANGLE 0x10000 -struct n_GRect; - +#include "types/rect.h" #include "graphics_reshandle.h" #include "graphics_resource.h" - -#include "gbitmap.h" +#include "pebble_defines.h" int32_t sin_lookup(int32_t angle); int32_t cos_lookup(int32_t angle); - - //! Represents insets for four sides. Negative values mean a side extends. //! @see \ref grect_inset typedef struct { diff --git a/rwatch/pebble_defines.h b/rwatch/pebble_defines.h index 9c5a8ffa..7e72c1d5 100755 --- a/rwatch/pebble_defines.h +++ b/rwatch/pebble_defines.h @@ -171,7 +171,5 @@ #define GColorBlack n_GColorBlack #define GColorClear n_GColorClear - #define GCornerNone n_GCornerNone -#include "gbitmap.h" diff --git a/rwatch/ui/animation/animation.c b/rwatch/ui/animation/animation.c index 02620831..304d5da9 100644 --- a/rwatch/ui/animation/animation.c +++ b/rwatch/ui/animation/animation.c @@ -39,6 +39,7 @@ #include "appmanager.h" #include "FreeRTOS.h" #include "animation.h" +#include "rebble_util.h" /* Configure Logging */ #define MODULE_NAME "anim" diff --git a/rwatch/ui/animation/animation.h b/rwatch/ui/animation/animation.h index 8967f252..9c9e3963 100644 --- a/rwatch/ui/animation/animation.h +++ b/rwatch/ui/animation/animation.h @@ -8,7 +8,7 @@ #include "FreeRTOS.h" -#include "librebble.h" +//#include "librebble.h" #include "point.h" #include "rect.h" #include "size.h" diff --git a/rwatch/ui/layer/bitmap_layer.h b/rwatch/ui/layer/bitmap_layer.h index dbb6b4c9..57ad444f 100644 --- a/rwatch/ui/layer/bitmap_layer.h +++ b/rwatch/ui/layer/bitmap_layer.h @@ -6,15 +6,16 @@ * Author: Barry Carter */ -#include "point.h" -#include "rect.h" -#include "size.h" -#include "gbitmap.h" +// neographics includes +#include "types/point.h" +#include "types/rect.h" +#include "types/size.h" -struct Window; -struct Layer; -struct BitmapLayer; +// rwatch includes +#include "graphics/gbitmap.h" +#include "layer/layer.h" +struct Window; // TODO in neogfx? diff --git a/rwatch/ui/layer/content_indicator.h b/rwatch/ui/layer/content_indicator.h new file mode 100644 index 00000000..05d4e345 --- /dev/null +++ b/rwatch/ui/layer/content_indicator.h @@ -0,0 +1,28 @@ +#pragma once + +#include "types/color.h" +#include "layer/layer.h" +#include "pebble_defines.h" + +typedef struct GColourPair +{ + GColor foreground; + GColor background; +} GColourPair; + +typedef struct ContentIndicatorConfig +{ + struct Layer *layer; + bool times_out; + GAlign alignment; + GColourPair colors; +} ContentIndicatorConfig; + +typedef struct ContentIndicator ContentIndicator; + +typedef enum ContentIndicatorDirection +{ + ContentIndicatorDirectionUp, + ContentIndicatorDirectionDown, + NumContentIndicatorDirections +} ContentIndicatorDirection; diff --git a/rwatch/ui/layer/layer.h b/rwatch/ui/layer/layer.h index f0c15c6d..3a46720e 100644 --- a/rwatch/ui/layer/layer.h +++ b/rwatch/ui/layer/layer.h @@ -9,8 +9,10 @@ #include "point.h" #include "rect.h" #include "size.h" +#include "window.h" + +#include "pebble_defines.h" -struct Window; struct Layer; // Callback for the layer drawing @@ -24,7 +26,7 @@ typedef struct Layer struct Layer *sibling; struct Layer *parent; void *container; // pointer to parent type, if any. i.e. a textlayer - struct Window *window; + Window *window; GRect bounds; GRect frame; bool clip; diff --git a/rwatch/ui/layer/menu_layer.h b/rwatch/ui/layer/menu_layer.h index 1afc0b7b..14950794 100644 --- a/rwatch/ui/layer/menu_layer.h +++ b/rwatch/ui/layer/menu_layer.h @@ -5,6 +5,10 @@ * RebbleOS */ +#include "scroll_layer.h" +#include "context.h" + +#include "pebble_defines.h" void menu_cell_basic_draw(GContext *ctx, const Layer *layer, const char *title, const char *subtitle, GBitmap *icon); diff --git a/rwatch/ui/layer/scroll_layer.h b/rwatch/ui/layer/scroll_layer.h index 5081bdec..1083506f 100644 --- a/rwatch/ui/layer/scroll_layer.h +++ b/rwatch/ui/layer/scroll_layer.h @@ -6,12 +6,13 @@ * Author: Barry Carter */ -#include "librebble.h" +//#include "librebble.h" #include "point.h" #include "rect.h" #include "size.h" #include "animation.h" #include "click_config.h" +#include "content_indicator.h" struct ScrollLayer; diff --git a/rwatch/ui/notifications/mini_message.c b/rwatch/ui/notifications/mini_message.c index 98caf679..d16b900e 100644 --- a/rwatch/ui/notifications/mini_message.c +++ b/rwatch/ui/notifications/mini_message.c @@ -8,6 +8,7 @@ #include "protocol_notification.h" #include "notification_manager.h" #include "platform_res.h" +#include "window.h" static void _minimsg_window_load(Window *window); static void _minimsg_window_unload(Window *window); diff --git a/rwatch/ui/window.h b/rwatch/ui/window.h index 925ea252..738fd079 100644 --- a/rwatch/ui/window.h +++ b/rwatch/ui/window.h @@ -9,11 +9,16 @@ #include #include "point.h" +#include "color.h" #include "rect.h" #include "size.h" #include "node_list.h" +#include "graphics/gbitmap.h" +#include "input/click_config.h" struct Layer; +struct Window; + typedef void (*WindowHandler)(struct Window *window); typedef struct WindowHandlers @@ -33,9 +38,8 @@ typedef enum WindowLoadState { typedef struct window_node window_node; -typedef struct Window -{ - Layer *root_layer; +typedef struct Window { + struct Layer *root_layer; const GBitmap *status_bar_icon; //WindowInputHandlers input_handlers; WindowHandlers window_handlers; @@ -65,7 +69,7 @@ void window_set_click_config_provider_with_context(Window *window, ClickConfigPr ClickConfigProvider window_get_click_config_provider(const Window *window); void *window_get_click_config_context(Window *window); void window_set_window_handlers(Window *window, WindowHandlers handlers); -Layer *window_get_root_layer(Window *window); +struct Layer *window_get_root_layer(Window *window); void window_set_background_color(Window *window, GColor background_color); bool window_is_loaded(Window *window); void window_set_user_data(Window *window, void *data);