Announcement

Collapse
No announcement yet.

DIPswitch -> GPIO BUS0 -> should let LED shine

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • DIPswitch -> GPIO BUS0 -> should let LED shine

    Hello together,

    At first I'm trying to descripe what I'm trying to do.
    I have created a simple program in ViSi Genie with a DipSwitch, my goal was it to shine a LED.
    So I have inserted a DipSwitch, how u can see in the picture below.

    Click image for larger version

Name:	P1010001.JPG
Views:	1
Size:	638.8 KB
ID:	44310

    My next step was to migrate the ViSi Genie into a ViSi code.
    Trough this step i got the code to make changes.

    Because I'm not so familar with programing, I have tried to use your could which I have found in one of your PDF's.

    bus_Set(0x00); //set all GPIO bus pins as outputs
    bus_Out(0x00); //then set them to low

    repeat
    state := touch_Get(TOUCH_STATUS);
    if(state == TOUCH_RELEASED)
    n := img_Touched(hndl,iDipswitch1);
    if(n == iDipswitch1)
    x := touch_Get(TOUCH_GETX);
    y := touch_Get(TOUCH_GETY);
    DIPstate := (y - 100) / (60/2);
    img_SetWord(hndl, iDipswitch1, IMAGE_INDEX, DIPstate);
    img_Show(hndl, iDipswitch1);
    //control BUS_0
    if (DIPstate == 0)
    pin_LO(BUS_0);
    else
    pin_HI(BUS_0);
    endif
    endif
    endif
    forever

    Where I have to enter this code, or better said how can I enter it that it will works?

    I have attached the program below:



    What I have entered:

    Click image for larger version

Name:	gpios_out.png
Views:	1
Size:	82.4 KB
ID:	44313



    Click image for larger version

Name:	code_for_led.png
Views:	1
Size:	76.4 KB
ID:	44312

    I added the var's because the program didn't compile.
    But anyhow I have made it wrong because it didn't work.
    Can anyone help me to bring the LED to shine =), would be nice.

    Thank you, and best regards!
    Dennis






  • #2
    Hi Dennis,

    Because I'm not so familar with programing, I have tried to use your could which I have found in one of your PDF's.
    Looking at the code you inserted, it seems that you got it from the application note

    ViSi GPIO Bus Control Using DIP Switch Objects Picaso

    http://www.4dsystems.com.au/appnote/4D-AN-00067/

    The application note already shows how to control the GPIO bus or a GPIO pin using a DIP switch. Is the application note not helpful enough? If something is not clear in that application note, please let me know.

    My next step was to migrate the ViSi Genie into a ViSi code.
    Trough this step i got the code to make changes.
    This method is not recommended. You would end up getting frustrated, especially if you are not familiar with programming. As you might have already observed, the code for a ViSi-Genie program is complicated. If you choose to continue with this, I cannot help you, sorry.

    I suggest that you start with the app note ViSi GPIO Bus Control Using DIP Switch Objects Picaso. Understand the attached basic programs and expand them if necessary to suit your application.

    By the way, you can now insert codes to a ViSi-Genie program using the new ViSi-Genie Magic objects. This way, you have more control over the program. You will need Workshop Pro though.

    Best Regards.
    Doff

    Comment

    Working...
    X