Skip to content

Commit

Permalink
Added notifications for main menu
Browse files Browse the repository at this point in the history
A small confirmation pops up after an item in the main menu has been selected. Furthermore "Preheat bed" and "Preheat nozzle" commands have been added.
  • Loading branch information
schlotzz committed Dec 9, 2016
1 parent 8ae055b commit 7d7841b
Show file tree
Hide file tree
Showing 22 changed files with 339 additions and 26 deletions.
10 changes: 8 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"author": "pebble@schlotzz.com",
"author": "schlotzz / go4u.de Webdesign",
"dependencies": {
"pebble-clay": "^1.0.4"
},
Expand All @@ -24,6 +24,12 @@
"projectType": "native",
"resources": {
"media": [
{
"file": "data/pdc_notification.pdc",
"name": "NOTIFICATION_PDC",
"targetPlatforms": null,
"type": "raw"
},
{
"file": "images/icon_refresh.png",
"name": "REFRESH_ICON",
Expand Down Expand Up @@ -104,5 +110,5 @@
"watchface": false
}
},
"version": "1.1.0"
"version": "1.2.0"
}
Binary file added resources/data/pdc_notification.pdc
Binary file not shown.
1 change: 0 additions & 1 deletion src/c/app_glance.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@

#define APP_GLANCE_DEFAULT_TIMEOUT 30*60 // 30 minutes after last update


static int s_app_glance_timeout = APP_GLANCE_SLICE_NO_EXPIRATION;


Expand Down
8 changes: 7 additions & 1 deletion src/c/app_glance.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
// OctoWatch2
// A Pebble watch app for monitoring and basic controlling of 3D printers via Octoprint
//
// Licence: CC BY-SA 3.0, http://creativecommons.org/licenses/by-sa/3.0/
// Author: Dominik Scholz <[email protected]>, go4u.de Webdesign <[email protected]>

#pragma once
#include <pebble.h>

void app_glance_destroy(void);
//static void app_glance_update(AppGlanceReloadSession *, size_t, void *);
1 change: 0 additions & 1 deletion src/c/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
#include "messaging.h"
#include "app_glance.h"


// do init
static void init(void) {
window_main_init();
Expand Down
9 changes: 7 additions & 2 deletions src/c/messaging.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
// OctoWatch2
// A Pebble watch app for monitoring and basic controlling of 3D printers via Octoprint
//
// Licence: CC BY-SA 3.0, http://creativecommons.org/licenses/by-sa/3.0/
// Author: Dominik Scholz <[email protected]>, go4u.de Webdesign <[email protected]>

#pragma once
#include <pebble.h>

//static void messaging_inbox_received(DictionaryIterator *, void *);
//static void messaging_inbox_dropped(AppMessageResult, void *);
void messaging_outbox_send(const char *, const char *);
void messaging_init(void);
void messaging_destroy(void);
8 changes: 7 additions & 1 deletion src/c/printer.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
// OctoWatch2
// A Pebble watch app for monitoring and basic controlling of 3D printers via Octoprint
//
// Licence: CC BY-SA 3.0, http://creativecommons.org/licenses/by-sa/3.0/
// Author: Dominik Scholz <[email protected]>, go4u.de Webdesign <[email protected]>

#pragma once
#include <pebble.h>

enum PRINTERSTATE {
LOADING,
Expand All @@ -10,7 +17,6 @@ enum PRINTERSTATE {
ERROR
};


enum PRINTERSTATE printer_get_state(void);
void printer_set_state(enum PRINTERSTATE);
void printer_set_state_by_char(const char *);
Expand Down
2 changes: 1 addition & 1 deletion src/c/progress_layer.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
// Author: Dominik Scholz <[email protected]>, go4u.de Webdesign <[email protected]>

// progress_layer
// taken from https://github.com/pebble-examples/ui-patterns/ (MIT License)
// taken from https://github.com/pebble-examples/ui-patterns/
//
// Licence: The MIT License (MIT)
// Author: C-D-Lewis
Expand Down
10 changes: 7 additions & 3 deletions src/c/progress_layer.h
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
#pragma once
// OctoWatch2
// A Pebble watch app for monitoring and basic controlling of 3D printers via Octoprint
//
// Licence: CC BY-SA 3.0, http://creativecommons.org/licenses/by-sa/3.0/
// Author: Dominik Scholz <[email protected]>, go4u.de Webdesign <[email protected]>

#pragma once
#include <pebble.h>

typedef Layer ProgressLayer;

ProgressLayer* progress_layer_create(GRect frame);
void progress_layer_destroy(ProgressLayer* progress_layer);
void progress_layer_increment_progress(ProgressLayer* progress_layer, int16_t progress);
void progress_layer_set_progress(ProgressLayer* progress_layer, int16_t progress_percent);
void progress_layer_set_corner_radius(ProgressLayer* progress_layer, uint16_t corner_radius);
void progress_layer_set_foreground_color(ProgressLayer* progress_layer, GColor color);
void progress_layer_set_background_color(ProgressLayer* progress_layer, GColor color);
void progress_layer_set_background_color(ProgressLayer* progress_layer, GColor color);
8 changes: 7 additions & 1 deletion src/c/window_confirm.c
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
// OctoWatch2
// A Pebble watch app for monitoring and basic controlling of 3D printers via Octoprint
//
// Licence: CC BY-SA 3.0, http://creativecommons.org/licenses/by-sa/3.0/
// Author: Dominik Scholz <[email protected]>, go4u.de Webdesign <[email protected]>

#include <pebble.h>
#include "window_confirm.h"

Expand Down Expand Up @@ -37,7 +43,7 @@ static void window_main_actionbar_config(void *context) {
}


// render background layer
// render icon layer
static void window_main_draw_icon_layer(Layer *layer, GContext *context) {
GRect bounds = layer_get_bounds(layer);
const GEdgeInsets frame_insets = {
Expand Down
4 changes: 3 additions & 1 deletion src/c/window_confirm.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
// Author: Dominik Scholz <[email protected]>, go4u.de Webdesign <[email protected]>

#pragma once
#include <pebble.h>

void window_confirm_init(void);
void window_confirm_init_custom(const char *, GColor, void(*)(void));
void window_confirm_destroy(void);
void window_confirm_destroy(void);
12 changes: 7 additions & 5 deletions src/c/window_main.h
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
// OctoWatch2
// A Pebble watch app for monitoring and basic controlling of 3D printers via Octoprint
//
// Licence: CC BY-SA 3.0, http://creativecommons.org/licenses/by-sa/3.0/
// Author: Dominik Scholz <[email protected]>, go4u.de Webdesign <[email protected]>

#pragma once
#include <pebble.h>

//static void window_main_actionbar_up(ClickRecognizerRef, void *);
//static void window_main_actionbar_select(ClickRecognizerRef, void *);
//static void window_main_actionbar_down(ClickRecognizerRef, void *);
void window_main_actionbar_config(void *);
//static void window_main_load_handler(Window *);
//static void window_main_unload_handler(Window *);
void window_main_set_time_remaing_counter(const char *);
void window_main_set_filename(const char *);
void window_main_set_nozzle(const uint16_t, const uint16_t);
Expand Down
37 changes: 34 additions & 3 deletions src/c/window_menu.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,12 @@
#include <pebble.h>
#include "window_menu.h"
#include "window_confirm.h"
#include "window_message.h"
#include "messaging.h"

#define MENU_SECTIONS 3
#define MENU_FIRST_ITEMS 1
#define MENU_SECOND_ITEMS 4
#define MENU_SECOND_ITEMS 6
#define MENU_THIRD_ITEMS 2

static Window *s_window_main;
Expand All @@ -37,36 +38,56 @@ static void window_menu_confirm_cancel_printjob(int s, void *ctx) {

// preheat bed and nozzle
static void window_menu_preheat(int s, void *ctx) {
window_message_init_custom("Preheat", GColorOrange);
messaging_outbox_send("preheat", "");
}


// preheat bed
static void window_menu_preheat_bed(int s, void *ctx) {
window_message_init_custom("Preheat Bed", GColorOrange);
messaging_outbox_send("preheat", "bed");
}


// preheat nozzle
static void window_menu_preheat_nozzle(int s, void *ctx) {
window_message_init_custom("Preheat Nozzle", GColorOrange);
messaging_outbox_send("preheat", "nozzle");
}


// cooldown bed and nozzle
static void window_menu_cooldown(int s, void *ctx) {
window_message_init_custom("Cooldown", GColorCyan);
messaging_outbox_send("gcode", "M117 Cooldown...\nM140 S0\nM104 S0");
}


// turn fans on
static void window_menu_fans_on(int s, void *ctx) {
window_message_init_custom("Fans on", GColorGreen);
messaging_outbox_send("gcode", "M117 Fans on...\nM106 S255");
}


// turn fans off
static void window_menu_fans_off(int s, void *ctx) {
window_message_init_custom("Fans off", GColorGreen);
messaging_outbox_send("gcode", "M117 Fans off...\nM106 S0");
}


// home all axes
static void window_menu_home_axes(int s, void *ctx) {
window_message_init_custom("Homing", GColorMagenta);
messaging_outbox_send("gcode", "M117 Homing...\nG28");
}


// turn all motors off
static void window_menu_motors_off(int s, void *ctx) {
window_message_init_custom("Motors off", GColorVividViolet);
messaging_outbox_send("gcode", "M117 Motors off...\nM18");
}

Expand Down Expand Up @@ -96,16 +117,26 @@ static void window_menu_load_handler(Window *window) {
.callback = window_menu_preheat
};
s_menu_items_second[1] = (SimpleMenuItem) {
.title = "Preheat bed",
.subtitle = "Preheat bed only",
.callback = window_menu_preheat_bed
};
s_menu_items_second[2] = (SimpleMenuItem) {
.title = "Preheat nozzle",
.subtitle = "Preheat nozzle only",
.callback = window_menu_preheat_nozzle
};
s_menu_items_second[3] = (SimpleMenuItem) {
.title = "Cooldown",
.subtitle = "Cooldown nozzle and bed",
.callback = window_menu_cooldown
};
s_menu_items_second[2] = (SimpleMenuItem) {
s_menu_items_second[4] = (SimpleMenuItem) {
.title = "Fans on",
.subtitle = "Turn the fans on",
.callback = window_menu_fans_on
};
s_menu_items_second[3] = (SimpleMenuItem) {
s_menu_items_second[5] = (SimpleMenuItem) {
.title = "Fans off",
.subtitle = "Turn the fans off",
.callback = window_menu_fans_off
Expand Down
9 changes: 8 additions & 1 deletion src/c/window_menu.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
// OctoWatch2
// A Pebble watch app for monitoring and basic controlling of 3D printers via Octoprint
//
// Licence: CC BY-SA 3.0, http://creativecommons.org/licenses/by-sa/3.0/
// Author: Dominik Scholz <[email protected]>, go4u.de Webdesign <[email protected]>

#pragma once
#include <pebble.h>

void window_menu_init(void);
void window_menu_destroy(void);
void window_menu_destroy(void);
Loading

0 comments on commit 7d7841b

Please sign in to comment.