<commit_before>#include "pebble.h"
#include "simple_classic.h"

static Window *s_window;
static Layer *s_back_layer, *s_date_layer, *s_hand_layer, *s_batt_layer;

static char s_date_buffer[16] = "";
static char s_wday_buffer[16] = "";
static int g_wday = -1;
static BatteryChargeState g_charge;

static GFont s_font;

static struct color_map charge_colors[] = {
    { 100, 0x00FF55 },
    {  90, 0x00FF00 },
    {  80, 0x55FF00 },
    {  70, 0xAAFF00 },
    {  50, 0xFFFF00 },
    {  30, 0xFFAA00 },
    {  20, 0xFF5500 },
    {   0, 0xFF0000 },
    {  -1, 0xFFFFFF }
};

// get battery charge indicator color
GColor get_charging_color(int percent)
{
  struct color_map *cm = charge_colors;
  GColor c;

  if (percent < 0)
    percent = 0;
  
  do {
    c = GColorFromHEX(cm->color);
    cm += 1;
  } while (percent <= cm->key);

  return c;
}

// convert angle in minutes (1° = 60 min) to lookup table index
uint32_t minute_index(int16_t m)
{
  return (TRIG_MAX_ANGLE * m + 10800) / 21600;
}

// round fixed point number to nearest integer
int16_t fixed_round(uint32_t a)
{
  return (int16_t)((a + TRIG_MAX_RATIO / 2) / TRIG_MAX_RATIO);
}

static void back_update_proc(Layer *layer, GContext *ctx) {
  GRect bounds = layer_get_bounds(layer);
  GPoint center = grect_center_point(&bounds);

  graphics_context_set_antialiased(ctx, true);
                                   
  graphics_context_set_fill_color(ctx, GColorBlack);
  graphics_fill_rect(ctx, layer_get_bounds(layer), 0, GCornerNone);
  graphics_context_set_fill_color(ctx, GColorWindsorTan);
  graphics_context_set_stroke_color(ctx, GColorWhite);
  const int32_t tick_span = 66;

  for (int i = 0; i < 12; i += 1) {
    int32_t tick_angle = TRIG_MAX_ANGLE * i / 12;
    GPoint tick_center = {
      .x = center.x + fixed_round(sin_lookup(tick_angle) * tick_span),
      .y = center.y - fixed_round(cos_lookup(tick_angle) * tick_span),
    };
    graphics_fill_circle(ctx, tick_center, 3);
    graphics_draw_circle(ctx, tick_center, 3);
  }
}

static void batt_update_proc(Layer *layer, GContext *ctx) {
  GRect bounds = layer_get_bounds(layer);
  GPoint center = grect_center_point(&bounds);
  GRect charge_frame = {
#ifdef PBL_ROUND
    .origin = { center.x - 26, center.x + 74 },
    .size = { 52, 8 },
#else
    .origin = { center.x - 51, bounds.size.h - 8},
    .size = { 102, 8 },
#endif
  };

  GRect charge_level = {
#ifdef PBL_ROUND
    .origin = { center.x - 25, center.y + 75 },
    .size = { g_charge.charge_percent / 2, 6 },
#else
    .origin = { center.x - 50, bounds.size.h - 7 },
    .size = { g_charge.charge_percent, 6 },
#endif
  };

  GColor c = get_charging_color(g_charge.charge_percent);
  graphics_context_set_stroke_color(ctx, GColorWhite);
  graphics_context_set_fill_color(ctx, c);<commit_msg>Change battery indicator size<commit_after>#include "pebble.h"
#include "simple_classic.h"

static Window *s_window;
static Layer *s_back_layer, *s_date_layer, *s_hand_layer, *s_batt_layer;

static char s_date_buffer[16] = "";
static char s_wday_buffer[16] = "";
static int g_wday = -1;
static BatteryChargeState g_charge;

static GFont s_font;

static struct color_map charge_colors[] = {
    { 100, 0x00FF55 },
    {  90, 0x00FF00 },
    {  80, 0x55FF00 },
    {  70, 0xAAFF00 },
    {  50, 0xFFFF00 },
    {  30, 0xFFAA00 },
    {  20, 0xFF5500 },
    {   0, 0xFF0000 },
    {  -1, 0xFFFFFF }
};

// get battery charge indicator color
GColor get_charging_color(int percent)
{
  struct color_map *cm = charge_colors;
  GColor c;

  if (percent < 0)
    percent = 0;
  
  do {
    c = GColorFromHEX(cm->color);
    cm += 1;
  } while (percent <= cm->key);

  return c;
}

// convert angle in minutes (1° = 60 min) to lookup table index
uint32_t minute_index(int16_t m)
{
  return (TRIG_MAX_ANGLE * m + 10800) / 21600;
}

// round fixed point number to nearest integer
int16_t fixed_round(uint32_t a)
{
  return (int16_t)((a + TRIG_MAX_RATIO / 2) / TRIG_MAX_RATIO);
}

static void back_update_proc(Layer *layer, GContext *ctx) {
  GRect bounds = layer_get_bounds(layer);
  GPoint center = grect_center_point(&bounds);

  graphics_context_set_antialiased(ctx, true);
                                   
  graphics_context_set_fill_color(ctx, GColorBlack);
  graphics_fill_rect(ctx, layer_get_bounds(layer), 0, GCornerNone);
  graphics_context_set_fill_color(ctx, GColorWindsorTan);
  graphics_context_set_stroke_color(ctx, GColorWhite);
  const int32_t tick_span = 66;

  for (int i = 0; i < 12; i += 1) {
    int32_t tick_angle = TRIG_MAX_ANGLE * i / 12;
    GPoint tick_center = {
      .x = center.x + fixed_round(sin_lookup(tick_angle) * tick_span),
      .y = center.y - fixed_round(cos_lookup(tick_angle) * tick_span),
    };
    graphics_fill_circle(ctx, tick_center, 3);
    graphics_draw_circle(ctx, tick_center, 3);
  }
}

static void batt_update_proc(Layer *layer, GContext *ctx) {
  GRect bounds = layer_get_bounds(layer);
  GPoint center = grect_center_point(&bounds);
  int c = g_charge.charge_percent;
  GRect charge_frame = {
#ifdef PBL_ROUND
    .origin = { center.x - 21, center.x + 74 },
    .size = { 42, 8 },
#else
    .origin = { center.x - 31, bounds.size.h - 8},
    .size = { 62, 8 },
#endif
  };

  GRect charge_level = {
#ifdef PBL_ROUND
    .origin = { center.x - 20, center.y + 75  },
    .size = { (c / 5) * 2, 6 },
#else
    .origin = { center.x - 30, bounds.size.h - 7 },
    .size = { (c / 5) * 3, 6 },
#endif
  };

  GColor color = get_charging_color(g_charge.charge_percent);
  graphics_context_set_stroke_color(ctx, GColorWhite);
  graphics_context_set_fill_color(ctx, color);
{'fraction_non_alphanumeric': 0.12555893400107315, 'fraction_numerical': 0.04435700232516544, 'mean_word_length': 3.4066193853427897, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 7, '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': '5142427', 'n_tokens_mistral': 2324, 'n_tokens_neox': 2115, 'n_words': 478}