<commit_before>#include <pebble.h>
#define BUTTON_UP 1
#define BUTTON_SELECT 2
#define BUTTON_DOWN 3
#define DATA_KEY 4
#define KEY_BUTTON_EVENT 0

static Window *window;
static GBitmap *image;
static Layer *layer;

static void in_received_handler(DictionaryIterator *iter, void *context) 
{
    
}
/*


	*	Function to send a key press using a pre-agreed key
	
static void send_cmd(uint8_t cmd) {	//uint8_t is an unsigned 8-bit int (0 - 255)
	//Create a key-value pair
  Tuplet value = TupletInteger(DATA_KEY, cmd);
  
  //Construct the dictionary
  DictionaryIterator *iter;
  app_message_out_get(&iter);
  
  //If not constructed, do not send - return straight away
  if (iter == NULL)
    return;
  
  //Write the tuplet to the dictionary
  dict_write_tuplet(iter, &value);
  dict_write_end(iter);
  
  //Send the dictionary and release the buffer
  app_message_out_send();
  app_message_out_release();
}

*/

static void inbox_received_callback(DictionaryIterator *iterator, void *context) {
  APP_LOG(APP_LOG_LEVEL_INFO, "Message received!");
}

static void inbox_dropped_callback(AppMessageResult reason, void *context) {
  APP_LOG(APP_LOG_LEVEL_ERROR, "Message dropped!");
}

static void outbox_failed_callback(DictionaryIterator *iterator, AppMessageResult reason, void *context) {
  APP_LOG(APP_LOG_LEVEL_ERROR, "Outbox send failed!");
}

static void outbox_sent_callback(DictionaryIterator *iterator, void *context) {
  APP_LOG(APP_LOG_LEVEL_INFO, "Outbox send success!");
}

/*static void inbox_recieved_callback() {
	 // Get the first pair
  Tuple *t = dict_read_first(iterator);

  // Process all pairs present
  while(t != NULL) {
    // Process this pair's key
    switch (t->key) {
      case KEY_DATA:
        APP_LOG(APP_LOG_LEVEL_INFO, "KEY_DATA received with value %d", (int)t->value->int32);
        break;
    }

    // Get next pair, if any
    t = dict_read_next(iterator);
  }
};
*/

static void layer_update_callback(Layer *me, GContext* ctx) {
  // We make sure the dimensions of the GRect to draw into
  // are equal to the size of the bitmap--otherwise the image

  GRect bounds = image->bounds;

  graphics_draw_bitmap_in_rect(ctx, image, (GRect) { .origin = { 0, 0 }, .size = bounds.size });

}


static void window_load(Window *window) {
	// Init the layer for display the image
  Layer *window_layer = window_get_root_layer(window);
	//window_set_fullscreen(window, true);
  GRect bounds = layer_get_frame(window_layer);
  layer = layer_create(bounds);
  layer_set_update_proc(layer, layer_update_callback);
  layer_add_child(window_layer, layer);

	//Draws the Image
  image = gbitmap_create_with_resource(RESOURCE_ID_IMAGE_HOME);
	
}

void send_int(uint8_t key, uint8_t cmd)
{
    DictionaryIterator *iter;
    app_message_outbox_begin(&iter);
      
    Tuplet value = TupletInteger(key, cmd);
    dict_write_tuplet(iter, &value);
      
    app_message_outbox_send();
}

static void select_click_handler(ClickRecognizerRef recognizer, void *context) {
	send_int(KEY_BUTTON_EVENT, BUTTON_SELECT);
	gbitmap_destroy(image);
	layer_destroy(layer);
	// Init the layer for display the image
  Layer *window_layer = window_get_root_layer(window);
	//window_set_fullscreen(window, true);
  GRect bounds = layer_get_frame(window_layer);
  layer = layer_create(bounds);
  layer_set_update_proc(layer, layer_update_callback);
  layer_add_child(window_layer, layer);

	//Draws the Image
	image = gbitmap_create_with_resource(RESOURCE_ID_IMAGE_EMERGENCY);
}

static void up_click_handler(ClickRecognizerRef recognizer, void *context) {
	send_int(KEY_BUTTON_EVENT, BUTTON_UP);
	gbitmap_destroy(image);
	layer_destroy(layer);
	// Init the layer for display the image
  Layer *window_layer = window_get_root_layer(window);
	//window_set_fullscreen(window, true);
  GRect bounds = layer_get_frame(window_layer);
  layer = layer_create(bounds);
  layer_set_update_proc(layer, layer_update_callback);
  layer_add_child(window_layer, layer);

	//Draws the Image
	image = gbitmap_create_with_resource(RESOURCE_ID_IMAGE_AMBULANCE);
}

static void down_click_handler(ClickRecognizerRef recognizer, void *context) {
	send_int(KEY_BUTTON_EVENT, BUTTON_DOWN);
	gbitmap_destroy(image);
	layer_destroy(layer);
	// Init the layer for display the image
  Layer *window_layer = window_get_root_layer(window);
	//window_set_fullscreen(window, true);
  GRect bounds = layer_get_frame(window_layer);
  layer = layer_create(bounds);
  layer_set_update_proc(layer, layer_update_callback);
  layer_add_child(window_layer, layer);

	//Draws the Image
	image = gbitmap_create_with_resource(RESOURCE_ID_IMAGE_FIRE_POLICE);
}

static void click_config_provider(void *context) {
  window_single_click_subscribe(BUTTON_ID_SELECT, select_click_handler);
  window_single_click_subscribe(BUTTON_ID_UP, up_click_handler);
  window_single_click_subscribe(BUTTON_ID_DOWN, down_click_handler);
}

static void init(void) {
	
	//Register AppMessage events
	app_message_register_inbox_received(in_received_handler);           
	app_message_open(512, 512);    //Large input and output buffer sizes
	
	// Register callbacks
	app_message_register_inbox_received(inbox_received_callback);
	app_message_register_inbox_dropped(inbox_dropped_callback);
	app_message_register_outbox_failed(outbox_failed_callback);
	app_message_register_outbox_sent(outbox_sent_callback);
	
	
	//Open AppMessage
	app_message_open(app_message_inbox_size_maximum(), app_message_outbox_size_maximum());
	
  window = window_create();
  window_set_click_config_provider(window, click_config_provider);
  window_set_window_handlers(window, (WindowHandlers) {
	.load = window_load,
  });

	
  const bool animated = true;
  window_stack_push(window, animated);
}

static void deinit(void) {
  window_destroy(window);
	gbitmap_destroy(image);
	layer_destroy(layer);
}

int main(void) {
  init();
  app_event_loop();
  deinit();
}<commit_msg>Remove old methods<commit_after>#include <pebble.h>
#define BUTTON_UP 1
#define BUTTON_SELECT 2
#define BUTTON_DOWN 3
#define KEY_BUTTON_EVENT 0

static Window *window;
static GBitmap *image;
static Layer *layer;

static void in_received_handler(DictionaryIterator *iter, void *context) 
{
    
}

static void inbox_received_callback(DictionaryIterator *iterator, void *context) {
  APP_LOG(APP_LOG_LEVEL_INFO, "Message received!");
}

static void inbox_dropped_callback(AppMessageResult reason, void *context) {
  APP_LOG(APP_LOG_LEVEL_ERROR, "Message dropped!");
}

static void outbox_failed_callback(DictionaryIterator *iterator, AppMessageResult reason, void *context) {
  APP_LOG(APP_LOG_LEVEL_ERROR, "Outbox send failed!");
}

static void outbox_sent_callback(DictionaryIterator *iterator, void *context) {
  APP_LOG(APP_LOG_LEVEL_INFO, "Outbox send success!");
}


static void layer_update_callback(Layer *me, GContext* ctx) {
  // We make sure the dimensions of the GRect to draw into
  // are equal to the size of the bitmap--otherwise the image

  GRect bounds = image->bounds;

  graphics_draw_bitmap_in_rect(ctx, image, (GRect) { .origin = { 0, 0 }, .size = bounds.size });

}


static void window_load(Window *window) {
	// Init the layer for display the image
  Layer *window_layer = window_get_root_layer(window);
	//window_set_fullscreen(window, true);
  GRect bounds = layer_get_frame(window_layer);
  layer = layer_create(bounds);
  layer_set_update_proc(layer, layer_update_callback);
  layer_add_child(window_layer, layer);

	//Draws the Image
  image = gbitmap_create_with_resource(RESOURCE_ID_IMAGE_HOME);
	
}

void send_int(uint8_t key, uint8_t cmd)
{
    DictionaryIterator *iter;
    app_message_outbox_begin(&iter);
      
    Tuplet value = TupletInteger(key, cmd);
    dict_write_tuplet(iter, &value);
      
    app_message_outbox_send();
}

static void select_click_handler(ClickRecognizerRef recognizer, void *context) {
	send_int(KEY_BUTTON_EVENT, BUTTON_SELECT);
	gbitmap_destroy(image);
	layer_destroy(layer);
	// Init the layer for display the image
  Layer *window_layer = window_get_root_layer(window);
	//window_set_fullscreen(window, true);
  GRect bounds = layer_get_frame(window_layer);
  layer = layer_create(bounds);
  layer_set_update_proc(layer, layer_update_callback);
  layer_add_child(window_layer, layer);

	//Draws the Image
	image = gbitmap_create_with_resource(RESOURCE_ID_IMAGE_EMERGENCY);
}

static void up_click_handler(ClickRecognizerRef recognizer, void *context) {
	send_int(KEY_BUTTON_EVENT, BUTTON_UP);
	gbitmap_destroy(image);
	layer_destroy(layer);
	// Init the layer for display the image
  Layer *window_layer = window_get_root_layer(window);
	//window_set_fullscreen(window, true);
  GRect bounds = layer_get_frame(window_layer);
  layer = layer_create(bounds);
  layer_set_update_proc(layer, layer_update_callback);
  layer_add_child(window_layer, layer);

	//Draws the Image
	image = gbitmap_create_with_resource(RESOURCE_ID_IMAGE_AMBULANCE);
}

static void down_click_handler(ClickRecognizerRef recognizer, void *context) {
	send_int(KEY_BUTTON_EVENT, BUTTON_DOWN);
	gbitmap_destroy(image);
	layer_destroy(layer);
	// Init the layer for display the image
  Layer *window_layer = window_get_root_layer(window);
	//window_set_fullscreen(window, true);
  GRect bounds = layer_get_frame(window_layer);
  layer = layer_create(bounds);
  layer_set_update_proc(layer, layer_update_callback);
  layer_add_child(window_layer, layer);

	//Draws the Image
	image = gbitmap_create_with_resource(RESOURCE_ID_IMAGE_FIRE_POLICE);
}

static void click_config_provider(void *context) {
  window_single_click_subscribe(BUTTON_ID_SELECT, select_click_handler);
  window_single_click_subscribe(BUTTON_ID_UP, up_click_handler);
  window_single_click_subscribe(BUTTON_ID_DOWN, down_click_handler);
}

static void init(void) {
	
	//Register AppMessage events
	app_message_register_inbox_received(in_received_handler);           
	app_message_open(512, 512);    //Large input and output buffer sizes
	
	// Register callbacks
	app_message_register_inbox_received(inbox_received_callback);
	app_message_register_inbox_dropped(inbox_dropped_callback);
	app_message_register_outbox_failed(outbox_failed_callback);
	app_message_register_outbox_sent(outbox_sent_callback);
	
	
	//Open AppMessage
	app_message_open(app_message_inbox_size_maximum(), app_message_outbox_size_maximum());
	
  window = window_create();
  window_set_click_config_provider(window, click_config_provider);
  window_set_window_handlers(window, (WindowHandlers) {
	.load = window_load,
  });

	
  const bool animated = true;
  window_stack_push(window, animated);
}

static void deinit(void) {
  window_destroy(window);
	gbitmap_destroy(image);
	layer_destroy(layer);
}

int main(void) {
  init();
  app_event_loop();
  deinit();
}
{'fraction_non_alphanumeric': 0.09261157178794373, 'fraction_numerical': 0.0035404826236839653, 'mean_word_length': 5.8984575835475574, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 10, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1585121', 'n_tokens_mistral': 3649, 'n_tokens_neox': 3546, 'n_words': 751}