ultrasound Posted April 27, 2007 Report Share Posted April 27, 2007 HelloI have an idea but i dont know how to do this:When i will press button #1 - the led under the button will turn onwhen i will press button #6 - the led under the button #1 will turn off and the led under button #6 will turn on...and so on...... and, how can i make some groups ?By groups i mean something like this:I have one group of 10 buttons with leds and another group of 10 buttons with leds, and i want that leds in only one group will switch betwen them.Greets Quote Link to comment Share on other sites More sharing options...
stryd_one Posted April 27, 2007 Report Share Posted April 27, 2007 There are a few ways that you could do something like this, and the best will depend on lots of factors... I would probably store the button/LED on/off states in an int (or 2 chars) and update the CS accordingly. You could use arrays to 'group' these ints. Hope that helps! Quote Link to comment Share on other sites More sharing options...
audiocommander Posted April 27, 2007 Report Share Posted April 27, 2007 You could use arrays to 'group' these ints. yes.or you could set up one or more bitfields (8 bits max) instead of an array. this involves strucs (and unions), so I hope I don't confuse you ;)example: typedef union { struct { unsigned ALL:8; }; struct { unsigned led1:1; unsigned led2:1; unsigned led3:1; unsigned led4:1; unsigned free:4; }; } something_t; // declare var something_t something; // set bits something.led1 = 1; something.led3 = 0; // get number mynum = something.ALL; regards,Michael Quote Link to comment Share on other sites More sharing options...
tos Posted December 17, 2007 Report Share Posted December 17, 2007 this piece of code should be placed somewhere on a wiki code snippets section.along with other ones like reading jog-shuttle encoder or using bankstick..... Quote Link to comment Share on other sites More sharing options...
audiocommander Posted December 18, 2007 Report Share Posted December 18, 2007 http://www.midibox.org/dokuwiki/c_tips_and_tricks_for_pic_programming#bitfields_unions_structs;) Quote Link to comment Share on other sites More sharing options...
julienvoirin Posted January 15, 2008 Report Share Posted January 15, 2008 AC rocks !! a long time i am waiting for these explanations. Thanks Quote Link to comment Share on other sites More sharing options...
DavidBanner Posted January 16, 2008 Report Share Posted January 16, 2008 I've got a similar bit of functionality to write and in the back of my mind I have using tables as one of the options to explore.would it be possible to use a table for the same sort of functionality?and if so, what are the advantages/disadvantages? Quote Link to comment Share on other sites More sharing options...
audiocommander Posted January 17, 2008 Report Share Posted January 17, 2008 Hi David,generally spoken, this is a nice, clean (clearly named) and effective method to set some values; very small in size - and by making a union out of the structure, these states can easily be accessed as an unsigned int, which makes conversions unnecessary (eg when reading or writing a patch - or setting all bits at once!).The disadvantage is, that SDCC currently only allowes bitfields of 8 bits maximum, which might make things complicated (at least it has been for SDCC 2.4.x, dunno about 2.7.x).Another disadvantage can be the way to access the bits. For example, you need to loop through all values in the struct, one by one. This way you either have to work on the bits with bitmasks or you need to address all struct names seperately which is not possible with a counter.I guess, a (boolean) array should be nearly as effective as a bitfield. Its maximum is 255 bytes (? can't remember exactly, nevertheless this is big). Access is easy, but not that straightforward if you want to load/save the whole array.So, it clearly depends ;DBest,Michaelps: thanks, julien :D Quote Link to comment Share on other sites More sharing options...
stryd_one Posted February 11, 2008 Report Share Posted February 11, 2008 bitfields (8 bits max)Good news, I have just tested a 15-bit bitfield (15, not 16, to test correct alignment of odd sizes across bytes), and all accesses are correct :)This was with a post 2.7.0 release. Quote Link to comment Share on other sites More sharing options...
ultrasound Posted February 28, 2008 Author Report Share Posted February 28, 2008 HiI'm looking for somebody who can help me with led groups for buttons [notes]example:While pressing button #1 - the led under the button will turn onWhile pressing button #6 - the led under the button #1 will turn off and the led under button #6 will turn onI have one group of 10 buttons with leds and another group of 10 buttons with leds, and i want that groups of leds work independently. So that, when I push the button from 1st group and the button from 2nd group, they both led will be turn on. But when I turn on, for example, the other button from 2nd group, the led from the 2nd group will switch(the new one will be now shinning) but in the 1st group nothing will change.My controller (check the enclosure):group 1:90x0090x0190x0290x0390x0490x0590x0690x0790x0890x0990x0A90x0BGroup 2:90x1C90x2C90x3C90x4C90x5C90x6C90x7CGroup3:90x1D90x2D90x3D90x4D90x5D90x6D90x7DGroup4:90x1090x1190x1290x1390x1490x1590x1690x1790x1890x1990x1A90x1B90x2090x2190x2290x2390x2490x2590x2690x2790x2890x2990x2A90x2B90x3090x3190x3290x3390x3490x3590x3690x3790x3890x3990x3A90x3B90x4090x4190x4290x4390x4490x4590x4690x4790x4890x4990x4A90x4B90x5090x5190x5290x5390x5490x5590x5690x5790x5890x5990x5A90x5B90x6090x6190x6290x6390x6490x6590x6690x6790x6890x6990x6A90x6B90x7090x7190x7290x7390x7490x7590x7690x7790x7890x7990x7A90x7BNEXT NOTES Of WHAT I NEED:90x0C90x0D90x0F90x1F90x2F90x3F90x4F90x5F90x6FBut leds for that and rest notes must be like that, I push the button>led turn on, I push the button again (turn off the effect)>led turn offCan anyone help me to change ain64_din128_dout128_v1_3 code?I hope, that all i wrote, it's not too knotty..Best RegardsWaiting for proposition Quote Link to comment Share on other sites More sharing options...
ultrasound Posted March 3, 2008 Author Report Share Posted March 3, 2008 HiI'm looking for somebody who can help me with led groups for buttons [notes]example:While pressing button #1 - the led under the button will turn onWhile pressing button #6 - the led under the button #1 will turn off and the led under button #6 will turn onI have one group of 10 buttons with leds and another group of 10 buttons with leds, and i want that groups of leds work independently. So that, when I push the button from 1st group and the button from 2nd group, they both led will be turn on. But when I turn on, for example, the other button from 2nd group, the led from the 2nd group will switch(the new one will be now shinning) but in the 1st group nothing will change.My controller (check the enclosure):group 1:90x0090x0190x0290x0390x0490x0590x0690x0790x0890x0990x0A90x0BGroup 2:90x1C90x2C90x3C90x4C90x5C90x6C90x7CGroup3:90x1D90x2D90x3D90x4D90x5D90x6D90x7DGroup4:90x1090x1190x1290x1390x1490x1590x1690x1790x1890x1990x1A90x1B90x2090x2190x2290x2390x2490x2590x2690x2790x2890x2990x2A90x2B90x3090x3190x3290x3390x3490x3590x3690x3790x3890x3990x3A90x3B90x4090x4190x4290x4390x4490x4590x4690x4790x4890x4990x4A90x4B90x5090x5190x5290x5390x5490x5590x5690x5790x5890x5990x5A90x5B90x6090x6190x6290x6390x6490x6590x6690x6790x6890x6990x6A90x6B90x7090x7190x7290x7390x7490x7590x7690x7790x7890x7990x7A90x7BNEXT NOTES Of WHAT I NEED:90x0C90x0D90x0F90x1F90x2F90x3F90x4F90x5F90x6FBut leds for that and rest notes must be like that, I push the button>led turn on, I push the button again (turn off the effect)>led turn offCan anyone help me to change ain64_din128_dout128_v1_3 code?I hope, that all i wrote, it's not too knotty..Best RegardsWaiting for proposition Quote Link to comment Share on other sites More sharing options...
DavidBanner Posted March 3, 2008 Report Share Posted March 3, 2008 what you are asking for (I think, I'm a bit confused from the explaination) is very easy to do in C.Find the function that is triggered when a midi note is received.Build a switch or series of If statements that catch the note value.Turn LED on or off according to a flag (variable) for each LED Then reset the flag.easy! Quote Link to comment Share on other sites More sharing options...
consi_hh Posted April 17, 2008 Report Share Posted April 17, 2008 do you have any idea how it works? I have the same problem at the momet but i don´t have any idea to fix it.. Quote Link to comment Share on other sites More sharing options...
LX Posted April 17, 2008 Report Share Posted April 17, 2008 Hi UltrasoundI can maybe help. I modificate the ain64_din128_dout128_v1_3 program quite a lot, but I dont understand what you want :-\Can you more describe your set up? Are you make some changes in program yet?B.R.LX Quote Link to comment Share on other sites More sharing options...
nILS Posted April 17, 2008 Report Share Posted April 17, 2008 http://www.midibox.org/forum/index.php/topic,9118.msg64842.html#msg64842http://www.midibox.org/forum/index.php/topic,10910.msg84305.html#msg84305http://www.midibox.org/forum/index.php/topic,10880.msg83929.html#msg83929What's the matter ultrasound? Quote Link to comment Share on other sites More sharing options...
nILS Posted April 17, 2008 Report Share Posted April 17, 2008 http://www.midibox.org/forum/index.php/topic,9118.msg64842.html#msg64842http://www.midibox.org/forum/index.php/topic,10910.msg84305.html#msg84305http://www.midibox.org/forum/index.php/topic,10880.msg83929.html#msg83929What's the matter ultrasound? Quote Link to comment Share on other sites More sharing options...
stryd_one Posted April 17, 2008 Report Share Posted April 17, 2008 Don't crosspost please. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.