HISE Logo Forum
    • Categories
    • Register
    • Login

    Calculator Project

    Scheduled Pinned Locked Moved Scripting
    34 Posts 3 Posters 2.3k Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • ustkU
      ustk @Sawer
      last edited by

      @sawer Oh, seeing @d-healey answer, I realise you might want to make a calculator WITH buttons...
      Then it's a bit harder to append the digits

      Can't help pressing F5 in the forum...

      S 1 Reply Last reply Reply Quote 0
      • S
        Sawer @d.healey
        last edited by

        @d-healey Thanks so much for the int.
        Diving into the snippet now.

        1 Reply Last reply Reply Quote 0
        • S
          Sawer @ustk
          last edited by

          @ustk Interesting approach.
          So my real intent is to use customised panels for the digits and screen.
          I'm now working on the backend of the calculator, and buttons are the most accessible thing to do numbers digits and equal signs.
          But thanks so much h for this. When done with the algorithm part of the calculator, ill use your idea for the gui (frontend)

          1 Reply Last reply Reply Quote 0
          • S
            Sawer @ustk
            last edited by Sawer

            @ustk said in Calculator Project:

            I realise you might want to make a calculator WITH buttons...
            Then it's a bit harder to append the digits

            @ustk Yeah, I thought it was easier. I want to do it like a normal phone calculator. So either buttons or panels, they all need to be assigned to a digit (0-9).

            1 Reply Last reply Reply Quote 0
            • d.healeyD
              d.healey
              last edited by d.healey

              Here's a basic calculator (less than 100 lines of code). Maybe don't look at it until you've tried to do it yourself. Use buttons for your first attempt because they make it easier to understand what's happening. Then try swapping all of the buttons for one or two panels - Christoph showed how to use a panel as a grid of buttons in one of the live streams I did (I think it was the second one).

              636a2d73-6b65-41d1-9068-cfbdb00d9bdd-image.png

              HiseSnippet 1347.3ocuXttaaaCE.lxIJa1csqEXO.B9WJKoI14dQav7hS7fwxEi4thATzUPKQaSDZROIpj3sUf8NrWn9nrGg9FrcntXQmXkXaL07ijb34B+3gWNhrkmvg36K7PFEe8ngDjwWY1dDW1udeLkiZdLx3qMcvLm.FVJ7ZDvQGMZH12m3hLLV5GTFYT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V2c9YcurVCj2rt27y59YsF3icxWV2e9Y8frVCj2rdv7y5KxZMPdy5KlQVeho12ZpW4x5O+LR6lKBsUyh17d+02tHztUVzl2UDd9hP61YQad+MLqMiz9Hyw2eHqsX4MpGNinVxL4QAx5P17kTSy5Luow5iiY8TbGBK9jqzKbneJaGMXQmWKtqMM9UCDJoaMMdEnDyn83CB6kuvzKTSW3asaS+cs2daqXxRjKWqSujWhq3JPC+czS2cmmk5olmIbiddP8WIS8zfwJfaeLwSSod9ItOUNR+oC+e6oylUDelYKpzo+zYrvTXDtiRdvX7CN9XyS51k3HSAbYyF+R975hneRDHo7dmgkdTXIkITXrMLS6PfdmyIL0s+LJntmVjbEkrJCzFt2cnv+B+DqrpR1HVY0DknAXGOw6chtyo5IM+xvV.l3gulaQyyTxVUQg2CUsmnxFUPCf8Su2wQM7eNbgjo6yVKfOau.9ryB3ytKfO6s.9r+B3yA2qOpix99.oXPz1AngVmDd4bCiSBOqKbUH5+vsCMIZ
              

              Libre Wave - Freedom respecting instruments and effects
              My Patreon - HISE tutorials
              YouTube Channel - Public HISE tutorials

              ustkU S 2 Replies Last reply Reply Quote 2
              • ustkU
                ustk @d.healey
                last edited by

                @d-healey haha, I don't look either, I'm taking the challenge :)

                Can't help pressing F5 in the forum...

                S 1 Reply Last reply Reply Quote 1
                • S
                  Sawer @d.healey
                  last edited by

                  @d-healey Yeah, I Won't look until I made it myself. But thanks
                  Thanks so much David.
                  But learning from your previous script I have some question:

                  Screenshot 2022-01-31 at 14.19.58.png

                  I know it requires experience for you to create such efficient and effective code in less time, but I want to know how do you think?
                  How can you know that for a certain task it requires a precise tool.
                  Do I also need to learn a bit of logics?

                  d.healeyD 1 Reply Last reply Reply Quote 0
                  • S
                    Sawer @ustk
                    last edited by

                    @ustk Ahahah It's a challenging but cool project. I'm learning a lot!
                    Thanks so much guys.

                    1 Reply Last reply Reply Quote 0
                    • d.healeyD
                      d.healey @Sawer
                      last edited by

                      @sawer said in Calculator Project:

                      Do I also need to learn a bit of logics?

                      This is absolutely the most important part of programming. Once you understand boolean logic, operators, and control statements (loops and ifs) then you'll be able to plan your strategy more quickly and efficiently.

                      But I change things as I go too. For example in my calculator example I've used two different methods for adding the input to the label, but I think the second method (getting the button text) is actually better in this example and I should have used it for both.

                      Libre Wave - Freedom respecting instruments and effects
                      My Patreon - HISE tutorials
                      YouTube Channel - Public HISE tutorials

                      S 1 Reply Last reply Reply Quote 0
                      • S
                        Sawer @d.healey
                        last edited by

                        @d-healey said in Calculator Project:

                        This is absolutely the most important part of programming.

                        Thanks.
                        How and where to learn logics? Wanna do that on a daily basis to be more proficient in thinking.

                        d.healeyD 1 Reply Last reply Reply Quote 0
                        • d.healeyD
                          d.healey @Sawer
                          last edited by

                          @sawer said in Calculator Project:

                          How and where to learn logics?

                          There are some links to Javascript tutorials in the HISE docs which are a good place to start. Once you get the basics you need to read and write lots of code to practice and get it to become a natural part of your thinking when you're presented with a programming challenge.

                          YouTube is also a good for general info - https://www.youtube.com/results?search_query=boolean+logic

                          Libre Wave - Freedom respecting instruments and effects
                          My Patreon - HISE tutorials
                          YouTube Channel - Public HISE tutorials

                          S 1 Reply Last reply Reply Quote 0
                          • S
                            Sawer @d.healey
                            last edited by

                            @d-healey Thanks a lot!

                            1 Reply Last reply Reply Quote 0
                            • S
                              Sawer
                              last edited by Sawer

                              HiseSnippet 1155.3ocsW1uahaDD.eMI9zg6Gpmz8.rG+EQIkCx2mRSaBjjJT9BURipTzoSarWBqhYWqcWmFTUj56SeI5iTeCZmwFBlD7o.zCIDL67g+Mi2c73VZkO2XTZhSwK5GwINesa69Ra2FcYBIo4A3B6aLhajmE2yPp2OhYL7.hiyB+LZgSwEIIe9mepNKjI84iVhPtTI74mH5IriVs0dGKBCOhEvuPzKi0quWSekrgJTECzrfaURDy+V1M7yXnYEbINu5v.gUoaaYVtg3rXcUP+1cU+tL09KEFw0gbTnFoMDnzkOREFfDiqRZzUDFzZXVaHPTZMpFrPZM3stmJBDOt9nZw2knfNxir0Cm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oylfu8wqSVAXRl7hWEcOEko0HIyq.94VsRUROXi2m78wz+6gQLlrOqNC9r1L3y5yfOaLC9r4L3yVyfOa+Y8AOyuerU0K83.rPqCSFhyw4vjlBI6BI+GfQeWT2
                              

                              @d-healey @ustk Ehehe, I think Really tried my best. Probably the challenge is too big for me. This is how far I got and I don't really know how to break the problem into a smaller one..So I'm stuck.

                              d.healeyD 1 Reply Last reply Reply Quote 0
                              • d.healeyD
                                d.healey @Sawer
                                last edited by

                                @sawer Add a label to display the output and add an = button that when pressed carries out the calculation.

                                Libre Wave - Freedom respecting instruments and effects
                                My Patreon - HISE tutorials
                                YouTube Channel - Public HISE tutorials

                                S 1 Reply Last reply Reply Quote 0
                                • S
                                  Sawer @d.healey
                                  last edited by

                                  @d-healey Thanks.
                                  Given some tome to try understanding your code:

                                  1. How did you come up with he appendInput function , especially the "+="
                                  2. What's eval? There's no this such as that in the Api.

                                  I'm learning a lot. Thanks

                                  d.healeyD 1 Reply Last reply Reply Quote 0
                                  • d.healeyD
                                    d.healey @Sawer
                                    last edited by d.healey

                                    @sawer said in Calculator Project:

                                    How did you come up with he appendInput function , especially the "+="

                                    += Is a standard js operator

                                    @sawer said in Calculator Project:

                                    What's eval? There's no this such as that in the Api.

                                    Libre Wave - Freedom respecting instruments and effects
                                    My Patreon - HISE tutorials
                                    YouTube Channel - Public HISE tutorials

                                    S 1 Reply Last reply Reply Quote 0
                                    • S
                                      Sawer @d.healey
                                      last edited by Sawer

                                      @d-healey Thanks David.

                                      So I realised that I'm trying to solve problems that are bigger than me. This project is bigger than me. I'm pausing it for now and and solve easier problems while getting more of the logical thinking. Once I get more experience on this, I'll come back with more knowledge and more confidence to solve.
                                      Thanks a lot.

                                      1 Reply Last reply Reply Quote 2
                                      • S
                                        Sawer
                                        last edited by Sawer

                                        Hello everyone!
                                        I've finally managed to build the calculator with my own fingers and brain.
                                        I understood the logics behind the operations and especially the input to the label component.

                                        Screen Recording 2022-02-08 at 15.31.27.gif

                                        I'm getting excited to improve it just a little bit, and by that I have 3 questions:

                                        1. How can I use the operational button as "switches" where only on sign can be accepted by the input for each operation (23 +- 21, I do not want this to happen).

                                        2. Is there a way to not "show" the operational sign to the label without affecting the input?

                                        3. Is there a way to reset the label after first addendum and operational sign have been selected? In that case the label would be blank waiting for the second addend.

                                        Any help is appreciated, hope there's a way that doesn't require too much code, but by what I'm thinking, conditional statements are key to make these work.

                                        1 Reply Last reply Reply Quote 1
                                        • S
                                          Sawer
                                          last edited by

                                          Hello everyone!
                                          Screen Recording 2022-02-18 at 11.35.21.gif

                                          Trying to style this calculator here, I'm working on the customisation of the buttons.
                                          I just want to set an animation that once a number is pressed, a background pops up and scales itself while fading thru opacity, (just like website buttons).

                                          I'm currently running with 2 issues:

                                          1. As shown in the video , once the mouse is gone, the buttons background goes away but the buttons frame remains until I press another button.

                                          2. For the scaling and fading implementation, I've tried to set a Timer where the opacity of the background fades in 1000 milliseconds. It didn't work on the
                                            if(obj.down) functions/Conditional Statement. Also want to know if there is a way to scale the rectangle by x.

                                          Any Help is super appreciated. I'm so far happy of the improvements, just wanna add this little UX feature.

                                          d.healeyD 1 Reply Last reply Reply Quote 1
                                          • d.healeyD
                                            d.healey @Sawer
                                            last edited by d.healey

                                            @Sawer Is that individual buttons or are you using a panel? You should be using a panel really.

                                            Libre Wave - Freedom respecting instruments and effects
                                            My Patreon - HISE tutorials
                                            YouTube Channel - Public HISE tutorials

                                            S 2 Replies Last reply Reply Quote 0
                                            • First post
                                              Last post

                                            46

                                            Online

                                            1.7k

                                            Users

                                            11.7k

                                            Topics

                                            101.9k

                                            Posts