News:

Let's find out together what makes a PIC Tick!

Main Menu

Macro to add continuation lines

Started by RGV250, May 02, 2021, 02:48 PM

Previous topic - Next topic

RGV250

Hi,
I am trying to add large custom fonts to the FT800 display, there is a converter but the output is not compatible with Proton.
Below is a sample for 1 character, if I do 0-9 it runs into 300 or so lines, adding the underscore at the end of each line takes ages.
The first couple of lines are not regular but there are not a lot of them. It looks like the actual data are in rows of 32 values / commas, I was wondering if it would be possible to create a macro to add the underscore after every 32 commas.

Regards,
Bob

/* 148 Metric Block Begin +++  */
/*('file properties ', 'format ', 'L4', ' stride ', 17, ' width ', 34, 'height', 55)*/
{
/* Widths */
0,33,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
/* Format */
2,0,0,0,
/* Stride */
17,0,0,0,
/* Max Width */
34,0,0,0,
/* Max Height */
55,0,0,0,
/* Raw Data Address in Decimal: <213> */
213,0,0,0,

/* 148 Metric Block End ---  */

/*Bitmap Raw Data begin +++*/
/*The expected raw bitmap size is 935 Bytes */
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,95,255,80,0,0,0,0,0,0,0,0,0,0,0,0,0,1,223,255,80,0,0,0,0,0,0,0,0,0,
0,0,0,0,11,255,255,80,0,0,0,0,0,0,0,0,0,0,0,0,0,159,255,255,80,0,0,0,0,0,0,0,
0,0,0,0,0,8,255,255,255,80,0,0,0,0,0,0,0,0,0,0,0,0,159,255,255,255,80,0,0,0,0,0,
0,0,0,0,0,0,28,255,255,255,255,80,0,0,0,0,0,0,0,0,0,0,5,239,255,255,255,255,80,0,0,0,
0,0,0,0,0,0,1,175,255,255,255,255,255,80,0,0,0,0,0,0,0,0,1,126,255,255,255,190,255,255,80,0,
0,0,0,0,0,0,0,78,255,255,255,249,14,255,255,80,0,0,0,0,0,0,0,0,127,255,255,253,64,14,255,255,
80,0,0,0,0,0,0,0,0,127,255,255,129,0,14,255,255,80,0,0,0,0,0,0,0,0,127,255,162,0,0,14,
255,255,80,0,0,0,0,0,0,0,0,127,163,0,0,0,14,255,255,80,0,0,0,0,0,0,0,0,49,0,0,0,
0,14,255,255,80,0,0,0,0,0,0,0,0,0,0,0,0,0,14,255,255,80,0,0,0,0,0,0,0,0,0,0,
0,0,0,14,255,255,80,0,0,0,0,0,0,0,0,0,0,0,0,0,14,255,255,80,0,0,0,0,0,0,0,0,
0,0,0,0,0,14,255,255,80,0,0,0,0,0,0,0,0,0,0,0,0,0,14,255,255,80,0,0,0,0,0,0,
0,0,0,0,0,0,0,14,255,255,80,0,0,0,0,0,0,0,0,0,0,0,0,0,14,255,255,80,0,0,0,0,
0,0,0,0,0,0,0,0,0,14,255,255,80,0,0,0,0,0,0,0,0,0,0,0,0,0,14,255,255,80,0,0,
0,0,0,0,0,0,0,0,0,0,0,14,255,255,80,0,0,0,0,0,0,0,0,0,0,0,0,0,14,255,255,80,
0,0,0,0,0,0,0,0,0,0,0,0,0,14,255,255,80,0,0,0,0,0,0,0,0,0,0,0,0,0,14,255,
255,80,0,0,0,0,0,0,0,0,0,0,0,0,0,14,255,255,80,0,0,0,0,0,0,0,0,0,0,0,0,0,
14,255,255,80,0,0,0,0,0,0,0,0,0,0,0,0,0,14,255,255,80,0,0,0,0,0,0,0,0,0,0,0,
0,0,14,255,255,80,0,0,0,0,0,0,0,0,0,0,0,0,0,14,255,255,80,0,0,0,0,0,0,0,0,0,
0,0,0,0,14,255,255,80,0,0,0,0,0,0,0,0,0,0,0,0,0,14,255,255,80,0,0,0,0,0,0,0,
0,0,0,0,0,0,14,255,255,80,0,0,0,0,0,0,0,0,0,0,0,0,0,14,255,255,80,0,0,0,0,0,
0,0,0,0,0,0,0,0,14,255,255,80,0,0,0,0,0,0,0,0,0,0,0,0,0,14,255,255,80,0,0,0,
0,0,0,0,0,0,0,0,0,0,14,255,255,80,0,0,0,0,0,0,0,0,0,0,0,0,0,14,255,255,80,0,
0,0,0,0,0,0,0,
/*Bitmap Raw Data end ---*/
}

trastikata

#1
Quote from: RGV250 on May 02, 2021, 02:48 PMI was wondering if it would be possible to create a macro to add the underscore after every 32 commas.

Let me know if you need specific modifications, takes no time to make it.

WindowsApp1.zip

Public Class Form1

    Dim TempString As String
    Dim OutString As String
    Dim counter As Integer

    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        TempString = TextBox_in.Text.Trim.Replace(Chr(0), "")
        TempString = TempString.Trim.Replace(Chr(11), "")
        TempString = TempString.Trim.Replace(vbNewLine, "")
        OutString = ""
        counter = 0

        If TempString.Length > 0 Then
            For Each c As Char In TempString
                OutString = OutString + c
                If c = "," Then
                    counter = counter + 1
                End If
                If counter = 32 Then
                    counter = 0
                    OutString = OutString + "_" + vbNewLine
                End If
            Next
        End If

        TextBox_out.Text = OutString
    End Sub
End Class

TimB


For situations like that I use word and record a macro

Start macro and assign a key press to it. Then right key enough times to move cursor enough then add the _ and carriage return. Stop macro

keep pressing the assigned key until its all converted 

RGV250

Hi,
Thanks for your suggestions.
Hi Trastikata, Norton didn't like the app and promptly deleted it?, I am not sure what program runs the code.

Hi Tim, I had not thought of Word which seems like the easiest way, I tried a simple macro but it put the underscore at every 32 characters rather than commas.
I will experiment with a combination of the 2 ideas as the code Trastikata posted gives me a guide to what I need to do.

I will not need it for a while as I have issues with the actual PIC code as it is unstable with large fonts and bitmaps.
The other issue is the demo I made uses over 99% of the 18F25K20 so I need to be looking at a 16 bit device.

Regards,
Bob 

trastikata

#4
RGV250,

it's a Visual Studio (VB.NET) form (application) for windows. Nowadays all AV software complain of unknown files and submit it for scanning. But you can use the code with minor modifications to Excel or Word and use VBA macros as Tim said.

If you don't have enough space for the font, can't you use an EEPROM memory chip to store the data and read from to display?

RGV250

Hi,
I suppose that is a possibility but after looking into the custom fonts they seem to be a nightmare, you cannot just print as text/numbers. You have to treat each one as a bitmap and they are a pain to display a lot of them. It took 24 lines of code (plus all the  code in the procedures) just to print one.
I am having a look at other intelligent displays but I think I am fight ting a losing battle. I looked at Nextion which it seems to be easy to get very large fonts and they do them with bezels but the graphics seem to be limited and what really lets it down in my opinion is there are no examples at all. I looked at buyDisplay as I think Tim used them but there are so many and loads of different controllers.

Bob

top204

#6
That is a "truly" dreadful piece of flash memory data handling, and typical of C programming. ;-) Over complex, untidy and very little thought into its efficiency on a microcontroller.

I think I added the "{" and "}" blocks in version 3.7.5.5 of the compiler as betas, but I'm not sure. They are definately in the new Positron compiler upgrades and documented in the manuals. If I did add them in version 3.7.5.5, the above, dreadful, code can be written as:

(* 148 Metric Block Begin +++  *)
(*('file properties ', 'format ', 'L4', ' stride ', 17, ' width ', 34, 'height', 55)*)
                            (* widths *)
Dim MyFlashTable As Flash8 = {0,33,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
(* Format *)
2,0,0,0,
(* Stride *)
17,0,0,0,
(* Max Width *)
34,0,0,0,
(* Max Height *)
55,0,0,0,
(* Raw Data Address in Decimal: <213> *)
213,0,0,0,

(* 148 Metric Block End ---  *)

(*Bitmap Raw Data begin +++*)
(*The expected raw bitmap size is 935 Bytes *)
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,95,255,80,0,0,0,0,0,0,0,0,0,0,0,0,0,1,223,255,80,0,0,0,0,0,0,0,0,0,
0,0,0,0,11,255,255,80,0,0,0,0,0,0,0,0,0,0,0,0,0,159,255,255,80,0,0,0,0,0,0,0,
0,0,0,0,0,8,255,255,255,80,0,0,0,0,0,0,0,0,0,0,0,0,159,255,255,255,80,0,0,0,0,0,
0,0,0,0,0,0,28,255,255,255,255,80,0,0,0,0,0,0,0,0,0,0,5,239,255,255,255,255,80,0,0,0,
0,0,0,0,0,0,1,175,255,255,255,255,255,80,0,0,0,0,0,0,0,0,1,126,255,255,255,190,255,255,80,0,
0,0,0,0,0,0,0,78,255,255,255,249,14,255,255,80,0,0,0,0,0,0,0,0,127,255,255,253,64,14,255,255,
80,0,0,0,0,0,0,0,0,127,255,255,129,0,14,255,255,80,0,0,0,0,0,0,0,0,127,255,162,0,0,14,
255,255,80,0,0,0,0,0,0,0,0,127,163,0,0,0,14,255,255,80,0,0,0,0,0,0,0,0,49,0,0,0,
0,14,255,255,80,0,0,0,0,0,0,0,0,0,0,0,0,0,14,255,255,80,0,0,0,0,0,0,0,0,0,0,
0,0,0,14,255,255,80,0,0,0,0,0,0,0,0,0,0,0,0,0,14,255,255,80,0,0,0,0,0,0,0,0,
0,0,0,0,0,14,255,255,80,0,0,0,0,0,0,0,0,0,0,0,0,0,14,255,255,80,0,0,0,0,0,0,
0,0,0,0,0,0,0,14,255,255,80,0,0,0,0,0,0,0,0,0,0,0,0,0,14,255,255,80,0,0,0,0,
0,0,0,0,0,0,0,0,0,14,255,255,80,0,0,0,0,0,0,0,0,0,0,0,0,0,14,255,255,80,0,0,
0,0,0,0,0,0,0,0,0,0,0,14,255,255,80,0,0,0,0,0,0,0,0,0,0,0,0,0,14,255,255,80,
0,0,0,0,0,0,0,0,0,0,0,0,0,14,255,255,80,0,0,0,0,0,0,0,0,0,0,0,0,0,14,255,
255,80,0,0,0,0,0,0,0,0,0,0,0,0,0,14,255,255,80,0,0,0,0,0,0,0,0,0,0,0,0,0,
14,255,255,80,0,0,0,0,0,0,0,0,0,0,0,0,0,14,255,255,80,0,0,0,0,0,0,0,0,0,0,0,
0,0,14,255,255,80,0,0,0,0,0,0,0,0,0,0,0,0,0,14,255,255,80,0,0,0,0,0,0,0,0,0,
0,0,0,0,14,255,255,80,0,0,0,0,0,0,0,0,0,0,0,0,0,14,255,255,80,0,0,0,0,0,0,0,
0,0,0,0,0,0,14,255,255,80,0,0,0,0,0,0,0,0,0,0,0,0,0,14,255,255,80,0,0,0,0,0,
0,0,0,0,0,0,0,0,14,255,255,80,0,0,0,0,0,0,0,0,0,0,0,0,0,14,255,255,80,0,0,0,
0,0,0,0,0,0,0,0,0,0,14,255,255,80,0,0,0,0,0,0,0,0,0,0,0,0,0,14,255,255,80,0,
0,0,0,0,0,0,0,
(*Bitmap Raw Data end ---*)
}

Notice the "{" and "}" characters starting and terminating the flash memory data block, and no line continuation required at the end of the lines, just a comma. :-) I'm busy working on a comma by itself at the end of a line being the standard line continuation as well as the ",_". Easier said than done in the compiler's many, many, many thousands of lines of C++ code. LOL

To read the data from the flash memory table, the Cread8 command can easily be used with an index, or use the cPtr8 function with an address of the flash memory table as its index.

RGV250

Hi Les,
That is brilliant, I am using 3.7.5.5 and it compiles.
how long have () been used for commenting out code?
I have been using LData / LRead VarPtr(FTDI_LOGO) so should not take a lot to modify.

Regards,
Bob