how to implement DIM AS CODE


Closed Thread
Results 1 to 7 of 7
  1. #1
    Join Date
    Jun 2015
    Posts
    2

    Default how to implement DIM AS CODE

    hello,

    i am trying to write code for my 5*5*5 led cube. this is a test setup before i start building my 8*8*8 RGB led cube to avoid any errors in the final project.
    i am of course using shift register to extend the amount of outputs, however the electronics itself are not the problem since i am struggeling with the code.
    i already did get the shout command working and also used array's bud the downside of that is that they are stored as variabels.
    so i was looking for a method to store the data in the flash memory of the pic, i found the following command: DIM ...... AS CODE in the documentation.
    it is able to do exactly what i want. bud the documentation doesn't tell me how to implement it. i would like to store 8bit values, so it should look a bid like this:

    %10000000
    %11000000
    %11100000

    i want to store data tables that the program needs to walk trough one by one. the problem is how can i write this kind of data table to the flash memory with the DIM .... AS CODE command?

    thanks in advance

  2. #2
    Join Date
    Jan 2005
    Location
    Montreal, Quebec, Canada
    Posts
    2,597


    Did you find this post helpful? Yes | No

    Default Re: how to implement DIM AS CODE

    DIM is BASIC, this forum is for PIC BASIC.

    From the manual:
    4.5. Arrays
    Variable arrays can be created in a similar manner to variables.
    Label VAR Size[Number of elements]

    Label is any identifier, excluding keywords, as described above. Size is BIT, BYTE or WORD. Number of elements is how many array locations is desired. Some examples of creating arrays are:

    sharks var byte[10]
    fish var bit[8]
    Robert
    My Creality Ender 3 S1 Plus is a giant paperweight that can't even be used as a boat anchor, cause I'd be fined for polluting our waterways with electronic devices.

    Not as dumb as yesterday, but stupider than tomorrow!

  3. #3
    Join Date
    Jan 2005
    Location
    Montreal, Quebec, Canada
    Posts
    2,597


    Did you find this post helpful? Yes | No

    Default Re: how to implement DIM AS CODE

    I bet you're using PROTON PIC:
    http://www.picbasic.nl/indexes_uk.htm

    Try here:
    http://www.protonbasic.co.uk/forum.php

    Robert
    Last edited by Demon; - 14th June 2015 at 02:27. Reason: Link

  4. #4
    Join Date
    Jun 2015
    Posts
    2


    Did you find this post helpful? Yes | No

    Default Re: how to implement DIM AS CODE

    thanks for the response. i didn't know there was a diffrence to be honest. is there a big difference between the two?

  5. #5
    Join Date
    Jan 2005
    Location
    Montreal, Quebec, Canada
    Posts
    2,597


    Did you find this post helpful? Yes | No

    Default Re: how to implement DIM AS CODE

    Can't say, I'm not familiar with Proton.

    But BASIC is BASIC so it can't be very different.

  6. #6
    Join Date
    Aug 2003
    Posts
    985


    Did you find this post helpful? Yes | No

    Default Re: how to implement DIM AS CODE

    That would be a lookup table in PBP.

  7. #7
    Join Date
    Aug 2003
    Posts
    985


    Did you find this post helpful? Yes | No

    Default Re: how to implement DIM AS CODE

    and you’d generate patterns like that on the fly
    Code:
    pattern var byte
    i var byte
    displayram var byte[8]
    
    pattern = %11111111
    
    for i = 0 to 7
    pattern = pattern << 1
    displayram[7-i] = pattern
    next i

Similar Threads

  1. Very quick question... To help a dim wit !!
    By andybarrett1 in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 6th October 2014, 21:01
  2. Maths help for the terminally dim please
    By retepsnikrep in forum mel PIC BASIC Pro
    Replies: 12
    Last Post: - 7th July 2013, 19:15
  3. question about how to implement ASM and ENDASM
    By karenhornby in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 9th March 2008, 09:21
  4. dim a led
    By fred.pacc in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 21st November 2006, 17:49
  5. Implement a timer without using an interrupt
    By coyotegd in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 26th February 2006, 18:44

Members who have read this thread : 1

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts