APP request: Drink counter

Posted on
of 2
/ 2
  • The only app that I now really miss from my Pebble is the Drink Counter:­/304ol2/app_drink_counter_preview_for_pe­bble_time/

    Does anyone have the time to work on this? I might be willing to help, but time and skills are limited :)

  • Do you specifically want the blood alcohol level in there, or is it just for counting drinks?

    I am reminded of­QpE


  • Actually both :)

  • I always thought that was an odd app on the Pebble - surely it isn't that hard to remember how many drinks one has had in a week?

  • Hey, this is just for science!

  • Hank, how about we do it the other way around. You develop the app and we help you :)

  • Yeah, well, I am more or less someone who can adjust code. Writing a whole new thing is something I am not that comfortable with.
    However, what we need is

    1. 4 way swipe (left/right to select item; up/down to increase/decrease amount)
    2. Double tap (and confirm) to reset settings
    3. Making sure you don't accidentally exit the app (remember, you probably had some alcohol for science)
    4. The calculations
    5. The images
    6. A settings page for things like beer size, age, weight, sex etc.
  • ok, the good news is that already you have seen source code. Lets see if we can help you to create a new app. The most important in development: Do one thing at a time, not all 6 steps you have.

    I suggest you start with the layout and before that you should have done the following three tutorials:­pment­App­

  • I think an ethanol sensor should be added via BLE.­s/PMC6407881/

  • Looked into the oiginal Pebble sources. BAC calculation seems to be rather straigt forward. Will look into it on the weekend.
    Adding a sensor is item 128374 on my list :)

  • Lame question as I don't get the concept of the display buffer.
    I cuccently do

    	g.setBgColor(­,145,176,176); //Clear
    	g.drawString(drinks[activeDrink], (40 * (activeDrink + 1)) -20, 165);

    But having this fillRect to clear the previous written number feels totally wrong. What is the right way to do it?

  • What is the right way to do it?

    Just use clearRect (you don't need to set the color then since it used the background color).

    However in an ideal world you might use the Layout library (­) which would handle the positioning (and erasing of the background) for you - so then it'd all be in the right position on Bangle.js 1 too

  • Made pretty good progress. If someone wants to review the code for tweaks it would be the right time.
    All that is missing is a settings page and a double check if the calculations are right. The settings are hard coded for now, but you get an idea of the app though.

    1 Attachment

    • screenshot_230.jpg
  • I know how to do that - just no time for now :) .

  • @Hank on top of Gordon's suggestion with the layout module I would have those suggestions:

    • Replace your custom time handling with the locale module­e

      // Current time, e.g. 15:49
      require("locale").time(new Date(), 1);
      // First drink, e.g. 15:49
      require("locale").time(firstDrinkTime, 1);
    • You have a bunch of assignments like

      a = a + 1;
      b = b - 1;

    that can be shortened to

  • To be honest, I get better along without the Layout library :)
    I considered using the locales, but for BAC calculation I need a full time element including date to calculate the correct difference. Will work on that.
    ++ shortening is really necessary in the code clean up I will do when development is stable. Will do that then. Thanks for the suggestions!

  • The app should now be usable more or less. Thanks for the suggestions. PR pending...

    I learned ther is no function to invert an image, is there?
    Currently for the reset icon I use two different ones ant then decide by theme background which one to show. Is there a better way to do this?

  • @Hank if your icon is using 1 or 2bpp then you can style it by setting the FG and BG colors before rendering, see­377280/#comment16583897

  • Seems to be working fine. Thanks a lot!

  • Merged!

  • There ya go @ajkm - your new favorite app :)

  • Well, I wouldn't go that far - and the number of times I drink in a week, and the number of drinks, can be counted on one hand usually!

  • Post a reply
    • Bold
    • Italics
    • Link
    • Image
    • List
    • Quote
    • code
    • Preview

APP request: Drink counter

Posted by Avatar for Hank @Hank