ON SITE - Sending variable value to buttons - Alignment issue
mkleynhans
Posts: 78
Hi Guys,
I am parsing a Denon tuner for station info and have written a bit of code that saves the current station
as a preset on a button and pops the station name on the button label.
The parsed value for a Denon station short name is 8 chars long but some stations have less characters
in the name such as 'XFM'.
What I am finding is that the labels on the buttons look a bit wierd as the shorter character stations are
off to the left. Is there anything that I can do about adjusting the storage variable length based on the
actual size of the preset name? (Hoping that this would then centre the channel name in the middle of
the button...)
The variable for preset 1 starts off as NON_VOLATILE CHAR cDabPreset1[]='Preset 1'
On the present button holdpress, I giving cDabPreset1 the same value as DAB_STATION_NAME which
starts off as CHAR DAB_STATION_NAME[8]. I have tried changing the dab station name variable to
CHAR DAB_STATION_NAME[] this is the same and removing brackets brings up warnings that I am trying
to convert string to char...
Are there any ways to adjust the variable length or at least adjust the value being sent?
(Sorry reading this it sound pretty confusing...)
I am parsing a Denon tuner for station info and have written a bit of code that saves the current station
as a preset on a button and pops the station name on the button label.
The parsed value for a Denon station short name is 8 chars long but some stations have less characters
in the name such as 'XFM'.
What I am finding is that the labels on the buttons look a bit wierd as the shorter character stations are
off to the left. Is there anything that I can do about adjusting the storage variable length based on the
actual size of the preset name? (Hoping that this would then centre the channel name in the middle of
the button...)
The variable for preset 1 starts off as NON_VOLATILE CHAR cDabPreset1[]='Preset 1'
On the present button holdpress, I giving cDabPreset1 the same value as DAB_STATION_NAME which
starts off as CHAR DAB_STATION_NAME[8]. I have tried changing the dab station name variable to
CHAR DAB_STATION_NAME[] this is the same and removing brackets brings up warnings that I am trying
to convert string to char...
Are there any ways to adjust the variable length or at least adjust the value being sent?
(Sorry reading this it sound pretty confusing...)
0
Comments
If you are centering the text as suggested but are still seeing alignment issues it might be that your Staion ID data has some other non-Alpha chars in it like spaces or whatnot. You can see this in debug by looking at the variable value while you have the shorter name in.
So what you may have for example is really
[SPACE][SPACE]XFM[SPACE][SPACE][SPACE]
so the button is dutifully centering this text but what you see is janky.
If its something like this you just need to search through your return string and remove what you don't need.
Now cReply is the same string minus the whitespace.
Simon
Receipt of the Station Name is done with...
Start Zone DABStation Nil String Length
$21, $01, $18, $00, $10
Data inbound within Notifications Tab
Line 729 (12:43:14):: String From [5001:6:1]-[!$01$18$00$10Capital <9Spaces> $0D]
(I have added the <9Spaces> part as the forum removes the spaces...)
My Data Event Parse Code
My Call based on previous recommendation to remove whitespace..
But still my cDabSN and cDabSN1 are still both 17 chars long and the full value gets sent to
my current programme area and sits off to the left when a short station name is true.........
In the FOR loop above, I have also tried IF ( cDabSN[nLoop] != ' ') but that makes no difference.
When I look at the values for cDabSN and cDabSN1 within my Debug they show as...
43,61,70,69,74,61,6C,20,20,20,20,20,20,20,20,20,D
Is the D on the end the culprit?
Please HEEELP
Is the 'D' simply a checksum character? Remove it first then run the loop.
Simon
There are many other ways to skin this cat, but that is the quickest way I can think of to make the bulk of your existing code work.