Binary Conversion Selection of 8 bits first 4 bits are Bass last 4 are Treble
I'm trying to make some code for a speaker remote replacement that has tone control. The device has an I2C volume control IC on it: Attached Image
I have it setup so I can click a button and it switches between the 9 modes from 0 - 8 addresses on the IC so I added two more 9/10 dimensional array units to store the 4 bits for bass and 4 bits for treble. I modify these bits with a rotary encoder up and down. I then want to add these two 4 bit values back together and store them back in Address 07 as an 8 bit value again. I'm just not sure how to modify the bits back and forth between 4 and 8 bit values.
I hold the chip values in a multidimensional array

31 Replies
So once I select the 9 position for BASS and then dial it up and down between 0 -> 15 (4 bits) and then select position 10 for TREBLE and dial it between 0->15 (4 bits)
How do I combined those both back into 8 bits to store in 07 position. How would I also separate the 8 into two 4 bit values to store back in position 9 / 10 of the multidirectional array spots?
Unknown User•3y ago
Message Not Public
Sign In & Join Server To View
?
Unknown User•3y ago
Message Not Public
Sign In & Join Server To View
Icesythe7 --verbose
Unknown User•3y ago
Message Not Public
Sign In & Join Server To View
10001000
Unknown User•3y ago
Message Not Public
Sign In & Join Server To View
upperbits = date & ?;
Need the upper and lower spit to two 4 bit
Unknown User•3y ago
Message Not Public
Sign In & Join Server To View
then how do you put them back together if you changed them separately?
Say you added the decimal 4 to the lower then subtracted decimal 4 from the upper how do you put the lower and upper back together again after the manipulation to 8 bits again?
Unknown User•3y ago
Message Not Public
Sign In & Join Server To View
ok
Unknown User•3y ago
Message Not Public
Sign In & Join Server To View
Thank you I was just trying to manipulate it but failing https://www.onlinegdb.com/fork/oSGxtpL1Av
Need to store the values as decimals in the multi dimensional array
Using a rotary encoder
Unknown User•3y ago
Message Not Public
Sign In & Join Server To View
Unknown User•3y ago
Message Not Public
Sign In & Join Server To View
yes
after manipulating 9 and 10
adding or subtracting 1 to it that comes from rotating the rotary encoder
Unknown User•3y ago
Message Not Public
Sign In & Join Server To View
Unknown User•3y ago
Message Not Public
Sign In & Join Server To View
Unknown User•3y ago
Message Not Public
Sign In & Join Server To View
mem[selectState][0] = newENC; selectState == the first dimension of the array to select what option we are controlling and that is selected by pushing the button in the encoder spindle the following 0 is where the encoder value is stored
so selectState would be 9 or 10 to store the bass and treble separate and 7 would store them together for the actual I2C command for the chip to alter those on the hardware
The button to change states:
The i2c cmd gets sent to speaker like this:
You can see the data in the multiD in my fork of your online compiler code
The second dimension is stored like this // CurrentValue,MinValue,MaxValue,Red,Green,Blue.
Unknown User•3y ago
Message Not Public
Sign In & Join Server To View
Unknown User•3y ago
Message Not Public
Sign In & Join Server To View
What is the & doing?
Unknown User•3y ago
Message Not Public
Sign In & Join Server To View