Android Question string to integer on android sysfs.

salim safran

Member
Licensed User
Longtime User
I have this string
"adc0:5
adc1:63
adc2:4095
adc3:1200
adc4:4095
adc5:4095"
the value for each adc (analog value) varies from 0 to 4095 the output is string value from a shell command , there will be a total of 400 samples , the command to generate the string is a shell command # cat /proc/adc* and the result as above mentioned, I need to write a code in b4a to convert that string to an array of 5 channels and do 400 shell command #cat /proc/adc* separated by 50milliscond and use the chart to draw the 5 channels on the chart from the saved arrays, then save arrays to a file , also an option to retrieve the arrays from a file and draw it back again on a chart. willing to pay for your help. let me know. i made a function to in b4a called readadc and get that string. I do not want u to do that part that I already done it by readying the great support from other members in this forum. please advise
 

salim safran

Member
Licensed User
Longtime User
There are 6 values in the above string. What should the array look like?
every of one the 6 adc shall have it it's own array for example adc0[400], adc1[400] and so on then I need to use your chart to display the values I select from the six analogue inputs there must be an option to show all the arrays, if i remember your chart can take up to 4 arrays only each with different color, all arrays shall be saved to text file, also to load them back from text file and draw the chart. o is zero voltage and 4095 shall be 3.3VDC, please advise, according to pcduino the max values for adc0 and adc1 is 63, but asked you to leave it 4095 so i can use generalize the code with others boards when needed.. the x axis will be the number of samples from 1 to 400 and the y axis is the actual value of the adc specific input.
 
Last edited:
Upvote 0

salim safran

Member
Licensed User
Longtime User
just completed the coding for what i needed yesterday, thanks to Margaret libraries. her support is really very useful and appreciated.

strValue = StdOut.ToString
val0 =sf.InString(strValue,"adc0:")
val1 =sf.InString(strValue,"adc1:")
val2 =sf.InString(strValue,"adc2:")
val3 =sf.InString(strValue,"adc3:")
val4 =sf.InString(strValue,"adc4:")
val5 =sf.InString(strValue,"adc5:")

pValue0 = sf.mid(strValue,6,val1-6)
pValue1=sf.Mid(strValue,val1+6,val2-6-val1)
pValue2=sf.mid(strValue,val2+6,val3-6-val2)
pValue3=sf.Mid(strValue,val3+6,val4-6-val3)
pValue4=sf.Mid(strValue,val4+6,val5-6-val4)
pValue5=sf.Mid(strValue,val5+6,sf.len(strValue)-val5-6)
 
Last edited:
Upvote 0
Top