Main Site Documentation

Snippet - .NET Micro Framework Calculator


#1

.NET Micro Framework Calculator

Hello Guys,
this is my second project with the Cerberus Starter Kit (btw. i startet programming in C# 2 days ago).
i wrote that Code just for fun so… , if you want you can try it out :wink:

If you get some bug issues just post them and i’ll fix them.

You need:
GHI Mainboard
Joystick
led7r

Instructions:
Once you compiled the Code you take the Joystick and push it upwards for calculating with “+”,
downwards for “-”, right for “*” and left for “/”.
you’ll need to hold it till you push once. Then you can pull the Joystick left or right for the first number you want to calculate with, after that push it again. Then you can choose the second number again with left and right and press it once more then you’ll get the solution. You can reset with pushing the button on the joystick

PS: you can also see on the led7r that when you choose your number the light above is going to light up when you increase it and when you decrease the other light will show up


#2

A video of it in action would be nice!


#3

Very nice but yes a video would make it super cool


#4

Ok i will add an Video soon, but it is late here in Germany so i will do it tomorrow.


#5

So finally got the video working you can watch it here: http://youtu.be/-DwgaCpY1H4 or just go to my codeshare post an there it is embedded


#6

Good job! :smiley:


#7

very good job in fact !

Here’s a suggestion for you. Make the LED7 indicate the results :slight_smile: Figuring out how to represent individual digit values shouldn’t be that hard, right? :wink:


#8

@ Brett - Yeah this is a very good idea, i actually have an idea right now how to make that work.


#9

Well done! :slight_smile:


#10

Great job! Very unique solution. Keep 'em coming!


#11

Now finally figured out how to display the solution on the LED, you can check out how it works in the sources changes.
I will also will try to make it completely independent from the Pc, so you don’t need to have the debug monitor.

I have an question: Is there any possibility that if something didn’t check out that it will be rebooting the cerberus ?


#12

If there is an unhandled exception it might crash you application if that what you are asking.


#13

@ Architect - Nevermind i got i found a solution :slight_smile:


#14

Hello Guys i have a little problem and i cant get it to work, so sometimes it doesn’t recognizes the joystick position.
There is normally the getjoystick method, but for demonstration purposes, i’ll go with these 2 numbers.
I push the button and i get the first Debug.Print with the numbers, but it dont gets through the if query. Do you guys have an idea.

In the Screenshot you can see the debug monitor

void joystick_JoystickPressed(Joystick sender, Joystick.JoystickState state)
        {
            double joystickPosX = 0;
            double joystickPosY = 0.20903540903540907;
            
                stoplightLED();
                Debug.Print("X:  " + joystickPosX + "Y:  " + joystickPosY);
                if (joystickPosX > 0 && joystickPosX < 0.3 && joystickPosY > 0 && joystickPosY < 1)
                {

                    j++;

                    Debug.Print(" You are calculating with: +");

                }

PS: The rest of the code you can see in the codeshare


#15

If JoystickPosX = 0, then it is not Greater than 0.

Change to:

if (joystickPosX >= 0 && joystickPosX < 0.3 && joystickPosY > 0 && joystickPosY < 1)


#16

@ Mark13 - Oh thank you, how can i just be that stupid :slight_smile: