Browse Source

Reworking menu

v1
Adam PIppin 3 years ago
parent
commit
261afab464
  1. 5
      watchos/Module_Input.cpp
  2. 11
      watchos/Module_Menu.cpp
  3. 25
      watchos/Module_Menu.h
  4. 47
      watchos/Module_Power.cpp
  5. 12
      watchos/Module_Power.h
  6. 119
      watchos/Module_UI.cpp
  7. 6
      watchos/Module_UI.h
  8. 9
      watchos/Task_Clock.cpp
  9. 312
      watchos/Task_Menu.cpp
  10. 2
      watchos/__vm/Compile.vmps.xml
  11. 2
      watchos/__vm/Upload.vmps.xml
  12. 37
      watchos/watchos.ino
  13. 21
      watchos/watchos_consts.h

5
watchos/Module_Input.cpp

@ -24,12 +24,15 @@ Module_Input::Module_Input()
m_button[0]->button = MODULE_INPUT_BUTTON_BACK;
m_button[0]->pin = HW_BUTTON_TL;
m_button[0]->mask = HW_BUTTON_TL_MASK;
m_button[1]->button = MODULE_INPUT_BUTTON_MENU;
m_button[1]->button = MODULE_INPUT_BUTTON_OK;
m_button[1]->pin = HW_BUTTON_BL;
m_button[1]->mask = HW_BUTTON_BL_MASK;
m_button[2]->button = MODULE_INPUT_BUTTON_UP;
m_button[2]->pin = HW_BUTTON_TR;
m_button[2]->mask = HW_BUTTON_TR_MASK;
m_button[3]->button = MODULE_INPUT_BUTTON_DOWN;
m_button[3]->pin = HW_BUTTON_BR;
m_button[3]->mask = HW_BUTTON_BR_MASK;

11
watchos/Module_Menu.cpp

@ -0,0 +1,11 @@
#include "Module_Menu.h"
#define MENU_EAT_OFFSET 3
// Maximum number of items any menu can contain
#define MODULE_MENU_MAX_OPTIONS 16
// How many menu items to show on screen at once
#define MODULE_MENU_SHOW_OPTIONS 8
// How long menu labels can be
#define MODULE_MENU_MAX_OPTION_LENGTH 15

25
watchos/Module_Menu.h

@ -0,0 +1,25 @@
#ifndef MODULE_MENU_H
#define MODULE_MENU_H
#include "watchos.h"
struct MenuItem;
class Module_Menu : public Module
{
ButtonState* m_button[MODULE_INPUT_BUTTONS];
void poll();
public:
Module_Input();
void initialize();
void suspend();
int getId();
void tick();
bool isAnyPressed();
bool isPressed(byte button);
};
#endif

47
watchos/Module_Power.cpp

@ -9,7 +9,8 @@ Module_Power::Module_Power()
{
module_input = (Module_Input*)Kernel::get()->getModule(MODULE_INPUT);
m_last_tick = 0;
m_accumulator = 0;
m_light_sleep_accumulator = 0;
m_deep_sleep_accumulator = 0;
switch (esp_sleep_get_wakeup_cause())
{
@ -40,25 +41,43 @@ int Module_Power::getId()
return MODULE_POWER;
}
void Module_Power::disableSleep()
void Module_Power::disableLightSleep()
{
m_sleep_enabled = false;
m_light_sleep_enabled = false;
}
void Module_Power::enableSleep()
void Module_Power::enableLightSleep()
{
m_sleep_enabled = true;
m_light_sleep_enabled = true;
}
void Module_Power::disableDeepSleep()
{
m_deep_sleep_enabled = false;
}
void Module_Power::enableDeepSleep()
{
m_deep_sleep_enabled = true;
}
void Module_Power::tick()
{
if (m_last_tick == 0)
{
m_accumulator = 0;
m_deep_sleep_accumulator = 0;
m_light_sleep_accumulator = 0;
}
else if (m_sleep_enabled)
else
{
m_accumulator += millis() - m_last_tick;
if (m_light_sleep_enabled)
{
m_light_sleep_accumulator += millis() - m_last_tick;
}
if (m_deep_sleep_enabled)
{
m_deep_sleep_accumulator += millis() - m_last_tick;
}
}
m_last_tick = millis();
@ -67,13 +86,15 @@ void Module_Power::tick()
// In case we woke up because of RTC/etc, but have since received a button press
m_light_sleep_delay = MODULE_POWER_INTERACTIVE_LIGHT_SLEEP_DELAY;
m_deep_sleep_delay = MODULE_POWER_INTERACTIVE_DEEP_SLEEP_DELAY;
m_accumulator = 0;
m_light_sleep_accumulator = 0;
m_deep_sleep_accumulator = 0;
}
if (m_accumulator > m_deep_sleep_delay)
if (m_deep_sleep_accumulator > m_deep_sleep_delay)
{
Kernel::debug("Going into deep sleep");
m_accumulator = 0;
m_light_sleep_accumulator = 0;
m_deep_sleep_accumulator = 0;
Kernel::get()->suspend();
@ -84,12 +105,12 @@ void Module_Power::tick()
esp_sleep_enable_ext1_wakeup(HW_BUTTON_MASK, ESP_EXT1_WAKEUP_ANY_HIGH);
esp_deep_sleep_start();
}
else if (m_accumulator > m_light_sleep_delay)
else if (m_light_sleep_accumulator > m_light_sleep_delay)
{
Kernel::debug("Going into light sleep");
// If nothing else happens, wake up when it's time to hibernate.
esp_sleep_enable_timer_wakeup((m_deep_sleep_delay * 1000) - m_accumulator);
esp_sleep_enable_timer_wakeup((m_deep_sleep_delay - m_deep_sleep_accumulator) * 1000);
// Wake up if the RTC fires
esp_sleep_enable_ext0_wakeup(HW_RTC, 0);
// Wake up if any button presses

12
watchos/Module_Power.h

@ -7,9 +7,11 @@ class Module_Power : public Module
{
int m_light_sleep_delay = 0;
int m_deep_sleep_delay = 0;
int m_accumulator = 0;
int m_deep_sleep_accumulator = 0;
int m_light_sleep_accumulator = 0;
unsigned long m_last_tick;
bool m_sleep_enabled = true;
bool m_light_sleep_enabled = true;
bool m_deep_sleep_enabled = true;
public:
Module_Power();
@ -17,8 +19,10 @@ public:
void suspend();
int getId();
void tick();
void disableSleep();
void enableSleep();
void disableLightSleep();
void enableLightSleep();
void disableDeepSleep();
void enableDeepSleep();
};
#endif

119
watchos/Module_UI.cpp

@ -2,6 +2,7 @@
#include "watchos_hw.h"
#include "Module_UI.h"
#include "Module_Power.h"
#include "Module_EAT.h"
#include "Task.h"
#include <GxEPD2_BW.h>
@ -9,6 +10,7 @@
GxEPD2_BW<GxEPD2_154_D67, GxEPD2_154_D67::HEIGHT> gfx = GxEPD2_154_D67(HW_DISPLAY_CS, HW_DISPLAY_DC, HW_DISPLAY_RESET, HW_DISPLAY_BUSY);
Module_UI* module_ui;
Module_Power* module_power;
Module_EAT* module_eat;
TaskHandle_t draw_task;
struct UI_Window
@ -41,6 +43,21 @@ Module_UI::Module_UI()
createWindow(-1, 0);
module_power = (Module_Power*)Kernel::get()->getModule(MODULE_POWER);
module_eat = (Module_EAT*)Kernel::get()->getModule(MODULE_EAT);
char msg[255];
if (module_eat->allocate(MODULE_UI, 1))
{
sprintf(msg, "Wrote default root window: %d", m_root_window);
Kernel::debug(msg);
module_eat->write(MODULE_UI, 0, 0);
}
else
{
m_root_window = module_eat->read(MODULE_UI, 0);
sprintf(msg, "Read root window: %d", m_root_window);
Kernel::debug(msg);
}
}
void Module_UI::initialize()
@ -50,6 +67,7 @@ void Module_UI::initialize()
gfx.fillScreen(COLOUR_SECONDARY);
gfx.display(true);
m_redraw = true;
m_initialized = true;
}
void Module_UI::tick()
@ -59,6 +77,12 @@ void Module_UI::tick()
void Module_UI::suspend()
{
if (m_initialized)
gfx.hibernate();
module_eat->write(MODULE_UI, 0, (byte)m_root_window);
char msg[255];
sprintf(msg, "Wrote root window: %d", m_root_window);
Kernel::debug(msg);
}
int Module_UI::getId()
@ -143,6 +167,18 @@ int Module_UI::createWindow(int parent, int zorder)
Kernel::panic("Exceeded MODULE_UI_MAX_WINDOWS!");
}
void Module_UI::setRootWindow(int hwnd)
{
m_root_window = hwnd;
m_dirty = true;
m_redraw = true;
}
int Module_UI::getRootWindow()
{
return m_root_window;
}
void Module_UI::setLayoutMode(int hwnd, byte layout_mode)
{
for (int i = 0; i < MODULE_UI_MAX_WINDOWS; i++)
@ -158,31 +194,36 @@ void Module_UI::setLayoutMode(int hwnd, byte layout_mode)
void Module_UI::setDirty(int hwnd)
{
// This sort of doesn't work beyond the simplest of cases.
// If we mark all parent windows as dirty but have them redraw their entire window, then they'll overwrite
// sibling windows, so currently we just end up losing half the screen. Or we redraw siblings and their children
// and... we're basically back in the same spot.
UI_Window* window = nullptr;
for (int i = 0; i < MODULE_UI_MAX_WINDOWS; i++)
{
if (m_window[i]->hwnd == hwnd)
if (m_window[i] != nullptr && m_window[i]->hwnd == hwnd)
{
window = m_window[i];
break;
}
}
if (window == nullptr)
{
char msg[255];
sprintf(msg, "trying to setDirty invalid hwnd %d", hwnd);
Kernel::panic(msg);
}
window->dirty = true;
/*
// If this window is underneath the root window it will actually be drawn, so we should actually call draw
// the next time draw() is called
while (window != nullptr)
{
window->dirty = true;
if (window->hwnd == m_root_window)
{
m_dirty = true;
break;
}
window = window->parent;
}
*/
m_dirty = true;
}
void Module_UI::draw(bool spawn_task)
@ -190,27 +231,54 @@ void Module_UI::draw(bool spawn_task)
if (spawn_task && (m_dirty || m_redraw) && draw_task == nullptr)
{
m_dirty = false;
m_redraw = false;
module_ui = this;
xTaskCreatePinnedToCore(draw_wrapper, "Draw", MODULE_UI_MULTICORE_STACK_SIZE, NULL, 0, &draw_task, 0);
}
else if (!spawn_task)
{
module_power->disableSleep();
getGfx()->init(0, false);
draw(0, 0, 0, DISPLAY_WIDTH, DISPLAY_HEIGHT);
// TODO: optimize, if areas covering the whole screen need drawing, just make one call
//getGfx()->display(true);
module_power->disableDeepSleep();
module_power->disableLightSleep();
if (!m_initialized)
{
m_initialized = true;
gfx.init(0, false);
}
draw(m_root_window, 0, 0, DISPLAY_WIDTH, DISPLAY_HEIGHT);
m_redraw = false;
// Check if we need a whole screen draw
bool whole_screen = false;
for (int i = 0; i < MODULE_UI_MAX_WINDOWS; i++)
{
if (m_window[i] != nullptr && m_window[i]->needs_draw)
if (m_window[i] != nullptr && m_window[i]->needs_draw &&
m_window[i]->draw_x == 0 && m_window[i]->draw_y == 0 &&
m_window[i]->draw_w == DISPLAY_WIDTH && m_window[i]->draw_h == DISPLAY_HEIGHT)
{
getGfx()->displayWindow(m_window[i]->draw_x, m_window[i]->draw_y, m_window[i]->draw_w, m_window[i]->draw_h);
whole_screen = true;
break;
}
}
getGfx()->hibernate();
delay(500);
module_power->enableSleep();
if (whole_screen)
{
getGfx()->display(true);
}
else
{
for (int i = 0; i < MODULE_UI_MAX_WINDOWS; i++)
{
if (m_window[i] != nullptr && m_window[i]->needs_draw)
{
getGfx()->displayWindow(m_window[i]->draw_x, m_window[i]->draw_y, m_window[i]->draw_w, m_window[i]->draw_h);
m_window[i]->needs_draw = false;
}
}
}
module_power->enableLightSleep();
module_power->enableDeepSleep();
}
}
@ -227,17 +295,14 @@ void Module_UI::draw(int hwnd, int x, int y, int width, int height)
}
if (window == nullptr)
{
Kernel::panic("Trying to draw non-existent window!");
char msg[255];
sprintf(msg, "Trying to draw non-existent window: %d", hwnd);
Kernel::panic(msg);
}
char msg[255];
// Draw window if applicable
if (window->dirty || m_redraw)
{
sprintf(msg, "Drawing hwnd %d", window->hwnd);
Kernel::debug(msg);
bool did_draw = false;
window->dirty = false;
if (window->callback != nullptr)

6
watchos/Module_UI.h

@ -12,6 +12,8 @@ class Module_UI : public Module
UI_Window* m_window[MODULE_UI_MAX_WINDOWS];
int m_nextHwnd = 0;
bool m_dirty = false, m_redraw = false;
int m_root_window = 0;
bool m_initialized = false;
public:
@ -27,8 +29,12 @@ public:
void draw(bool spawn_task = MODULE_UI_MULTICORE_RENDERING);
void draw(int hwnd, int x, int y, int width, int height);
GxEPD2_GFX* getGfx();
void setLayoutMode(int hwnd, byte layout_mode);
void setDirty(int hwnd);
void setRootWindow(int hwnd);
int getRootWindow();
};
#endif

9
watchos/Task_Clock.cpp

@ -10,6 +10,7 @@ private:
int hwnd;
Module_UI* ui;
byte hour, minute;
bool read_rtc = false;
public:
@ -63,6 +64,14 @@ public:
void draw(int hwnd, int x, int y, int width, int height)
{
if (!read_rtc)
{
Module_RTC* rtc = (Module_RTC*)Kernel::get()->getModule(MODULE_RTC);
hour = rtc->getHour();
minute = rtc->getMinute();
read_rtc = true;
}
char time[6];
sprintf(time, "%02d:%02d", hour, minute);

312
watchos/Task_Menu.cpp

@ -0,0 +1,312 @@
#include "watchos.h"
#include "Module_EAT.h"
#include "Module_UI.h"
#include "watchos_fonts.h"
#include "Events.h"
struct MenuItem
{
byte id;
char label[MENU_MAX_OPTION_LENGTH];
int window_hwnd;
};
/*
* EAT Layout
* byte selected_idx
* byte view_offset
*
* each entry:
* byte id
* char[31] label
*/
class Task_Menu : public Task
{
private:
int m_hwnd;
Module_UI* ui;
Module_EAT* eat;
MenuItem* m_item[MENU_MAX_OPTIONS];
int m_hwnd_menu_option[MENU_SHOW_OPTIONS];
int m_prev_root_hwnd;
int m_view_offset = 0;
int m_selected = 0;
bool m_result_ok = false;
bool m_result_back = false;
public:
Task_Menu()
{
ui = (Module_UI*)Kernel::get()->getModule(MODULE_UI);
m_hwnd = ui->createWindow((Task*)this, -1, 0);
ui->setLayoutMode(m_hwnd, MODULE_UI_LAYOUT_MODE_SPLIT_HORIZONTAL);
for (int i = 0; i < MENU_SHOW_OPTIONS; i++)
{
m_hwnd_menu_option[i] = ui->createWindow((Task*)this, m_hwnd, 0);
}
for (int i = 0; i < MENU_MAX_OPTIONS; i++)
{
m_item[i] = nullptr;
}
eat = (Module_EAT*)Kernel::get()->getModule(MODULE_EAT);
int item_length = (1 + MENU_MAX_OPTION_LENGTH);
if (!eat->allocate(MENU_EAT_ID, MENU_EAT_OFFSET + item_length * MENU_MAX_OPTIONS))
{
m_selected = eat->read(MENU_EAT_ID, 0);
m_view_offset = eat->read(MENU_EAT_ID, 1);
m_prev_root_hwnd = eat->read(MENU_EAT_ID, 2);
byte id;
for (int i = 0; i < MENU_MAX_OPTIONS; i++)
{
id = eat->read(MENU_EAT_ID, MENU_EAT_OFFSET + (i * item_length));
if (id != 0xFF)
{
m_item[i] = new MenuItem();
m_item[i]->id = id;
for (int j = 0; j < MENU_MAX_OPTION_LENGTH; j++)
{
m_item[i]->label[j] = (char)eat->read(MENU_EAT_ID, MENU_EAT_OFFSET + (i * item_length) + j + 1);
if (m_item[i]->label[j] == '\0')
{
break;
}
}
}
else
{
break;
}
}
}
}
void initialize()
{
ui->setDirty(m_hwnd);
for (int i = 0; i < MENU_SHOW_OPTIONS; i++)
{
ui->setDirty(m_hwnd_menu_option[i]);
}
}
void tick(unsigned int signal)
{
Event* e;
int prev_selected = -1;
byte scroll_direction = 128; // not const'ing this... 128=middle, 0=up, 255=down
while (this->hasEvent())
{
e = this->popEvent();
if (ui->getRootWindow() != m_hwnd) continue;
if (e->source == MODULE_INPUT && e->event == MODULE_INPUT_EVENT_PRESS)
{
if ((e->param1 & MODULE_INPUT_BUTTON_UP) != 0)
{
Kernel::debug("Scroll up");
prev_selected = m_selected;
m_selected -= 1;
if (m_selected < 0)
m_selected = 0;
else
scroll_direction = 0;
}
if ((e->param1 & MODULE_INPUT_BUTTON_DOWN) != 0)
{
Kernel::debug("Scroll down");
prev_selected = m_selected;
m_selected += 1;
if (m_item[m_selected] == nullptr)
m_selected -= 1;
else
scroll_direction = 255;
}
if ((e->param1 & MODULE_INPUT_BUTTON_OK) != 0)
{
Kernel::debug("OK");
hide();
m_result_ok = true;
return;
}
if ((e->param1 & MODULE_INPUT_BUTTON_BACK) != 0)
{
Kernel::debug("Back");
m_result_back = true;
return;
}
}
}
if (scroll_direction == 0 && m_selected < m_view_offset)
{
m_view_offset -= MENU_SHOW_OPTIONS;
if (m_view_offset < 0) m_view_offset = 0;
}
else if (scroll_direction == 255 && m_selected >= m_view_offset + MENU_SHOW_OPTIONS)
{
m_view_offset += MENU_SHOW_OPTIONS;
}
// if (scroll)
// elseif (dirty individual items)
// Drawing individual menu items is sloooow, let's just refresh everything.
/*
if (prev_selected >= 0 && m_selected != prev_selected)
{
if (prev_selected - m_view_offset >= 0 && prev_selected - m_view_offset < MENU_MAX_OPTIONS)
{
ui->setDirty(m_hwnd_menu_option[prev_selected - m_view_offset]);
sprintf(msg, "Marking dirty idx %d hwnd %d", prev_selected - m_view_offset, m_hwnd_menu_option[prev_selected - m_view_offset]);
Kernel::debug(msg);
}
if (m_selected - m_view_offset >= 0 && m_selected - m_view_offset < MENU_MAX_OPTIONS)
{
ui->setDirty(m_hwnd_menu_option[m_selected - m_view_offset]);
sprintf(msg, "Marking dirty idx %d hwnd %d", m_selected - m_view_offset, m_hwnd_menu_option[m_selected - m_view_offset]);
Kernel::debug(msg);
}
}
*/
if (prev_selected >= 0 && m_selected != prev_selected)
{
ui->setDirty(m_hwnd);
for (int i = 0; i < MENU_SHOW_OPTIONS; i++)
{
ui->setDirty(m_hwnd_menu_option[i]);
}
}
}
void suspend()
{
eat->write(MENU_EAT_ID, 0, (byte)m_selected);
eat->write(MENU_EAT_ID, 1, (byte)m_view_offset);
eat->write(MENU_EAT_ID, 2, (byte)m_prev_root_hwnd);
int item_length = (1 + MENU_MAX_OPTION_LENGTH);
for (int i = 0; i < MENU_MAX_OPTIONS; i++)
{
if (m_item[i] == nullptr)
{
eat->write(MENU_EAT_ID, MENU_EAT_OFFSET + (i * item_length), 0xFF);
}
else
{
eat->write(MENU_EAT_ID, MENU_EAT_OFFSET + (i * item_length), m_item[i]->id);
for (int j = 0; j < MENU_MAX_OPTION_LENGTH && m_item[i]->label[j] != '\0'; j++)
{
eat->write(MENU_EAT_ID, MENU_EAT_OFFSET + (i * item_length) + j + 1, (byte)(m_item[i]->label[j]));
}
}
}
}
void draw(int hwnd, int x, int y, int width, int height)
{
if (hwnd == m_hwnd)
{
// Root window
ui->getGfx()->fillRect(x, y, width, height, COLOUR_SECONDARY);
}
else
{
// Menu option
for (int i = 0; i < MENU_SHOW_OPTIONS; i++)
{
if (m_hwnd_menu_option[i] == hwnd)
{
int idx = m_view_offset + i;
if (m_item[idx] != nullptr)
{
ui->getGfx()->setFont(&FreeMono12pt7b);
if (idx == m_selected)
{
ui->getGfx()->fillRect(x, y, width, height, COLOUR_PRIMARY);
ui->getGfx()->setTextColor(COLOUR_SECONDARY);
}
else
{
ui->getGfx()->fillRect(x, y, width, height, COLOUR_SECONDARY);
ui->getGfx()->setTextColor(COLOUR_PRIMARY);
}
ui->getGfx()->setCursor(x, y + height - (int)((height - 12) / 2));
ui->getGfx()->print(m_item[idx]->label);
}
}
}
}
}
void addItem(byte id, char* label)
{
for (int i = 0; i < MENU_MAX_OPTIONS; i++)
{
if (m_item[i] == nullptr)
{
m_item[i] = new MenuItem();
m_item[i]->id = id;
strcpy(m_item[i]->label, label);
return;
}
}
Kernel::panic("Tried to add more options to menu than MENU_MAX_OPTIONS.");
}
void clear()
{
for (int i = 0; i < MENU_MAX_OPTIONS; i++)
{
if (m_item[i] != nullptr)
{
delete m_item[i];
m_item[i] = nullptr;
}
}
}
void show()
{
m_prev_root_hwnd = ui->getRootWindow();
ui->setRootWindow(m_hwnd);
}
void hide()
{
ui->setRootWindow(m_prev_root_hwnd);
m_prev_root_hwnd = NULL;
}
bool isSelected()
{
return m_result_ok;
}
bool isCancelled()
{
return m_result_back;
}
bool isDone()
{
return m_result_ok || m_result_back;
}
byte getSelectedId()
{
return m_item[m_selected]->id;
}
};

2
watchos/__vm/Compile.vmps.xml

File diff suppressed because one or more lines are too long

2
watchos/__vm/Upload.vmps.xml

File diff suppressed because one or more lines are too long

37
watchos/watchos.ino

@ -10,6 +10,7 @@
#include "Task_Clock.cpp"
#include "Task_Counter.cpp"
#include "Task_Battery.cpp"
#include "Task_Menu.cpp"
#include <GxEPD2_BW.h>
@ -33,6 +34,8 @@ void test_draw(int hwnd, int x, int y, int width, int height)
void setup()
{
bool is_reset = false;
Serial.begin(115200);
k = Kernel::get();
@ -45,6 +48,20 @@ void setup()
{
module_eat->reset();
}
switch (esp_sleep_get_wakeup_cause())
{
case ESP_SLEEP_WAKEUP_TIMER:
case ESP_SLEEP_WAKEUP_EXT0:
case ESP_SLEEP_WAKEUP_EXT1:
break;
default:
is_reset = true;
Kernel::debug("Resetting EAT");
module_eat->reset();
break;
}
// Register module with the kernel
k->registerModule(module_eat);
@ -68,6 +85,25 @@ void setup()
k->registerTask(new Task_Counter(bottom_hwnd));
k->registerTask(new Task_Battery(bottom_hwnd));
Task_Menu* tm = new Task_Menu();
if (is_reset)
{
tm->addItem(0, "First Option");
tm->addItem(1, "Second Option");
tm->addItem(2, "Third Option");
tm->addItem(3, "Fourth Option");
tm->addItem(4, "Fifth Option");
tm->addItem(5, "Sixth Option");
tm->addItem(7, "Seventh Option");
tm->addItem(8, "Eighth Option");
tm->addItem(9, "Ninth Option");
tm->addItem(10, "Tenth Option");
tm->addItem(11, "Eleventh Option");
tm->addItem(12, "Twelfth Option");
tm->show();
}
k->registerTask(tm);
// TODO: Figure out why we woke up
wakeup();
@ -75,6 +111,7 @@ void setup()
void loop()
{
//Kernel::debug("Tick");
k->tick();
Module_UI* ui = (Module_UI*)k->getModule(MODULE_UI);
ui->draw();

21
watchos/watchos_consts.h

@ -24,6 +24,9 @@
#define MODULE_RTC 0x04
#define MODULE_INPUT 0x08
#define MODULE_POWER 0x10
#define MODULE_MENU 0x20
#define MODULE_UNUSED_1 0x40
#define MODULE_UNUSED_2 0x80
//////////
// Events
@ -95,13 +98,14 @@
// Bitmask for input module events to signal which buttons are pressed
// and provide semantic meaning.
#define MODULE_INPUT_BUTTON_BACK 0x01
#define MODULE_INPUT_BUTTON_MENU 0x04
#define MODULE_INPUT_BUTTON_OK 0x04
#define MODULE_INPUT_BUTTON_UP 0x08
#define MODULE_INPUT_BUTTON_DOWN 0x10
// NOTE: The actual tie-in between hardware buttons and these semantic
// buttons is specified in Module_Input.cpp.
//////////
// Module - Power
@ -112,8 +116,8 @@
// When an interactive event occurs (e.g., button press) how long to
// wait before going back to sleep.
#define MODULE_POWER_INTERACTIVE_LIGHT_SLEEP_DELAY 100
#define MODULE_POWER_INTERACTIVE_DEEP_SLEEP_DELAY 3000
#define MODULE_POWER_INTERACTIVE_LIGHT_SLEEP_DELAY 100
#define MODULE_POWER_INTERACTIVE_DEEP_SLEEP_DELAY 3000
// The rationale behind this separation is that generally if someone's
// pressed _a_ button, there's a good chance they may follow up with
@ -122,4 +126,15 @@
// menu items (and putting wear on flash suspending and resuming, and
// adding delay to each press).
//////////
// Module - Menu
// Maximum number of items any menu can contain
#define MODULE_MENU_MAX_OPTIONS 16
// How many menu items to show on screen at once
#define MODULE_MENU_SHOW_OPTIONS 8
// How long menu labels can be
#define MODULE_MENU_MAX_OPTION_LENGTH 15
#endif
Loading…
Cancel
Save