From eca118bc18d7789f32e8a6bc8cd9224d4a101587 Mon Sep 17 00:00:00 2001 From: James Steinberg Date: Sun, 29 Oct 2023 18:06:12 -0400 Subject: [PATCH] 28x6 --- apps/twentyeightbysix/ChangeLog | 3 + apps/twentyeightbysix/app-icon.js | 1 + apps/twentyeightbysix/app.js | 0 apps/twentyeightbysix/app.png | Bin 0 -> 1428 bytes apps/twentyeightbysix/boot.js | 0 apps/twentyeightbysix/metadata.json | 19 + apps/twentyeightbysix/twentyeightbysix.js | 667 ++++++++++++++++++++++ apps/twentyeightbysix/widget.js | 0 8 files changed, 690 insertions(+) create mode 100644 apps/twentyeightbysix/ChangeLog create mode 100644 apps/twentyeightbysix/app-icon.js create mode 100644 apps/twentyeightbysix/app.js create mode 100644 apps/twentyeightbysix/app.png create mode 100644 apps/twentyeightbysix/boot.js create mode 100644 apps/twentyeightbysix/metadata.json create mode 100644 apps/twentyeightbysix/twentyeightbysix.js create mode 100644 apps/twentyeightbysix/widget.js diff --git a/apps/twentyeightbysix/ChangeLog b/apps/twentyeightbysix/ChangeLog new file mode 100644 index 000000000..13fadf45e --- /dev/null +++ b/apps/twentyeightbysix/ChangeLog @@ -0,0 +1,3 @@ +0.01: Add 28 hour clock +0.02: Preview rest of the week +0.03: Fixed crashing bug diff --git a/apps/twentyeightbysix/app-icon.js b/apps/twentyeightbysix/app-icon.js new file mode 100644 index 000000000..3a084899a --- /dev/null +++ b/apps/twentyeightbysix/app-icon.js @@ -0,0 +1 @@ +require("heatshrink").decompress(atob("mEwwkEIf4A/AH4A/AH4AqiAFKAAkBAgcC///mIFE+QWHiYLBkAFB/8hiX/FYMvmMRn4MCFon/iMS+YGBBoUfAYIICgfwC4oHDiIJEh8ggJECgXxC4olCAAwvHgRoCkZSBP5EvL4QaBAQMBDoMCHAMvgMjD4RoDIgRsB/5GCj8wAIMAmcfmU/AoJeDAoUT+cj+Y1BFoJPCn4gBGoQACn7SCR40/AYZ3CmaXDIAUBAYwXDNoQHBFw0CXYY8BI4kfB4QvCFwZ6EX4R3ENwQODl8xiMREIM/kMRl8wU4oFBBQRGCUIKiCgQEBCIJ5EEYMT/5NCAH4A/AH4A/AH4A/AF4")) diff --git a/apps/twentyeightbysix/app.js b/apps/twentyeightbysix/app.js new file mode 100644 index 000000000..e69de29bb diff --git a/apps/twentyeightbysix/app.png b/apps/twentyeightbysix/app.png new file mode 100644 index 0000000000000000000000000000000000000000..4382aeec186fbe1efab29116de136460b7be3835 GIT binary patch literal 1428 zcmV;F1#9|=P)Px#L}ge>W=%~1DgXcg2mk?xX#fNO00031000^Q000001E2u_0{{R30RRC20H6W@ z1ONa40RR91FrWhf1ONa40RR91FaQ7m0NXcg3;+NG{z*hZRA>e5S6wKcZy0}kjEn;< zYKB;7Wn!2kX%0l>D^2;z8jd+2-{s@PBwLaw;$WGGA}87$kT{r4$VWto$qtxr$;Y+l zcWw9kf1dY!|C&7qOFehJ?)$#3-*w&B*L~d&3rUhl{@vMOd1o#EZMg2hzs{hZ0X+j6 zBcPX%#sF#-*E66wgc=p-8PFI&&Ek3nG>1^50xMa*(pZO+lau7{@6Y6;qa$OsYHw|A zEqQo&NWQ+l64uAZ$I|unwF;wUv#Rj_0NLByQ%y|`ef#!}lw*E= zp2EY!83Ua7$;MK7c{%;~@k0scJ?P*I?BC3xp`kQ6IjPdUwY5bB1qH^sCAxqAK5cAl zknADV)zwi#LIOQ|_KXS(3u$d_jpQtlx3{;-pm*=yvGT#eLCVU?qNh)v@{BzO_pHMGFfHTnXmv2@VdXjEoGW-v7$N++ip! zxu&V3qr)Kd*@nh!Y<>m2t4<9~MVU_xg z);BxQ(9pmN0|Ek63QI~#n64~6q#S#Uva&J*-p9v>FZayM4Bt0lKxJhmV{tJBt+~0G z_V)I8|Ki09s;{r7&!0cj`}glDJ3HI>0t5H|4n#&qa{08jwi*sl;?vU7m=7zyfB(+L z;7?{|rU^beI-0JouIR&u56p{=jb+)+&Q29}WMqWU`BG9+=&A&Xg*7rLW@Zt8%uvokF%EpgiY{QQ()UZd@z<@WXUk*%$*ijO_$ z;G+R34&rrBPY*kRjJdnJoA8H+hnbHOHI~I59m;GQ6<`Mk2d+67fX778m2*;35+8#8 ztfY%I?h6KRf`%EFc3@zDdAqy2hKsAjw70i2A0?-xi*9v+%9Wy-<90n-IefGR2~r1J z&V2Ofk%}%hE-o&TTpeP|Gkc2YpoY=&)6>(svHrPr@toBg@E zy0Rc%+o7Q$er?;@+UVuWmxPvw8GF3K;EPvU{?H>iTQogAt!fCRrKNnP@uLN2(Sd+} z_39PjaYIn>-8D5eMGqc4Fm>R|moKdBraw_pQ3gR=(4wLu!uJZYhJhJ-(8UFIbabTU z)|gfs?Fv$&oC%^}pNK+k~20BRQ3GoU$y i8Wrdn&=^3?;y(eYaq-LHJ>!r70000= 8 && weirdHour <= 27) { + text = "Awake"; + otherText = "Sleep"; + blockSize = (weirdDayWidth / timeWidth) * screenWidth * (weirdAwakeHours / weirdDayWidth); + otherBlockSize = (weirdDayWidth / timeWidth) * screenWidth * (weirdSleepHours / weirdDayWidth); + blockWidth = weirdAwakeHours; + textColor = awakeTextColor; + blockColor = awakeBlockColor; + otherBlockColor = sleepBlockColor; + otherTextColor = sleepTextColor; + internalBlockTime = weirdHour - 8; + } else { + text = "Sleep"; + otherText = "Awake"; + blockSize = (weirdDayWidth / timeWidth) * screenWidth * (weirdSleepHours / weirdDayWidth); + otherBlockSize = (weirdDayWidth / timeWidth) * screenWidth * (weirdAwakeHours / weirdDayWidth); + blockWidth = weirdSleepHours; + textColor = sleepTextColor; + blockColor = sleepBlockColor; + otherBlockColor = awakeBlockColor; + otherTextColor = awakeTextColor; + if(weirdHour <= 8) { + internalBlockTime = weirdHour + 1; + } else { + internalBlockTime = 0; + } + } + + return { + "text": text, + "otherText": otherText, + "blockSize": blockSize, + "otherBlockSize": otherBlockSize, + "blockWidth": blockWidth, + "textColor": textColor, + "blockColor": blockColor, + "otherBlockColor": otherBlockColor, + "otherTextColor": otherTextColor, + "internalBlockTime": internalBlockTime + }; +} + + + + + + + + + + +function getNormalDayBlockSize() { + return ((normalDayWidth / timeWidth) * screenWidth); +} + +function printNormalWeekDay(dayText, percentOfBlock, startingPoint) { + g.setColor(dayBlockColor); + g.fillRect(startingPoint - (percentOfBlock * getNormalDayBlockSize()), normalWeekDayHeight - 10, startingPoint - (percentOfBlock * getNormalDayBlockSize()) + getNormalDayBlockSize(), normalWeekDayHeight + 10); + + g.setColor(dayTextColor); + g.drawRect(startingPoint - (percentOfBlock * getNormalDayBlockSize()), normalWeekDayHeight - 10, startingPoint - (percentOfBlock * getNormalDayBlockSize()) + getNormalDayBlockSize(), normalWeekDayHeight + 10); + g.drawString(dayText, startingPoint - (percentOfBlock * getNormalDayBlockSize()) + (getNormalDayBlockSize() / 2), normalWeekDayHeight); +} + +function printNormalWeekDays(normalDate) { + var percentOfBlock = dailyHourCount(normalDate.hour, normalDate.minute) / normalDayWidth; + printNormalWeekDay(normalDate.dayText, percentOfBlock, screenWidth / 2); + printNormalWeekDay(getNormalDayName((normalDate.day + 7 - 1) % 7), percentOfBlock, screenWidth / 2 - getNormalDayBlockSize()); + printNormalWeekDay(getNormalDayName((normalDate.day + 7 + 1) % 7), percentOfBlock, screenWidth / 2 + getNormalDayBlockSize()); +} + + + + + + + + + + +function printNormalSleepDay(sleepText, blockSize, textColor, blockColor, startingPoint) { + g.setColor(blockColor); + g.fillRect(startingPoint, normalSleepDayHeight - 8, startingPoint + blockSize, normalSleepDayHeight + 6); + g.setColor(textColor); + g.drawString(sleepText, startingPoint + (blockSize / 2), normalSleepDayHeight); +} + + + + +function printNormalSleepDays(normalDate) { + var sleepInfo = getNormalSleepInfo(normalDate.hour); + var percentOfBlock = sleepInfo.internalBlockTime / sleepInfo.blockWidth; + var startingPoint = (screenWidth / 2) - (percentOfBlock * sleepInfo.blockSize); + + printNormalSleepDay(sleepInfo.text, sleepInfo.blockSize, sleepInfo.textColor, sleepInfo.blockColor, startingPoint); + + printNormalSleepDay(sleepInfo.otherText, sleepInfo.otherBlockSize, sleepInfo.otherTextColor, sleepInfo.otherBlockColor, startingPoint - sleepInfo.otherBlockSize); + printNormalSleepDay(sleepInfo.text, sleepInfo.blockSize, sleepInfo.textColor, sleepInfo.blockColor, startingPoint - sleepInfo.otherBlockSize - sleepInfo.blockSize); + + printNormalSleepDay(sleepInfo.otherText, sleepInfo.otherBlockSize, sleepInfo.otherTextColor, sleepInfo.otherBlockColor, startingPoint + sleepInfo.blockSize); + printNormalSleepDay(sleepInfo.text, sleepInfo.blockSize, sleepInfo.textColor, sleepInfo.blockColor, startingPoint + sleepInfo.otherBlockSize + sleepInfo.blockSize); +} + +function getNormalSleepInfo(normalHour) { + var text; + var otherText; + var blockSize; + var otherBlockSize; + var blockWidth; + var internalBlockTime; + var textColor; + var blockColor; + var otherTextColor; + var otherBlockColor; + if(normalHour >= 8 && normalHour <= 23) { + text = "Awake"; + otherText = "Sleep"; + blockSize = (normalDayWidth / timeWidth) * screenWidth * (normalAwakeHours / normalDayWidth); + otherBlockSize = (normalDayWidth / timeWidth) * screenWidth * (normalSleepHours / normalDayWidth); + blockWidth = normalAwakeHours; + internalBlockTime = normalHour - 8; + textColor = awakeTextColor; + blockColor = awakeBlockColor; + otherBlockColor = sleepBlockColor; + otherTextColor = sleepTextColor; + } else { + text = "Sleep"; + otherText = "Awake"; + blockSize = (normalDayWidth / timeWidth) * screenWidth * (normalSleepHours / normalDayWidth); + otherBlockSize = (normalDayWidth / timeWidth) * screenWidth * (normalAwakeHours / normalDayWidth); + blockWidth = normalSleepHours; + textColor = sleepTextColor; + blockColor = sleepBlockColor; + otherBlockColor = awakeBlockColor; + otherTextColor = awakeTextColor; + if(normalHour <= 8) { + internalBlockTime = normalHour + 1; + } else { + internalBlockTime = 0; + } + } + + return { + "text": text, + "otherText": otherText, + "blockSize": blockSize, + "otherBlockSize": otherBlockSize, + "blockWidth": blockWidth, + "textColor": textColor, + "blockColor": blockColor, + "otherBlockColor": otherBlockColor, + "otherTextColor": otherTextColor, + "internalBlockTime": internalBlockTime + }; +} + + +function drawClockPointer() { + g.setColor(watchColor); + var middle = screenWidth / 2; + var circleTop = normalSleepDayHeight + 38; + var circleBottom = weirdSleepDayHeight - 40; + + g.fillPoly([ + middle, circleBottom, + middle - 25, circleBottom - 5, + middle - 40, circleBottom - 16, + middle - 10, circleBottom + 5, + middle - 3, circleBottom + 10, + middle, circleBottom + 15 + ]); + + g.fillPoly([ + middle, circleBottom, + middle + 25, circleBottom - 5, + middle + 40, circleBottom - 16, + middle + 10, circleBottom + 5, + middle + 3, circleBottom + 10, + middle, circleBottom + 15 + ]); + + g.fillPoly([ + middle, circleTop, + middle - 25, circleTop + 5, + middle - 40, circleTop + 16, + middle - 10, circleTop - 5, + middle - 3, circleTop - 10, + middle, circleTop - 15 + ]); + + var circleTopRightY = normalSleepDayHeight + 29; + g.fillPoly([ + middle, circleTop, + middle + 25, circleTop + 5, + middle + 40, circleTop + 16, + middle + 10, circleTop - 5, + middle + 3, circleTop - 10, + middle, circleTop - 15 + ]); + +} + +function getNormalEvent(date) { + if(date.hour == 8) { + if(date.minute <= 15) { + return "Starting Breakfast"; + } + else if(date.minute >= 45) { + return "Ending Breakfast"; + } + return "Breakfast"; + } + else if(date.hour == 12) { + if(date.minute <= 15) { + return "Starting Lunch"; + } + else if(date.minute >= 45) { + return "Ending Lunch"; + } + return "Lunch"; + } + else if(date.hour == 7) { + if(date.minute <= 15) { + return "Starting Dinner"; + } + else if(date.minute >= 45) { + return "Ending Dinner"; + } + return "Dinner"; + } + else if(date.dayText == "Saturday" || date.dayText == "Sunday") { + if(date.dayText == "Sunday" && date.hour == 23 && date.minute >= 45) { + return "Weekend Ending"; + } + return "Weekend"; + } + else if(date.hour >= 9 && date.hour <= 17) { + if(date.dayText == "Monday" && date.hour == 9 && date.minute <= 15) { + return "Starting Work"; + } + else if(date.dayText == "Friday" && date.hour == 17 && date.minute >= 45) { + return "Work Ending"; + } + return "Work"; + } + return ""; +} + +function getWeirdEvent(date) { + if(date.hour == 8) { + if(date.minute <= 15) { + return "Starting Breakfast"; + } + else if(date.minute >= 45) { + return "Ending Breakfast"; + } + return "Breakfast"; + } + else if(date.hour == 14) { + if(date.minute <= 15) { + return "Starting Lincoln Lunch"; + } + else if(date.minute >= 45) { + return "Ending Lincoln Lunch"; + } + return "Lincoln Lunch"; + } + else if(date.hour == 23) { + if(date.minute <= 15) { + return "Starting Dinner"; + } + else if(date.minute >= 45) { + return "Ending Dinner"; + } + return "Dinner"; + } + else if(date.dayText == "Saturday" || date.dayText == "Sunday") { + if(date.dayText == "Sunday" && date.hour == 27 && date.minute >= 45) { + return "Weekend Ending"; + } + return "Weekend"; + } + else if(date.hour >= 9 && date.hour <= 19) { + if(date.dayText == "Monday" && date.hour == 9 && date.minute <= 15) { + return "Starting Work"; + } + else if(date.dayText == "Friday" && date.hour == 19 && date.minute >= 45) { + return "Work Ending"; + } + return "Work"; + } + return ""; +} + +function getWeirdHourLabel(hour){ + if(hour == 13) { + return ["Mid-day", "Nothingness", ""]; + } + else if(hour == 14) { + return ["Forescoreteen", "Lincoln's", "Hour"]; + } + else if(hour == 27) { + return ["", "Threeteen", ""]; + } else if (hour == 28) { + return ["", "The Void", ""]; + } + return ["", "", ""]; +} + +function printTime(thisDate, isShowTime) { + + printBackground(); + + var weirdDate = normalTo28HourDate(thisDate); + var normalDate = getNormalDateText(thisDate); + + var normalTime = normalDate.hourText + ":" + normalDate.minuteText; + var weirdTime = weirdDate.hourText + ":" + weirdDate.minuteText; + + g.setFontAlign(0, 0, 0); + g.setColor(mainTextColor); + + if(isShowTime) { + g.setFont("Vector", 36); + g.drawString(weirdTime, (screenWidth / 2) + 3, (screenHeight / 2) + 3); + + g.setFont("6x8", 2); + g.drawString(normalTime, screenWidth / 2 + 3, 84); + + g.setFont("6x8", 1); + var threeLabels = getWeirdHourLabel(weirdDate.hour); + g.drawString(threeLabels[0], screenWidth / 2 + 3, weirdSleepDayHeight - 70); + g.drawString(threeLabels[1], screenWidth / 2 + 3, weirdSleepDayHeight - 60); + g.drawString(threeLabels[2], screenWidth / 2 + 3, weirdSleepDayHeight - 50); + + } else { + g.setFont("6x8", 1); + g.drawString(quotes[quoteId][0], (screenWidth / 2) + 1, (screenHeight / 2) - 25); + g.drawString(quotes[quoteId][1], (screenWidth / 2) + 1, (screenHeight / 2) - 15); + g.drawString(quotes[quoteId][2], (screenWidth / 2) + 1, (screenHeight / 2) - 5); + g.drawString(quotes[quoteId][3], (screenWidth / 2) + 1, (screenHeight / 2) + 5); + g.drawString(quotes[quoteId][4], (screenWidth / 2) + 1, (screenHeight / 2) + 15); + g.drawString(quotes[quoteId][5], (screenWidth / 2) + 1, (screenHeight / 2) + 25); + + g.setFont("6x8", 1); + g.drawString("Forward ->", screenWidth - 40, normalSleepDayHeight + 35); + g.drawString("Backwards ->", screenWidth - 40, weirdSleepDayHeight - 35); + } + + g.setFont("6x8", 1); + g.drawString(getNormalEvent(normalDate), screenWidth / 2 + 3, normalSleepDayHeight + 16); + g.drawString(getWeirdEvent(weirdDate), screenWidth / 2 + 3, weirdSleepDayHeight - 16); + + g.setFont("6x8", 2); + printWeirdWeekDays(weirdDate); + printNormalWeekDays(normalDate); + + g.setColor(sleepTextColor); + g.setFont("6x8", 1); + printWeirdSleepDays(weirdDate); + printNormalSleepDays(normalDate); +} + +function printBackground() { + g.setFontAlign(0, 0, 0); + g.setColor(backgroundColor); + g.fillRect(0, normalSleepDayHeight + 9, screenWidth, weirdSleepDayHeight - 9); + + g.setColor(mainTextColor); + g.drawLine(0, screenHeight / 2, 64, screenHeight / 2); + g.drawLine(173, screenHeight / 2, screenWidth, screenHeight / 2); + + g.setFont("6x8", 2); + g.drawString("24x7", 30, normalSleepDayHeight + 50); + g.drawString("28x6", 30, weirdSleepDayHeight - 50); + + g.setColor(watchColor); + g.drawCircle(screenWidth / 2, screenHeight / 2, 55); + g.drawCircle(screenWidth / 2, screenHeight / 2, 54); + g.drawCircle(screenWidth / 2, screenHeight / 2, 53); + + drawClockPointer(); +} + +var now = new Date(); +var minute = now.getMinutes(); +var lookingDate = false; +var lookBack = false; +var timeout = false; +printTime(now, true); + +function isPrintTime() { + var currentTime = new Date(); + var thisMinute = currentTime.getMinutes(); + if(thisMinute != minute || lookBack) { + if(lookBack) { + lookBack = false; + timeout = false; + minute = thisMinute; + printTime(currentTime, true); + } + } +} + + +var secondInterval = setInterval(isPrintTime, 1000); +// Stop updates when LCD is off, restart when on +Bangle.on('lcdPower',on=>{ + if (secondInterval) clearInterval(secondInterval); + secondInterval = undefined; + if (on) { + secondInterval = setInterval(isPrintTime, 1000); + } +}); + + +function lookCurrent() { + lookBack = true; +} + +setWatch(() => { + var timeAhead = 3600000 * 12; + if(quoteId >= quotes.length - 1) { + quoteId = 0; + } else { + quoteId = quoteId + 1; + } + if(!lookingDate) { + lookingDate = new Date(); + } + lookingDate = new Date(lookingDate.getTime() + timeAhead); + printTime(lookingDate, false); + if(timeout) { + clearTimeout(timeout); + } + timeout = setTimeout(()=>lookCurrent(), 3000); +}, BTN1, { repeat: true, edge: "falling" }); + +setWatch(() => { + + var timeBehind = 3600000 * 12; + if(quoteId <= 0) { + quoteId = quotes.length - 1; + } else { + quoteId = quoteId - 1; + } + if(!lookingDate) { + lookingDate = new Date(); + } + lookingDate = new Date(lookingDate.getTime() - timeBehind); + printTime(lookingDate, false); + if(timeout) { + clearTimeout(timeout); + } + timeout = setTimeout(()=>lookCurrent(), 3000); +}, BTN3, { repeat: true, edge: "falling" }); + +setWatch(Bangle.showLauncher, BTN2, { repeat: false, edge: "falling" }); diff --git a/apps/twentyeightbysix/widget.js b/apps/twentyeightbysix/widget.js new file mode 100644 index 000000000..e69de29bb