Creative ways to make macros with the least amount of code space


+ Reply to Thread
Results 1 to 5 of 5
  1. #1
    Join Date
    Nov 2007
    Posts
    42

    Default Creative ways to make macros with the least amount of code space

    So I have been thinking about making a project to create macros but can't think of a creative way to save on the code space.

    Here is a simple way of explaining what I am attempting to do.

    So lets say we have 5 leds and each has it's it's own tactile switch to turn it on. The way I have envisioned the code is have an included file called "button checks" which has a routine that checks each button (tris register) and sets a bit if the button is pressed. In the main program, you have the routines that check the bits and turn on the LED if the bit returns the expected value.

    Now, say I want to have a "macro" button that can be programmed to turn on a particular set of LED's when it's pressed. So of course you would have a programming mode and while it's in the programming mode, you would press the buttons for which leds you want to turn on with the macro button. So out of the 5 led's, lets say I wanted the button to turn on the red and green leds with the macro button.

    While I know I could do this using a lot of code space, I am trying to find a creative way to do it with the least amount of code space. There are a lot of commands in picbasic that I have yet to use, or use in the best way, that I am hoping will help keep this project low in code space.

    Any thoughts?

  2. #2
    Join Date
    Aug 2006
    Location
    Look, behind you.
    Posts
    2,817


    Did you find this post helpful? Yes | No

    Default Re: Creative ways to make macros with the least amount of code space

    Using the TRIS register, simply state TRISx = %11111100 assuming you have already set the portx to %00000011 that would make outputs on. You would be switching between input and hot(logic 1) output. Why a macro?
    If you do not believe in MAGIC, Consider how currency has value simply by printing it, and is then traded for real assets.
    .
    Gold is the money of kings, silver is the money of gentlemen, barter is the money of peasants - but debt is the money of slaves
    .
    There simply is no "Happy Spam" If you do it you will disappear from this forum.

  3. #3
    Join Date
    Nov 2007
    Posts
    42


    Did you find this post helpful? Yes | No

    Default Re: Creative ways to make macros with the least amount of code space

    Maybe I didn't explain it right.

    Lets say you had a keypad with button 0 to 10. Each button press is read as a number under normal operation. Now put a big read button on the wall and allow that button to be custom programmed to be any button combination. So I could make that big red button on the wall bee 554422 or 541874, whatever I wanted. So you would put that button in to a "programming mode" and then on the keypad, type in the sequence you want, exit programming mode and now the big red button does that sequence every time you press it. It's like using a gaming keypad on a computer. You can record a macro or keystrokes that are replayed when pressing the button you chose to use to play the macro back (in our case the big red button).

    The only way I see to do this with little code space is getting creative with arrays but I have nearly zero experience with arrays.

  4. #4
    Join Date
    Aug 2006
    Location
    Look, behind you.
    Posts
    2,817


    Did you find this post helpful? Yes | No

    Default Re: Creative ways to make macros with the least amount of code space

    I'm a little weak with arrays too, but a keypad reader will require one. What you can do is have a subroutine with the master code and use the "big red button" control it. Mister_e did a keypad routine as an include, but you'll have to roll your own array to store the results.
    If you do not believe in MAGIC, Consider how currency has value simply by printing it, and is then traded for real assets.
    .
    Gold is the money of kings, silver is the money of gentlemen, barter is the money of peasants - but debt is the money of slaves
    .
    There simply is no "Happy Spam" If you do it you will disappear from this forum.

  5. #5
    Join Date
    Jun 2009
    Location
    Sc*nthorpe, UK
    Posts
    333


    Did you find this post helpful? Yes | No

    Default Re: Creative ways to make macros with the least amount of code space

    Quote Originally Posted by plyrathrt View Post
    Maybe I didn't explain it right.

    Lets say you had a keypad with button 0 to 10. Each button press is read as a number under normal operation. Now put a big read button on the wall and allow that button to be custom programmed to be any button combination. So I could make that big red button on the wall bee 554422 or 541874, whatever I wanted. So you would put that button in to a "programming mode" and then on the keypad, type in the sequence you want, exit programming mode and now the big red button does that sequence every time you press it. It's like using a gaming keypad on a computer. You can record a macro or keystrokes that are replayed when pressing the button you chose to use to play the macro back (in our case the big red button).
    Sound easy enough to me.
    The only way I see to do this with little code space is getting creative with arrays but I have nearly zero experience with arrays.
    Looks like a good reason to learn. Let me know if you want me to help.

Similar Threads

  1. Working code but my layman approach uses too much code space
    By Christopher4187 in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 14th December 2012, 20:44
  2. I'm running out of code space example.
    By retepsnikrep in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 21st June 2010, 20:33
  3. Ways to make code easily reviewable and extendable
    By Ted's in forum mel PIC BASIC Pro
    Replies: 14
    Last Post: - 23rd August 2008, 00:10
  4. Need more code space
    By Sphere in forum General
    Replies: 2
    Last Post: - 19th September 2005, 20:49
  5. Need more code space
    By ghutchison in forum General
    Replies: 1
    Last Post: - 12th February 2005, 20:54

Posting Permissions

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