
Graphics.prototype.setFontOrbitron = function() {
// Actual height 32 (35 - 4)
var widths = atob("ChcmEiUlISUlHiYlCg==");
var font = atob("AAAAAAAAAAAAAAAAAAAAPAAAAAAB4AAAAAAPAAAAAAB4AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAfAAAAAAPwAAAAAD8AAAAAA+AAAAAAPgAAAAAD4AAAAAB+AAAAAAfgAAAAAHwAAAAAB8AAAAAAfAAAAAAPwAAAAAD4AAAAAA+AAAAAAPgAAAAAH4AAAAAB+AAAAAAfAAAAAAHwAAAAAB8AAAAAA/AAAAAAPwAAAAAD4AAAAAAAAAAAAAAAAAAAAAB///+AAA////8AAP////wAD/////AAfgAA/4ADwAAH/AAeAAB94ADwAAfPAAeAAH54ADwAB+PAAeAAPh4ADwAD4PAAeAA+B4ADwAPgPAAeAD8B4ADwAfAPAAeAHwB4ADwB8APAAeAfAB4ADwH4APAAeB+AB4ADwPgAPAAeD4AB4ADw+AAPAAePwAB4ADz8AAPAAefAAB4AD3wAAPAAf8AAB4AD/////AAf////4AB////+AAH////gAAH///gAAAAAAAAAAAAAAAAAACAAAAAAAwAAAAAAOAAAAAADwAAAAAB+AAAAAAfwAAAAAH4AAAAAB+AAAAAAfgAAAAAD4AAAAAAf////4AD/////AAf////4AD/////AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABwAf/4AA+AP//AAPwD//4AD+Af//AAfgH4H4ADwA8APAAeAHgB4ADwA8APAAeAHgB4ADwA8APAAeAHgB4ADwA8APAAeAHgB4ADwA8APAAeAHgB4ADwA8APAAeAHgB4ADwA8APAAeAHgB4ADwA8APAAeAHgB4ADwA8APAAeAHgB4ADwA8APAAeAHgB4ADwA8APAAeAHgB4ADwA8APAAeAHgB4AD//8APAAf//gB4AB//4APAAH/+AB4AAH+AAHAAAAAAAAAAAAAAAAAAAAAAAAAOAAA4AAHwAAHgAB+AAA+AAfwAAH4AD4AAAfAAeAAAB4ADwA8APAAeAHgB4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AAAAeAAAAAADwAAAAAAeAAAAAADwAAAAAAeAAAAAADwAAAAAAeAAAAAADwAAAAAAf////4AB/////AAP////4AA/////AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAP+D/wAAH////gAB////+AAf////4AD8D+A/AAeAHgB4ADwA4APAAeAHAB4ADwA4APAAeAHAB4ADwA4APAAeAHAB4ADwA4APAAeAHAB4ADwA4APAAeAHAB4ADwA4APAAeAHAB4ADwA4APAAeAHAB4ADwA4APAAeAHAB4ADwA4APAAeAHAB4ADwA4APAAeAHAB4ADwA4APAAeAHAB4ADwA8APAAf////4AB/////AAP////wAAf/v/8AAA/gP8AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAf/gAAAAH/+ABgAB//4AOAAf//gB4AD4B8APAAeAHgB4ADwA8APAAeAHgB4ADwA8APAAeAHgB4ADwA8APAAeAHgB4ADwA8APAAeAHgB4ADwA8APAAeAHgB4ADwA8APAAeAHgB4ADwA8APAAeAHgB4ADwA8APAAeAHgB4ADwA8APAAeAHgB4ADwA8APAAeAHgB4ADwA8APAAeAHgB4ADwA+APAAf////4AB////+AAP////wAAf///4AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAeAAB4AADwAAPAAAeAAB4AADwAAPAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=");
var scale = 1; // size multiplier for this font
g.setFontCustom(font, 46, widths, 45+(scale<<8)+(1<<16));
};

Graphics.prototype.setFontCabinSketch = function() {
// Actual height 48 (51 - 4)
var widths = atob("ECMtGCEiJSIkHyYlDw==");
var font = atob("[encoded data, 4496 characters]");
var scale = 1; // size multiplier for this font
g.setFontCustom(font, 46, widths, 65+(scale<<8)+(1<<16));  
};

Graphics.prototype.setFontGochiHand = function() {
// Actual height 54 (59 - 6)
var widths = atob("GRMtICcqJiopKiwoGQ==");
var font = atob("[encoded data, 6320 characters]");
var scale = 1; // size multiplier for this font
g.setFontCustom(font, 46, widths, 80+(scale<<8)+(1<<16));
};

Graphics.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//gAAAAAAAAB8AAf8ADpwAMhgAyGADIYAMhgA6GAB4wADhAAAAACAAAMAAH/+A//4DMAAMwAAzAAABAcAff4D/5gMbmAwmYDCZgMZmA/mYD8fAMA4AgAAAAAAAAAf/+B//4AGAAAwAADAAAMAAA4AAD/4AH/gAAAAAAACAAAc/+Bz/4CAAAAAAAAABiAAGc//5z//CAAAAAAAAAAAAAAf/+B//4AAYAADgAAfAAHuAA4cADAYAIAgAAAAAAAAAAAf/+B//4AAAAAAAAAAAAAAAA/+AD/4AEAAAwAADAAAMAAA/+AB/4AH/gAwAADAAAMAAA4AAD/4AD/gAAAAAAAAAAAA/+AD/4AGAAAwAADAAAMAAAwAAD/4AH/gAAAAAAAAD+AAf8ADg4AMBgAwGADAYAMBgA4OAB/wAD+AADgAAAAAP/+A//4BgwAMBgAwGADAYAMBgA8eAB/wAD8AAAAAAAAAB+AAf8ADx4AMBgAwGADAYAMBgAYMAD//gP/+AAAAAAAAP/gA/+ABwAAOAAAwAADAAAMAAAAAAAAQAHhgA/GADMYAMxgAxmADH4AEPAAAQAAAAAMAAAwAAf/wD//gAwGADAYAMBgAAAAAAAAP/AA/+AAAYAABgAAGAAAYAADAA/+AD/4AAAAAAAADgAAPgAAfgAAPwAAPgAAeAAHwAD8AA/AADgAAIAAA4AAD8AAD+AAB+AAB4AA/AAfgADwAAPgAAfwAAP4AAHgAB+AA/gAPwAA4AAAAAAAAgAwGADh4AHvAAPwAAOAAB8AAe8ADh4AMBgAgCACAAAOAAA+AAA/BgA/eAA/wAD8AA/AAPgAD4AAOAAAgGADA4AMHgAx+ADOYANxgA+GADgYAMBgAAAAAMAD//4f9/xgADEAAEAAAAAAAAAAAAAAB///n//+AAAAAAAAAAAAAABAABGAAMf9/w//+AAwAAAAAAAAAA4AADgAAYAABgAAHAAAMAAAwAADAAAcAADgAAAAAAAA");
var scale = 1; // size multiplier for this font
g.setFontCustom(font, 32, widths, 22+(scale<<8)+(1<<16));
};

Graphics.prototype.setFontLato = function() {
// Actual height 50 (53 - 4)
var widths = atob("DhglJSUlJSUlJSUlEA==");
var font = atob("[encoded data, 4524 characters]");
var scale = 1; // size multiplier for this font
g.setFontCustom(font, 46, widths, 64+(scale<<8)+(1<<16));
};

Graphics.prototype.setFontArchitect = function() {
// Actual height 40 (41 - 2)
var widths = atob("CBolByEeJykkJCYhCg==");
var font = atob("AAAAAAAAAAAAAAAAYAAAAAAAADgAAAAAAAAeAAAAAAAAB4AAAAAAAAHgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAeAAAAAAAAD4AAAAAAAA/AAAAAAAAH4AAAAAAAB/AAAAAAAAf4AAAAAAAD+AAAAAAAA/wAAAAAAAH+AAAAAAAB/gAAAAAAAP8AAAAAAAD/AAAAAAAAf4AAAAAAAH+AAAAAAAA/gAAAAAAAP8AAAAAAAB/AAAAAAAAfwAAAAAAAH8AAAAAAAA/AAAAAAAAPwAAAAAAAB8AAAAAAAAfAAAAAAAADwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAP8AAAAAAAP/8AAAAAAH//4AAAAAB///wAAAAAf/APgAAAAD/gAeAAAAA/wAA8AAAAH8AABwAAAA/AAAHgAAAHwAAAeAAAA+AAAA4AAADgAAADgAAAcAAAAOAAABwAAAA4AAAOAAAADgAAA4AAAAOAAADgAAAA4AAAOAAAADgAAA4AAAAOAAADgAAAB4AAAOAAAAHAAAA4AAAAcAAADwAAADwAAAHAAAAOAAAAeAAAB4AAAA4AAAPAAAADwAAB4AAAAHwAAPgAAAAPgAD8AAAAAf4D/gAAAAAf//4AAAAAAf/+AAAAAAAP/AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD8AAAAP////4AAAB/////gAAAH////+AAAAf////gAAAAAAAAAAAAAAAAAAAAAAAAcAAAAAAAADwAADAAAAAeAAAeAAAAD4AAD4AAAAfAAAfgAAAD4AAD+AAAAPAAAf4AAAB8AAH/AAAAHgAA/8AAAAcAAH/wAAADwAA/vAAAAO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OAAABwAwAA4AAAHAHAADgAAAcAcAAOAAABwBwAA4AAAHAPAAHgAAAcA8AAcAAABwDgABwAAAHAeAAHAAAAcB8AA4AAABwPwAHgAAAHg/AAcAAAAeH8ADwAAAB4/4AeAAAAD//gD4AAAAP+fA/AAAAAfx//4AAAAAAD//AAAAAAAP/wAAAAAAAP8AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAH4AAAAAAAA/wAAAAAAAH/gAAAAAAA/+AAAAAAAH/8AAAAAAA/nwAAAAAAD4PAAAAAAAeA8AAAAAADwDwAAAAAAPAPAAAAAAB4A8AAwAAAHgDwAHgAAAeAPAAeAAADwA8AD4AAAPADwAfgAAA8AOAB8AAADwA4APwAAAPADgB+AAAA8AeAPwAAAD4B4B/AAAAHgHgf4AAAAfA+D+AAAAA/D5/wAAAAB///+AAAAAH///gAAAAAH//4AAAAAAP/+AAAAAAAP/AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAOAAAAAAAAA4AAAAAAAADwDAAAAAAAOAeAAAAAAAYB4AAAAAAAAHgAAAAAAAAMAAAAAAAAAAAAA=");
var scale = 1; // size multiplier for this font
g.setFontCustom(font, 46, widths, 58+(scale<<8)+(1<<16));
};

Graphics.prototype.setFontMonoton = function(scale) {
  // Actual height 44 (43 - 0)
  g.setFontCustom(atob("AAAAAAAAAAAAAAAAAAAABmwAAAAAAzYAAAAAAZsAAAAAAM2AAAAAAGbAAAAAADNgAAAAABmwAAAAAAzYAAAAAAZsAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAcAAAAAAD+AAAAAAf8AAAAAD/ggAAAAf8HwAAAD/g/4AAAf8H/AAAD/g/4OAAf8H/B/AD/g/4P+Af8H/B/wAfg/4P+AAMH/B/wAAA/4H+AAAD/A/4AAAB4H/AAAAAA/4AAAAAH/AAAAAAP4AAAAAAHAAAAAAAAAAAAAAAAAAAAAAAAAAA/gAAAAAH//gAAAAf//8A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bMbNgbNjNmNmwNmxmzGzYGzYzZjZsDZsZsxs2Bs2M2Y2bA2bGbMbNgbNzNmNmwP2Zm7s3YDbv7M+7MBszt3OZuA3MGZwd2ANn/uf8zAGY+zn47gDvAc4A7gA78/Pj5gAOf/z/zwADj8cPjwAA+A/gHgAAH/9//gAAA/4P/AAAAAAAAAAAAAAAAAAAAAAAAAAAAB+AAAAAAD/4AAAAAHw/AAAAAHADwADAAHP8cABgAHf/nAA4AHeB5gDuAHcfOYAzADc/7uBdwBs8ezBmYBu4DdgbsA2Z924s3AbN+bM3bgfsxt2duwNm4zbG3YGzYZtjZsDZsM2xs2Bs2GbY2bA2bDNsbNgbNhv2NmwP242zO3YHbszbm7sBs3AAHZuA2Z///M2Abuf//O7AGzh/8ObgDc8AA+dgB3P//+dwAdx//8cwAGeAAA8wADn///44AA8///54AAPgAAB4AAB+AAPwAAAP///gAAAA//+AAAAAAAAAAAAAAAAAAAAAAAAAAAADbBmwAAABtgzYAAAA2wZsAAAAbYM2AAAANsGbAAAAG2DNgAAADbBmwAAABtgzYAAAA2wZsAAAAAAAAAAAAAAAAAAA="), 46, atob("DRYpFR0eHiImHygmDQ=="), 49+(scale<<8)+(1<<16));
}

Graphics.prototype.setFontSpecialElite = function(scale) {
  // Actual height 40 (39 - 0)
  g.setFontCustom(atob("AAAAAAAAAAAAAAAAAAAAAYAAAAAAAfwAAAAAAP/AAAAAAH/4AAAAAB/+AAAAAAf/gAAAAAH/4AAAAAB/+AAAAAAf/gAAAAAH/4AAAAAAv8AAAAAAN6AAAAAAAeAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA4AAAAAAAfAAAAAAAPwAAAAAAP8AAAAAAH+AAAAAAH+AAAAAAD+AAAAAAD/AAAAAAD/AAAAAAB/AAAAAAB/AAAAAAB/AAAAAAB/gAAAAAB/gAAAAAB/gAAAAAA/gAAAAAB/wAAAAAA/4AAAAAA/wAAAAAA/4AAAAAA/4AAAAAAf8AAAAAAP8AAAAAAD8AAAA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B/8f/4AAAP8D/8AAAAAAf8AAAAAAAYAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAeAAAAAAA/4APAAAA//gH4AAAP/8D/gAAP4Pg/8AADwB8P/AAB4AfD/4AAeAD4d+AAHAA+AfwADwAHgH8AA4AA8A/AAOAAPAPgADgADwD4AA8AA4B+AAPAAeAfAAB4AHgHgAAeADwD4AAHwA8A8AAA+AfA/AAAHp/h/gAAA3//+gAAAB//+gAAAAd//gAAAACf/wAAAAAH/wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABwAAAABwB/AAAAB/A/8AAAA/wf/gAAAP+H/4AAAH/h/+AAAB/8f/gAAAP+H/4AAAD/h/+AAAAfwf/gAAAH8C/wAAAAAA3oAAAAAABwAAAAAAAAAAAAAAAAAAAA=="), 46, atob("ERwfHB0cHxsdHB4dEQ=="), 50+(scale<<8)+(1<<16));
}

const SETTINGS_FILE = "pastel.json";
let settings = undefined;

function loadSettings() {
  //Console.log("loadSettings()");
  settings = require("Storage").readJSON(SETTINGS_FILE,1)||{};
  settings.grid = settings.grid||false;
  settings.date = settings.date||false;
  settings.font = settings.font||"Lato";
  //console.log(settings);
}

var mm_prev = "xx";

function draw() {
  var d = new Date();
  var da = d.toString().split(" ");
  var time = da[4].substr(0,5);
  
  var hh = da[4].substr(0,2);
  var mm = da[4].substr(3,2);
  var day = da[0];
  var month_day = da[1] + " " + da[2];
  
  // fix hh for 12hr clock
  var h2 = "0" + parseInt(hh) % 12 || 12;
  if (parseInt(hh) > 12)
    hh = h2.substr(h2.length -2);

  var w = g.getWidth();
  var h = g.getHeight();
  var x = (g.getWidth()/2);
  var y = (g.getHeight()/3);
  
  g.reset();

  if (process.env.HWVERSION == 1) {
    // avoid flicker on a bangle 1 by comparing with previous minute
    if (mm_prev != mm) {
      mm_prev = mm;
      g.clearRect(0, 30, w, h - 24);
    }
  } else {
    // on a b2 safe to just clear anyway as there is no flicker
    g.clearRect(0, 30, w, h - 24);
  }
    
  // draw a grid like graph paper
  if (settings.grid && process.env.HWVERSION !=1) {
    g.setColor("#0f0");
    for (var gx=20; gx <= w; gx += 20)
      g.drawLine(gx, 30, gx, h - 24); 
    for (var gy=30; gy <= h - 24; gy += 20)
      g.drawLine(0, gy, w, gy);
  }

  g.setColor(g.theme.fg);

  if (settings.font == "Architect")
    g.setFontArchitect();
  else if (settings.font == "GochiHand")
    g.setFontGochiHand();
  else if (settings.font == "CabinSketch")
    g.setFontCabinSketch();
  else if (settings.font == "Orbitron")
    g.setFontOrbitron();
  else if (settings.font == "Monoton")
    g.setFontMonoton();
  else if (settings.font == "Elite")
    g.setFontSpecialElite();
  else
    g.setFontLato();
    
  g.setFontAlign(1,-1);  // right aligned
  g.drawString(hh, x - 6, y);
  g.setFontAlign(-1,-1); // left aligned
  g.drawString(mm, x + 6, y);

  // for the colon
  g.setFontAlign(0,-1); // centre aligned

  if (d.getSeconds()&1) {
    g.drawString(":", x,y);
  } else {
    // on bangle 1, we are not using clearRect(), hide : by printing over it in reverse color
    if (process.env.HWVERSION == 1) {
      g.setColor(g.theme.bg);
      g.drawString(":", x,y);
      g.setColor(g.theme.fg);
    }
  }

  if (settings.date) {
    g.setFontLatoSmall();
    g.setFontAlign(1, -1);
    g.drawString(day + "   ", w, h - 24 - 24);
    g.drawString(month_day + "   ", w, h - 24);
  }
}

// Only update when display turns on
if (process.env.BOARD!="SMAQ3") // hack for Q3 which is always-on
Bangle.on('lcdPower', function(on) {
  if (secondInterval)
    clearInterval(secondInterval);
  secondInterval = undefined;
  if (on)
    secondInterval = setInterval(draw, 1000);
  draw();
});

loadSettings();
g.clear();
var secondInterval = setInterval(draw, 1000);
draw();
// Show launcher when button pressed
Bangle.setUI("clock");
Bangle.loadWidgets();
Bangle.drawWidgets();
